function pageEntry($inPath) { /** * 初始化类 */ $cap = new SCaptcha(); /** * 生成图片,返回验证码 */ $code = $cap->CreateImage(); /** * 检验验证码 */ if (SCaptcha::check($code)) { error_log(true); } else { error_log(false); } }
function pagelogin($inPath) { $urlParams = $this->getUrlParams($inPath); if (!$_POST) { $this->params['head_title'] = "管理登录-" . $this->params['head_title']; return $this->render("main/login.html", $this->params); } else { $_POST = base_Utils::shtmlspecialchars($_POST); //session_start(); if (!SCaptcha::check($_POST['captcha'])) { $modelAdmin = new m_admin(); $loginInfo = $modelAdmin->checkLogin($_POST['username'], $_POST['pwd'], (int) $_POST['timeout']); if ($loginInfo) { $this->redirect($this->createUrl('/')); } else { $this->ShowMsg("用户名或者密码错误!"); } } else { $this->ShowMsg("验证码错误!"); } } }
/** * 验证验证码 */ public function checkCatcha($s) { session_start(); $oSC = new SCaptcha(); return $oSC->check($s); }