codice:
function send_images($title, $date, $consol, $gameid, $img1, $img1_name, $img1_type, $img1_size, $hits, $id) {
global $abpath, $ablink, $sizelim, $admin, $size, $EditedMessage, $prefix, $dbi, $module_name, $db, $widthprefer;
include ('header.php');
OpenTable();
$result = $db->sql_query("SELECT * FROM ".$prefix."_Games_Images");
$numresults = $db->sql_numrows($result);
$nomeimgz = $numresults+1;
$date = date("Y-m-d", time());
$titleimg = $_POST['title'];
$consol =$_POST['consol'];
$gameid =$_POST['gameid'];
//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/ief"; //Ief type
$cert5 = "image/png"; //Png type
$cert6 = "image/tiff"; //Tiff type
$cert7 = "image/bmp"; //Bmp Type
$cert8 = "image/vnd.wap.wbmp"; //Wbmp type
$cert9 = "image/x-cmu-raster"; //Ras type
$cert10 = "image/x-x-portable-anymap"; //Pnm type
$cert11 = "image/x-portable-bitmap"; //Pbm type
$cert12 = "image/x-portable-graymap"; //Pgm type
$cert13 = "image/x-portable-pixmap"; //Ppm type
$cert14 = "image/x-rgb"; //Rgb type
$cert15 = "image/x-xbitmap"; //Xbm type
$cert16 = "image/x-xpixmap"; //Xpm type
$cert17 = "image/x-xwindowdump"; //Xwd type
$log = "";
if ($img1_type == $cert2){$imgtypex =".jpg"; }
if ($img1_type == $cert3){$imgtypex =".gif"; }
if ($img1_type == $cert5){$imgtypex =".png"; }
//begin upload 1
//checks if file exists
if ($img1_name == "") {
$log .= "No file selected for upload 1
";
}
if ($img1_name != "") {
//checks if file exists
if (file_exists("$abpath/$consol/$img1_name")) {
$log .= "File 1 already existed
";
} else {
//checks if files to big
if ($sizelim == "yes") {
if ($img1_size > $size) {
$log .= "File 1 was too big
";
}
}
//Checks if file is an image
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4) or ($img1_type == $cert5) or ($img1_type == $cert6) or ($img1_type == $cert7) or ($img1_type == $cert8) or ($img1_type == $cert9) or ($img1_type == $cert10) or ($img1_type == $cert11) or ($img1_type == $cert12) or ($img1_type == $cert13) or ($img1_type == $cert14) or ($img1_type == $cert15) or ($img1_type == $cert16) or ($img1_type == $cert17)) {
@copy($img1, "$abpath/$consol/$nomeimgz$imgtypex") or $log .= "Couldn't copy image 1 to server
";
if (file_exists("$abpath/$consol/$img1_name")) {
$log .= "File 1 was uploaded
";
}
} else {
$log .= "File 1 is not an image
";
}
}
}
Print ("$log");
list($width, $height, $type, $attr) = getimagesize("$abpath/$consol/$nomeimgz$imgtypex");
$arrivo = "$abpath/$consol/small/$nomeimgz$imgtypex";
$part = "$abpath/$consol/$nomeimgz$imgtypex";
if ($type== 1)
{$abc = imagecreatefromgif("$part"); }
if ($type== 2)
{$abc = imagecreatefromjpeg("$part"); }
if ($type== 3)
{$abc = imagecreatefrompng("$part"); }
// $widthN = $width / 4;
// $heightN = $height / 4;
// $widthN = 100;
// $heightN = 100;
$widthN =$widthprefer;
$heightN = $height * $widthprefer / $width ;
$def = imagecreate($widthN, $heightN);
$ci = imagecopyresampled($def, $abc, 0, 0, 0, 0, $widthN, $heightN, $width, $height);
if ($type== 1)
{imagegif($def, $arrivo); }
if ($type== 2)
{imagejpeg($def, $arrivo, 100); }
if ($type== 3)
{imagepng($def, $arrivo); }
ImageDestroy($abc);
ImageDestroy($def);
if ($ci)
{
print ("Resize eseguito");
print ( "<img src=\"$ablink/$consol/small/$nomeimgz$imgtypex\">");
print ( "<img src=\"$ablink/$consol/$nomeimgz$imgtypex\">");
}
else
{
print ("Resize non riuscito
");
print ( "<img src=\"$arrivo\">");
print ( "<img src=\"$part\">");
}
$grande = "$nomeimgz$imgtypex";
$piccolo = "$nomeimgz$imgtypex";
$hits = 0;
$query = "INSERT INTO nuke_Games_Images VALUES (NULL, '$gameid', '$consol', '$date', '$titleimg', '$grande', '$piccolo', '$hits')";
if (mysql_query($query, $dbi))
{
echo "
la Game e' stata inserita correttamente
<center>[ <a href=\"modules.php?name=$module_name\">INDIETRO</a> ]</center>";
}
else
{
echo "Erorre durante l'inserimento";
}
mysql_close($dbi);
CloseTable();
include ("footer.php");
}
[][]