예제 #1
0
 function captcha()
 {
     require dirname(__FILE__) . '/captcha-config.php';
     $this->keystring = '';
     for ($i = 0; $i < $length; $i++) {
         $this->keystring .= $use_symbols[mt_rand(0, $use_symbols_len - 1)];
     }
     $im = imagecreatefromgif(dirname(__FILE__) . "/back.gif");
     $width = imagesx($im);
     $height = imagesy($im);
     $rc = mt_rand(120, 140);
     $font_color = imagecolorresolve($im, $rc, $rc, $rc);
     $px = $margin_left;
     for ($i = 0; $i < $length; $i++) {
         imagettftext($im, $font_size, 0, $px, $margin_top, $font_color, dirname(__FILE__) . "/CARTOON8.TTF", $this->keystring[$i]);
         $px += $font_width + mt_rand($rand_bsimb_min, $rand_bsimb_max);
     }
     $h_y = mt_rand(0, $height);
     $h_y1 = mt_rand(0, $height);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     $h_y = mt_rand(0, $height);
     $h_y1 = mt_rand(0, $height);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     image_make_pomexi($im, 50, 80);
     $rand = mt_rand(0, 1);
     if ($rand) {
         $rand = -1;
     } else {
         $rand = 1;
     }
     wave_region($im, 0, 0, $width, $height, $rand * mt_rand($amplitude_min, $amplitude_max), mt_rand(30, 40));
     header('Expires: Sat, 17 May 2008 05:00:00 GMT');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Cache-Control: post-check=0, pre-check=0', FALSE);
     header('Pragma: no-cache');
     if (function_exists("imagejpeg")) {
         header("Content-Type: image/jpeg");
         imagejpeg($im, null, $jpeg_quality);
     } else {
         if (function_exists("imagegif")) {
             header("Content-Type: image/gif");
             imagegif($im);
         } else {
             if (function_exists("imagepng")) {
                 header("Content-Type: image/x-png");
                 imagepng($im);
             }
         }
     }
 }
예제 #2
0
{
    return hexdec(substr($col, 1, 2));
}
function GetGValue($col)
{
    return hexdec(substr($col, 3, 2));
}
function GetBValue($col)
{
    return hexdec(substr($col, 5, 2));
}
header("Content-type: image/png");
$fontface = "./images/courbd.ttf";
$fontcolor = array("#336666", "#336699", "#990066", "#CC6600", "#009933");
$verifyNum = mystr(4);
if (isset($_GET['do']) && $_GET['do'] == "topic") {
    @setcookie("topicVerify", md5(base64_encode(md5(strtolower($verifyNum)))));
}
if (isset($_GET['do']) && $_GET['do'] == "reply") {
    @setcookie("replyVerify", md5(base64_encode(md5(strtolower($verifyNum)))));
}
$im_w = 130;
$im_h = 53;
$im = imagecreate($im_w, $im_h);
imagecolorallocatealpha($im, 255, 255, 255, 100);
$col = $fontcolor[rand(1, count($fontcolor)) - 1];
$color = imagecolorallocate($im, GetRValue($col), GetGValue($col), GetBValue($col));
imagettftext($im, 32, 0, 8, 38, $color, $fontface, $verifyNum);
wave_region($im, 0, 0, $im_w, $im_h, 6);
imagepng($im);
imagedestroy($im);