Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Gregwar\Captcha\CaptchaBuilder as GregwarCaptchaBuilder;
- class CaptchaBuilder {
- protected $captchaSessionKey = 'captcha';
- protected $CI;
- protected $captchaBuilder;
- public function __construct() {
- $this->CI = &get_instance();
- }
- public function init($width = 150, $height = 40, $usePrevCaptcha = false) {
- $captcha = $usePrevCaptcha ? $this->getCaptchaFromSession() : null;
- $this->captchaBuilder = new GregwarCaptchaBuilder($captcha);
- $this->captchaBuilder->build($width, $height);
- $this->CI->session->set_userdata($this->captchaSessionKey, $this->captchaBuilder->getPhrase());
- }
- public function getInline() {
- return $this->captchaBuilder->inline();
- }
- public function reset() {
- $this->CI->session->unset_userdata($this->captchaSessionKey);
- }
- public function setCaptchaSessionKey($key) {
- $this->captchaSessionKey = $key;
- return $this;
- }
- public function getCaptchaSessionKey() {
- return $this->captchaSessionKey;
- }
- public function check($checkString) {
- return ($checkString == $this->getCaptchaFromSession());
- }
- public function getCaptchaFromSession() {
- return isset($this->CI->session->{$this->captchaSessionKey}) ? $this->CI->session->{$this->captchaSessionKey} : null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement