private function check_verifycode() { /*********** 验证码 ***********/ include ROOT_PATH . 'lib/class/verifycode.class.php'; $mVerifyCode = new verifyCode(); if (defined('IS_RESETPASSWORD_VERIFYCODE') && IS_RESETPASSWORD_VERIFYCODE && $this->settings['App_verifycode'] && empty($this->input['is_mobile_verifycode'])) { $code = trim($this->input['verify_code']); //验证码 $session_id = $this->input['session_id']; //标识 if (!$code) { $this->errorOutput(NO_VERIFY_CODE); } if (!$session_id) { $this->errorOutput(NO_SESSION_ID); } $check_result = $mVerifyCode->check_verify_code($code, $session_id); //验证验证码 if ($check_result != 'SUCCESS') { $this->errorOutput(VERIFY_FAILED); } } /***************************/ }
<?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); //验证码 error_reporting(E_ERROR | E_WARNING | E_PARSE); $verify = new verifyCode(); for ($i = 0; $i <= 3; $i++) { $zz = rand(1, 9); $code .= $zz; } setCookie("CODEIMG", $code, time() + 3600, "/"); //$code=$_COOKIE["CODEIMG"]; $code = strrev($code) + 5 * 2 - 9; $code = substr($code, 0, 4); $verify->vCode($code); $verify->Output(); class verifyCode { var $Noisy = 0; // 干扰点出现的概率 var $Count = 4; // 字符数量 var $Width = 60; // 图片宽度 var $Height = 18; // 图片高度 var $Angle = 0; // 角度随机变化量
/** * * 验证码 * @param unknown_type $verifycode 验证码 * @param unknown_type $session_id 验证码标识 */ private function check_verify_code($verifycode, $session_id) { require_once ROOT_PATH . 'lib/class/verifycode.class.php'; $mVerifyCode = new verifyCode(); $check_result = $mVerifyCode->check_verify_code($verifycode, $session_id); //验证验证码 if ($check_result != 'SUCCESS') { $this->errorOutput($check_result); } }
private function check_verifycode($type = '') { /*********** 验证码 ***********/ require ROOT_PATH . 'lib/class/verifycode.class.php'; $mVerifyCode = new verifyCode(); $avoidLoginVerifyCode = dexplode($this->settings['avoidLoginVerifyCode'], 1); if (defined('IS_LOGIN_VERIFYCODE') && IS_LOGIN_VERIFYCODE && $this->settings['App_verifycode'] && empty($this->input['is_mobile_verifycode']) && empty($this->input['isSynLogin']) && !in_array($type, $avoidLoginVerifyCode)) { $code = trim($this->input['verify_code']); //验证码 $session_id = $this->input['session_id']; //标识 if (!$code) { $this->errorOutput(NO_VERIFY_CODE); } if (!$session_id) { $this->errorOutput(NO_SESSION_ID); } $check_result = $mVerifyCode->check_verify_code($code, $session_id); //验证验证码 if ($check_result != 'SUCCESS') { $this->errorOutput(VERIFY_FAILED); } } /***************************/ }