public function display($captcha_id) { $this->init(); $text = xE::$memcache->get('captcha.' . $captcha_id, TRUE); if ($text === FALSE) { exit('Not found.'); } if (!xE::$memcache->add('captchaseen.' . $captcha_id, 1, 3600)) { exit('Already viewed.'); } require_once QUICKY_DIR . 'plugins/Captcha/Captcha_draw.class.php'; $image = new CAPTCHA_draw(); $image->skin = $this->skin; $image->text = $text; $image->show(); }
public function __construct($properties = array()) { require_once QUICKY_DIR . 'plugins/Captcha/Captcha_draw.class.php'; $CAPTCHA = new CAPTCHA_draw(); $CAPTCHA->generate_text(); if (!session_id()) { session_start(); } if (!isset($_SESSION['captcha'])) { $_SESSION['captcha'] = array(); } $this->_imgid = -1; while ($this->_imgid == -1 or isset($_SESSION['captcha'][$this->_imgid])) { $this->_imgid = rand(0, mt_getrandmax()); } $_SESSION['captcha'][$this->_imgid] = array($CAPTCHA->text, 0); foreach ($properties as $k => $v) { $this->{$k} = $v; } }
<?php session_start(); if (!isset($_REQUEST['id']) || !isset($_SESSION['captcha'][$id = intval($_REQUEST['id'])])) { exit(';-)'); } //if ($_SESSION['captcha'][$id][1]) {exit(':-D');} $_SESSION['captcha'][$id][1] = 1; require_once '../plugins/Captcha/Captcha_draw.class.php'; $CAPTCHA = new CAPTCHA_draw(); $CAPTCHA->text = $_SESSION['captcha'][$id][0]; $CAPTCHA->show();