Codice PHP:
<?php
session_start();
include ("funzioni.php");
echo intestazione();
include("../inc/inizio.php");
include ("../inc/header.php");
echo "<div id='pagina'>
<div id='contenuto'>";
include ("../inc/col_left2.php");
echo "<div id='centrale'>";
if (!(isset($_SESSION["pwd"])) and isset($_COOKIE["filtro"]))
{
echo "<font color='#CFCFCF'><h3 align=center>Impossibile visualizzare la pagina</h3>
<table align=center><tr><td>[url='../index.php']Torna indietro[/url]</td></tr></table></font>";
}
else
{
echo "<table align=center><tr><td>[img]../imma/01_tasto_InviaArticolo.png[/img]</td></tr></table>";
$db=connessione();
$ut=$_SESSION['utente'];
//reperisco i dati nella tabella degli autori
$sql ="SELECT * FROM autori, utenti WHERE id_ut=Cod_ut and id_ut=$ut";
$s=$db->query($sql)or die("Errore2 ".$db->error);
$dati = $s->fetch_assoc();
$cod_aut=$dati['id_aut'];
echo "<font color=white>$cod_aut</font>";
$tit=$_POST["tit"];
if(strpos($tit,"href"))
{
$err_tit=true;
}
$video=$_POST["url"];
$testo1=$_POST["ta"];
$testo="<div style='text-align:justify;'>".str_replace("
","
",$testo1)."</div>";
$tag_disp=car_tag($db);
$accettaz=$_POST['accettaz'];
$commenti=$_POST['commenti'];
$data=(date("y-m-d"));
$ora=(date("G:i:S"));
$ok1=false;
$ok2=false;
$ok3=true;
$tipo="h";
$capt=$_SESSION["session_captchaText"];
$input_capt=$_POST["input_capt"];
if($capt!=$input_capt)
{
$err_capt=true;
}
if (isset($_POST['foto2']))
{
$foto=$_POST['foto2'];
$ok3=false;
}
if ($tit=="")
{
$err_tit=true;
}
if ($accettaz=="no")
{
$err_acc=true;
}
$pres_tag="no";
for ($i=0;$i<=41;$i++)
{
if (isset($_POST["$i"]))
{
$pres_tag="si";
break;
}
}
if ($pres_tag=="no")
{
$err_tag=true;
}
//PROCEDURA PER IL CARICAMENTO DEL FILE
// assegnazione del file trasmesso - struttura con if per compatibilit� versioni diverse
if(!isset($_FILES))
{
$_FILES = $HTTP_POST_FILES;
}
if(!isset($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
}
// controllo dimensioni file
if ($_FILES["upfile"]["size"][0] > 100000000)
{
$err_foto1=true;
}
else
{
// controllo dimensioni file
if ($_FILES["upfile"]["size"][0] != 0)
{
//Nuovo nome da dare al file uploadato, pu� anche non essere assegnato
$all_est=array('.jpeg','.jpg','.bmp','.tif','.tiff','.gif');
$estensione = strtolower(substr($_FILES["upfile"]["name"][0], strrpos($_FILES["upfile"]["name"][0], "."), strlen($_FILES["upfile"]["name"][0])-strrpos($_FILES["upfile"]["name"][0], ".")));
if (!in_array($estensione,$all_est))
{
$err_foto2=true;
}
else
{
if ($ok3==true)
{
$sql="SELECT * FROM codici_foto ORDER BY cod DESC LIMIT 1";
$a=$db->query($sql)or die("Errore ".$db->error);
$riga = $a->fetch_assoc();
$cod=$riga["cod"];
$cod2=$cod+1;
$nome_file1 = $cod2."$estensione";
$sql = "INSERT INTO codici_foto
(cod,nome_foto)
VALUES
($cod2,'$nome_file1')";
$db->query($sql)or die("Errore1 ".$db->error);
}
else
{
$codice=substr($foto,0,strpos($foto,"."));
$nome_file1=$codice."$estensione";
}
//Percorso assoluto della cartella dove si desiderano salvare i files uploadati
$upload_dir = "/opt/lampp/htdocs/www.ilprincipe.eu/upload";
//Controllo il file che � stato uploadato e lo sposto nella cartella definita nella variabile $upload_dir
if(is_uploaded_file($_FILES["upfile"]["tmp_name"][0]))
{
move_uploaded_file($_FILES["upfile"]["tmp_name"][0], "$upload_dir/$nome_file1")
or die($_FILES["upfile"]["error"][0]);
list($width, $height, $type, $attr) = getimagesize("$upload_dir/$nome_file1");
if($width>450)
{
$newheight=ceil(450*$height/$width);
$thumb = imagecreatetruecolor(450,$newheight);
switch($type)
{
case 1:
$source = imagecreatefromgif("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 450,$newheight, $width, $height);
imagegif($thumb, "$upload_dir/$nome_file1", 75);
break;
case 2:
$source = imagecreatefromjpeg("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 450,$newheight, $width, $height);
imagejpeg($thumb, "$upload_dir/$nome_file1", 75);
break;
case 4:
$source = imagecreatefromwbmp("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 450,$newheight, $width, $height);
imagewbmp($thumb, "$upload_dir/$nome_file1", 75);
break;
}
imagedestroy($thumb);
}
list($width, $height, $type, $attr) = getimagesize("$upload_dir/$nome_file1");
$newheight=ceil(150*$height/$width);
$thumb = imagecreatetruecolor(150,$newheight);
switch($type)
{
case 1:
$source = imagecreatefromgif("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 150,$newheight, $width, $height);
imagegif($thumb, "$upload_dir/anteprima/$nome_file1", 75);
break;
case 2:
$source = imagecreatefromjpeg("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 150,$newheight, $width, $height);
imagejpeg($thumb, "$upload_dir/anteprima/$nome_file1", 75);
break;
case 4:
$source = imagecreatefromwbmp("$upload_dir/$nome_file1");
imagecopyresized($thumb, $source, 0, 0, 0, 0, 150,$newheight, $width, $height);
imagewbmp($thumb, "$upload_dir/anteprima/$nome_file1", 75);
break;
default: copy("$upload_dir/$nome_file1","$upload_dir/anteprima/$nome_file1");
}
imagedestroy($thumb);
}
}
}
}
echo "<font color=#CFCFCF><H3 align=center>Operazione Riuscita: Riepilogo dati</H3>
<div class='invia_modulo1'>
<u>Inserisci l'articolo:</u>
<table width=450px align=center style='margin-bottom:11px;'>
<tr> <td width=29%>[b]IMMAGINE [/b]</td><td width=71%>";
if(!isset($nome_file1))
{
if(empty($foto))
{
$nome_file1="";
}
else
{
$nome_file1=$foto;
}
}
if(isset($nome_file1) and !(empty($nome_file1)))
{
echo "[img]../upload/$nome_file1[/img]"; // qui visualizzo la foto "incriminata"
}
echo "</td></tr></table>
<table width=450px align=center style='margin-bottom:11px;'>
<tr> <td width=29%>[b]TITOLO ARTICOLO[/b]</td><td width=71%>$tit</td></tr></table>
<table width=450px align=center style='margin-bottom:11px;'>
<tr><td colspan=2>[b]TESTO ARTICOLO[/b]</td></tr>
<tr><td colspan=2>$testo</td></tr></table>
<table width=450px align=center style='margin-bottom:11px;'>
<tr> <td>[b]TAG ASSOCIATE[/b]</td></tr>
<tr><td>";
for ($i=0;$i<=41;$i++)
{
$tag=$tag_disp[$i];
if (isset($_POST["$i"]))
{
echo "$tag
";
}
}
echo "</td></tr>
</table>
</div>
</font>";
echo "<table align=center><tr><td>[url='mod_articoli.php'][img]../imma/tasto-back.jpg[/img][/url]</td></tr></table>";
//inserisco i dati nella tabella degli autori
$sql = "INSERT INTO articoli
(titolo,foto,testo,accett,comm,data,Cod_aut,tipo_adm,video";
for ($i=0;$i<=41;$i++)
{
$sql .=",tag$i";
}
$sql.=")
VALUES
('$tit','$nome_file1','$testo','$accettaz',$commenti,'$data $ora',$cod_aut,'$tipo','$video'";
for ($i=0;$i<=41;$i++)
{
$tag=$tag_disp[$i];
if (isset($_POST["$i"]))
{
$sql .=",true";
}
else
{
$sql .=",false";
}
}
$sql.=")";
$db->query($sql)or die("Errore3 ".$db->error);
}
$db->close();
}
?>
</div>
<?php
include("../inc/col_right2.php");
?>
</div>
<?php
include ("../inc/fine.php");
echo "</div>";
echo piepagina();
?>