index.php 1.13 KB
<?php
     //print $_SERVER['DOCUMENT_ROOT'];
           $ttf = "{$_SERVER['DOCUMENT_ROOT']}/fonts/timeset.ttf";
if (!file_exists($ttf))exit;


$img = imagecreate(120,30);
$colorGrey=imagecolorallocate($img, 192, 192, 192);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$white);
$n[] = rand(0,9);
$n[] = rand(0,9);
$n[] = rand(0,9);
$n[] = rand(0,9);
$_SESSION['spam'] = implode('',$n);
$home=getenv("DOCUMENT_ROOT");
imagettftext($img,20,0,9,25,$black,$ttf,implode(' ',$n));
//imageline($img, 0, 0, 0, 150, $black);
//imageline($img, 0, 0, 150, 0, $black);
//imageline($img, 60, 60, 60, 60, $black);
$p = 0;
while ($p<1000)
{
   $x = mt_rand(1,149); // ñëó÷àéíàÿ êîîðäèíàòà ïèêñåëÿ øóìà ïî îñè X
   $y = mt_rand(1,59); // îñü Y
   $pixel = imagecolorat($img,$x,$y); // óçíàåì êàêîé öâåò èñïîëüçóåòñÿ íà ìåñòå áóäóùåãî ïèêñåëÿ øóìà
   $point = ($pixel == $black) ? $white : $black; // åñëè áûë ÷åðíûé, êðàñèì ïèêñåëü áåëûì, åñëè áåëûé - êðàñèì ÷åðíûì
   imagesetpixel($img,$x,$y,$point); // ðèñóåì ñàì ïèêñåëü
   $p++;
}
imagepng($img);
imagedestroy($img);
header('Content-Type: image/png');
?>