Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. <?php
  2. $img_path = 'images/'; // Specifica la path dove vengono salvate le immagini es. images/ basandoti sulla cartella dove si trova lo script.
  3. if(isset($_POST['nome']) && isset($_POST['cognome']) && isset($_POST['eta']) && isset($_POST['luogo']) && isset($_POST['sito']) && isset($_POST['sesso'])) {
  4.     $img = imagecreatefrompng('back.png');
  5.     $color = imagecolorallocate($img, 0, 0, 0);
  6.     putenv('GDFONTPATH=' . realpath('.'));
  7.     $font = 'OpenSans-Light.ttf';
  8.     if(!imagettftext($img, 30, 0, 210, 165, $color, $font, $_POST['nome'])) die("Errore nel generare l'immagine");
  9.     if(!imagettftext($img, 30, 0, 465, 165, $color, $font, $_POST['cognome'])) die("Errore nel generare l'immagine");
  10.     if(!imagettftext($img, 30, 0, 210, 220, $color, $font, $_POST['eta'])) die("Errore nel generare l'immagine");
  11.     if(!imagettftext($img, 30, 0, 465, 220, $color, $font, $_POST['luogo'])) die("Errore nel generare l'immagine");
  12.     if(!imagettftext($img, 30, 0, 210, 275, $color, $font, $_POST['sito'])) die("Errore nel generare l'immagine");
  13.     if(!imagettftext($img, 30, 0, 465, 275, $color, $font, $_POST['sesso'])) die("Errore nel generare l'immagine");
  14.     $rs = randomString();
  15.     while(file_exists($img_path.$rs)) $rs = randomString();
  16.     if(!imagepng($img, $img_path.$rs)) die('Salvataggio immagine fallito');
  17.     header('Content-type: image/png');
  18.     imagepng($img);
  19.     imagedestroy($img);
  20. }
  21. else echo "Dati mancanti, inserisci tutti i dati per creare l'immagine";
  22.  
  23. function randomString($length = 6) {
  24.     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  25.     $charactersLength = strlen($characters);
  26.     $randomString = '';
  27.     for ($i = 0; $i < $length; $i++) {
  28.         $randomString .= $characters[rand(0, $charactersLength - 1)];
  29.     }
  30.     return $randomString;
  31. }
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement