phpDocumentor VFront
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file img_rand.php

Documentation is available at img_rand.php

  1. <?php
  2. /**
  3. * Script che mostra una stringa alfanumerica casuale sotto forma di immagine.
  4. * Lo script viene utilizzato nel caso di modifica della password
  5. * ed è richiamato dalla pagina {@link password_recover.php}
  6. @package VFront
  7. @author Mario Marcello Verona <marcelloverona@gmail.com>
  8. @copyright 2007 Mario Marcello Verona
  9. @version 0.90
  10. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  11. */
  12.  
  13.  
  14. $rand='';
  15.  
  16. for($i=49;$i<122;$i++){
  17.     $a[$i]=chr($i);
  18. }
  19.  
  20. unset($a[96],$a[95],$a[94],$a[93],$a[92],$a[91]);
  21.  
  22. $x=array_rand($a,6);
  23.  
  24. shuffle($x);
  25.  
  26. for($i=0;$i<count($x);$i++){
  27.     $rand.=$a[$x[$i]];
  28. }
  29.  
  30.  
  31. // create the hash for the random number and put it in the session
  32. $_SESSION['image_random_value'md5($rand);
  33.  
  34. // create the image
  35. $image imagecreate(7020);
  36.  
  37. // use white as the background image
  38. $bgColor imagecolorallocate ($image255255255);
  39.  
  40. // the text color is black
  41. $textColor imagecolorallocate ($image000);
  42.  
  43. // write the random number
  44. imagestring($image655$rand$textColor);
  45.  
  46. // send several headers to make sure the image is not cached
  47. // taken directly from the PHP Manual
  48.  
  49. // Date in the past
  50. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  51.  
  52. // always modified
  53. header("Last-Modified: " gmdate("D, d M Y H:i:s"" GMT");
  54.  
  55. // HTTP/1.1
  56. header("Cache-Control: no-store, no-cache, must-revalidate");
  57. header("Cache-Control: post-check=0, pre-check=0"false);
  58.  
  59. // HTTP/1.0
  60. header("Pragma: no-cache");
  61.  
  62.  
  63. // send the content type header so the image is displayed properly
  64. header('Content-type: image/jpeg');
  65.  
  66. // send the image to the browser
  67. imagejpeg($image);
  68.  
  69. // destroy the image to free up the memory
  70. imagedestroy($image);
  71. ?>

Documentation generated on Sat, 22 Sep 2007 11:50:45 +0200 by phpDocumentor 1.4.0a2