예제 #1
0
 /**
  * Returns a singleton instance of the CaptchaBuilder
  * 
  * @return \Gregwar\Captcha\CaptchaBuilder
  */
 protected function getCatpchaBuilder($reset = false)
 {
     static $captchaBuilder = null;
     if ($captchaBuilder === null || $reset === true) {
         $captchaBuilder = \Gregwar\Captcha\CaptchaBuilder::create();
     }
     return $captchaBuilder;
 }
예제 #2
0
 /**
  * @param string $phrase
  * @return bool
  */
 public function verifyCaptcha($phrase)
 {
     if ($phrase) {
         $ip = Request::get()->getRequest()->ip;
         $key = md5($phrase . $ip);
         $v = getCache()->get($key);
         $b = CaptchaBuilder::create($v);
         if ($b->testPhrase($phrase)) {
             return true;
         }
     }
     return false;
 }
예제 #3
0
파일: output.php 프로젝트: ccq18/EduSoho
<?php

include __DIR__ . '/../CaptchaBuilderInterface.php';
include __DIR__ . '/../PhraseBuilderInterface.php';
include __DIR__ . '/../CaptchaBuilder.php';
include __DIR__ . '/../PhraseBuilder.php';
use Gregwar\Captcha\CaptchaBuilder;
header('Content-type: image/jpeg');
CaptchaBuilder::create()->build()->output();
예제 #4
0
<?php

include __DIR__ . '/../CaptchaBuilderInterface.php';
include __DIR__ . '/../PhraseBuilderInterface.php';
include __DIR__ . '/../CaptchaBuilder.php';
include __DIR__ . '/../PhraseBuilder.php';
use Gregwar\Captcha\CaptchaBuilder;
echo count(CaptchaBuilder::create()->build()->getFingerprint());
echo "\n";
예제 #5
0
파일: CaptchaRender.php 프로젝트: jarick/bx
 /**
  * Create render
  * @param string $code
  * @return ICaptchaRender
  */
 public function create($code)
 {
     return CaptchaBuilder::create($code)->build();
 }
예제 #6
0
 public static function captcha($name)
 {
     $builder = CaptchaBuilder::create()->build();
     Controller::$instance->session->set('captcha_' . $name, ['phrase' => $builder->getPhrase(), 'try' => 0]);
     return $builder->inline();
 }