Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $img_path = 'images/'; // Specifica la path dove vengono salvate le immagini es. images/ basandoti sulla cartella dove si trova lo script.
- if(isset($_POST['nome']) && isset($_POST['cognome']) && isset($_POST['eta']) && isset($_POST['luogo']) && isset($_POST['sito']) && isset($_POST['sesso'])) {
- $img = imagecreatefrompng('back.png');
- $color = imagecolorallocate($img, 0, 0, 0);
- putenv('GDFONTPATH=' . realpath('.'));
- $font = 'OpenSans-Light.ttf';
- if(!imagettftext($img, 30, 0, 210, 165, $color, $font, $_POST['nome'])) die("Errore nel generare l'immagine");
- if(!imagettftext($img, 30, 0, 465, 165, $color, $font, $_POST['cognome'])) die("Errore nel generare l'immagine");
- if(!imagettftext($img, 30, 0, 210, 220, $color, $font, $_POST['eta'])) die("Errore nel generare l'immagine");
- if(!imagettftext($img, 30, 0, 465, 220, $color, $font, $_POST['luogo'])) die("Errore nel generare l'immagine");
- if(!imagettftext($img, 30, 0, 210, 275, $color, $font, $_POST['sito'])) die("Errore nel generare l'immagine");
- if(!imagettftext($img, 30, 0, 465, 275, $color, $font, $_POST['sesso'])) die("Errore nel generare l'immagine");
- $rs = randomString();
- while(file_exists($img_path.$rs)) $rs = randomString();
- if(!imagepng($img, $img_path.$rs)) die('Salvataggio immagine fallito');
- header('Content-type: image/png');
- imagepng($img);
- imagedestroy($img);
- }
- else echo "Dati mancanti, inserisci tutti i dati per creare l'immagine";
- function randomString($length = 6) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement