<?php
include "../core.php";
$uid = 0;
$time = 0;
$verify = '';
include SAXUE_ROOT_PATH . "/common/function.php";
$data = trim( $_REQUEST['data'] );
if ( !empty( $data ) ) {
		$tmp = saxue_crypt( $data );
		$arr = explode( '|', $tmp );
		if ( is_array( $arr ) && count( $arr ) == 3 ) {
				$uid = intval( $arr[0] );
				$time = intval( $arr[1] );
				$verify = trim( $arr[2] );
		}
}
if ( empty( $uid ) || empty( $time ) || empty( $verify ) ) {
		saxue_printfail( '帐号激活链接错误' );
} 
saxue_getconfigs( 'configs', 'member' );
$saxueConfigs['member']['regacttime'] = intval( $saxueConfigs['member']['regacttime'] );
if ( !empty( $saxueConfigs['member']['regacttime'] ) && ( $saxueConfigs['member']['regacttime'] * 3600 + $time ) < SAXUE_NOW_TIME ) {
		saxue_printfail( '帐号激活链接已过期' );
} 
include SAXUE_ROOT_PATH . "/model/member_users.php";
$users_handler = &saxuememberusershandler :: getinstance( "saxuememberusershandler" );
$saxueUsers = $users_handler -> get( $uid );
if ( !$saxueUsers || $saxueUsers -> getvar( "status", "n" ) != 0 ) {
		saxue_printfail( 'ID不存在或您不是等待验证会员' );
} 
$tmp = md5( $uid . $saxueUsers -> getvar( "email" ) . $saxueUsers -> getvar( "password" ) );
if ( $verify != $tmp ) {
		saxue_printfail( '帐号激活链接验证失败' );
} 
$saxueUsers -> setvar( "status", 1 );
$saxueUsers -> unsetnew();
if ( !$users_handler -> insert( $saxueUsers ) ) {
		saxue_printfail( '帐号激活失败，请与管理员联系' );
} 
saxue_jumppage( '/member/', '您的帐号已激活，正在跳转到会员登录页面' );
