public function create($img = false) { return Captcha::create($img, $this->sets); }
/** * @see Page::readData() */ public function readData() { parent::readData(); // captcha $this->captchaID = 0; if (REGISTER_USE_CAPTCHA && !WCF::getSession()->getVar('captchaDone')) { $this->captchaID = Captcha::create(); } $this->options = $this->getOptionTree('profile'); //$this->options = $this->getCategoryOptions(); }
/** * @see Page::show() */ public function show() { parent::show(); if ($this->action == 'newCaptchaID') { // get new captcha id $captchaID = Captcha::create(); // send header header('Content-type: text/xml'); HeaderUtil::sendNoCacheHeaders(); // print xml echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<captchaid>" . $captchaID . "</captchaid>"; exit; } else { // send header header("Content-type: image/png"); // show image $image = new CaptchaImage($this->captcha->captchaString); } }
public function mews() { return Captcha::create('welcome.index'); }
<?php Route::get('captcha', function () { Captcha::create(Input::has('id') ? Input::get('id') : null); });
/** * @see Page::readData() */ public function readData() { parent::readData(); // captcha $this->captchaID = 0; if ($this->useCaptcha) { $this->captchaID = Captcha::create(); } }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if (FAILED_LOGIN_IP_CAPTCHA > 0 || FAILED_LOGIN_IP_BAN > 0) { if ($eventName == 'readParameters') { // get number of failed logins require_once WCF_DIR . 'lib/data/user/login/FailedLogin.class.php'; $failedLogins = FailedLogin::countFailedLogins(); if (FAILED_LOGIN_IP_BAN > 0 && $failedLogins >= FAILED_LOGIN_IP_BAN) { throw new PermissionDeniedException(); } else { if (FAILED_LOGIN_IP_CAPTCHA > 0 && $failedLogins >= FAILED_LOGIN_IP_CAPTCHA) { if (!$eventObj instanceof UserLoginForm || !LOGIN_USE_CAPTCHA || WCF::getSession()->getVar('captchaDone')) { $this->useCaptcha = true; } } } } else { if ($eventName == 'readFormParameters') { if ($this->useCaptcha) { if (isset($_POST['captchaID'])) { $this->captchaID = intval($_POST['captchaID']); } if (isset($_POST['captchaString'])) { $this->captchaString = StringUtil::trim($_POST['captchaString']); } } } else { if ($eventName == 'validate') { if ($this->useCaptcha) { $this->captcha = new Captcha($this->captchaID); $this->captcha->validate($this->captchaString); } } else { if ($eventName == 'save') { // delete captcha if ($this->useCaptcha) { $this->captcha->delete(); } } else { if ($eventName == 'readData') { // captcha $this->captchaID = 0; if ($this->useCaptcha) { $this->captchaID = Captcha::create(); } // save failed logins if ($eventObj->errorField == 'username' || $eventObj->errorField == 'password') { require_once WCF_DIR . 'lib/data/user/login/FailedLoginEditor.class.php'; FailedLoginEditor::create($eventObj instanceof UserLoginForm ? 'user' : 'admin', $eventObj->user !== null ? $eventObj->userID : 0, $eventObj->username, TIME_NOW, WCF::getSession()->ipAddress, WCF::getSession()->userAgent); } } else { if ($eventName == 'assignVariables') { if ($this->useCaptcha) { WCF::getTPL()->assign(array('captchaID' => $this->captchaID, 'errorField' => $eventObj->errorField, 'errorType' => $eventObj->errorType)); WCF::getTPL()->append('additionalFields', WCF::getTPL()->fetch('captcha')); WCF::getTPL()->clearAssign('captchaID'); } } } } } } } } }
<?php Route::get('/captcha/{hashedUrl}', function ($hashedUrl) { return Captcha::create($hashedUrl); });
<?php Route::get(Config::get('laravel-captcha::config.url'), function () { return Captcha::create(); });
if ($value !== '') { $_SESSION[$name] = $value; } else { unset($_SESSION[$name]); } } else { return isset($_SESSION[$name]) ? $_SESSION[$name] : ''; } } } session_start(); $obj = new Captcha($sname); # 創建Captcha類對象 # $sname為保存captcha的session name,可留空,留空則為'm_captcha' $param = array('width' => 13, 'height' => 18, 'pnum' => 100, 'lnum' => 2); $obj->create($length, $param); # 創建Captcha并輸出圖片 # $length為Captcha長度,可留空,默認為4 /* $param = array( 'width' => 13 captcha 字符寬度 'height' => 18 captcha 字符高度 'pnum' => 100 干擾點個數 'lnum' => 2 干擾線條數 ) 可留空 */ $obj->check($captcha, $flag); # 檢查用戶輸入的驗證碼是否正確,true or false # $captcha為用戶輸入的驗證碼,必填 # $flag 可留空,默認為1 # 1:當驗證成功后自動清除captcha session
<?php //echo phpinfo(); ini_set("display_errors", "1"); error_reporting(E_ALL); require_once '../../../wp-load.php'; require_once 'class/captcha.class.php'; $settings = array('font_dir' => plugin_dir_path(__FILE__) . 'class/fonts', 'wordlist' => plugin_dir_path(__FILE__) . 'class/wordlist.php', 'log_dir' => plugin_dir_path(__FILE__) . 'class/logs'); ////print_r($settings); $c = new Captcha(); $c->set_variables($settings); echo $c->create(); //echo "test";
|-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ //后台 Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () { Route::get('/', ['as' => 'login_user', 'uses' => 'IndexController@index']); Route::get('/index/main', ['as' => 'login_user', 'uses' => 'IndexController@main']); Route::get('/alert', function () { return view('admin.common.alert')->with(Session::all()); }); #公共 Route::group(['prefix' => 'common', 'namespace' => 'Common'], function () { Route::controller('login', 'LoginController'); Route::controller('left', 'LeftController'); //验证码 Route::get('captcha/{type}', function ($type = 'default') { return Captcha::create($type); }); }); #权限管理 Route::group(['prefix' => 'rbac', 'namespace' => 'Rbac', 'middleware' => 'authLogin'], function () { Route::resource('roles', 'RolesController'); Route::resource('permission', 'PermissionController'); Route::resource('manage', 'ManageController'); Route::resource('navigation', 'NavigationController'); }); });