http://www.mtmer.com/bbs/hack.php?H_name=idcards

解决方案 »

  1.   

    <?php
    $w = 80; // 图片宽度
    $h = 26; // 图片高度
    $str = Array();
    $vcode = "";
    $scrstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    for ( $i = 0; $i < 4; $i++ ) { // 随机生成一个验证码
      $str[$i] = $scrstr[ rand (0, 35 ) ];  // 用rand()函数产生一个0~35的随机整数
      $vcode .= $str[$i]; 
    }
    session_start(); // 启动一个会话
    $_SESSION["vcode"] = $vcode; // 将验证码保存在会话变量中
    $im = imagecreatetruecolor ( $w, $h ); // 创建一个真彩色图像
    $white = imagecolorallocate ( $im, 255, 255, 255 ); // 分配颜色
    $black = imagecolorallocate ($im, 0, 0, 0);
    imagefilledrectangle ( $im, 0, 0, $w, $h, $white ); // 用白色画矩形并填充
    imagerectangle ( $im, 0, 0, $w - 1, $h - 1, $black ); // 用黑色画图片边框
    // 以下循环语句用于生成图像的雪花背景
    for ( $i = 1; $i < 200; $i++ ) {
      $x = mt_rand ( 1, $w - 9 ); // 用mt_rand()函数生成随机数
      $y = mt_rand (1, $h - 9 );
      $color = imagecolorallocate ( $im, mt_rand ( 200, 255 ),
             mt_rand ( 200, 255 ), mt_rand ( 200, 255 ) ); // 随机生成一种颜色
      imagechar ( $im, 1, $x, $y, "*", $color ); // 在图像中写入一个星号
    }
    // 以下循环语句用于将验证码写入图像中
    for ( $i = 0; $i < count($str); $i++ ) {
      $x = 13 + $i * ( $w -15 ) / 4;
      $y = mt_rand ( 3, $h / 3 );
      $color = imagecolorallocate ( $im, mt_rand ( 0, 225 ),
             mt_rand ( 0, 150 ), mt_rand ( 0, 225 ) );
      imagechar ($im, 5, $x,  $y, $str[$i], $color );
    }
    header("Content-type:image/jpeg");
    imagejpeg ( $im );
    //imagedestroy ( $im );
    ?>用的时候  将图片的src设成这个文件就好了!
      

  2.   


    你的这个是验证码
    我说的是名片生成系统
    就是在GIF,JPG,BMP,SWF,PNG等格式上添加文字
    设置坐标可以放在任意的地方