<?php

class reEmailVer_sxExe extends xIExecutor {

	public function main() {
		global $_SLEX;
		if(!xUser::$cur->is(USR_R0_EMAILVER)) {
			$key = new xKey(true, 11, 32, xUser::$cur, 1, 0, 3600); 
			// --- 发送邮件 ---
			include_once(__ROOT__.'exts/PHPMailer_5.2.4/class.phpmailer.php');
			$mail = new PHPMailer();
			$mail->CharSet = 'UTF-8';
			$mail->IsSMTP();
			$mail->SMTPAuth = true;
			if($_SLEX['smtp']['ssl']=='1') $mail->SMTPSecure = 'ssl';
			$mail->SetFrom($_SLEX['smtp']['from'], $_SLEX['smtp']['from']);
			$mail->AddReplyTo($_SLEX['smtp']['from'], $_SLEX['smtp']['from']);
			$mail->Port = $_SLEX['smtp']['port'];
			$mail->Host = $_SLEX['smtp']['smtp'];
			$mail->Username = $_SLEX['smtp']['username'];
			$mail->Password = $_SLEX['smtp']['password'];
			$mail->Subject = '【邮箱验证】' . $_SLEX['site']['title'];
			$mail->AltBody = '';
			$mail->MsgHTML('请点击以下链接进行邮箱验证：<a href="http://'.$_SERVER['HTTP_HOST'].'/verify.php?key='.$key->key.'" target="_blank">http://'.$_SERVER['HTTP_HOST'].'/verify.php?key='.$key->key.'</a><br />（如果以上链接无法点击请复制到浏览器进行访问）');
			$mail->AddAddress(xUser::$cur->email, xUser::$cur->email);
			$mail->Send();
			echo json_encode(array(
				'result' => '1'
			));
		} else {
			echo json_encode(array(
				'result' => '0',
				'msg' => '您的账户已经经过验证无需再次验证'
			));
		}
	}

	public function onError($result) {

	}
}

