where(['email' => $email, 'appid' => $appid])->find(); //false if ($res_user) out(115, '您的邮箱已经注册过账号了', $app_res); //账号已存在 $title = $app_res['name'] . '注册账号'; $muban = "您注册账号的验证码是:" . $code . ",请不要把验证码泄露给其他人
【" . $app_res['name'] . "】"; } else if ($type == 'seek') { $res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false if (!$res_user) out(122, $app_res); //账号不存在 if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用 if (defined('USER_LOG') && USER_LOG == 1) { Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志 } $title = $app_res['name'] . '找回密码'; $muban = "您找回密码的验证码是:" . $code . ",请不要把验证码泄露给其他人
【" . $app_res['name'] . "】"; } else if ($type == 'untie') { $res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false if (!$res_user) out(122, $app_res); //邮箱不存在 if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用 if (defined('USER_LOG') && USER_LOG == 1) { Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志 } $title = $app_res['name'] . '解绑邮箱'; $muban = "您解绑邮箱的验证码是:" . $code . ",请不要把验证码泄露给其他人
【" . $app_res['name'] . "】"; } else if ($type == 'bind') { $res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false if ($res_user) out(115, '您的邮箱已经绑定过账号了', $app_res); //账号已存在 $title = $app_res['name'] . '绑定邮箱'; $muban = "您绑定邮箱的验证码是:" . $code . ",请不要把验证码泄露给其他人
【" . $app_res['name'] . "】"; } $res_code = Db::table('captcha')->where(['email' => $email, 'appid' => $appid])->order('id DESC')->find(); //false if ($res_code && $res_code['time'] > time() - 180) out(123, $app_res); //验证码频率过快 $config = array(); $config['from_email'] = $app_res['smtp_user']; //发信邮箱 $config['smtp_user'] = $app_res['smtp_user']; //发信邮箱 $config['smtp_port'] = $app_res['smtp_port']; //发信端口 $config['smtp_host'] = $app_res['smtp_host']; //发信服务器 $config['from_name'] = $app_res['name']; //发信标题 $config['smtp_pass'] = $app_res['smtp_pass']; //发信密码 $config['reply_email'] = $app_res['smtp_user']; //回复电子邮件 $config['reply_name'] = $app_res['name']; //回复名称 $config['email_to'] = $email; //收信人 if ($app_res['smtp_user'] == '' or $app_res['smtp_pass'] == '') json(201, '验证码不可用'); $rs = send_mail($config['email_to'], $app_res['name'], $title, $muban, '', $config); if ($rs) { $time = time(); $add_res = Db::table('captcha')->add(['email' => $email, 'code' => $code, 'time' => $time, 'appid' => $appid]); if ($add_res) { out(200, '发送成功', $app_res); //验证码发送成功 } out(201, '验证码入库失败', $app_res); //验证码发送失败 } else { out(201, '发送失败', $app_res); //验证码发送失败 } ?>