public function captcha() { $captcha = new SimpleCaptcha(); $captcha->resourcesPath = JPATH_ROOT . DS . 'components' . DS . 'com_hp_comment' . DS . 'helpers' . DS . 'simple_captcha' . DS . 'resources'; $captcha->CreateImage(); exit; }
public static function yz_auth_getcaptcha() { include_once dirname(__FILE__) . '/captcha/captcha.php'; session_start(); $captcha = new SimpleCaptcha(); $captcha->CreateImage(); die; }
public static function showCaptcha() { $captcha = new SimpleCaptcha(); $captcha->resourcesPath = app_path() . '/third_party/captcha/resources'; $captcha->backgroundColor = [78, 93, 108]; $captcha->width = 400; $captcha->height = 140; $captcha->fonts = array('Antykwa' => array('spacing' => -3, 'minSize' => 37, 'maxSize' => 40, 'font' => 'AntykwaBold.ttf'), 'VeraSans' => array('spacing' => -1, 'minSize' => 30, 'maxSize' => 38, 'font' => 'VeraSansBold.ttf')); $captcha->colors = [[235, 235, 235]]; return Response::make($captcha->CreateImage(), 200, ['Content-Type' => 'image/jpeg']); }
static function _get_image() { if (STInput::get('st_get_captcha')) { $key = STInput::get('key'); $captcha = new SimpleCaptcha(); if ($key) { $captcha->session_var = $key; } $captcha->CreateImage(); die; } }
function getImage(){ $captcha = new SimpleCaptcha(); $captcha->wordsFile = 'words/es.php'; $captcha->resourcesPath = "www/resourcesCaptcha"; // Image generation $captcha->CreateImage($this->session); }
function generate_captcha($extra = '1234567890') { global $config; $text = rand_string($config['captcha']['length'], $extra); $captcha = new SimpleCaptcha(); $cookie = rand_string(20, "abcdefghijklmnopqrstuvwxyz"); ob_start(); $captcha->CreateImage($text); $image = ob_get_contents(); ob_end_clean(); $html = '<image src="data:image/png;base64,' . base64_encode($image) . '">'; $query = prepare("INSERT INTO `captchas` (`cookie`, `extra`, `text`, `created_at`) VALUES (?, ?, ?, ?)"); $query->execute([$cookie, $extra, $text, time()]); return array("cookie" => $cookie, "html" => $html); }
function index($ctx) { $this->is_ajax = false; $this->layout = false; require_once APP_PATH . '/classes/captcha/SimpleCaptcha.php'; $captcha = new SimpleCaptcha(); $captcha->width = 140; $captcha->height = 60; $captcha->scale = 4; $captcha->blur = true; // OPTIONAL Change configuration... //$captcha->imageFormat = 'png'; //$captcha->resourcesPath = "/var/cool-php-captcha/resources"; $code = $captcha->getText(); session_start(); $_SESSION['verify_code'] = $code; $captcha->CreateImage(); }
function index($ctx) { $this->is_ajax = false; $this->layout = false; require_once APP_PATH . '/classes/captcha/SimpleCaptcha.php'; $captcha = new SimpleCaptcha(); $captcha->width = 140; $captcha->height = 60; $captcha->scale = 4; $captcha->blur = true; // OPTIONAL Change configuration... //$captcha->imageFormat = 'png'; //$captcha->resourcesPath = "/var/cool-php-captcha/resources"; if (isset($_GET['token']) && $_GET['token']) { $code = SafeUtil::get_captcha($_GET['token']); $captcha->setText($code); } else { $code = $captcha->getText(); } if (strlen($code)) { SafeUtil::set_captcha($code, 300); $captcha->CreateImage(); } }
//$captcha->lineWidth = 3; //$captcha->scale = 3; $captcha->blur = true; $captcha->resourcesPath = dirname(__FILE__) . "/resources"; $captcha->colors = array(array(0, 138, 201)); // OPTIONAL Simple autodetect language example /* if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $langs = array('en', 'es'); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if (in_array($lang, $langs)) { $captcha->wordsFile = "words/$lang.php"; } } */ // Image generation $captcha->CreateImage(); /** * SimpleCaptcha class * */ class SimpleCaptcha { /** Width of the image */ public $width = 200; /** Height of the image */ public $height = 70; /** Dictionary word file (empty for random text) */ public $wordsFile = 'words/en.php'; /** * Path for resource files (fonts, words, etc.) *
<?php include 'SimpleCaptcha.php'; session_start(); $captcha = new SimpleCaptcha(); $captcha->width = 140; $captcha->height = 60; $captcha->scale = 3; $captcha->blur = true; // OPTIONAL Change configuration... //$captcha->wordsFile = 'words/es.php'; //$captcha->session_var = 'secretword'; //$captcha->imageFormat = 'png'; //$captcha->resourcesPath = "/var/cool-php-captcha/resources"; // Image generation $text = $captcha->CreateImage();
public function action_captcha() { Session::instance(); $path = Kohana::find_file('vendor', 'cool-php-captcha-0.3.1/captcha'); require_once $path; $captcha = new SimpleCaptcha(); // OPTIONAL Change configuration... $captcha->wordsFile = 'words/en.php'; $captcha->session_var = 'captcha'; $captcha->imageFormat = 'png'; $captcha->lineWidth = 3; //$captcha->scale = 3; $captcha->blur = true; $captcha->resourcesPath = APPPATH . "vendor/cool-php-captcha-0.3.1/resources"; // OPTIONAL Simple autodetect language example /* if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $langs = array('en', 'es'); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if (in_array($lang, $langs)) { $captcha->wordsFile = "words/$lang.php"; } } */ // Image generation ob_start(); $captcha->CreateImage(); $content = ob_get_contents(); ob_end_clean(); $this->response->headers('Content-type', 'image/png'); $this->response->send_headers(); $this->response->body($content); }
function cn_modify_comm_captcha($e) { $ID = 'cn_comm_captcha_' . $e['id']; $cpath = getoption('http_script_dir') . '/captcha.php'; if (getoption('hide_captcha') && function_exists('imagecreatetruecolor')) { // Create obfuscated captcha $captcha = new SimpleCaptcha(); $captcha->imageFormat = 'png'; $captcha->session_var = 'CSW'; $captcha->scale = 2; $captcha->blur = true; $captcha->resourcesPath = SERVDIR . '/core/captcha/resources'; // Image generation ob_start(); $captcha->CreateImage(true); $captcha_text = ob_get_clean(); $echo = '<div class="cn_comm_captcha"><img src="data:image/png;base64,' . base64_encode($captcha_text) . '" /></div>'; } else { $echo = '<div class="cn_comm_captcha"><a href="#" onclick="cn_get_id(\'' . $ID . '\').src = \'' . $cpath . '?r=\' + Math.random(); return false;"><img src="' . $cpath . '" alt="CAPTCHA, click to refresh" id="' . $ID . '"/></a>'; } $echo .= '<div class="cn_comm_cinput"><input type="text" name="cm_captcha" value=""/></div>'; return $echo; }