public function captcha(){ //获取验证码 $captcha = new Captcha(); //修改响应头 header('Content-type:image/png'); $captcha->generate(); }
/** * Generate a Captcha * @return Response */ public function start($howmany) { $session = new SessionCaptcha(); $captcha = new Captcha($session); $captcha->generate($howmany); return Response::json($captcha->getFrontEndData()); }
/** * ajaxChangeCaptcha 更换验证码 * * @param mixed $request * @param mixed $response * @access public * @return void */ public function ajaxChangeCaptcha($request,$response) {/*{{{*/ $user = UserClient::getInstance()->getCurrentUser(); $userId = 0; if($user->isNull() == false) { $userId = $user->id; } echo Captcha::generate('suggestion', $userId, ContentFactory::TYPE_CHAR, 4, XIpLocation::getIp(), 3); exit; }/*}}}*/
public function executeShow() { // retrieve the user, by fetching from the class defined in app.yml (or in the sfGuardUser class) $user_class = sfConfig::get('app_sfSimpleBlog_user_class', 'sfGuardUser'); $this->user = call_user_func(array($user_class . "Peer", "retrieveByPK"), $this->getUser()->getId()); $this->post = sfSimpleBlogPostPeer::retrieveByStrippedTitleAndDate($this->getRequestParameter('stripped_title'), $this->getDateFromRequest()); $this->forward404Unless($this->post); $this->comments = $this->post->getComments(); if (sfConfig::get('app_sfSimpleBlog_comment_automoderation', 'first_post') === 'captcha') { $g = new Captcha(); $this->getUser()->setAttribute('captcha', $g->generate()); } }
public function execute(&$value, &$error) { $user = sfContext::getInstance()->getUser(); $g = new Captcha($user->getAttribute('captcha')); if ($g->verify($value)) { return true; } // captcha validation failure => we generate another one $g = new Captcha(); $user->setAttribute('captcha', $g->generate()); $error = $this->getParameter('error'); return false; }
public function executeAddComment() { // retrieve contentPeer class from content $this->content_peer = get_class($this->content) . "Peer"; // embed stylesheets $response = sfContext::getInstance()->getResponse(); $response->addStylesheet('/deppPropelActAsCommentableBehaviorPlugin/css/depp_commenting.css'); if (!sfContext::getInstance()->getUser()->isAuthenticated() && $this->automoderation == 'captcha') { $g = new Captcha(); $this->getUser()->setAttribute('captcha', $g->generate()); } // when the current user is authenticated, a connection to the user table is made // then informations about the user (name, email and website) are gathered from the user table // being parametric, this is somewhat complicated, // and is based on the app_deppPropelActAsCommentableBehaviorPlugin plugin $user_options = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_user', array()); $curr_user = $this->getUser(); if ($user_options['enabled'] && $curr_user->isAuthenticated()) { if (is_callable(array($curr_user, $user_options['cu_id_method']))) { $author_id = call_user_func(array($curr_user, $user_options['cu_id_method'])); } if (is_callable(array($user_options['class'] . 'Peer', 'retrieveByPK'))) { $user = call_user_func($user_options['class'] . 'Peer::retrieveByPk', $author_id); if (array_key_exists('name_method', $user_options) && is_callable(get_class($user), $user_options['name_method'])) { $this->author_name = call_user_func(array($user, $user_options['name_method'])); } if (array_key_exists('email_method', $user_options) && is_callable(get_class($user), $user_options['email_method'])) { $this->author_email = call_user_func(array($user, $user_options['email_method'])); } if (array_key_exists('website_method', $user_options) && is_callable(get_class($user), $user_options['website_method'])) { $this->author_website = call_user_func(array($user, $user_options['website_method'])); } } } // set session variable for comments (namespace comment) $this->getUser()->setAttribute('content_id', $this->content->getId(), 'comment'); $this->getUser()->setAttribute('content_peer', $this->content_peer, 'comment'); if (isset($this->original_url)) { $this->getUser()->setAttribute('original_url', $this->original_url, 'comment'); } else { $this->getUser()->setAttribute('original_url', $this->getRequest()->getURI(), 'comment'); } $this->getUser()->setAttribute('read_only', $this->read_only, 'comment'); $this->getUser()->setAttribute('automoderation', $this->automoderation, 'comment'); }
function render() { $config =& Config::getConfig(); // check whether we should also display one of those authentication images if ($config->getValue("use_captcha_auth")) { // generate a file with the captcha class include_once PLOG_CLASS_PATH . "class/data/captcha/captcha.class.php"; $captcha = new Captcha(); $captchaFile = $captcha->generate(); // and then build a full url based on it... $url = $config->getValue("base_url") . "/" . $captchaFile; $this->setValue("userAuthImgPath", $url); $this->setValue("useCaptchaAuth", true); } else { $this->setValue("useCaptchaAuth", false); } parent::render(); }
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $config = Config::getInstance(); $is_registration_open = $config->getValue('is_registration_open'); $this->disableCaching(); $invite_dao = DAOFactory::getDAO('InviteDAO'); if (isset($_GET['code'])) { $invite_code = $_GET['code']; } else { $invite_code = null; } $this->addToView('invite_code', $invite_code); $is_invite_code_valid = $invite_dao->isInviteValid($invite_code); if (!$is_registration_open && !$is_invite_code_valid) { $this->addToView('closed', true); $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>'); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { $valid_input = true; if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email'); $valid_input = false; } if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match.", 'password'); $valid_input = false; } else { if (strlen($_POST['pass1']) < 5) { $this->addErrorMessage("Password must be at least 5 characters.", 'password'); $valid_input = false; } } if (!$captcha->doesTextMatchImage()) { $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha'); $valid_input = false; } if ($valid_input) { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists.", 'email'); } else { // Insert the details into the database $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']); if ($activation_code != false) { $es = new SmartyThinkUp(); $es->caching = false; $server = $_SERVER['HTTP_HOST']; $es->assign('server', $server); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activation_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message); SessionCache::unsetKey('ckey'); $this->addSuccessMessage("Success! Check your email for an activation link."); //delete invite code if ($is_invite_code_valid) { $invite_dao->deleteInviteCode($invite_code); } } else { $this->addErrorMessage("Unable to register a new user. Please try again."); } } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } $this->view_mgr->addHelp('register', 'userguide/accounts/index'); return $this->generateView(); } }
/** * [实现验证码] */ public function captcha() { $captcha = new Captcha(); ob_clean(); //清楚ob缓存 $captcha->generate(); }
public function addComment($request, $response) {/*{{{*/ if (!session_id()) { session_start(); } $type = (int)$request->getRequest('type', DoctorComment::TYPE_UNKONW); $doctorCommentId = $request->comment_id; $doctorId = $request->doctor_id; $doctorIdPrimary = $request->doctor_id_primary; $doctorName = $request->doctor_name; if(empty($doctorIdPrimary)) $this->_exit404(); $doctor = DAL::get()->find('Doctor', $doctorId); $this->setAnyOneSpace($doctor, $response); if(false == $doctor->canReceiveComment()) { MsgHtml::msg('目前还不能给'.$doctor->name.'大夫写看病经验和感谢信!', $doctor->getUrl(), array('delay' => '10', 'button' => 'close')); } $params = $this->getParams($request); if (false == $params['addType']) { $this->addSession($params); Crumb::ensure(DoctorCommentClient::getInstance()->genCommentCrumbKey(), $request->crumb, self::TTL); if($type == DoctorComment::TYPE_COMMENT) { //防注入时会打开此验证码代码。勿删 //$verifyStr = $request->verifystr; //$verifyOk = Captcha::verify($verifyStr, XIpLocation::getIp(), 'comment', $request->doctor_id, $request->token); //if($verifyOk == false) //{ // $this->message('您输入的验证码有误!', $response); // return false; //} //这个判断用来阻止,在就医经验页面修改隐藏域刷票的情况 --lhl if($params['type'] == 3 || $params['type'] == 1) { $this->doAddComment($doctorCommentId, $doctor, $params, $request, $response); } } else if($type == DoctorComment::TYPE_VOTE) { if (false == ($doctor->canVote())) { $response->msg = "请描述您的看病过程,完成投票..."; } else { $doctorCommentId = $this->doAddVote($doctor, $params); } } else { error_log($doctor->id." web type ".$type."\n", 3, "/tmp/addcomment.log"); MsgHtml::msg('操作失败!请稍后再尝试,谢谢!', $doctor->getUrl(), array('delay' => '10', 'button' => 'close')); } $response->doctorCommentId = $doctorCommentId; } else { $response->msg = "您正在给".$doctor->hospitalfaculty->hospital->commonName.$doctor->name."大夫写"; } $response->crumb = $this->genCrumb(); $response->doctor = $doctor; $response->params = $params; $response->needMoreInfo = $this->needMoreInfo(); $response->user = $this->curUser; $this->clearDoctorCache($doctor); $response->recommendPresents = PresentClient::getInstance()->getRecommendedPresents(); $response->ref = DAL::get()->find_by_userid_and_spaceid('DoctorPatientRef', $this->curUser->id, $doctor->space->id); $response->token = Captcha::generate('comment', $doctor->id, ContentFactory::TYPE_ARITHMATIC, 4, XIpLocation::getIp(), 3); }/*}}}*/
public function doFindPwdVerifyKey($request, $response) {/*{{{*/ if (Captcha::verify($request->key, XIpLocation::getIp(), 'password', $request->mobile, $request->token)) { $newToken = Captcha::generate('password', $request->mobile, ContentFactory::TYPE_NUM, 4, XIpLocation::getIp(), 10); $cacher = Cacher::get()->getCache(Cacher::CACHETYPE_CAPTCHA); $captchaInfos = $cacher->get($newToken); $newKey = strtolower($captchaInfos['question']); if(stripos($request->forward, 'weixUserId') === 0) { $nextUrl = $response->router->urlfor('weixin/afterfinduserpwd').'?'.$request->forward; $results = array('res' => 'success', 'msg' => '', 'next' => $nextUrl, 'forward' => $request->forward); } else { $results = array('res' => 'success', 'msg' => '', 'next' => $response->router->urlfor('user/findpwd', array('userId' => $request->userId, 'mobile' => $request->mobile,'key' => $newKey, 'token' => $newToken, 'forward' => $request->forward))); } } else { $results = array('res' => 'failure', 'msg' => mb_convert_encoding('验证码输入有误', 'UTF-8', 'GBK'), 'next' => ''); } echo json_encode($results); return self::DIRECT_OUTPUT; }/*}}}*/
public function captcha(){ $captcha = new Captcha(); header('Content-type:image/png'); $captcha->generate(); }
public function showDetail($request, $response) {/*{{{*/ $id = $request->id; $id = (int)Codec::getInstance()->decodeId($id); if(empty($id)) { throw new BizException('医生信息不存在.'); exit(); } $doctor = DAL::get()->find('doctor', $id); if($doctor == null || $doctor->isNull() || $doctor->hospitalfaculty instanceof NullEntity) { throw new BizException('医生信息不存在.'); exit(); } $this->skipHospitals($doctor->hospitalfaculty->hospital->id, $response); $this->skipDoctors($doctor->id, $response); $response->doctor = $doctor; $scheduleTable = array(); $scheduleTables1 = DoctorClient::getInstance()->getFormatScheduleList($doctor->id); if($doctor->id != $doctor->primaryId) { $scheduleTables = DoctorClient::getInstance()->getFormatScheduleList($doctor->primaryId); $tmpInfos1 = $scheduleTables1[$doctor->id]; $tmpInfos2 = $scheduleTables[$doctor->primaryId]; foreach($tmpInfos1 as $i=>$infos) { if(empty($infos) || false==is_array($infos)) continue; $items = array(); foreach($infos as $j=>$info) { $items[$j] = (false == empty($tmpInfos1[$i][$j])) ? $tmpInfos1[$i][$j] : ""; } $scheduleTable[$i] = $items; } } else { $scheduleTable = $scheduleTables1[$doctor->id]; } $options['doctor'] = $doctor->primaryId; $pageInfo['pageSize'] = 10; $commentList = DoctorCommentClient::getInstance()->getCommentList($options, $pageInfo); $commentList = $commentList['commentList']; $diseaseAry = DiseaseClient::getInstance()->getDiseaseDoctorList(array($doctor->primaryId), 50); $diseaseIds = array(); foreach ($diseaseAry as $diseaseDorctor) { $diseaseIds[$diseaseDorctor->fld_diseaseid]['id'] = $diseaseDorctor->fld_diseaseid; $diseaseIds[$diseaseDorctor->fld_diseaseid]['name'] = $diseaseDorctor->disease->name; $diseaseIds[$diseaseDorctor->fld_diseaseid]['key'] = $diseaseDorctor->disease->key; } $sameDiseaseDoctorList = array(); if(empty($diseaseIds) == false) { $sameDiseaseDoctorList = DoctorClient::getInstance()->getSameProfessionalDoctors($doctor->primaryId, array_keys($diseaseIds), $limit=4); } $articleList = array(); $spaceCaseList = array(); if($doctor->hasSpace() && $doctor->space->isOpened()) { $articleList = ArticleClient::getInstance()->getTitleListBySpace($doctor->space->id, 3); $spaceCaseList = DAL::get()->find_all_lastpost_by_space('doctorpatientref', $doctor->space, 10); } $response->articleList = $articleList; $response->spaceCaseList = $spaceCaseList; $response->hospitalfaculty = $doctor->hospitalfaculty; $response->hospital = $doctor->hospitalfaculty->hospital; $response->faculty = $doctor->hospitalfaculty->faculty; $response->scheduleTable = $scheduleTable ; $response->commentList = $commentList ; $response->diseaseAry = $diseaseAry; $response->diseaseIds = $diseaseIds; $response->VOTE_DISPLAY_LIMIT = 4; $response->sameDiseaseDoctorList = $sameDiseaseDoctorList; if($doctor->space->isNull()) { $spaceAskedThreadsCount = $spaceAskedFlowsCount = $spaceRepliedThreadsCount = $spaceRepliedFlowsCount; } else { $spaceAskedThreadsCount = SpaceClient::getInstance()->getCountOfAskedThreadsCount($doctor->space->id, $this->_newUser->id); $spaceAskedFlowsCount = SpaceClient::getInstance()->getCountOfAskedFlowsCount($doctor->space->id, $this->_newUser->id); $spaceRepliedThreadsCount = SpaceClient::getInstance()->getCountOfRepliedThreadsCount($doctor->space->id, $this->_newUser->id); $spaceRepliedFlowsCount = SpaceClient::getInstance()->getCountOfRepliedFlowsCount($doctor->space->id, $this->_newUser->id); } $response->spaceAskedCount = $spaceAskedThreadsCount + $spaceAskedFlowsCount; $response->spaceRepliedCount = $spaceRepliedThreadsCount + $spaceRepliedFlowsCount; $response->crumb = Crumb::create(DoctorCommentClient::getInstance()->genCommentCrumbKey(), self::TTL); $space = $doctor->space; $response->space = $space; $commonCaseNote = $doctor->getCommonCaseNote4Display(); $response->commonCaseNote = $commonCaseNote; $response->successOrderCount = count(DAL::get()->find_id_finishStatus_and_maybeSuccessCallBackStatus('BookingOrder', $space)); $bookingCondition = $space->getSpaceBusinessRequirement4Booking()->disease; $response->bookingCondition = empty($bookingCondition) ? '不限' : $bookingCondition; $response->token = Captcha::generate('comment', $doctor->id, ContentFactory::TYPE_ARITHMATIC, 4, XIpLocation::getIp(), 3); }/*}}}*/
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $this->disableCaching(); $config = Config::getInstance(); if (!$config->getValue('is_registration_open')) { $this->addToView('closed', true); $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://github.com/ginatrapani/thinkup/tree/master">Install ThinkUp on your own ' . 'server.</a></p>'); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address."); } elseif (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match."); } elseif (!$captcha->check()) { // Captcha not valid, captcha handles message... } else { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists."); } else { $es = new SmartyThinkUp(); $es->caching = false; $session = new Session(); $activ_code = rand(1000, 9999); $cryptpass = $session->pwdcrypt($_POST['pass2']); $server = $_SERVER['HTTP_HOST']; $owner_dao->create($_POST['email'], $cryptpass, $activ_code, $_POST['full_name']); $es->assign('server', $server); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activ_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message); unset($_SESSION['ckey']); $this->addSuccessMessage("Success! Check your email for an activation link."); } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } return $this->generateView(); } }
function __construct($label,$key,array $options = null) { using('lepton.web.captcha'); $this->setKey($key); $this->label = $label; parent::__construct($options); $this->captchaid = Captcha::generate(); }
$activ_code = rand(1000, 9999); $cryptpass = $session->pwdcrypt($_POST['pass2']); $server = $_SERVER['HTTP_HOST']; $od->create($_POST['email'], $cryptpass, $_POST['country'], $activ_code, $_POST['full_name']); $es->assign('apptitle', $THINKTANK_CFG['app_title']); $es->assign('server', $server); $es->assign('site_root_path', $THINKTANK_CFG['site_root_path']); $es->assign('email', urlencode($_POST[email])); $es->assign('activ_code', $activ_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $THINKTANK_CFG['app_title'] . " Account", $message); // echo $message; // debug unset($_SESSION['ckey']); $successmsg = "Success! Check your email for an activation link."; } } $s->assign('name', $_POST["full_name"]); $s->assign('mail', $_POST["email"]); } $challenge = $captcha->generate(); $s->assign('captcha', $challenge); } if (isset($errormsg)) { $s->assign('errormsg', $errormsg); } elseif (isset($successmsg)) { $s->assign('successmsg', $successmsg); } $db->closeConnection($conn); $cfg = new Config(); $s->assign('cfg', $cfg); $s->display('session.register.tpl');
<?php require '../../../libraries/captcha.php'; $captcha = new Captcha(); $captcha->generate(); $captcha->output(70, 25);
<?php require_once "lib/captcha_class.php"; Captcha::generate();
public function indexAction() { Captcha::generate(); }
public function executeInvite() { $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->getRequestParameter('id')); $this->personal = PersonalPeer::doSelectOne($c); $this->email = $this->personal->getEmail(); if ($this->getUser()->getAttribute('userid')) { $this->userid = $this->getUser()->getAttribute('userid'); $user = UserPeer::retrieveByPK($this->userid); $this->fullname = $user->getFullname(); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $this->userid); $personal = PersonalPeer::doSelectOne($c); $this->senderemail = $personal->getEmail(); } else { $this->fullname = ""; $this->senderemail = ""; } $g = new Captcha(); $this->getUser()->setAttribute('captcha', $g->generate()); }
public function executeSignUp() { $redirect_param = $this->getRequestParameter('redirect', ''); if ($this->getUser()->isConnected()) { // user is connected thus doesn't need to signup $referer = $this->getRequestParameter('referer'); if (!empty($redirect_param)) { $redirect_uri = str_replace('_', '/', $redirect_param); } elseif ($referer && !empty($referer)) { $redirect_uri = $referer; } else { $redirect_uri = '@homepage'; } $this->setNoticeAndRedirect('You are already connected !', $redirect_uri); } else { // user isn't connected if ($this->getRequest()->getMethod() == sfRequest::POST) { $login_name = strtolower(trim($this->getRequestParameter('login_name'))); $email = trim($this->getRequestParameter('email')); // generate a new password $password = UserPrivateData::generatePwd(); if ($this->getUser()->signUp($login_name, $password, $email)) { // sign up is OK $this->getRequest()->setAttribute('password', $password); $this->getRequest()->setAttribute('login_name', $login_name); $this->getRequest()->setAttribute('redirect', $redirect_param); // send a confirmation email $this->sendC2cEmail($this->getModuleName(), 'messageSignupPassword', $this->__('signup email title'), $email); // display a confirmation message $msg = 'Thanks for signing up. You should receive an email with your password soon'; $referer = $this->getRequest()->getReferer(); $redirect = strstr($referer, 'signUp') ? '@homepage' : $referer; $this->statsdIncrement('success'); return $this->setNoticeAndRedirect($msg, $redirect); } else { $this->statsdIncrement('failure'); if (empty($redirect_param)) { $redirect_uri = '@signUp'; } else { $redirect_uri = url_for('@signUp', true) . '?redirect=' . $redirect_param; } return $this->setErrorAndRedirect('Sign up failed, please try again', $redirect_uri); } } else { // display form $this->redirect_param = $redirect_param; $g = new Captcha(); $this->getUser()->setAttribute('captcha', $g->generate()); $this->statsdIncrement('captcha'); $this->setPageTitle($this->__('Signup')); } } }
public function ajaxChangeCaptcha($request,$response) {/*{{{*/ $kind = $request->kind; echo Captcha::generate($kind, XIpLocation::getIp(), ContentFactory::TYPE_CHAR, 4, XIpLocation::getIp(), 3); exit; }/*}}}*/
public function domobileBindUser($request, $response) {/*{{{*/ if (Captcha::verify($request->key, XIpLocation::getIp(), 'password', $request->mobile, $request->token)) { $newToken = Captcha::generate('password', $request->mobile, ContentFactory::TYPE_NUM, 4, XIpLocation::getIp(), 10); $cacher = Cacher::get()->getCache(Cacher::CACHETYPE_CAPTCHA); $captchaInfos = $cacher->get($newToken); $newKey = strtolower($captchaInfos['question']); $bindRes = WeixClient::getInstance()->bindUser($this->weixSpaceUser->id,$request->spaceId, WeixUser::WEIXINTYPE_SPACE); if($bindRes == true ) { $user = UserClient::getInstance()->login4Weix($request->spaceId); $res = "success"; $forward = (empty($forward)) ? $response->router->urlfor('weixindoctor/bindsuccess') : $forward; } else { $res = "hasbind"; //该用户已绑定 } $results = array('res' => $res, 'msg' => ''); } else { $results = array('res' => 'failure', 'msg' => mb_convert_encoding('验证码输入有误', 'UTF-8', 'GBK'), 'next' => ''); } echo json_encode($results); return self::DIRECT_OUTPUT; }/*}}}*/
<?php require_once "random.php"; require_once "Captcha.php"; $Captcha = new Captcha(); $Captcha->generate(new Random()); echo $Captcha->result() . "\n";
$this->drawLines($image, $lines); //PHP >= 4.3 //$image = imagerotate($image, rand(-17,17), 0); //Output image directly: header("Content-type: image/jpeg"); imagejpeg($image); //Return image data as base64 encoded: /*ob_start(); imagejpeg($image); $img = base64_encode(ob_get_contents()); ob_end_clean(); return 'data:image/jpeg;base64,' . $img; */ } private function drawLines($image, $amount) { $amount = $amount ? $amount : 1; while ($amount) { imagesetthickness($image, rand(1, 2)); $line_color = imagecolorallocate($image, rand(0, 152), rand(0, 152), rand(0, 152)); imageline($image, rx(), ry(), rx(), ry(), $line_color); $amount--; } } } //If accessed directly, generate the captcha like normal (produce JPEG): if ($_SERVER['SCRIPT_FILENAME'] == __FILE__) { $a = new Captcha(); $a->generate(); }
public function ajaxChangeVerifyCode($request, $response) { /*{{{*/ $token = Captcha::generate('article', $request->article_id, ContentFactory::TYPE_ARITHMATIC, 4, XIpLocation::getIp(), 3); echo $token; return parent::DIRECT_OUTPUT; }
$activ_code = rand(1000, 9999); $cryptpass = $session->pwdcrypt($_POST['pass2']); $server = $_SERVER['HTTP_HOST']; $od->create($_POST['email'], $cryptpass, $_POST['country'], $activ_code, $_POST['full_name']); $es->assign('apptitle', $THINKTANK_CFG['app_title']); $es->assign('server', $server); $es->assign('site_root_path', $THINKTANK_CFG['site_root_path']); $es->assign('email', urlencode($_POST[email])); $es->assign('activ_code', $activ_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $THINKTANK_CFG['app_title'] . " Account", $message); echo $message; unset($_SESSION['ckey']); $successmsg = "Success! Check your email for an activation link."; } } $s->assign('name', $_POST["full_name"]); $s->assign('mail', $_POST["email"]); } $challenge = $captcha->generate($msg); $s->assign('captcha', $challenge); } if (isset($errormsg)) { $s->assign('errormsg', $errormsg); } elseif (isset($successmsg)) { $s->assign('successmsg', $successmsg); } $db->closeConnection($conn); $cfg = new Config(); $s->assign('cfg', $cfg); $s->display('session.register.tpl');
<?php require_once dirname(__FILE__).'/../init.php'; $request = new Request(); $hospitalFacultyId = Codec::getInstance()->decodeId($request->getRequest('id')); $hospitalFaculty = DAL::get()->find('HospitalFaculty', $hospitalFacultyId); $user = UserClient::getInstance()->getCurrentUser(); $token = Captcha::generate('dcapply', $user->id, ContentFactory::TYPE_CHAR, 4, XIpLocation::getIp(), 3); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>添加医生信息基本信息</title> <link href="http://i1.hdfimg.com/css/css.css?1303386395" rel="stylesheet" type="text/css" /> <link href="http://i1.hdfimg.com/css/frame.css?20131224" rel="stylesheet" type="text/css" /> <link href="http://i1.hdfimg.com/css/inside.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="http://i1.hdfimg.com/space/js/calendar.css" /> <script type="text/javascript" language="javascript" src="http://i1.hdfimg.com/space/js/tools.js?1366769791"></script> <script type="text/javascript" src="http://i1.hdfimg.com/space/js/calendar.js"></script> <script type="text/javascript" src="http://i1.hdfimg.com/space/js/calendar-zh.js"></script> <script type="text/javascript" src="http://i1.hdfimg.com/space/js/calendar-setup.js"></script> <style type="text/css"> .table_green { border-collapse: collapse; } .table_green td { padding: 5px; border: 1px #B6E4A7 solid; } </style> <link href="http://i1.hdfimg.com/nav/nav.css?1303460346" rel="stylesheet" type="text/css"/>
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { // register form validation $this->addHeaderCSS('assets/css/validate_password.css'); $this->addHeaderJavaScript('assets/js/jquery.validate.min.js'); $this->addHeaderJavaScript('assets/js/jquery.validate.password.js'); $this->addHeaderJavaScript('assets/js/validate_password.js'); $config = Config::getInstance(); $is_registration_open = $config->getValue('is_registration_open'); $this->disableCaching(); $invite_dao = DAOFactory::getDAO('InviteDAO'); if (isset($_GET['code'])) { $invite_code = $_GET['code']; } else { $invite_code = null; } $this->addToView('invite_code', $invite_code); $is_invite_code_valid = $invite_dao->isInviteValid($invite_code); if ($invite_code != null && $is_invite_code_valid) { $this->addSuccessMessage("Welcome, VIP! You've been invited to register on " . $config->getValue('app_title_prefix') . "ThinkUp."); } $has_been_registered = false; if (!$is_registration_open && !$is_invite_code_valid) { $this->addToView('closed', true); $disable_xss = true; $this->addErrorMessage('<p>Sorry, registration is closed on this installation of ' . $config->getValue('app_title_prefix') . "ThinkUp.</p>" . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>', null, $disable_xss); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { $valid_input = true; if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email'); $valid_input = false; } if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match.", 'password'); $valid_input = false; } else { if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $_POST['pass1'])) { $this->addErrorMessage("Password must be at least 8 characters and contain both numbers " . "and letters.", 'password'); $valid_input = false; } } if (!$captcha->doesTextMatchImage()) { $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha'); $valid_input = false; } if ($valid_input) { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists.", 'email'); } else { // Insert the details into the database $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']); if ($activation_code != false) { $es = new ViewManager(); $es->caching = false; $es->assign('application_url', Utils::getApplicationURL(false)); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activation_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your Account on " . $config->getValue('app_title_prefix') . "ThinkUp", $message); SessionCache::unsetKey('ckey'); $this->addSuccessMessage("Success! Check your email for an activation link."); //delete invite code if ($is_invite_code_valid) { $invite_dao->deleteInviteCode($invite_code); } $has_been_registered = true; } else { $this->addErrorMessage("Unable to register a new user. Please try again."); } } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } $this->addToView('has_been_registered', $has_been_registered); } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } $this->view_mgr->addHelp('register', 'userguide/accounts/index'); return $this->generateView(); } }
public function confirmPassword($request, $response) {/*{{{*/ DBC::requireNotEmptyString($request->username, 'username不能为空'); DBC::requireNotEmptyString($request->key, '验证码不能为空'); $response->title = '取回密码_好大夫'; $response->message = ''; $response->user = DAL::get()->find_by_name('user', $request->username); if ($request->isPost() == false) { if('email' == $request->type) { $verifyOk = Captcha::verifyKey($request->key, $response->user->id); DBC::requireTrue($verifyOk, '验证码错误, 请重新找回密码'); } else { $verifyOk = Captcha::verify($request->key, XIpLocation::getIp(), 'password', md5($request->username), $request->token); DBC::requireTrue($verifyOk, '验证码错误, 请重新找回密码'); } $newToken = Captcha::generate('password', md5($request->username), ContentFactory::TYPE_CHAR, 4, XIpLocation::getIp(), 10); $cacher = Cacher::get()->getCache(Cacher::CACHETYPE_CAPTCHA); $captchaInfos = $cacher->get($newToken); $response->key = $captchaInfos['question']; $response->token = $newToken; } if (false == $response->user->isNull()) { if ($request->isPost()) { $verifyOk = Captcha::verify($request->key, XIpLocation::getIp(), 'password', md5($request->username), $request->token); DBC::requireTrue($verifyOk, '验证码错误, 请重新找回密码'); DBC::requireNotEmptyString($request->password, '新密码不能为空'); DBC::requireNotEmptyString($request->confirmPassword, '确认密码不能为空'); DBC::requireEquals($request->password, $request->confirmPassword, '密码和确认密码不一致'); UserClient::getInstance()->updatePassword($response->user->id, $request->password); $response->setRedirect($response->router->urlfor('user/login', array('forward'=>$request->forward))); } } else { throw new BizException('取回密码过期,请重新取回'); } }/*}}}*/