예제 #1
0
 /**
  * Display captcha image
  *
  * @access public
  */
 public function image()
 {
     $this->response->withContentType('image/jpeg')->send();
     $builder = new CaptchaBuilder();
     $builder->build();
     $this->sessionStorage->captcha = $builder->getPhrase();
     $builder->output();
 }
예제 #2
0
 /**
  * Display captcha image
  *
  * @access public
  */
 public function captcha()
 {
     $this->response->contentType('image/jpeg');
     $builder = new CaptchaBuilder();
     $builder->build();
     $this->session['captcha'] = $builder->getPhrase();
     $builder->output();
 }
예제 #3
0
 public function index()
 {
     $builder = new CaptchaBuilder();
     $builder->build($width = 100, $height = 34, $font = null);
     Session::put('phrase', $builder->getPhrase());
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-Type: image/jpeg');
     $builder->output();
 }
예제 #4
0
 public function index()
 {
     $builder = new CaptchaBuilder();
     $builder->build(150, 32);
     //session(['captcha'=>$builder->getPhrase()]);
     \Session::set('captcha', $builder->getPhrase());
     //存储验证码
     return response($builder->output())->header('Content-type', 'image/jpeg');
 }
예제 #5
0
 public function captcha($tmp)
 {
     ob_clean();
     //生成验证码图片的Builder对象,配置相应属性
     $builder = new CaptchaBuilder();
     $builder->build(100, 25);
     \Session::set('phrase', $builder->getPhrase());
     //存储验证码
     return response($builder->output())->header('Content-type', 'image/jpeg');
 }
예제 #6
0
 public function captcha($request, $response, $args)
 {
     $id = $args['id'];
     $builder = new CaptchaBuilder();
     $builder->build();
     //$builder->getPhrase();
     $newResponse = $response->withHeader('Content-type', ' image/jpeg');
     //->getBody()->write($builder->output());
     $newResponse->getBody()->write($builder->output());
     return $newResponse;
 }
예제 #7
0
 /**
  * Generates the captcha, "returns" a real image, this is why there is header('Content-type: image/jpeg')
  * Note: This is a very special method, as this is echoes out binary data.
  */
 public static function generateAndShowCaptcha()
 {
     // create a captcha with the CaptchaBuilder lib (loaded via Composer)
     $captcha = new CaptchaBuilder();
     $captcha->build(Config::get('CAPTCHA_WIDTH'), Config::get('CAPTCHA_HEIGHT'));
     // write the captcha character into session
     Session::set('captcha', $captcha->getPhrase());
     // render an image showing the characters (=the captcha)
     header('Content-type: image/jpeg');
     $captcha->output();
 }
예제 #8
0
 public function captcha()
 {
     session_start();
     $builder = new CaptchaBuilder();
     $builder->build();
     $_SESSION['phrase'] = $builder->getPhrase();
     header("Cache-Control: no-cache, must-revalidate");
     header('Content-Type: image/jpeg');
     // return $_SESSION['phrase'];
     $builder->output();
     exit;
 }
예제 #9
0
파일: Captcha.php 프로젝트: phpffcms/ffcms
 /**
  * Build gregwar captcha image
  */
 public function actionGregwar()
 {
     // set header. Class response->header->set is not working here (content output directly before)
     header('Content-type: image/jpeg');
     $builder = new CaptchaBuilder();
     $builder->build(200, 60);
     // build and set width/height
     // set captcha value to session
     App::$Session->set('captcha', $builder->getPhrase());
     // set header and display JPEG
     $this->response->headers->set('Content-type', 'image/jpeg');
     $builder->output();
 }
예제 #10
0
 /**
  * 输出验证码
  */
 public function captcha()
 {
     $builder = new CaptchaBuilder();
     $builder->build();
     $phrase = $builder->getPhrase();
     Crypt::setKey(Config::get('app.cookie_key'));
     $phrase_new = Crypt::encrypt($phrase);
     Session::flash('__captcha', $phrase_new);
     header("Cache-Control: no-cache, must-revalidate");
     header('Content-Type: image/jpeg');
     $builder->output();
     exit;
 }
예제 #11
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function captcha($tmp)
 {
     //生成验证码图片的Builder对象,配置相应属性
     $builder = new CaptchaBuilder();
     //可以设置图片宽高及字体
     $builder->build($width = 140, $height = 50, $font = null);
     //获取验证码的内容
     $phrase = $builder->getPhrase();
     //把内容存入session
     Session::put('milkcaptcha', $phrase);
     //生成图片
     header("Cache-Control: no-cache, must-revalidate");
     header('Content-Type: image/jpeg');
     $builder->output();
 }
