/**
  * Make a request to this method to get a captcha image.
  */
 public function index()
 {
     header('Content-type: image/jpeg');
     $builder = new Gregwar\Captcha\CaptchaBuilder();
     $builder->build()->output();
     $this->session->set_userdata('captcha_phrase', $builder->getPhrase());
 }
 /**
  * get captcha image for registration form
  *
  * @return Gregwar\Captcha\CaptchaBuilder
  * @see views/login/index.php
  */
 public function getCaptcha()
 {
     //create a captcha with the Captcha library
     $captcha = new Gregwar\Captcha\CaptchaBuilder();
     $captcha->build();
     //save the captcha characters in session
     Session::set('captcha', $captcha->getPhrase());
     return $captcha;
 }
Exemple #3
0
 /**
  * Проверочный код
  */
 public function captcha()
 {
     header('Content-type: image/jpeg');
     $phrase = new Gregwar\Captcha\PhraseBuilder();
     $phrase = $phrase->build(5, '0123456789');
     $builder = new Gregwar\Captcha\CaptchaBuilder($phrase);
     $builder->setBackgroundColor(mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
     $builder->setDistortion(false)->build()->output();
     $_SESSION['captcha'] = $builder->getPhrase();
 }
Exemple #4
0
 /**
  * 验证码的action 通用化
  */
 public function validimgAction()
 {
     //php composer.phar require "gregwar/captcha"
     $builder = new \Gregwar\Captcha\CaptchaBuilder();
     $builder->build(90, 26);
     header('Content-type: image/jpeg');
     $this->ini->viewRenderType('echo');
     $builder->output();
     \Sooh\Base\Session\Data::getInstance()->set('validImg', $builder->getPhrase());
 }
Exemple #5
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 Gregwar\Captcha\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();
 }
Exemple #6
0
 public function index()
 {
     $builder = new Gregwar\Captcha\CaptchaBuilder();
     $builder->setDistortion(false);
     $builder->build();
     $this->session->set_userdata('captcha', $builder->getPhrase());
     $registrant = [];
     if (empty($this->session->flashdata('data')) === false) {
         $registrant = $this->session->flashdata('data');
     }
     $this->load->view('login/index', ['builder' => $builder, 'registrant' => $registrant]);
 }
Exemple #7
0
    };
};
/* NO ES NECESARIO POR AHORA
function checkUserAuth($action, $checkMod = false) {
    global $app;
    $roles = $app->session->rolesAllowedTo($action);
    if ($checkMod && count($roles) == 1 && $roles[0] == 'mod') {
        return $checkAdminAuth('admConteni');
    } else {
        return checkRole($roles);
    }
}
*/
// Prepare dispatcher
$app->get('/captcha', function () use($app) {
    $builder = new Gregwar\Captcha\CaptchaBuilder();
    $builder->build();
    $app->response->headers->set('Content-Type', 'image/jpeg');
    $app->response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate');
    $app->flash('captcha', $builder->getPhrase());
    $builder->output();
})->name('shwCaptcha');
//$app->get('/userlog', 'UserlogCtrl:listar')->name('shwListaUserlog');
$app->get('/', 'PortalCtrl:verIndex')->name('shwIndex');
$app->get('/portal', 'PortalCtrl:verPortal')->name('shwPortal');
$app->get('/tos', 'PortalCtrl:verTos')->name('shwTos');
$app->get('/login', $checkNoSession, 'PortalCtrl:verLogin')->name('shwLogin');
$app->post('/login', $checkNoSession, 'PortalCtrl:login')->name('runLogin');
$app->post('/logout', 'PortalCtrl:logout')->name('runLogout');
$app->get('/registro', $checkNoSession, 'PortalCtrl:verRegistrar')->name('shwCrearUsuario');
$app->post('/registro', $checkNoSession, 'PortalCtrl:registrar')->name('runCrearUsuario');
Exemple #8
0
 * @Copyright (C) 2014 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 12/28/2009 23:50
 */
if (!defined('NV_MAINFILE')) {
    die('Stop!!!');
}
mt_srand((double) microtime() * 1000000);
$maxran = 1000000;
$random_num = mt_rand(1, $maxran);
$nv_Request->set_Session('random_num', $random_num);
$datekey = date('F j');
$rcode = strtoupper(md5(NV_USER_AGENT . $global_config['sitekey'] . $random_num . $datekey));
$code = substr($rcode, 2, NV_GFX_NUM);
if ($global_config['captcha_type'] == 1) {
    $builder = new Gregwar\Captcha\CaptchaBuilder($code);
    $builder->build(NV_GFX_WIDTH, NV_GFX_HEIGHT);
    header('Content-type: image/jpeg');
    $builder->output();
} else {
    $image = imagecreate(NV_GFX_WIDTH, NV_GFX_HEIGHT);
    $bgc = imagecolorallocate($image, 240, 240, 240);
    imagefilledrectangle($image, 0, 0, NV_GFX_WIDTH, NV_GFX_HEIGHT, $bgc);
    $text_color = ImageColorAllocate($image, 50, 50, 50);
    /* output each character */
    for ($l = 0; $l < 5; ++$l) {
        $r = mt_rand(120, 255);
        $g = mt_rand(120, 255);
        $b = mt_rand(120, 255);
        $color_elipse = ImageColorAllocate($image, round($r * 0.9), round($g * 0.9), round($b * 0.9));
        $cx = mt_rand(0, NV_GFX_WIDTH - NV_GFX_HEIGHT);
 public function captcha()
 {
     $builder = new \Gregwar\Captcha\CaptchaBuilder();
     $builder->build($width = 100, $height = 34);
     Session::put('phrase', $builder->getPhrase());
     $builder->output();
     return \Response::png();
 }