public function getCaptcha() { $width = Input::get('w', 100); $height = Input::get('h', 25); $letters = Input::get('letters', 4); $cpa = new Captcha($width, $height, $letters); header("Content-Type: image/png"); return $cpa->createImage(); }
/** * Exibe Captcha */ public function displayAction() { // - Cria, gera randomico $captcha = new Captcha(); $valor_captcha = $captcha->getRandCaptcha(); // - Guarda na sessao //session_start(); $_SESSION["captcha"] = $valor_captcha; session_write_close(); // - Cria a imagem $captcha->createImage(); }
<?php //Bootstrap SPF require 'includes/master.inc.php'; // Set the headers so the image gets created header("Content-type:image/jpeg"); // Lets check if we should be creating a image and we will only be able to do specific types if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'captcha') { header("Content-Disposition:inline ;filename=captcha.jpg"); Captcha::createImage(100, 50, 5); } // Wallpaper request, I will decide later if we will be allowing only registered users to download if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_wallpaper' && isset($_REQUEST['width']) && !empty($_REQUEST['width']) && isset($_REQUEST['height']) && !empty($_REQUEST['height']) && isset($_REQUEST['img']) && !empty($_REQUEST['img'])) { $img = new GD(); set_time_limit(3600); $imgSaveName = str_replace('.jpg', "_wallpaper_" . $_REQUEST['width'] . "_" . $_REQUEST['height'] . ".jpg", $_REQUEST['img']); header("Content-Disposition:inline ;filename=" . $imgSaveName); $img->resizeToResolution($_REQUEST['img'], $_REQUEST['width'], $_REQUEST['height']); }
/** * 提供验证码Action * * @access public * @return mixed */ public function captcha() { ob_start(); $this->layout = null; $w = Req::args('w') === null ? 120 : intval(Req::args('w')); $h = Req::args('h') === null ? 50 : intval(Req::args('h')); $l = Req::args('l') === null ? 4 : intval(Req::args('l')); $bc = Req::args('bc') === null ? array(255, 255, 255) : '#' . Req::args('bc'); $c = Req::args('c') === null ? null : '#' . Req::args('c'); $captcha = new Captcha($w, $h, $l, $bc, $c); $captcha->createImage($code); $this->safebox = Safebox::getInstance(); $this->safebox->set($this->captchaKey, $code); ob_end_flush(); }
<?php // This script can be used as a PNG file, and it creates session data session_start(); require_once 'captcha_class.php'; $myCaptcha = new Captcha(); $_SESSION['hashed_phrase'] = $myCaptcha->hashedPhrase(); $myCaptcha->createImage();