Ejemplo n.º 1
0
    $rand2 = mt_rand(5, 10);
    for ($yy = $rand; $yy <= +$rand + 2; $yy++) {
        for ($px = -80; $px <= 80; $px = $px + 0.1) {
            $x = $px / $rand1;
            if ($x != 0) {
                $y = sin($x);
            }
            $py = $y * $rand2;
            //imagesetpixel($distortion_im, $px+80, $py+$yy, $text_c);
        }
    }
    Header("Content-type: image/JPEG");
    ImagePNG($distortion_im);
    ImageDestroy($distortion_im);
    ImageDestroy($im);
}
function make_rand($length = "36")
{
    $str = "abcdefghijklmnopqrstuvwxyz0123456789";
    $result = "";
    for ($i = 0; $i < $length; $i++) {
        $num[$i] = rand(0, 35);
        $result .= $str[$num[$i]];
    }
    return $result;
}
$checkcode = make_rand($num);
session_start();
$_SESSION['coupon_submit_code'] = strtolower($checkcode);
getAuthImage($checkcode, $width, $height, $move_x, $move_y, $font_size, $count);
Ejemplo n.º 2
0
 /**
  * 显示验证码
  */
 public static function showImage($paramArr)
 {
     $options = array('token' => 0, 'numCnt' => 4, 'width' => 100, 'height' => 40, 'type' => 1, 'plex' => 5);
     if (is_array($paramArr)) {
         $options = array_merge($options, $paramArr);
     }
     extract($options);
     if (!$token && LJL_Api::$_globalVars['_COOKIE'] && isset(LJL_Api::$_globalVars['_COOKIE']["ip_ck"])) {
         $token = LJL_Api::$_globalVars['_COOKIE']["ip_ck"];
     }
     if (!$token) {
         #不返回了,直接生成 ip_ck cookie 值
         $token = API_Item_Base_Page::createIpCk(array('setCookie' => 1));
         //            return false;
     }
     #获得唯一的用户码
     $uniqCode = API_Item_Security_Algos::getUniqueCode();
     $text = self::getAuthCode($uniqCode, $numCnt);
     #将数据数据到Redis
     $redis = API_Redis::getLink(self::$server);
     #获得redis对象
     $key = self::$keyPre . $token;
     $redis->setex($key, 3600, $text);
     //最长1小时的缓存周期
     #输出图片
     $param = array('token' => $token, 'width' => $width, 'height' => $height, 'numCnt' => $numCnt, 'text' => $text);
     switch ($type) {
         case 2:
             self::getCodeColorImage($param);
             #黑白
             break;
         case 3:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/GifCode.php";
             getGifCode($param);
             break;
         case 4:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/GgCode.php";
             getAuthImage($param);
             break;
         case 5:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/code_math.php";
             $param['redis'] = $redis;
             $param['key'] = $key;
             getMathCode($param);
             break;
         case 6:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/CaptchaBuilderInterface.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/PhraseBuilderInterface.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/CaptchaBuilder.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/PhraseBuilder.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/captchaBuilderFunc.php";
             $param['plex'] = $plex;
             getCaptchaBuilder($param);
             break;
         case 1:
         default:
             self::getCodeSimpleImage($param);
             #彩色
             break;
     }
     exit;
 }
Ejemplo n.º 3
0
            }
            $py = $y * $rand2;
            imagesetpixel($distortion_im, $px + 80, $py + $yy, $text_c);
        }
    }
    //设置文件头;
    Header("Content-type: image/JPEG");
    //以PNG格式将图像输出到浏览器或文件;
    ImagePNG($distortion_im);
    //销毁一图像,释放与image关联的内存;
    ImageDestroy($distortion_im);
    ImageDestroy($im);
}
function make_rand($length = "32")
{
    //验证码文字生成函数
    $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $result = "";
    for ($i = 0; $i < $length; $i++) {
        $num[$i] = rand(0, 25);
        $result .= $str[$num[$i]];
    }
    return $result;
}
//输出调用
$checkcode = make_rand(4);
session_start();
//将随机数存入session中
$_SESSION['helloweba_gg'] = strtolower($checkcode);
getAuthImage($checkcode);
Ejemplo n.º 4
0
 /**
  * 验证码生成
  */
 public function getcapcode($type = 'reg')
 {
     $checkcode = make_rand(4);
     $_SESSION['capcode_' . $type] = strtolower($checkcode);
     getAuthImage($checkcode);
 }