zoukankan      html  css  js  c++  java
  • 一个简单的php图形验证码生成程序

    <?php
    /**
     *
     * @file imgvcode.php
     * @create date 2007-09-25
     * @copyright (c) 2005 - 2007 eifr.com
     * @license http://www.hzhuti.com/nokia/n97/
     * eifr is free software
     */
    session_start();
    // main
    $vcodes = '';
    //generate Number 4
    srand((double)microtime()*1000000);
    for($i=0;$i<4;$i++){
        $vcodes.=rand(1,9);
    }
    $_SESSION['eifr_checkvcode'] = $vcodes;
    if(function_exists('imagecreate')){
        //generate picture validation code
        Header("Content-type: image/PNG");
        $img = imagecreate(44,18);
        $bg = ImageColorAllocate($img, 245,245,245);
        imagefill($img,0,0,$bg); //background
       
        //generate Number 4
        for($i=0;$i<4;$i++){
            $font = ImageColorAllocate($img, rand(100,255),rand(0,100),rand(100,255));
            $vnum = substr($vcodes, $i, 1);
            imagestring($img, 5, 2+$i*10, 1, $vnum, $font);
        }
        //add interference
        for($i=0;$i<100;$i++)
        {
            $randcolor = ImageColorallocate($img,rand(0,255),rand(0,255),rand(0,255));
            imagesetpixel($img, rand()%70 , rand()%30 , $randcolor);
        }
        ImagePNG($img);
        ImageDestroy($img);
    }
    ?>

  • 相关阅读:
    数据库基本概念(一)
    Java语言概述
    Linx
    小菜鸟之Cisco
    小菜鸟之网络基础1
    小菜鸟之JAVA输入输出
    小菜鸟之java JDBC编程
    小菜鸟之JAVA面试题库1
    小菜鸟之java异常
    小菜鸟之正则表达式
  • 原文地址:https://www.cnblogs.com/phpfans2012/p/2357326.html
Copyright © 2011-2022 走看看