public function verification()
{
if ($_GET['verification'] != null) {
$list = explode("\t", base64_decode($_GET['verification']));
if (count($list) > 2) {
$user = User::getUserByEmail($list[0]);
$verification = trim($list[1]);
$json = json_decode($user->forgePwdCode, true);
$userVerificationCode = $json['verification'];
$verifyTime = intval($json['time']);
$baseURL = BASE_URL . 'auth/login';
if ($userVerificationCode == $verification && $verifyTime + 1800 > time()) {
$mailer = Mailer::getInstance();
$mailer->toQueue(true, true);
$mail = new Mail();
$mail->to = $user->email;
$mail->subject = '[' . SITE_NAME . '] 账户注册并校验成功通知';
$mail->content = Option::get('custom_mail_register_content');
$params = ['nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
$mail->content = Utils::placeholderReplace($mail->content, $params);
$mailer->send($mail);
$user->enable = 1;
$user->forgePwdCode = null;
$user->save();
$html = <<<EOF
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8">
<title>邮箱校验成功 - 账户注册</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
</head>
<body>
<p>校验成功,感谢您的注册。您现在可以使用本站所有服务了。</p>
<p style="color: #999; font-size: 12px;"><a href="{$baseURL}">3秒后跳转到登录页</a></p>
<script>setTimeout("window.location.href = '/auth/login#login';", 3000);</script>
</body>
</html>
EOF;
echo $html;
exit;
}
}
$html = <<<EOF
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8">
<title>邮箱校验失败 - 账户注册</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
</head>
<body>
<p>校验失败,校验时间超时或校验码不对。</p>
<p style="color: #999; font-size: 12px;"><a href="{$baseURL}">3秒后跳转到登录页</a></p>
<script>setTimeout("window.location.href = '/auth/login#login';", 3000);</script>
</body>
</html>
EOF;
echo $html;
exit;
}
}