[PHP] Güvenlik Resmi Oluşturan Fonksiyon

Silverday

Altın Üye
Altın Üye
Katılım
3 May 2006
Mesajlar
3,551
Reaction score
0
Puanları
0
Konum
sakarya
PHP:
   <?php 
//olusturulmus resmi tarayiciya gonderir
create_image(); 
exit(); 

function create_image() 
{ 
    //md5 ile rastgele sayi uretelim
    $md5 = md5(rand(0,999));  
    //32 karakter yerine sadece 5 karakterini aliyoruz
    $pass = substr($md5, 10, 5); 

    //resmin boyutlarini ayarliyoruz
    $width = 100; 
    $height = 20;  

    //resim kaynagini olusturuyoruz
    $image = ImageCreate($width, $height);  

    //Beyaz siyah ve gri renklerini olusturuyoruz
    $white = ImageColorAllocate($image, 255, 255, 255); 
    $black = ImageColorAllocate($image, 0, 0, 0); 
    $grey = ImageColorAllocate($image, 204, 204, 204); 

    //Zemini siyah yapiyoruz  
    ImageFill($image, 0, 0, $black); 

    //Rastgele sayiyi resmin uzerine yaziyoruz
    ImageString($image, 3, 30, 3, $pass, $white); 

    //resme birkac cizgi koyuyoruz
    ImageRectangle($image,0,0,$width-1,$height-1,$grey);  
    imageline($image, 0, $height/2, $width, $height/2, $grey); 
    imageline($image, $width/2, 0, $width/2, $height, $grey);  
 
    //sunucuya resmin turunu belirtiyoruz
    header("Content-Type: image/jpeg");  

    //Yeni jpeg formatindaki resmin ciktisini aliyoruz
    ImageJpeg($image); 
    
    //Kaynagi temizliyoruz
    ImageDestroy($image); 
} 
?>
alıntıdır.
 
Geri
Üst