register.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,948 行 · 第 1/5 页
PHP
1,948 行
} } $this->bash_dead_validations(); //----------------------------------------- // Clean out anti-spam stuffy //----------------------------------------- if ($this->ipsclass->vars['bot_antispam']) { // Set a new ID for this reg request... $regid = md5( uniqid(microtime()) ); // Set a new 6 character numerical string mt_srand ((double) microtime() * 1000000); $reg_code = mt_rand(100000,999999); // Insert into the DB $this->ipsclass->DB->do_insert( 'reg_antispam', array ( 'regid' => $regid, 'regcode' => $reg_code, 'ip_address' => $this->ipsclass->input['IP_ADDRESS'], 'ctime' => time(), ) ); } //----------------------------------------- // Custom profile fields stuff //----------------------------------------- $required_output = ""; $optional_output = ""; require_once( ROOT_PATH.'sources/classes/class_custom_fields.php' ); $fields = new custom_fields( $this->ipsclass->DB ); $fields->cache_data = $this->ipsclass->cache['profilefields']; $fields->init_data(); $fields->parse_to_register(); foreach( $fields->out_fields as $id => $data ) { if ( $fields->cache_data[ $id ]['pf_not_null'] == 1 ) { $ftype = 'required_output'; } else { $ftype = 'optional_output'; } if ( $fields->cache_data[ $id ]['pf_type'] == 'drop' ) { $form_element = $this->ipsclass->compiled_templates['skin_register']->field_dropdown( 'field_'.$id, $data ); } else if ( $fields->cache_data[ $id ]['pf_type'] == 'area' ) { $data = $this->ipsclass->input['field_'.$id] ? $this->ipsclass->input['field_'.$id] : $data; $form_element = $this->ipsclass->compiled_templates['skin_register']->field_textarea( 'field_'.$id, $data ); } else { $data = $this->ipsclass->input['field_'.$id] ? $this->ipsclass->input['field_'.$id] : $data; $form_element = $this->ipsclass->compiled_templates['skin_register']->field_textinput( 'field_'.$id, $data ); } ${$ftype} .= $this->ipsclass->compiled_templates['skin_register']->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $form_element ); } $this->page_title = $this->ipsclass->lang['registration_form']; $this->nav = array( $this->ipsclass->lang['registration_form'] ); //----------------------------------------- // ERROR CHECK //----------------------------------------- if ( is_array( $form_errors['general'] ) AND count( $form_errors['general'] ) ) { $this->output .= $this->ipsclass->compiled_templates['skin_register']->errors( implode( "<br />", $form_errors['general'] ) ); } //----------------------------------------- // Other errors //----------------------------------------- foreach( array( 'username', 'dname', 'password', 'email' ) as $thing ) { if ( is_array( $form_errors[ $thing ] ) AND count( $form_errors[ $thing ] ) ) { $final_errors[ $thing ] = implode( "<br />", $form_errors[ $thing ] ); } } $this->output .= $this->ipsclass->compiled_templates['skin_register']->ShowForm( array( 'TEXT' => $this->ipsclass->lang['std_text'], 'coppa_user' => $coppa ), $final_errors ); //----------------------------------------- // Replace elements //----------------------------------------- if ($this->ipsclass->vars['bot_antispam'] == 'gd') { $this->output = str_replace( "<!--{REG.ANTISPAM}-->", $this->ipsclass->compiled_templates['skin_register']->bot_antispam_gd( $regid ), $this->output ); } else if ($this->ipsclass->vars['bot_antispam'] == 'gif') { $this->output = str_replace( "<!--{REG.ANTISPAM}-->", $this->ipsclass->compiled_templates['skin_register']->bot_antispam( $regid ), $this->output ); } if ($required_output != "") { $this->output = str_replace( "<!--{REQUIRED.FIELDS}-->", "\n".$required_output, $this->output ); } if ($optional_output != "") { $this->output = str_replace( "<!--{OPTIONAL.FIELDS}-->", $this->ipsclass->compiled_templates['skin_register']->optional_title()."\n".$optional_output, $this->output ); } //----------------------------------------- // Time zone... //----------------------------------------- $this->ipsclass->load_language('lang_ucp'); $offset = ( $this->ipsclass->input['time_offset'] != "" ) ? $this->ipsclass->input['time_offset'] : $this->ipsclass->vars['time_offset']; $time_select = "<select name='time_offset' class='forminput'>"; foreach( $this->ipsclass->lang as $off => $words ) { if (preg_match("/^time_([\d\.\-]+)$/", $off, $match)) { $time_select .= $match[1] == $offset ? "<option value='{$match[1]}' selected='selected'>$words</option>" : "<option value='{$match[1]}'>$words</option>"; } } $time_select .= "</select>"; $this->output = str_replace( "<!--{TIME_ZONE}-->", "\n".$time_select, $this->output ); //----------------------------------------- // Boxes checked? //----------------------------------------- $admin_checked = 'checked="checked"'; if ( $this->ipsclass->input['CODE'] == '02' ) { //----------------------------------------- // Form submitted... //----------------------------------------- if ( ! $this->ipsclass->input['allow_admin_mail'] ) { $admin_checked = ''; } } $member_checked = $this->ipsclass->input['allow_member_mail'] ? 'checked="checked"' : ''; $dst_checked = $this->ipsclass->input['dst'] ? 'checked="checked"' : ''; $this->output = str_replace( "<!--[admin.checked]-->" , $admin_checked , $this->output ); $this->output = str_replace( "<!--[member.checked]-->", $member_checked, $this->output ); $this->output = str_replace( "<!--[dst.checked]-->" , $dst_checked , $this->output ); //----------------------------------------- // Subscribe on register? //----------------------------------------- $all_currency = array(); $def_currency = ""; $subs = array(); $subs_output = ""; $desc_output = ""; if ( $this->ipsclass->vars['subsm_show_reg'] ) { $this->ipsclass->load_language('lang_subscriptions'); //----------------------------------------- // Get currency buns! // Ok, we did that joke in another module and it // wasn't funny then //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'subscription_currency' ) ); $this->ipsclass->DB->simple_exec(); while ( $c = $this->ipsclass->DB->fetch_row() ) { $all_currency[ $c['subcurrency_code'] ] = $c; if ( $c['subcurrency_default'] ) { $def_currency = $c; } } //----------------------------------------- // Get subscription packages //----------------------------------------- $sub_output = $this->ipsclass->compiled_templates['skin_register']->subsm_start( $def_currency['subcurrency_code'] ); //----------------------------------------- // Enforcing? //----------------------------------------- if ( ! $this->ipsclass->vars['subsm_enforce'] ) { $sub_output .= $this->ipsclass->compiled_templates['skin_register']->subsm_row( '0', $this->ipsclass->lang['subsm_none'], '0.00', $this->ipsclass->lang['subsm_na'] ); } $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'subscriptions', 'order' => 'sub_cost' ) ); $this->ipsclass->DB->simple_exec(); while ( $row = $this->ipsclass->DB->fetch_row() ) { $duration = $row['sub_length']; if ( $duration > 1 ) { $duration .= ' '.$this->ipsclass->lang[ 'timep_'.$row['sub_unit'] ]; } else { $duration .= ' '.$this->ipsclass->lang[ 'time_'.$row['sub_unit'] ]; } $sub_output .= $this->ipsclass->compiled_templates['skin_register']->subsm_row( $row['sub_id'], $row['sub_title'], sprintf( "%.2f", $row['sub_cost'] * $def_currency['subcurrency_exchange'] ), $duration ); $desc_output .= "\n subdesc[{$row['sub_id']}] = '".str_replace( "'", "\\'", str_replace( "\n", '\n',$row['sub_desc'] ) )."';"; } $sub_output .= $this->ipsclass->compiled_templates['skin_register']->subsm_end(); //----------------------------------------- // Parse 'n show //----------------------------------------- if ( $sub_output ) { $this->output = str_replace( '<!--{SUBS.MANAGER}-->', $sub_output , $this->output ); $this->output = str_replace( '<!--{SUBS.JSCRIPT}-->', str_replace( "\r", "", $desc_output ), $this->output ); } } if ( USE_MODULES == 1 ) { $this->modules->register_class($this); $this->modules->on_register_form(); } } /*-------------------------------------------------------------------------*/ // create_account /*-------------------------------------------------------------------------*/ function create_account() { //----------------------------------------- // INIT //----------------------------------------- if( $this->ipsclass->vars['converge_login_method'] == 'email' ) { $this->ipsclass->input['UserName'] = $this->ipsclass->input['members_display_name']; } $form_errors = array(); $coppa = ($this->ipsclass->input['coppa_user'] == 1) ? 1 : 0; $in_username = str_replace( '|', '|' , $this->ipsclass->input['UserName'] ); $in_password = trim($this->ipsclass->input['PassWord']); $in_email = strtolower( trim($this->ipsclass->input['EmailAddress']) ); $banfilters = array(); $members_display_name = trim( $this->ipsclass->input['members_display_name'] ); //----------------------------------------- // Load ban filters //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'banfilters' ) ); $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row() ) { $banfilters[ $r['ban_type'] ][] = $r['ban_content']; } //----------------------------------------- // Check //----------------------------------------- if ($_POST['act'] == "") { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) ); } if ($this->ipsclass->vars['no_reg'] == 1) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'reg_off' ) ); } //----------------------------------------- // Custom profile field stuff //----------------------------------------- require_once( ROOT_PATH.'sources/classes/class_custom_fields.php' ); $fields = new custom_fields( $this->ipsclass->DB ); $fields->cache_data = $this->ipsclass->cache['profilefields']; $fields->init_data(); $fields->parse_to_save( 1 ); //----------------------------------------- // Check... //----------------------------------------- if ( count( $fields->error_fields['empty'] ) ) { $form_errors['general'][] = $this->ipsclass->lang['err_complete_form']; } if ( count( $fields->error_fields['invalid'] ) ) { $form_errors['general'][] = $this->ipsclass->lang['err_invalid']; } if ( count( $fields->error_fields['toobig'] ) ) { $form_errors['general'][] = $this->ipsclass->lang['err_cf_to_long']; } //----------------------------------------- // Remove multiple spaces in the username //----------------------------------------- $in_username = preg_replace( "/\s{2,}/", " ", $in_username ); //----------------------------------------- // Remove 'sneaky' spaces //----------------------------------------- if ( $this->ipsclass->vars['strip_space_chr'] ) { // use hexdec to convert between '0xAD' and chr $in_username = str_replace( chr(160), ' ', $in_username ); $in_username = str_replace( chr(173), ' ', $in_username ); $members_display_name = str_replace( chr(160), ' ', $members_display_name ); $members_display_name = str_replace( chr(173), ' ', $members_display_name ); } //----------------------------------------- // Trim up.. //----------------------------------------- $in_username = trim($in_username); //----------------------------------------- // Test unicode name too //----------------------------------------- $unicode_name = preg_replace('/&#([0-9]+);/esi', "chr('\\1')", $in_username); $unicode_name = str_replace( "'" , ''', $unicode_name ); $unicode_name = str_replace( "\\", '\', $unicode_name ); $unicode_dname = preg_replace('/&#([0-9]+);/esi', "chr('\\1')", $members_display_name); $unicode_dname = str_replace( "'" , ''', $unicode_dname ); $unicode_dname = str_replace( "\\", '\', $unicode_dname ); //----------------------------------------- // Check the email address //----------------------------------------- $in_email = $this->ipsclass->clean_email($in_email); if ( ! $in_email OR strlen($in_email) < 6 ) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?