function test_verifyComplete() { $verify = new Verify(); $verify->initUser("11ad", "*****@*****.**", null); $verify->verifyUser(); $this->assertTrue(!empty($verify->status)); }
public function changeName() { $Verify = new Verify(); $first = trim(strip_tags($_POST['first'])); $middle = trim(strip_tags($_POST['middle'])); $last = trim(strip_tags($_POST['last'])); if (!$Verify->length($first, 255)) { $_SESSION['alert'] = 'Your first name is too long to store in the database.'; } elseif (!$Verify->length($middle, 255)) { $_SESSION['alert'] = 'Your middle name is too long to store in the database.'; } elseif (!$Verify->length($last, 255)) { $_SESSION['alert'] = 'Your last name is too long to store in the database.'; } else { $Db = new Db(); $query = $Db->query('user_name', array(array('user_id', '=', $_SESSION['user'], ''))); $numrows = mysqli_num_rows($query); if ($numrows != 1) { $_SESSION['alert'] = 'Error, please try again.'; } else { while ($row = mysqli_fetch_assoc($query)) { if ($first == '') { $first = $row['first']; } if ($middle == '') { $middle = $row['middle']; } if ($last == '') { $last = $row['last']; } } $updateFirst = $Db->update('user_name', array('first', '=', $first), array(array('user_id', '=', $_SESSION['user'], ''))); if (!$updateFirst) { $_SESSION['alert'] = 'Error, could not completely update name.'; } else { $updateMiddle = $Db->update('user_name', array('middle', '=', $middle), array(array('user_id', '=', $_SESSION['user'], ''))); if (!$updateMiddle) { $_SESSION['alert'] = 'Error, could not completely update name.'; } else { $updateLast = $Db->update('user_name', array('last', '=', $last), array(array('user_id', '=', $_SESSION['user'], ''))); if (!$updateLast) { $_SESSION['alert'] = 'Error, could not completely update name.'; } else { $_SESSION['alert'] = 'Your name has been updated.'; } } } } } }
/** * 复制文件或目录 * @param string $src * @param string $dst * @param string $except * @return boolean */ public static function copys($src, $dst, $except = null) { if (is_file($src)) { if ($except !== null && (realpath($except) == realpath($src) || realpath($except) == realpath($dst))) { return true; } return @copy($src, $dst); } Verify::isTrue(is_dir($src), "{$src} not a file nor a dir"); $dir = dir($src); @mkdir($dst); while (false !== ($file = $dir->read())) { if ($file != '.' && $file != '..') { $src_path = $src . '/' . $file; $dst_path = $dst . '/' . $file; if (!self::copys($src_path, $dst_path)) { $dir->close(); return false; } Logger::debug("file copy from {$src_path} to {$dst_path}"); } } $dir->close(); return true; }
/** * 写入文件 * @param string $path 路径 * @param mixed $data 写入的值 * @param boolean $overwrite 是否覆盖已有文件 * @return boolean */ public static function write($path, $data, $overwrite = true) { $path = str_replace('\\', '/', $path); $pos = strrpos($path, '/'); $file_name = ""; $file_dir = ""; if ($pos === false) { $file_name = $path; } else { $file_dir = substr($path, 0, $pos + 1); $file_name = substr($path, $pos + 1); } $tmp_file = tempnam($file_dir, 'tsb_sfw'); Verify::isTrue(false !== file_put_contents($tmp_file, $data), "write to file: {$tmp_file} failed"); if ($overwrite) { @unlink($path); //删除原始文件 } if (!@rename($tmp_file, $path)) { @unlink($tmp_file); //删除原始文件 Verify::e("write to file: {$tmp_file} failed"); return false; } return true; }
/** * @param string|array $file_name 文件的绝对路径 */ function __construct($file_name) { $file_names = array(); if (is_string($file_name)) { $file_names[] = $file_name; } else { Verify::isTrue(is_array($file_name)); $file_names = $file_name; } foreach ($file_names as $file_name) { if (is_file($file_name)) { $this->file_name[$file_name] = @filemtime($file_name); } else { $this->file_name[$file_name] = @filemtime($file_name); if (!is_dir($file_name)) { continue; } $files = @dir($file_name); Verify::isTrue($files !== null, "open dir {$file_name} failed"); while (!!($file = $files->read())) { if ($file == '.' || $file == '..') { continue; } $this->file_name[$file_name . '/' . $file] = @filemtime($file_name . '/' . $file); } $files->close(); } } }
/** * 获取校验结果 * @return type */ public static function getVerifyResult() { $context = new Context(); $typhoon = new Typhoon(); if ($typhoon->isValid()) { $ssid = $typhoon->_ssid; $name = $typhoon->_name; $value = $context->get($name, ''); if ($value != '') { if ($typhoon->_request_type == 1) { $ret = Valid::sendVerifyRemoteRequest($ssid, $value, $typhoon->_diff_time); } else { $ret = Valid::sendVerifyLocalRequest($ssid, $value); } self::$_result = Valid::getResult(); self::$_code = Valid::getCode(); self::$_details = Valid::getDetails(); } else { self::$_result = 0; self::$_code = 'E_VALUEEMPTY_001'; self::$_details = '验证码不可以为空'; } } else { self::$_result = 0; self::$_code = 'E_PARAM_001'; self::$_details = '重要参数传递错误'; } return self::$_result === 1 ? TRUE : FALSE; }
/** * 方法,绑定参数 * 如 * func,arg1,arg2 * array('a','method1'), arg1,arg2 */ public function __construct() { $args = func_get_args(); Verify::isTrue(count($args) > 0); Verify::isTrue(is_callable($args[0])); $this->func = $args[0]; $this->bind = array_slice($args, 1); }
/** * 初始化 * @param array $args 参数列表 */ public function initArgs($args) { $cnst = $this->refl->getConstructor(); if ($cnst !== null) { $cnst->invokeArgs($this->obj, $args); } else { Verify::isTrue(count($args) === 0, $this->refl->getName() . ' no constructor found with ' . func_num_args() . ' params'); } }
public function register() { $Token = new Token(); if (!$Token->check($_POST['token'])) { $_SESSION['alert'] = 'Error, please try again.'; } else { $Verify = new Verify(); $username = trim(strip_tags($_POST['username'])); $password = trim(strip_tags($_POST['password'])); $repassword = trim(strip_tags($_POST['repassword'])); $email = trim(strip_tags($_POST['email'])); $email = explode('@', $email); if (!isset($username) && !isset($password) && !isset($repassword) && !isset($email)) { $_SESSION['alert'] = 'Not all fields have been completed.'; } elseif (!$Verify->length($username, 255)) { $_SESSION['alert'] = 'The username is too long.'; } elseif (!$Verify->same($password, $repassword)) { $_SESSION['alert'] = 'The passwords entered are not the same.'; } elseif (!$Verify->length($email[0], 255)) { $_SESSION['alert'] = 'The email entered is too long.'; } elseif (!$Verify->length($email[1], 255)) { $_SESSION['alert'] = 'The email entered is too long.'; } else { $Db = new Db(); $query = $Db->query('user', array(array('username', '=', $username, ''))); $numrows = mysqli_num_rows($query); if ($numrows > 0) { $_SESSION['alert'] = 'Error, please try again.'; } else { $salt = base64_encode(mcrypt_create_iv(128, MCRYPT_DEV_URANDOM)); $crypt = hash('sha512', $username . $salt . $password); $datetime = date('Y-m-d H:i:s'); $rank = 0; $insert = $Db->insert('user', array('', $username, $crypt, $email[0], $email[1], $salt, $datetime, $rank)); if (!$insert) { $_SESSION['alert'] = 'User could not be registered.'; } else { $_SESSION['alert'] = 'Successfully registered, you can now login with your credentials.'; header('Location: login.php'); } } } } }
public function register($username, $password) { if (empty($username) || empty($password)) { $data = array('error' => 1, 'msg' => '用户名或密码不能为空'); return $data; } if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) { $data = array('error' => 1, 'msg' => '用户名格式不正确'); return $data; } //首先判断用户名是否重复 if ($this->where(array('user_name' => $username))->count()) { $data = array('error' => 1, 'msg' => '此用户名已经注册'); return $data; } //密码加密处理 //1.生成8位随机密钥 $salt = rand(10, 99) . substr(uniqid(), 7, 6); $new_password = md5(md5($password) . $salt); $arr = array('user_name' => $username, 'password' => $new_password, 'salt' => $salt, 'regtime' => time()); import('Org.Util.Verify'); //引入验证类 $verify = new \Verify(); $extends = array(); //1.如果用户格式为手机号 if ($verify->isMobile($username)) { $extends = array('phone' => $username); } //2.如果用户格式为邮箱 if ($verify->isEmail($username)) { //此处需要生成token,暂时未添加 $extends = array('email' => $username); } //合并数据 $arr = array_merge($arr, $extends); //var_dump($arr);exit; if ($this->add($arr)) { $data = array('error' => 0, 'msg' => '用户注册成功'); } else { $data = array('error' => 1, 'msg' => '用户注册失败,请稍后重试'); } return $data; }
public function create() { $Token = new Token(); if (!$Token->check($_POST['token'])) { $_SESSION['alert'] = 'Error, please try again.'; } else { $Verify = new Verify(); $username = trim(strip_tags($_POST['username'])); $email = trim(strip_tags($_POST['email'])); $password = trim(strip_tags($_POST['password'])); $rank = $_POST['rank']; $email = explode('@', $email); if (!isset($username) && !isset($email) && !isset($password) && !isset($rank)) { $_SESSION['alert'] = 'Not all fields have been completed.'; } elseif (!$Verify->length($username, 255)) { $_SESSION['alert'] = 'The username is too long.'; } elseif (!$Verify->length($email[0], 255)) { $_SESSION['alert'] = 'The email entered is too long.'; } elseif (!$Verify->length($email[1], 255)) { $_SESSION['alert'] = 'The email entered is too long.'; } else { $Db = new Db(); $query = $Db->query('user', array(array('username', '=', $username, ''))); $numrows = mysqli_num_rows($query); if ($numrows > 0) { $_SESSION['alert'] = 'Error, please try again.'; } else { $salt = base64_encode(mcrypt_create_iv(128, MCRYPT_DEV_URANDOM)); $crypt = hash('sha512', $username . $salt . $password); $datetime = date('Y-m-d H:i:s'); $insert = $Db->insert('user', array('', $username, $crypt, $email[0], $email[1], $salt, $datetime, $rank)); if (!$insert) { $_SESSION['alert'] = 'User could not be created.'; } else { $_SESSION['alert'] = 'The user "' . $username . '" was created.'; } } } } }
function verify_code($body_arr) { $fontSize = isset($body_arr['fontSize']) && $body_arr['fontSize'] != 'undefined' ? $body_arr['fontSize'] : 36; $length = isset($body_arr['length']) && $body_arr['length'] != 'undefined' ? $body_arr['length'] : 4; $useNoise = isset($body_arr['useNoise']) && $body_arr['useNoise'] != 'undefined' ? $body_arr['useNoise'] : 1; $useCurve = isset($body_arr['useCurve']) && $body_arr['useCurve'] != 'undefined' ? $body_arr['useCurve'] : 0; if (!isset($_SESSION)) { session_start(); } $config = array('fontSize' => $fontSize, 'length' => $length, 'useNoise' => $useNoise, 'useCurve' => $useCurve); $code = $body_arr['code']; //isset($_POST['inputcode'])?$_POST['inputcode']:''; //print_r($code); //echo $_SESSION["verify_code"];exit; $Verify = new Verify($config); if ($Verify->authcode(strtoupper($code)) == $_SESSION['verify_code']) { $data['status'] = 0; } else { $data['status'] = 1003; } //print_r($data);exit; return $data; }
public function verify() { global $_FANWE; $seccode = random(6, 1); $seccodeunits = ''; $s = sprintf('%04s', base_convert($seccode, 10, 24)); $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789'; $seccode = ''; for ($i = 0; $i < 4; $i++) { $unit = ord($s[$i]); $seccode .= $unit >= 0x30 && $unit <= 0x39 ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57]; } $rhash = $_FANWE['request']['rhash']; fSetCookie('verify' . $rhash, authcode(strtoupper($seccode) . "\t" . (TIME_UTC - 180) . "\t" . $rhash . "\t" . FORM_HASH, 'ENCODE', $_FANWE['config']['security']['authkey']), 0, 1, true); @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); require fimport('class/verify'); $verify = new Verify(); $verify->code = $seccode; $verify->width = 100; $verify->height = 36; $verify->display(); }
/** * 输出验证码并把验证码的值保存的session中 * 验证码保存到session的格式为: $_SESSION[self::$seKey] = array('code' => '验证码值', 'time' => '验证码创建时间'); */ public static function entry() { // 图片宽(px) self::$imageL || (self::$imageL = self::$length * self::$fontSize * 1.5 + self::$fontSize * 1.5); // 图片高(px) self::$imageH || (self::$imageH = self::$fontSize * 2); // 建立一幅 self::$imageL x self::$imageH 的图像 self::$_image = imagecreate(self::$imageL, self::$imageH); // 设置背景 imagecolorallocate(self::$_image, self::$bg[0], self::$bg[1], self::$bg[2]); // 验证码字体随机颜色 self::$_color = imagecolorallocate(self::$_image, mt_rand(1, 120), mt_rand(1, 120), mt_rand(1, 120)); // 验证码使用随机字体 $ttf = $_SERVER['DOCUMENT_ROOT'] . WEB_DATA . 'fonts/' . mt_rand(1, 6) . '.ttf'; //$ttf = $_SERVER['DOCUMENT_ROOT'].WEB_DATA.'fonts/4.ttf'. if (self::$useNoise) { // 绘杂点 self::_writeNoise(); } if (self::$useCurve) { // 绘干扰线 self::_writeCurve(); } // 绘验证码 $code = array(); // 验证码 $codeNX = 0; // 验证码第N个字符的左边距 for ($i = 0; $i < self::$length; $i++) { $code[$i] = self::$codeSet[mt_rand(0, 27)]; $codeNX += mt_rand(self::$fontSize * 1.2, self::$fontSize * 1.6); // 写一个验证码字符 imagettftext(self::$_image, self::$fontSize, mt_rand(-40, 70), $codeNX, self::$fontSize * 1.5, self::$_color, $ttf, $code[$i]); } // 保存验证码 isset($_SESSION) || session_start(); $_SESSION[self::$seKey]['code'] = join('', $code); // 把校验码保存到session $_SESSION[self::$seKey]['time'] = time(); // 验证码创建时间 header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header("content-type: image/png"); // 输出图像 imagepng(self::$_image); imagedestroy(self::$_image); }
function signupUser($email, $password, $name, $screenName) { global $dbCon; if (!Verify::email($email)) { echo 'invalid email'; return; } if (!Verify::password($password)) { echo 'invalid password'; return; } if (!Verify::name($name)) { echo 'invalid name'; return; } if (!Verify::name($screenName)) { echo 'invalid screen name'; return; } $cols = "email, password, name, screen_name"; $values = "'{$email}', '{$password}', '{$name}', '{$screenName}'"; //$dbCon = openConnection(); $sql = "SELECT user_id FROM users WHERE email='{$email}'"; $row = $dbCon->query($sql)->fetch(PDO::FETCH_ASSOC); if (!$row) { //echo $sql; $sql = 'INSERT INTO users (' . $cols . ') VALUES (' . $values . ')'; try { $rowCount = $dbCon->exec($sql); if ($rowCount > 0) { $sql = "SELECT user_id FROM users WHERE email='{$email}'"; $row = $dbCon->query($sql)->fetch(PDO::FETCH_ASSOC); _setNewUserPrefs($row['user_id']); loginUser($email, $password); } else { echo 'Error registering user, plese try again'; } } catch (Exception $e) { throw new Exception('DB error ' . $e->getMessage()); } } else { echo "e-mail already registered"; } }
public function resendCode() { $code = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 5); $mobile = $this->f3->get('SESSION.mobile'); $verify = new Verify($this->db); $verify->getUserMobile($mobile, $code); $this->f3->reroute('/confirmation/New code resend to your phone number'); }
public function login($admin = false) { global $mysql, $config; if (!isset($_POST['username']) || !isset($_POST['password'])) { return 'error_invalid_username_or_password'; } //验证码验证 if (isset($_POST['verify'])) { if (empty($_POST['verify'])) { return 'error_verify_invalid_empty'; } require_once ROOT_PATH . '/classes/Verify.class.php'; $verify = new Verify(); $yz_verify = $verify->check($_POST['verify'], 1); if (!$yz_verify) { return 'error_invalid_verify'; } } else { return 'error_verify_invalid_empty'; } $mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `users`\n\t\t\tWHERE `username` = '" . sql_quote($_POST['username']) . "' AND `password` = '" . md5(md5($_POST['password'])) . "'\n\t\t", __FUNCTION__); if ($mysql->num_rows() == 0) { return 'error_invalid_username_or_password'; } $row = $mysql->fetch_array(); if ($row['status'] != 'activate') { return 'error_invalid_activation_no'; } $user = $this->get($row['user_id']); if ($user['last_login_datetime'] == '' || $user['last_login_datetime'] == '0000-00-00 00:00:00') { $user['first_login'] = '******'; } if ($admin && ($user['groups'] == false || count($user['groups']) < 1)) { return 'error_invalid_username_or_password'; } $verKey = ''; if (isset($_POST['rememberme'])) { $verKey = md5(rand(0, 9999999) . time() . $user['user_id']); setcookie("user_id", $user['user_id'], time() + 2592000, "/", "." . $config['domain']); setcookie("verifyKey", $verKey, time() + 2592000, "/", "." . $config['domain']); } $mysql->query("\n\t\t\tUPDATE `users`\n\t\t\tSET `last_login_datetime` = NOW(),\n\t\t\t\t\t`ip_address` = '" . sql_quote($_SERVER['REMOTE_ADDR']) . "', \n\t\t\t\t\t`remember_key` = '" . sql_quote($verKey) . "'\n\t\t\tWHERE `user_id` = '" . intval($user['user_id']) . "'\n\t\t\tLIMIT 1\n\t\t", __FUNCTION__); $_SESSION['user'] = $user; return true; }
/** * 运行消息循环 * @return void */ public function run() { if ($this->is_running) { return; } Logger::debug("[MQ Pump] begin"); $this->is_running = true; while (count($this->next_action) || count($this->next_idle)) { //没有活动事件,执行idle事件 if (count($this->next_action) === 0) { $queue_id = array_pop($this->next_idle); if (!isset($this->idle_queues[$queue_id])) { // 队列可能被关闭 continue; } $idle = array_pop($this->idle_queues[$queue_id]); Verify::isTrue($idle !== null, 'never been here!!'); if ($idle[2] !== null) { try { call_user_func_array($idle[0], $idle[1]); } catch (\Exception $e) { $idle[2]($e); } } else { call_user_func_array($idle[0], $idle[1]); } continue; } $queue_id = array_pop($this->next_action); if (!isset($this->action_queues[$queue_id])) { // 队列可能被关闭 continue; } $actions =& $this->action_queues[$queue_id]; $left = count($actions); $action = array_pop($actions); if ($action !== null) { $this->callAction($queue_id, $action); } elseif ($left !== 0) { //null插入队列,表示执行队列结束, 可以安全关闭队列了 $onend = $this->end_handles[$queue_id]; unset($this->action_queues[$queue_id]); unset($this->idle_queues[$queue_id]); unset($this->end_handles[$queue_id]); Logger::debug("[MQ {$queue_id}] closed"); if ($onend !== null) { $onend(); } } } //不是在单个队列为空时将其关闭,因为对于存在子流程的时候,其消息队列可能为空,但 //其他流程执行可能导致子流程产生活动消息,所以不能在队列为空时就关闭队列 foreach ($this->end_handles as $onend) { if ($onend !== null) { $onend(); } } $this->next_action = array(); $this->next_idle = array(); $this->action_queues = array(); $this->idle_queues = array(); $this->end_handles = array(); $this->is_running = false; Logger::debug("[MQ Pump] end"); }
curl_setopt($ch, CURLOPT_TIMEOUT, 16); // timeout on response curl_setopt($ch, CURLOPT_ENCODING, ""); // handle all encodings curl_setopt($ch, CURLOPT_USERAGENT, ""); // who am i $response = curl_exec($ch); curl_close($ch); $resp = explode("\n", $response); } else { $resp = file("$url/$purl"); } return $resp; } } } } $verify = new Verify(); if($verify->account->valid=='true'){ echo $verify->showBadge_contents(); } unset($verify); class Verify{ public $sl_module_ver = '5.2.06'; public $account = null; public $filepath = null; public $ip = null; private $host = null; private $uri = null; private $config_fp = null;
<?php // +---------------------------------------------------------------------- // | Demila [ Beautiful Digital Content Trading System ] // +---------------------------------------------------------------------- // | Copyright (c) 2015 http://demila.org All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- //生成验证码 require_once ROOT_PATH . '/classes/Verify.class.php'; $verify = new Verify(); $verify->entry(1);
/** * 替换字典 * @see setDict * @param string|array $value * @return void */ private function replaceByDict($value, $dict) { if (is_string($value)) { $keys = $this->getDictKeys($value); foreach ($keys as $key) { Verify::isTrue(isset($dict[$key]), "{$key} not specified"); } foreach ($dict as $key => $replace) { $value = str_replace('{' . $key . '}', $replace, $value); } return $value; } else { if (is_array($value)) { foreach ($value as $k => $v) { $value[$k] = $this->replaceByDict($v, $dict); } return $value; } else { return $value; } } }
NSSError($theVerify->formInitError(), "Verify error"); $smarty->display('error.tpl'); } else { if (!$theVerify->sendVerifyEmail()) { NSSError("Sending the verification email failed.", "Email error"); } $smarty->assign('autoHome', TRUE); $smarty->display('verify_sent.tpl'); } exit; } // If they reached here, they failed the Captcha test $smarty->assign('verifyFailed', TRUE); } else { // They are an authorised user so don't need a Captcha if ($theVerify = new Verify($theDropbox)) { if ($theVerify->formInitError() != "") { NSSError($theVerify->formInitError(), "Verify error"); $smarty->display('error.tpl'); } else { // The for worked, go for it! $theDropbox->SetupPage(); $authFullName = $theDropbox->authorizedUserData("displayName"); $authEmail = $theDropbox->authorizedUserData("mail"); $authOrganization = paramPrepare($_POST['senderOrganization']); $authOrganization = preg_replace('/[^a-zA-Z0-9\\.\\-\\_\\+\\"\'\\@\\/\\:\\&\\, ]/', '', $authOrganization); $smarty->assign('senderName', $authFullName); $smarty->assign('senderOrg', $authOrganization); $smarty->assign('senderEmail', strtolower($authEmail)); $smarty->assign('recipEmailNum', 1); $smarty->assign('addressbook', $theDropbox->getAddressbook());
private function checkVerity($img_verity) { $verity = new Verify(); return $res = $verity->check($img_verity); }
<?php include_once "./Verify.class.php"; $fontSize = isset($_GET['fontSize']) && $_GET['fontSize'] != 'undefined' ? $_GET['fontSize'] : 36; $length = isset($_GET['length']) && $_GET['length'] != 'undefined' ? $_GET['length'] : 4; $useNoise = isset($_GET['useNoise']) && $_GET['useNoise'] != 'undefined' ? $_GET['useNoise'] : 1; $useCurve = isset($_GET['useCurve']) && $_GET['useCurve'] != 'undefined' ? $_GET['useCurve'] : 0; $config = array('fontSize' => $fontSize, 'length' => $length, 'useNoise' => $useNoise, 'useCurve' => $useCurve); if (!isset($_SESSION)) { session_start(); } $Verify = new Verify($config); $id = $Verify->entry(); echo $id;
_setTitle($langArray['contacts']); //是否登录 check_login(); #加载类别 $categoriesClass = new ccategories(); $categories = $categoriesClass->getAll(0, 0, " `visible` = 'true'"); abr('categories', $categories); #发送联系支持请求 if (isset($_POST['action'])) { //验证码验证 if (isset($_POST['verify'])) { if (empty($_POST['verify'])) { addErrorMessage($langArray['error_verify_invalid_empty'], '', 'error'); } require_once ROOT_PATH . '/classes/Verify.class.php'; $verify = new Verify(); $yz_verify = $verify->check($_POST['verify'], 1); if (!$yz_verify) { addErrorMessage($langArray['error_invalid_verify'], '', 'error'); } else { $contactsClass = new contacts(); $s = $contactsClass->add(); if ($s === true) { refresh('/' . $languageURL . 'support/', $langArray['complete_send_email'], 'complete'); } else { addErrorMessage($langArray['error_all_fields_required'], '', 'error'); } } } else { addErrorMessage($langArray['error_verify_invalid_empty'], '', 'error'); }
public function register() { $registerForm = $this->_createRegisterForm(); $this->set('register_form', $registerForm); if ($registerForm->checkSubmitAndValidate($this->args())) { $username = $this->args('username'); if (!Verify::username($username, $reason)) { /** @var FormField $field */ $field = $registerForm->get('username'); $field->error($reason); } $email = $this->args('email'); $testUser = User::byEmail($email); if ($testUser->isHydrated()) { /** @var FormField $emailField */ $emailField = $registerForm->get('email'); $emailField->error("That email is already being used"); } if ($this->args('pass1') != $this->args('pass2')) { /** @var FormField $field */ $field = $registerForm->get('pass2'); $field->error("Your passwords do not match"); } if (!$registerForm->hasError()) { //woot! $user = new User(); $user->set('username', $username); $user->set('email', $email); $user->set('pass_hash', User::hashPass($this->args('pass1'))); $user->set('registered_on', date("Y-m-d H:i:s")); $user->save(); //create a default queue for them $q = new Queue(); $q->set("name", 'Default'); $q->set("user_id", $user->id); $q->save(); Activity::log("registered a new account on BotQueue.", $user); $text = Controller::byName('email')->renderView('new_user', array('user' => $user)); $html = Controller::byName('email')->renderView('new_user_html', array('user' => $user)); Email::queue($user, "Welcome to " . RR_PROJECT_NAME . "!", $text, $html); //automatically log them in. $token = $user->createToken(); $token->setCookie(); $this->forwardToURL("/"); } } }
public function getCacheOptions($method) { if (!array_key_exists($method, $this->cachedMethods)) { $meta = $this->factory->getMetaInfo($this->factory->getClassName($this->id)); if (isset($meta['cache'][$method]['value'])) { $val = $meta['cache'][$method]['value']; list($k, $v) = $val; Verify::isTrue($k == 'ttl', "no TTL with @cache in {$method}"); $this->cachedMethods[$method][$k] = $v; } } return $this->cachedMethods[$method]; }
/** * 单例方法 */ private static function getInstance() { //规则单例 if (empty(self::$_rules)) { self::$_rules = (require __DIR__ . '/../configure/rules.php'); } //验证方法单例 if (!self::$_validate instanceof Validate) { self::$_validate = \Validate::getInstance(); } }
/** * 获取校验结果 * @return type */ public function run() { $ret = Verify::getVerifyResult(); $back_result = array('code' => Verify::getCode(), 'result' => Verify::getResult(), 'details' => Verify::getDetails()); echo 'yuc_site_config.ajaxresult=' . json_encode($back_result); }
/** * Where语句转 * @param null $where in type string or array * @return string */ private function lodeWhere($where = null) { $_inWhere = ''; // 拼接WHERE $where != null ? $_inWhere = ' WHERE ' : null; // 数组的方式 if (Verify::isArr($where)) { foreach ($where as $k => $v) { $_inWhere .= $k . "='{$v}'" . ' AND '; } $_inWhere = substr($_inWhere, 0, -4); } // 字符串方式 if (is_string($where)) { $_inWhere .= $where; } return $_inWhere; }