📄 register.php
字号:
<?php
class register
{
var $output = "";
var $page_title = "";
var $nav = array( );
var $html = "";
var $email = "";
function register( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_register", $ibforums->lang_id );
$this->html = $std->load_template( "skin_register" );
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_nosess = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
require( "./sources/lib/emailer.php" );
$this->email = new emailer( );
switch ( $ibforums->input['CODE'] )
{
case "02" :
$this->create_account( );
break;
case "03" :
$this->validate_user( );
break;
case "05" :
$this->show_manual_form( );
break;
case "06" :
$this->show_manual_form( "lostpass" );
break;
case "07" :
$this->show_manual_form( "newemail" );
break;
case "10" :
$this->lost_password_start( );
break;
case "11" :
$this->lost_password_end( );
break;
case "12" :
$this->coppa_perms_form( );
break;
case "coppa_two" :
$this->coppa_two( );
break;
case "image" :
$this->show_image( );
break;
default :
if ( $ibforums->vars['use_coppa'] == 1 && $ibforums->input['coppa_pass'] != 1 )
{
$this->coppa_start( );
}
else
{
$this->show_reg_form( );
break;
}
}
$print->add_output( "{$this->output}" );
$print->do_output( array(
"TITLE" => $this->page_title,
"JS" => 0,
NAV => $this->nav
) );
}
function coppa_perms_form( )
{
global $ibforums;
global $DB;
global $std;
echo $this->html->coppa_form( );
exit( );
}
function coppa_start( )
{
global $ibforums;
global $DB;
global $std;
$coppa_date = date( "j-F y", mktime( 0, 0, 0, date( "m" ), date( "d" ), date( "Y" ) - 13 ) );
$ibforums->lang['coppa_form_text'] = str_replace( "<#FORM_LINK#>", "<a href='{$ibforums->base_url}&act=Reg&CODE=12'>{$ibforums->lang['coppa_link_form']}</a>", $ibforums->lang['coppa_form_text'] );
$this->output .= $this->html->coppa_start( $coppa_date );
$this->page_title = $ibforums->lang['coppa_title'];
$this->nav = array(
$ibforums->lang['coppa_title']
);
}
function coppa_two( )
{
global $ibforums;
global $DB;
global $std;
$ibforums->lang['coppa_form_text'] = str_replace( "<#FORM_LINK#>", "<a href='{$ibforums->base_url}&act=Reg&CODE=12'>{$ibforums->lang['coppa_link_form']}</a>", $ibforums->lang['coppa_form_text'] );
$this->output .= $this->html->coppa_two( );
$this->page_title = $ibforums->lang['coppa_title'];
$this->nav = array(
$ibforums->lang['coppa_title']
);
}
function lost_password_start( $errors = "" )
{
global $ibforums;
global $DB;
global $std;
$r_date = time( ) - 21600;
$DB->query( "DELETE FROM ibf_reg_antispam WHERE ctime < '{$r_date}'" );
$regid = md5( uniqid( microtime( ) ) );
mt_srand( ( double )microtime( ) * 1000000 );
$reg_code = mt_rand( 100000, 999999 );
$str = $DB->compile_db_insert_string( array(
"regid" => $regid,
"regcode" => $reg_code,
"ip_address" => $ibforums->input['IP_ADDRESS'],
"ctime" => time( )
) );
$DB->query( "INSERT INTO ibf_reg_antispam ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
$this->page_title = $ibforums->lang['lost_pass_form'];
$this->nav = array(
$ibforums->lang['lost_pass_form']
);
if ( $errors != "" )
{
$this->output .= $this->html->errors( $ibforums->lang[$errors] );
}
$this->output .= $this->html->lost_pass_form( $regid );
}
function lost_password_end( )
{
global $ibforums;
global $DB;
global $std;
global $HTTP_POST_VARS;
global $print;
if ( $ibforums->input['regid'] == "" )
{
$this->lost_password_start( "err_reg_code" );
}
else
{
$DB->query( "SELECT * FROM ibf_reg_antispam WHERE regid='".trim( addslashes( $ibforums->input['regid'] ) )."'" );
if ( !( $row = $DB->fetch_row( ) ) )
{
$this->show_reg_form( "err_reg_code" );
}
else
{
if ( trim( intval( $ibforums->input['reg_code'] ) ) != $row['regcode'] )
{
$this->lost_password_start( "err_reg_code" );
}
else
{
if ( $HTTP_POST_VARS['member_name'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_username" ) );
}
$member_name = trim( strtolower( $ibforums->input['member_name'] ) );
if ( $member_name == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_username" ) );
}
$DB->query( "SELECT name, id, email, mgroup, validate_key FROM ibf_members WHERE LOWER(name)='{$member_name}'" );
if ( !$DB->get_num_rows( ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_such_user" ) );
}
else
{
$member = $DB->fetch_row( );
if ( $member['mgroup'] == $ibforums->vars['auth_group'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "val_key_present" ) );
}
if ( $member['id'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_such_user" ) );
}
$new_pass = $std->make_password( );
$validate_key = $std->make_password( );
$md5_pass = md5( $new_pass );
$DB->query( "UPDATE ibf_members SET new_pass='{$md5_pass}', validate_key='{$validate_key}' WHERE id='".$member['id']."'" );
$this->email->get_template( "lost_pass" );
$this->email->build_message( array(
"NAME" => $member['name'],
"PASSWORD" => $new_pass,
"MAN_LINK" => $this->base_url_nosess."?act=Reg&CODE=06",
"EMAIL" => $member['email'],
"ID" => $member['id'],
"CODE" => $validate_key,
"IP_ADDRESS" => $ibforums->input['IP_ADDRESS']
) );
$this->email->subject = $ibforums->lang['lp_subject']." ".$ibforums->vars['board_name'];
$this->email->to = $member['email'];
$this->email->send_mail( );
$std->my_setcookie( "pass_hash", "-1", 0 );
$print->redirect_screen( $ibforums->lang['lp_redirect'], "act=Reg&CODE=06" );
}
}
}
}
}
function show_reg_form( $errors = "" )
{
global $ibforums;
global $DB;
global $std;
if ( $ibforums->vars['no_reg'] == 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "reg_off" ) );
}
if ( $ibforums->vars['reg_auth_type'] )
{
$ibforums->lang['std_text'] .= "<br>".$ibforums->lang['email_validate_text'];
}
if ( $ibforums->vars['reg_antispam'] )
{
$r_date = time( ) - 21600;
$DB->query( "DELETE FROM ibf_reg_antispam WHERE ctime < '{$r_date}'" );
$regid = md5( uniqid( microtime( ) ) );
mt_srand( ( double )microtime( ) * 1000000 );
$reg_code = mt_rand( 100000, 999999 );
$str = $DB->compile_db_insert_string( array(
"regid" => $regid,
"regcode" => $reg_code,
"ip_address" => $ibforums->input['IP_ADDRESS'],
"ctime" => time( )
) );
$DB->query( "INSERT INTO ibf_reg_antispam ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
}
$required_output = "";
$optional_output = "";
$field_data = array( );
$DB->query( "SELECT * from ibf_pfields_data WHERE fedit=1 AND fshowreg=1 ORDER BY forder" );
while ( $row = $DB->fetch_row( ) )
{
$form_element = "";
if ( $row['freq'] == 1 )
{
$ftype = "required_output";
}
else
{
$ftype = "optional_output";
}
if ( $row['ftype'] == "drop" )
{
$carray = explode( "|", trim( $row['fcontent'] ) );
$d_content = "";
foreach ( $carray as $entry )
{
$value = explode( "=", $entry );
$ov = trim( $value[0] );
$td = trim( $value[1] );
if ( $ov != "" && $td != "" )
{
$d_content .= "<option value='{$ov}'>{$td}</option>\n";
}
}
if ( $d_content != "" )
{
$form_element = $this->html->field_dropdown( "field_".$row['fid'], $d_content );
}
}
else if ( $row['ftype'] == "area" )
{
$form_element = $this->html->field_textarea( "field_".$row['fid'], "" );
}
else
{
$form_element = $this->html->field_textinput( "field_".$row['fid'], "" );
}
$$ftype .= $this->html->field_entry( $row['ftitle'], $row['fdesc'], $form_element );
}
$this->page_title = $ibforums->lang['registration_form'];
$this->nav = array(
$ibforums->lang['registration_form']
);
$coppa = $ibforums->input['coppa_user'] == 1 ? 1 : 0;
if ( $errors != "" )
{
$this->output .= $this->html->errors( $ibforums->lang[$errors] );
}
$this->output .= $this->html->showform( array(
"TEXT" => $ibforums->lang['std_text'],
"RULES" => $ibforums->lang['click_wrap'],
"coppa_user" => $coppa
) );
if ( $ibforums->vars['reg_antispam'] )
{
$this->output = str_replace( "<!--{REG.ANTISPAM}-->", $this->html->reg_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->html->optional_title( )."\n".$optional_output, $this->output );
}
}
function create_account( )
{
global $ibforums;
global $std;
global $DB;
global $print;
global $HTTP_POST_VARS;
if ( $HTTP_POST_VARS['act'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
if ( $ibforums->vars['no_reg'] == 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "reg_off" ) );
}
$coppa = $ibforums->input['coppa_user'] == 1 ? 1 : 0;
$custom_fields = array( );
$DB->query( "SELECT * from ibf_pfields_data WHERE fedit=1" );
while ( $row = $DB->fetch_row( ) )
{
if ( $row['freq'] == 1 && $HTTP_POST_VARS["field_".$row['fid']] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
if ( 0 < $row['fmaxinput'] && $row['fmaxinput'] < strlen( $HTTP_POST_VARS["field_".$row['fid']] ) )
{
$std->error( array(
"LEVEL" => 1,
"MSG" => "cf_to_long",
"EXTRA" => $row['ftitle']
) );
}
$custom_fields["field_".$row['fid']] = $ibforums->input["field_".$row['fid']];
}
$in_username = trim( $ibforums->input['UserName'] );
$in_password = trim( $ibforums->input['PassWord'] );
$in_email = strtolower( trim( $ibforums->input['EmailAddress'] ) );
$ibforums->input['EmailAddress_two'] = strtolower( trim( $ibforums->input['EmailAddress_two'] ) );
if ( $ibforums->input['EmailAddress_two'] != $in_email )
{
$this->show_reg_form( "err_email_address_match" );
}
else
{
$in_username = preg_replace( "/\\s{2,}/", " ", $in_username );
if ( empty( $in_username ) )
{
$this->show_reg_form( "err_no_username" );
}
else if ( strlen( $in_username ) < 3 )
{
$this->show_reg_form( "err_no_username" );
}
else if ( 32 < strlen( $in_username ) )
{
$this->show_reg_form( "err_no_username" );
}
else if ( empty( $in_password ) )
{
$this->show_reg_form( "err_no_password" );
}
else if ( strlen( $in_password ) < 3 )
{
$this->show_reg_form( "err_no_password" );
}
else if ( 32 < strlen( $in_password ) )
{
$this->show_reg_form( "err_no_password" );
}
else if ( $ibforums->input['PassWord_Check'] != $in_password )
{
$this->show_reg_form( "err_pass_match" );
}
else if ( strlen( $in_email ) < 6 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -