本文整理汇总了PHP中Captcha::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::getInstance方法的具体用法?PHP Captcha::getInstance怎么用?PHP Captcha::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Captcha
的用法示例。
在下文中一共展示了Captcha::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preResolve
/**
* Do something before resolving is done
*
* @param \Cx\Core\Routing\Url $request The URL object for this request
*/
public function preResolve(\Cx\Core\Routing\Url $request)
{
global $url;
switch ($this->cx->getMode()) {
case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
$params = $url->getParamArray();
if (isset($params['section']) && $params['section'] == 'Captcha') {
/*
* Captcha Module
*
* Generates no output, requests are answered by a die()
* @since 2.1.5
*/
Captcha::getInstance()->getPage();
}
break;
default:
break;
}
}
示例2: postAsk
public function postAsk()
{
try {
if (!isset($_POST)) {
throw new \Exception('Request error!');
}
$keys = array('name', 'sex', 'email', 'ask', 'content', 'code', 'isPrivate', 'user_id');
$values = array();
$bool = true;
foreach ($keys as $key) {
$values[$key] = \Arr::get($_POST, $key, false);
if ($values[$key] === false) {
$bool = false;
}
}
if (!$bool) {
throw new \Exception('Request error!');
}
if (!\Captcha::getInstance()->valid($values['code'])) {
throw new \Exception('驗証碼錯誤');
}
$values['isPrivate'] = $values['isPrivate'] == 'n' ? '0' : '1';
$b = new \Board();
$b->name = $values['name'];
$b->gender = $values['sex'];
$b->email = $values['email'];
$b->topic = $values['ask'];
$b->content = $values['content'];
$b->isPrivate = $values['isPrivate'];
$b->user_id = empty($values['user_id']) ? '' : (int) $values['user_id'];
$b->save();
return \Response::json(array('status' => 'ok'));
} catch (\Exception $e) {
return \Response::json(array('status' => 'error', 'message' => $e->getMessage()));
}
}