/** * @param $session */ function image($session) { App::import('Vendor', 'Captcha', array('file' => 'captcha' . DS . 'captcha.php')); $captcha = new Captcha(); $captcha->session_var = $this->sessionName . $session; $captcha->CreateImage(); }
/** * @brief 生成验证码 * @return image图像 */ public function getCaptcha() { //清空布局 $this->layout = ''; //配置参数 $width = IReq::get('w') ? IReq::get('w') : 130; $height = IReq::get('h') ? IReq::get('h') : 45; $wordLength = IReq::get('l') ? IReq::get('l') : 5; $fontSize = IReq::get('s') ? IReq::get('s') : 25; //创建验证码 $ValidateObj = new Captcha(); $ValidateObj->width = $width; $ValidateObj->height = $height; $ValidateObj->maxWordLength = $wordLength; $ValidateObj->minWordLength = $wordLength; $ValidateObj->fontSize = $fontSize; $ValidateObj->CreateImage($text); //设置验证码 ISafe::set('captcha', $text); }
<?php $this->app->router->get('captcha/image', ['as' => 'captcha', 'middleware' => ['\\Illuminate\\Cookie\\Middleware\\EncryptCookies', '\\Illuminate\\Session\\Middleware\\StartSession'], function () { return \Captcha::CreateImage(); }]);
/** * 验证码 */ function captcha() { // 图片大小全局配置,扩展请在此添加 $conf = array('s' => array('width' => 250, 'height' => 40, 'minSize' => 20, 'maxSize' => 22, 'wave' => true), 'm' => array('width' => 130, 'height' => 40, 'minSize' => 14, 'maxSize' => 16, 'wave' => false), 'n' => array('width' => 100, 'height' => 30, 'minSize' => 12, 'maxSize' => 12, 'wave' => false)); $ini = $conf['s']; import('@.Rover.Captcha'); $captcha = new Captcha(); $captcha->resourcesPath = 'wp-include/ThirdParty/Captcha'; $captcha->width = $ini['width']; $captcha->height = $ini['height']; $captcha->fonts = array('ERASDEMI' => array('spacing' => 1, 'minSize' => $ini['minSize'], 'maxSize' => $ini['maxSize'], 'font' => 'ERASDEMI.ttf'), 'CourierNewBold' => array('spacing' => -1, 'minSize' => $ini['minSize'], 'maxSize' => $ini['maxSize'], 'font' => 'CourierNewBold.ttf')); $captcha->session_var = 'verification_code'; if ($ini['wave'] == true) { $captcha->Yperiod = 28; $captcha->Yamplitude = 8; $captcha->Xperiod = 18; $captcha->Xamplitude = 4; } else { $captcha->Yperiod = 0; $captcha->Yamplitude = 0; $captcha->Xperiod = 0; $captcha->Xamplitude = 0; $captcha->im_x = 20; } $captcha->lineWidth = 1; $captcha->im = imagecreatefromjpeg($captcha->resourcesPath . '/bg_' . mt_rand(0, 2) . '.jpg'); $captcha->scale = 3; $captcha->colors = array(array(27, 78, 181), array(19, 121, 100), array(42, 52, 64), array(128, 15, 87), array(214, 36, 7)); // red $captcha->shadowColor = array(255, 255, 255); $captcha->CreateImage(); }
/** * Script para la generaci�n de CAPTCHAS * * @author Jose Rodriguez <*****@*****.**> * @license GPLv3 * @link http://code.google.com/p/cool-php-captcha * @package captcha * @version 0.3 * */ namespace Captcha; session_start(); $captcha = new Captcha(); // Image generation $captcha->CreateImage(); /** * SimpleCaptcha class * */ class Captcha { /** Width of the image */ public $width = 200; /** Height of the image */ public $height = 70; /** Dictionary word file (empty for random text) */ public $wordsFile = ''; /** * Path for resource files (fonts, words, etc.) *
function getCaptcha() { $width = intval(IReq::get('w')) == 0 ? 130 : IFilter::act(IReq::get('w')); $height = intval(IReq::get('h')) == 0 ? 45 : IFilter::act(IReq::get('h')); $wordLength = intval(IReq::get('l')) == 0 ? 5 : IFilter::act(IReq::get('l')); $fontSize = intval(IReq::get('s')) == 0 ? 25 : IReq::get('s'); $ValidateObj = new Captcha(); $ValidateObj->width = $width; $ValidateObj->height = $height; $ValidateObj->maxWordLength = $wordLength; $ValidateObj->minWordLength = $wordLength; $ValidateObj->fontSize = $fontSize; $ValidateObj->CreateImage($text); exit; }
<?php session_start(); include_once 'Captcha.php'; $captcha = new Captcha(); $_SESSION['captcha'] = $captcha->CreateImage();
<?php session_start(); require_once 'file:///C|/wamp/www/CaptchaCodeManagemant/Captcha.php'; $objCaptcha = new Captcha(60, 20); $objCaptcha->CreateImage(); $objCaptcha->getImage(); $_SESSION["code"] = $objCaptcha->getCode(); //header('location:../CaptchaCodeManagemant/page.php');
/** * @brief 生成验证码 * @return image图像 */ public function getCaptcha() { //清空布局 $this->layout = ''; //配置参数 $width = intval(IReq::get('w')) == 0 ? 130 : IReq::get('w'); $height = intval(IReq::get('h')) == 0 ? 45 : IReq::get('h'); $wordLength = intval(IReq::get('l')) == 0 ? 5 : IReq::get('l'); $fontSize = intval(IReq::get('s')) == 0 ? 25 : IReq::get('s'); //创建验证码 $ValidateObj = new Captcha(); $ValidateObj->width = $width; $ValidateObj->height = $height; $ValidateObj->maxWordLength = $wordLength; $ValidateObj->minWordLength = $wordLength; $ValidateObj->fontSize = $fontSize; $ValidateObj->CreateImage($text); //设置验证码 ISafe::set('Captcha', $text); }