本文整理汇总了PHP中Captcha::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::generate方法的具体用法?PHP Captcha::generate怎么用?PHP Captcha::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Captcha
的用法示例。
在下文中一共展示了Captcha::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: captcha
public function captcha(){
//获取验证码
$captcha = new Captcha();
//修改响应头
header('Content-type:image/png');
$captcha->generate();
}
示例2: start
/**
* Generate a Captcha
* @return Response
*/
public function start($howmany)
{
$session = new SessionCaptcha();
$captcha = new Captcha($session);
$captcha->generate($howmany);
return Response::json($captcha->getFrontEndData());
}
示例3: ajaxChangeCaptcha
/**
* 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;
}/*}}}*/
示例4: executeShow
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());
}
}
示例5: execute
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;
}
示例6: executeAddComment
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');
}
示例7: render
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();
}
示例8: control
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();
}
}
示例9: captcha
/**
* [实现验证码]
*/
public function captcha()
{
$captcha = new Captcha();
ob_clean();
//清楚ob缓存
$captcha->generate();
}
示例10: addComment
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);
}/*}}}*/
示例11: doFindPwdVerifyKey
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;
}/*}}}*/
示例12: showDetail
//.........这里部分代码省略.........
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);
}/*}}}*/
示例13: control
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();
}
}
示例14: __construct
function __construct($label,$key,array $options = null) {
using('lepton.web.captcha');
$this->setKey($key);
$this->label = $label;
parent::__construct($options);
$this->captchaid = Captcha::generate();
}
示例15: rand
$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');