示例#1
0
文件: BL.php 项目: eddyn73/SURP
 protected function validaCaptcha()
 {
     $captcha = f::request('post', 'normal', f::id('captcha'));
     if (str_replace(' ', '', strtolower($captcha)) != str_replace(' ', '', strtolower(f::getSession('captcha')))) {
         v::setError('El código de la imágen no es válido.');
     } else {
         f::setSession('captcha', Cifrar::random(10));
     }
 }
示例#2
0
文件: captcha.php 项目: eddyn73/SURP
<?php

require_once './core/helper/f.php';
f::import('core/helper/Cifrar.php');
$random1 = Cifrar::random(4, 'int');
$random2 = Cifrar::random(4, 'int');
$texto = $random1 . ' ' . $random2;
$width = 149;
$height = 27;
$image = imagecreatetruecolor($width, $height);
$font = f::getPatchApp() . '/resource/plugin/reCaptcha/fonts/Courier.ttf';
$black = imagecolorallocate($image, 0, 0, 0);
// color negro
$white = imagecolorallocate($image, 255, 255, 255);
// background color blanco
//$black=$white;
imagefilledrectangle($image, 0, 0, $width, $height, $white);
$lineas = mt_rand(10, 15);
for ($i = 0; $i < $lineas; $i++) {
    $max = mt_rand(80, 100);
    $r = mt_rand(100, 200);
    $g = mt_rand(100, 200);
    $b = mt_rand(100, 200);
    $linescolor = imagecolorallocatealpha($image, $r, $g, $b, $max);
    $x1 = mt_rand(0, $width);
    $y1 = mt_rand(0, $height);
    $x2 = mt_rand(0, $width);
    $y2 = mt_rand(0, $height);
    imageline($image, $x1, $y1, $x2, $y2, $linescolor);
}
$aumentar = 16;