Esempio n. 1
0
<?php

/**
 * vCode(m,n,x,y) m个数字  显示大小为n   边宽x   边高y
 * http://blog.qita.in
 * 自己改写记录session $code
 */
session_start();
vCode(4, 14);
//4个数字,显示大小为15
function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    // 去掉了 0 1 O l 等
    //$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
    $str = "0123456789";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 235, 236, 237);
    $boer_color = imagecolorallocate($im, 118, 151, 199);
    $text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    imagerectangle($im, 0, 0, $width - 1, $height - 1, $boer_color);
Esempio n. 2
0
<?php

include MODEL . 'img.fun.php';
vCode();
Esempio n. 3
0
<?php

/**
 * vCode(m,n,x,y) m个数字  显示大小为n   边宽x   边高y
 * 
 * 自己改写记录session $code
 */
session_start();
vCode(4, 15, 60, 30);
//4个数字,显示大小为15
function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 235, 236, 237);
    $boer_color = imagecolorallocate($im, 118, 151, 199);
    $text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    imagerectangle($im, 0, 0, $width - 1, $height - 1, $boer_color);
    // 画干扰线
Esempio n. 4
0
<?php

/**
 * vCode(m,n,x,y) m个数字  显示大小为n   边宽x   边高y
 * http://blog.qita.in
 * 自己改写记录session $code
 */
header("Content-type:text/html;charset=utf-8");
session_start();
vCode(4, 24, 60, 34);
//4个数字,显示大小为15
function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    $str = "0123456789";
    //验证码字符全集
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 255, 255, 255);
    //    $boer_color = imagecolorallocate($im, 100, 100, 100);
    $text_color = imagecolorallocate($im, 50, 50, 50);
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    //    imagerectangle($im, 0, 0, $width-1, $height-1, $boer_color);
Esempio n. 5
0
<?php

/**
 * vCode(m,n,x,y) m个数字  显示大小为n   边宽x   边高y
 * 
 */
session_start();
vCode(4, 15);
//4个数字,显示大小为15
function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 235, 236, 237);
    $boer_color = imagecolorallocate($im, 118, 151, 199);
    $text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    imagerectangle($im, 0, 0, $width - 1, $height - 1, $boer_color);
    // 画干扰线
    for ($i = 0; $i < 5; $i++) {