All pastes #633958 Raw Edit

Chuckie_Ice

public php v1 · immutable
#633958 ·published 2007-07-26 01:45 UTC
rendered paste body
<?phpheader('Content-Type: image/png');if(!isset($_SESSION)) session_start();$captchalen=5;$captchax=rand(1,100);$captchay=rand(1,35);$captchastring="";$origin="";$charset=str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789");for($i=0; $i<$captchalen; $i++) {	$char=$charset[rand(0, (count($charset)-1))];	$captchastring.=$char." ";	$origin.=$char;}$_SESSION['CAPTCHA']=$origin;//imagettftext $im = imagecreatetruecolor(250,100);//Get the list of images$dir=opendir("./Images");$image_array = array();$ac = 0;while(($curr=readdir($dir)) != false) {if ($curr == ".." || $curr == ".")continue;if(is_file("./Images/" . $curr)) {$image_array[$ac] = $curr;$ac++;}}closedir($dir);//Get the list of fonts$dir=opendir("./Fonts");$font_array = array();$ac = 0;while(($curr=readdir($dir)) != false) {if ($curr == ".." || $curr == ".")continue;if(is_file("./Fonts/" . $curr)) {$font_array[$ac] = $curr;$ac++;}}closedir($dir);$image_file = $image_array[rand(0,count($image_array) - 1)];$bg_im = imagecreatefromjpeg("./Images/" . $image_file);$width = imagesx($bg_im);$height = imagesy($bg_im);$src_x = rand(0, $width - 250);$src_y = rand(0, $height - 100);imagecopyresampled($im, $bg_im, 0, 0, $src_x, $src_y, 250, 100, 250, 100);$r_c = array();$g_c = array();$b_c = array();for ($i = 1; $i <= 5; $i++){$x_pos = rand(($i - 1) * 50 + 10, $i * 40);$y_pos = rand(40, 80);$r = 0;$g = 0;$b = 0;for ($x=0; $x<=2; $x++){for ($y=0; $y<=2; $y++){$rgb = imagecolorat($im, $x_pos + 12 + ($x * 2), $y_pos - 15 + ($y * 2));$r += ($rgb >> 16) & 0xFF;$g += ($rgb >> 8) & 0xFF;$b += $rgb & 0xFF;}}$r = -($r / 9) + 255;$g = -($g / 9) + 255;$b = -($b / 9) + 255;$slashcolour = imagecolorallocate($im, $r, $g, $b);imageline($im, rand(0, 250), 0, rand(0, 250), 100, $slashcolour);//$rgb = imagecolorat($im, $x_pos + 8 + ($x * 2), $y_pos + 10 + ($y * 2));//$r = -(($rgb >> 16) & 0xFF) + 255;//$g = -(($rgb >> 8) & 0xFF) + 255;//$b = -($rgb & 0xFF) + 255;if ($r + $g + $b < 383){$r -= 30;$g -= 30;$b -= 30;} else {$r += 30;$g += 30;$b += 30;}if ($r > 255)$r = 255;if ($g > 255)$g = 255;if ($b > 255)$b = 255;if ($r < 0)$r = 0;if ($g < 0)$g = 0;if ($b < 0)$b = 0;if ($r + $g + $b > 250 && $r + $g + $b < 550 && abs((($r + $g + $b) / 3) - $r) < 50 && abs((($r + $g + $b) / 3) - $g) < 50 && abs((($r + $g + $b) / 3) - $b) < 50){if ($r + $g + $b < 383){$r -= 70;$g -= 70;$b -= 70;} else {$r += 70;$g += 70;$b += 70;}}$r_c[$i - 1] = $r;$g_c[$i - 1] = $g;$b_c[$i - 1] = $b;$textcolor=imagecolorallocate($im, $r, $g, $b);$font_file = "./Fonts/" . $font_array[rand(0,count($font_array) - 1)];imagettftext($im, rand(26, 32), rand(-30, 30), $x_pos, $y_pos, $textcolor, $font_file, substr($origin, $i - 1, 1));}for ($i = 0; $i <= 4; $i++){if (rand(0,1) == 0)continue;$slashcolour = imagecolorallocate($im, $r_c[$i], $g_c[$i], $b_c[$i]);imageline($im, rand(0, 250), 0, rand(0, 250), 100, $slashcolour);}imagepng($im);?>