public function captcha() { $captcha = new Captcha(); $captcha->getImage($this->session->getCaptcha()); }
<?php /********************************************************************* captcha.php Simply returns captcha image. Peter Rotich <*****@*****.**> Copyright (c) 2006-2013 osTicket http://www.osticket.com Released under the GNU General Public License WITHOUT ANY WARRANTY. See LICENSE.TXT for details. vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ require_once 'main.inc.php'; require INCLUDE_DIR . 'class.captcha.php'; $captcha = new Captcha(5, 12, ROOT_DIR . 'images/captcha/'); echo $captcha->getImage();
session_start(); class Captcha { private $text; //construct--------------------------------------------------------------------------------------------------------------------- function __construct() { } //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function generateText($length) { $this->text = md5(microtime() * mktime()); return substr($this->text, 0, $length); } function getImage() { $text = $this->generateText(10); $_SESSION['textCap'] = md5($text); $captcha = imagecreatefromgif("captcha.gif"); $colText = imagecolorallocate($captcha, rand(0, 300), rand(0, 100), rand(0, 50)); for ($x = 0; $x <= 77; $x = $x + 5) { imageline($captcha, rand(0, 100000), rand(0, 100), rand(10, 1000), rand(0, 100), $colText); } //imagestring($captcha,10, 50, 15,$text, $colText); return imagegif($captcha); } } $capt = new Captcha(); //header("Content-type: image/gif"); $capt->getImage();
<?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');
<?php $oCaptcha = new Captcha($fusebox['pathAssets'] . "fonts"); if ($oCaptcha->initialize()) { $_SESSION['SecretUserString'] = $oCaptcha->getSecretKey(); $oCaptcha->getImage(); }