public function index() { if ($_POST) { if (!Utility::CaptchaCheck($this->_post('verifycode'))) { Session::Set("error", "验证码有误,请重新输入"); redirect("/login"); } $email = $this->_get("email"); $password = $this->_get("password"); $users = D('Users'); $login_user = $users->getLogin($_POST['email'], $_POST['password']); if (!$login_user) { Session::Set('error', '用户名或密码错误'); $this->redirect("/frontend/login/index"); } else { if ($login_user['is_enabled'] == 'N' && $login_user['secret']) { Session::Set('error', '登录失败'); $this->redirect("/frontend/login/index"); } else { if (abs(intval($_POST['auto_login']))) { Login::Logon($login_user, true); } else { Login::Logon($login_user); } Session::set("success", "登录成功"); if ($_REQUEST['ref']) { redirect($_REQUEST['ref']); } else { redirect("/"); } } } } else { $this->display(); } }
public function submit_contact() { $captcha = $this->_param("captcha"); $subscribe = $this->_param("subscribe"); if (!Utility::CaptchaCheck($captcha, true)) { Session::Set("error", L("captcha_error")); $this->display("error"); return; } $subscriberModel = M("Subscribers"); if ($subscriberModel->create()) { $intrest = $this->_param("intrest"); if ($intrest) { $subscriberModel->intrest = implode(",", $intrest); } $subscriberModel->create_time = time(); $id = $subscriberModel->add(); //send email $contact = $this->_param("contact"); if ($contact) { // $name = $this->_param("name"); //如果联系方式是邮箱,就给对方发一封邮件 if (is_email($contact)) { $email_content = D("Options")->getOption("reply_email_content" . $this->lang); $email_title = D("Options")->getOption("reply_email_title" . $this->lang); Mailer::SmtpMail(null, array($contact), $email_title, $email_content); } } if ($subscribe) { $title = L('subscribe_success'); } else { $title = L('submit_success'); } $this->assign('title', $title); $this->display("subscribe_success"); } }
public function submit_forget_password() { $email = $this->_param("email"); if (!Utility::CaptchaCheck($this->_post('verifycode'))) { Session::Set("error", "验证码有误,请重新输入"); redirect("/register/forget_password"); } if ($email) { $user = D("CmsUsers")->where(array("email" => $email))->find(); if ($user) { $subject = D("Options")->getOption("verify_email_subject"); $repasscode = md5(generate_password()); D("CmsUsers")->where(array('id' => $user['id']))->setField("repasscode", $repasscode); $link = D("Options")->getOption("webroot_apply") . "/register/verify_repass?id=" . Crypt::en($user['id']) . "&repasscode={$repasscode}"; $link = "<a href='{$link}'>" . $link . "</a>"; $subject = D("Options")->getOption("repass_email_subject"); $content = D("Options")->getOption("repass_email_content"); $content = str_replace("[#link#]", $link, $content); Mailer::SmtpMail(null, $email, $subject, $content); redirect("/register/submit_forget_password_result?token=" . Crypt::en($email)); } else { Session::Set("error", "无此邮箱"); redirect("/register/forget_password"); } } else { Session::Set("error", "无此邮箱"); redirect("/register/forget_password"); } }
} } json($html, 'dialog'); } else { json('captcha_again();', 'eval'); } } else { if ('subscribe' == $action) { $html = render('ajax_dialog_smssub'); json($html, 'dialog'); } elseif ('subscribecheck' == $action) { $mobile = trim(strval($_GET['mobile'])); $verifycode = trim(strval($_GET['verifycode'])); $city_id = abs(intval($_GET['city_id'])); $secret = Utility::VerifyCode(); if (Utility::CaptchaCheck($verifycode)) { if (ZSMSSubscribe::Create($mobile, $city_id, $secret) === true) { $html = render('ajax_dialog_smssuc'); } else { $html = render('ajax_dialog_smscode'); sms_secret($mobile, $secret, true); } json($html, 'dialog'); } else { json('captcha_again();', 'eval'); } } else { if ('codeyes' == $action) { $mobile = trim(strval($_GET['mobile'])); $secretcode = trim(strval($_GET['secretcode'])); $sms = Table::Fetch('smssubscribe', $mobile, 'mobile');
function verify_captcha($reason = 'none', $rurl = null) { if (option_yes($reason, false)) { $v = strval($_REQUEST['vcaptcha']); if (!$v || !Utility::CaptchaCheck($v)) { Session::Set('error', '验证码不匹配,请重新输入'); redirect($rurl); } } return true; }