예제 #12
0
 public function getCaptchaImage()
 {
     session_start();
     $default_width = Config::get('site.captcha.default_width') ?: 150;
     $default_height = Config::get('site.captcha.default_height') ?: 40;
     $width = Input::get('w') ?: $default_width;
     $height = Input::get('h') ?: $default_height;
     $builder = new CaptchaBuilder();
     $builder->build($width, $height);
     $_SESSION['captcha_keystring'] = $builder->getPhrase();
     header('Content-type: image/jpeg');
     $builder->output();
 }
 public function captchaAction(Request $request)
 {
     $imgBuilder = new CaptchaBuilder();
     $imgBuilder->build($width = 150, $height = 32, $font = null);
     $request->getSession()->set('captcha_code', strtolower($imgBuilder->getPhrase()));
     ob_start();
     $imgBuilder->output();
     $str = ob_get_clean();
     $imgBuilder = null;
     $headers = array('Content-type' => 'image/jpeg', 'Content-Disposition' => 'inline; filename="' . "reg_captcha.jpg" . '"');
     return new Response($str, 200, $headers);
 }
예제 #14
0
 /**
  * Generates the captcha, "returns" a real image,
  * this is why there is header('Content-type: image/jpeg')
  * Note: This is a very special method, as this is echoes out binary data.
  * Eventually this is something to refactor
  */
 public function generateCaptcha()
 {
     // create a captcha with the CaptchaBuilder lib
     $builder = new CaptchaBuilder();
     $builder->build();
     // write the captcha character into session
     $_SESSION['captcha'] = $builder->getPhrase();
     // render an image showing the characters (=the captcha)
     header('Content-type: image/jpeg');
     $builder->output();
 }
예제 #15
0
 /**
  * 获取验证码
  * @param CaptchaBuilder $builder
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function getCaptcha(CaptchaBuilder $builder)
 {
     $builder->build(100);
     Session::put('captcha', $builder->getPhrase());
     return response($builder->output(), 200, ['Content-type', 'image/jpeg']);
 }
예제 #16
0
 /**
  * Outputs the image
  *
  * @access  public
  * @param   string  $quality  Image quality
  * @return  void
  */
 public function output($quality = 90)
 {
     return $this->builder->output($quality);
 }
예제 #17
0
 public function captcha()
 {
     $builder = new CaptchaBuilder();
     $builder->build(300, 122);
     Session::flash('phrase', $builder->getPhrase());
     //存储验证码
     return response($builder->output())->header('Content-type', 'image/jpeg');
 }
예제 #18
0
 public function captchaAction()
 {
     $builder = new CaptchaBuilder();
     $builder->build();
     if ($builder->testPhrase($userInput)) {
         // instructions if user phrase is good
     } else {
         // user phrase is wrong
     }
     header('Content-type: image/jpeg');
     $builder->output();
 }
예제 #19
0
 /**
  * 生成登录页面的图形验证码
  *
  * @author young
  * @name 生成登录页面的图形验证码
  * @version 2013.11.07 young
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function captchaAction()
 {
     $builder = new CaptchaBuilder();
     $builder->setBackgroundColor(255, 255, 255);
     $builder->setTextColor(255, 0, 255);
     $builder->setPhrase(rand(100000, 999999));
     $_SESSION['phrase'] = $builder->getPhrase();
     $builder->build(150, 40);
     header('Content-type: image/jpeg');
     $this->response->setContent($builder->output(80));
     return $this->response;
 }
예제 #20
0
 /**
  * 登录验证码生成
  *
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function captchaAction()
 {
     $builder = new CaptchaBuilder();
     // $builder->setBackgroundColor($r, $g, $b);
     // $builder->build($width = 150, $height = 40);
     $builder->build(150, 40);
     $_SESSION['phrase'] = $builder->getPhrase();
     // $builder->output($quality = 80);
     header('Content-type: image/jpeg');
     $this->response->setContent($builder->output(80));
     return $this->response;
 }
예제 #21
0
 public function captcha()
 {
     $builder = new CaptchaBuilder();
     $builder->build();
     Session::set('captcha', $builder->getPhrase());
     if ($builder->testPhrase(Session::get('captcha'))) {
         // instructions if user phrase is good
     } else {
         // user phrase is wrong
     }
     header('Content-type: image/jpeg');
     $builder->output();
 }
예제 #22
0
 public function captcha($tmp)
 {
     //生成验证码图片的Builder对象,配置相应属性
     $builder = new CaptchaBuilder();
     //可以设置图片宽高及字体
     $builder->build($width = 90, $height = 40, $font = null);
     //获取验证码的内容
     $phrase = $builder->getPhrase();
     //把内容存入session
     Session::flash('milkcaptcha', $phrase);
     //生成图片
     return response($builder->output())->header('Content-type', 'image/jpeg');
 }
예제 #23
0
 public function CaptchaMake()
 {
     $code = (string) rand(1000, 9999);
     $builder = new CaptchaBuilder($code);
     $builder->build();
     $phrase = $builder->getPhrase();
     $ip = $this->getIP();
     $codeKey = md5($ip);
     Cache::tags('register', 'code')->put($codeKey, $phrase, 1);
     header("Cache-Control: no-cache, must-revalidate");
     header('Content-Type: image/jpeg');
     $builder->output();
     exit;
 }
예제 #24
0
 /**
  * Publish CAPTCHA image
  *
  * @author kuma
  */
 public function captchaAction()
 {
     $builder = new CaptchaBuilder();
     $builder->build();
     $_SESSION['phrase'] = $builder->getPhrase();
     header('Content-type: image/jpeg');
     $builder->output();
     $this->view->disable();
 }