Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Creazione Loghi</title>
<script type="text/javascript">
function add_color(c, c1, c2)
{
document.modulo.c.value = c;
document.modulo.c1.value = c1;
document.modulo.c2.value = c2;
}
</script>
<style type="text/css">
body
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
}
table
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
}
a
{
color:#0000FF;
background-color:#FFFFFF;
text-decoration:none;
}
a:hover
{
color:#000000;
background-color:#FFFFFF;
text-decoration:underline;
}
</style>
</head>
<body>
<?
$dirs = './font/';
$img = '';
$font = '';
$b = 0;
$dir = './img/';
if( $handle = opendir($dir) )
{
while( $file = readdir($handle) )
{
if($file != '.' && $file != '..')
{
$imgs[] = $file;
}
}
closedir($handle);
}
if( $hand = opendir($dirs) )
{
while( $read = readdir($hand) )
{
if( $read != '.' && $read != '..' )
{
$fonts[] = $read;
$ext = strtolower(strrchr($read, '.'));
$read = str_replace($ext, '', $read);
$font .= "<option value=\"{$b}\">{$read}</option>\n";
$b++;
}
}
closedir($hand);
}
$color = array
(
'#000000' => '0, 0, 0',
'#FFFFFF' => '255, 255, 255',
'#0000FF' => '0, 0, 255',
'#FF0000' => '255, 0, 0',
'#00FF00' => '0, 255, 0',
'#FFFF00' => '255, 255, 0',
'#FF00FF' => '255, 0, 255',
'#FFD700' => '255, 215, 0',
'#FFC0CB' => '255, 192, 203',
'#87CEEB' => '135, 206, 235',
'#CCCCCC' => '204, 204, 204',
'#999999' => '153, 153, 153'
);
$col = '';
foreach($color as $esa => $rgb)
{
$col .= "<span style=\"border:1px solid #000000; margin:5px; width=5px; height:5px; background-color:{$esa}; cursor:pointer;\" onclick=\"add_color($rgb)\"> </span>";
}
if( isset($_POST['status']) == false )
{
?>
<form action="<?=$PHP_SELF?>" method="post" name="modulo">
<table align="center">
<tr>
<td>
Immagine di sfondo:
</td>
<td align="center">
<a href="#" onClick="window.open('img.php', 'img', 'width=400, height=400, status=no, resizable=no,top=20,left=250')">Visualizza</a>
</td>
</tr>
<tr>
<td>
Dimensione Immagine:
</td>
<td>
Larghezza: <input type="text" name="wh"><br>
Altezza: <input type="text" name="hh" style="margin-top:2px; position:relative; left:1px;">
</td>
</tr>
<tr>
<td>
Testo:
</td>
<td>
<input type="text" name="text">
</td>
</tr>
<tr>
<td>
Nome File:
</td>
<td>
<input type="text" name="name">
</td>
</tr>
<tr>
<td>
Font:
</td>
<td>
<select name="font">
<option value="">Scegli...</option>
<?=$font?>
</select>
</td>
</tr>
<tr>
<td>
Colore Testo:
</td>
<td>
<?=$col?>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="text" readonly name="c" size="3"> <input type="text" readonly name="c1" size="3"> <input type="text" readonly name="c2" size="3">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="sub" value="Invia"><input type="hidden" name="status" value="ok">
</td>
</tr>
</table>
</form>
<?
}
else
{
session_start();
$text = $_POST['text'];
$pimg = $_SESSION['img'];
$c = $_POST['c'];
$c1 = $_POST['c1'];
$c2 = $_POST['c2'];
$pfont = $_POST['font'];
$name = $_POST['name'];
$wh = $_POST['wh'];
$hh = $_POST['hh'];
$stat = getimagesize($dir . $imgs[$pimg]);
if($text == '' || $pimg == '' || $c == '' || $c1 == '' || $c2 == '' || $pfont == '' || $name == '' || $wh == '' || $hh == '')
{
die('Tutti i campi sono obbligatori');
}
if($wh > $stat[0])
{
if( strlen($text) >= 5 )
{
$new_wh = strlen($text) * 15;
if( $new_wh < $wh )
{
$new_wh = $wh;
}
}
else
{
$new_wh = $wh;
}
}
else
{
die('Dimensione immagine troppo piccola');
}
$new_hh = $hh;
$ar = 'archive/';
if(file_exists($ar) == false)
{
mkdir($ar, 0777);
}
if( file_exists($ar . $name . '.gif') == false )
{
$im = imagecreatefromgif($dir . $imgs[$pimg]);
$thimg = imagecreate($new_wh, $new_hh);
imagecolorallocate($thimg, 255, 255, 255);
imagecolorallocate($im, 255, 255, 255);
$cl = imagecolorallocate($thimg, $c, $c1, $c2);
imagecopyresized($thimg, $im, 0, 0, 0, 0, $new_wh, $new_hh, $wh, $hh);
imagettftext($thimg, 15, 0, ($stat[0]/3), ($stat[1]/1.5), $cl, $dirs . $fonts[$pfont], $text);
if( imagegif($thimg, $ar . $name . '.gif') )
{
echo "L'immagine è stata creata con successo.<br>
Anteprima: <img src=\"{$ar}{$name}.gif\" alt =\"\"><br>
Link: <a href=\"{$ar}{$name}.gif\">$name</a>";
}
imagedestroy($im);
imagedestroy($thimg);
}
else
{
die('Immagine già presente in archivio');
}
@session_destroy('img');
}
?>
</body>
</html>
se qualcono riesce a risolverlo xke ci sto sbattendo la testa da un po e nn funziona ancora...