register.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,948 行 · 第 1/5 页
PHP
1,948 行
if ( $this->ipsclass->converge->converge_check_for_member_by_email( $in_email ) == TRUE ) { $form_errors['email'][] = $this->ipsclass->lang['reg_error_email_taken']; } //----------------------------------------- // Are they banned [IP]? //----------------------------------------- if ( is_array( $banfilters['ip'] ) and count( $banfilters['ip'] ) ) { foreach ($banfilters['ip'] as $ip) { $ip = str_replace( '\*', '.*', preg_quote($ip, "/") ); if ( preg_match( "/^$ip/", $this->ipsclass->input['IP_ADDRESS'] ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'you_are_banned', 'INIT' => 1 ) ); } } } //----------------------------------------- // Are they banned [EMAIL]? //----------------------------------------- if ( is_array( $banfilters['email'] ) and count( $banfilters['email'] ) ) { foreach ( $banfilters['email'] as $email ) { $email = str_replace( "\*", '.*' , preg_quote($email, "/") ); if ( preg_match( "/$email/", $in_email ) ) { $form_errors['email'][] = $this->ipsclass->lang['reg_error_email_taken']; break; } } } //----------------------------------------- // CHECK 2: Any errors (duplicate names, etc)? //----------------------------------------- if ( count( $form_errors ) ) { $this->complete_login_form( $form_errors ); return; } //----------------------------------------- // Update: Members //----------------------------------------- $members_display_name = $this->ipsclass->vars['auth_allow_dnames'] ? $members_display_name : $tmp_member['name']; $this->ipsclass->DB->do_update( 'members', array( 'email' => $in_email, 'members_display_name' => $members_display_name ), 'id='.$mid ); //----------------------------------------- // Update: Converge //----------------------------------------- $this->ipsclass->DB->do_update( 'members_converge', array( 'converge_email' => $in_email ), 'converge_id='.$mid ); //----------------------------------------- // Delete: Partials row //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'members_partial', 'where' => 'partial_member_id='.$mid ) ); //----------------------------------------- // Update: Profile fields //----------------------------------------- if ( is_array($fields->out_fields) and count($fields->out_fields) ) { $this->ipsclass->DB->do_update( 'pfields_content', $fields->out_fields, 'member_id='.$mid ); } //----------------------------------------- // Send out admin email //----------------------------------------- if ( $this->ipsclass->vars['new_reg_notify'] ) { $date = $this->ipsclass->get_date( time(), 'LONG', 1 ); $this->email->get_template("admin_newuser"); $this->email->build_message( array( 'DATE' => $date, 'MEMBER_NAME' => $members_display_name ) ); $this->email->subject = $this->ipsclass->lang['new_registration_email'] . $this->ipsclass->vars['board_name']; $this->email->to = $this->ipsclass->vars['email_in']; $this->email->send_mail(); } //----------------------------------------- // Set cookies //----------------------------------------- $member = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => "id=$mid" ) ); $this->ipsclass->my_setcookie("member_id" , $member['id'] , 1); $this->ipsclass->my_setcookie("pass_hash" , $member['member_login_key'], 1); //----------------------------------------- // Create / Update session //----------------------------------------- if ( $cookie_id = $this->ipsclass->my_getcookie('session_id') ) { $poss_session_id = $this->ipsclass->my_getcookie('session_id'); } else if ( $this->ipsclass->input['s'] ) { $poss_session_id = $this->ipsclass->input['s']; } //----------------------------------------- // Clean... //----------------------------------------- $poss_session_id = preg_replace("/([^a-zA-Z0-9])/", "", $poss_session_id); //----------------------------------------- // Got a valid session ID... //----------------------------------------- if ($poss_session_id) { $session_id = $poss_session_id; //----------------------------------------- // Delete any old sessions with this users IP // addy that doesn't match our session ID. //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'delete' => 'sessions', 'where' => "ip_address='".$this->ipsclass->ip_address."' AND id != '$session_id'" ) ); $this->ipsclass->DB->simple_shutdown_exec(); $this->ipsclass->DB->do_shutdown_update( 'sessions', array ( 'member_name' => $member['members_display_name'], 'member_id' => $member['id'], 'running_time' => time(), 'member_group' => $member['mgroup'], 'login_type' => $this->ipsclass->input['Privacy'] ? 1 : 0 ), "id='".$session_id."'" ); } else { $session_id = md5( uniqid(microtime()) ); //----------------------------------------- // Delete any old sessions with this users IP addy. //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'delete' => 'sessions', 'where' => "ip_address='".$this->ipsclass->ip_address."'" ) ); $this->ipsclass->DB->simple_shutdown_exec(); $this->ipsclass->DB->do_shutdown_insert( 'sessions', array ( 'id' => $session_id, 'member_name' => $member['members_display_name'], 'member_id' => $member['id'], 'running_time' => time(), 'member_group' => $member['mgroup'], 'ip_address' => $this->ipsclass->ip_address, 'browser' => substr($this->ipsclass->clean_value($_SERVER['HTTP_USER_AGENT']), 0, 50), 'login_type' => $this->ipsclass->input['Privacy'] ? 1 : 0 ) ); } $this->ipsclass->member = $member; $this->ipsclass->session_id = $session_id; //----------------------------------------- // set cookie //----------------------------------------- $this->ipsclass->my_setcookie("session_id", $this->ipsclass->session_id, -1); //----------------------------------------- // Go to the board index //----------------------------------------- $this->ipsclass->print->redirect_screen( $this->ipsclass->lang['clogin_done'], 'act=idx' ); } /*-------------------------------------------------------------------------*/ // Show "check revalidate form" er.. form. thing. /*-------------------------------------------------------------------------*/ function complete_login_form( $form_errors=array() ) { //----------------------------------------- // INIT //----------------------------------------- $mid = intval( $this->ipsclass->input['mid'] ); $key = intval( $this->ipsclass->input['key'] ); $final_errors = array(); //----------------------------------------- // Get DB row //----------------------------------------- $reg = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id={$mid} AND partial_date={$key}" ) ); //----------------------------------------- // Got it? //----------------------------------------- if ( ! $reg['partial_id'] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'data_incorrect' ) ); } //----------------------------------------- // Custom profile fields stuff //----------------------------------------- $required_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 { continue; } 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 ); } //----------------------------------------- // 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 ] ); } } //----------------------------------------- // Show the form (email and display name) //----------------------------------------- $this->output .= $this->ipsclass->compiled_templates['skin_register']->reg_complete_login( $mid, $key, $required_output, $final_errors ); $this->page_title = $this->ipsclass->lang['clogin_title']; $this->nav = array( $this->ipsclass->lang['clogin_title'] ); } /*-------------------------------------------------------------------------*/ // Show "check revalidate form" er.. form. thing. /*-------------------------------------------------------------------------*/ function revalidate_one($errors="") { if ($errors != "") { $this->output .= $this->ipsclass->compiled_templates['skin_register']->errors( $this->ipsclass->lang[$errors] ); } $name = $this->ipsclass->member['id'] == "" ? '' : $this->ipsclass->member['name']; $this->output .= $this->ipsclass->compiled_templates['skin_register']->show_revalidate_form($name); $this->page_title = $this->ipsclass->lang['rv_title']; $this->nav = array( $this->ipsclass->lang['rv_title'] ); } /*-------------------------------------------------------------------------*/ // Complete revalidation /*-------------------------------------------------------------------------*/ function revalidate_two() { //----------------------------------------- // Check in the DB for entered member name //----------------------------------------- if ( $_POST['username'] == "" ) { $this->revalidate_one('err_no_username'); return; } $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'members', 'where' => "name='".$this->ipsclass->input['username']."'" ) ); $this->ipsclass->DB->simple_exec(); if ( ! $member = $this->ipsclass->DB->fetch_row() ) { $this->revalidate_one('err_no_username'); return; } //----------------------------------------- // Check in the DB for any validations //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'validating', 'where' => "member_id=".intval($member['id']) ) ); $this->ipsclass->DB->simple_exec(); if ( ! $val = $this->ipsclass->DB->fetch_row() ) { $this->revalidate_one('err_no_validations'); return; } //----------------------------------------- // Which type is it then? //----------------------------------------- if ( $val['lost_pass'] == 1 ) { $this->email->get_template("lost_pass"); $this->email->build_message( array( 'NAME' => $member['members_display_name'], 'THE_LINK' => $this->base_url_nosess."?act=Reg&CODE=lostpassform&uid=".$member['id']."&aid=".$val['vid'], 'MAN_LINK' => $this->base_url_nosess."?act=Reg&CODE=lostpassform", 'EMAIL' => $member['email'], 'ID' => $member['id'], 'CODE' => $val['vid'], 'IP_ADDRESS' => $this->ipsclass->input['IP_ADDRESS'], ) ); $this->email->subject = $this->ipsclass->lang['lp_subject'].' '.$this->ipsclass->vars['board_name']; $this->email->to = $member['email']; $this->email->send_mail(); } else if ( $val['new_reg'] == 1 ) { $this->email->get_template("reg_validate"); $this->email->build_message( array( 'THE_LINK' => $this->base_url_nosess."?act=Reg&CODE=03&uid=".$member['id']."&aid=".$val['vid'], 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->base_url_nosess."?act=Reg&CODE=05", 'EMAIL' => $member['email'], 'ID' => $member['id'], 'CODE' => $val['vid'], ) );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?