home *** CD-ROM | disk | FTP | other *** search
/ Internet CD 2005 March / Internet_CD_032005.iso / Warsztat_PHP / image.php < prev    next >
Encoding:
PHP Script  |  2005-01-02  |  682 b   |  21 lines

  1. <?php
  2. $passLenght = 6;
  3. $background = 'bg.png';
  4. $fontLoc = 'font.ttf';
  5.  
  6. $c = mysql_connect('localhost', 'user', 'haslo');
  7. mysql_select_db('nazwa_bazy', $c);
  8.  
  9. if(!@ereg("[a-z0-9]{32}", $_GET['hash']))
  10.     exit(); 
  11. $password = mysql_result(mysql_query('SELECT code FROM mi_secimg WHERE hash="'.$_GET['hash'].'"'), 0);
  12. if(strlen($password) != $passLenght)
  13.     exit();
  14.  
  15. header('content-type: image/png');
  16. $i = imagecreatefrompng($background);
  17. $color = imagecolorallocate($i, 255, 8, 8);
  18. $box = imagettfbbox (16, 3, $fontLoc, $password);
  19. imagettftext($i, 16, 3, (imagesx($i)-$box[2]+$box[0])/2, (imagesy($i)-$box[7]+$box[1])/2, $color, $fontLoc, $password);
  20. imagepng($i);
  21. ?>