| 
<?php
/*********************************
 Secure Number Image creator
 Author        : Armin Borumand
 E-mail        : [email protected]
 *********************************/
 class sni{
 var $show;
 var $imp;
 function sni($text=""){
 $this->show=$text==""?$this->random():$text;
 $this->imp=$this->create($this->show);
 $this->show($this->imp,"jpeg");
 }
 function random(){
 $rand = rand(1, 211111)*1.57;
 return round($rand);
 }
 function create($text){
 $image=imagecreate(100, 25);
 $bgcolor=imagecolorallocate($image, $r=rand(242,255), rand(247,255), 233);
 $textcolor=imagecolorallocate($image, 151, 153, 127);
 $fonth=imagefontheight(5);
 $fontw=imagefontwidth(5);
 imagestring($image, 5, $x=rand(0, 45), $y=rand(0, 25-$fonth), $text, $textcolor);
 imageline($image, $x, rand($y,$y+$fonth), $x+$fontw*6, rand($y,$y+$fonth), $textcolor);
 imageline($image, $x, rand($y,$y+$fonth), $x+$fontw*6, rand($y,$y+$fonth), $bgcolor);
 for($i=0; $i<2; $i++)
 $this->imageset9pixel($image, rand($x, $x+$fontw*6), rand($y, $y+$fonth), $bgcolor);
 for($i=0; $i<10; $i++)
 $this->imageset9pixel($image, rand(0, 100), rand(0,25), $textcolor);
 return $image;
 
 }
 function imageset9pixel($image,$x,$y,$color){
 for($i=$x-1;$i<$x+1;$i++){
 for($j=$y-1;$j<$y+1;$j++)
 imagesetpixel($image,$i,$j,$color);
 }
 }
 function show($image, $type="gif"){
 switch($type){
 case "gif":
 header("Content-type: image/".$type);
 imagegif($image);
 break;
 case "jpeg":
 header("Content-type: image/".$type);
 imagejpeg($image);
 break;
 case "png":
 header("Content-type: image/".$type);
 imagepng($image);
 break;
 default:
 die("Type error");
 }
 imagedestroy($image);
 }
 function getnum(){
 return $this->show;
 }
 }
 ?>
 |