"; $mySep2 = " > "; $mySep3 = ";"; $mySepR = "[r] "; $mySepS = "[s] "; $mySepA = "[a] "; $mySepDG = "[dg] "; //controllo tutti gli elementi in magazzino $q = "SELECT id_mag FROM CMZ_magazzino WHERE nome<>'' AND idu=".$idu; $r = $conn->Execute($q);//echo $q; while($rw=$r->FetchRow()) { if($rw[id_mag]) { $myDest = ""; //rubriche $qr = "SELECT nome FROM CMZ_rubriche WHERE (foto=".$rw[id_mag]." OR icona=".$rw[id_mag].") AND cancellato=0"; $rr = $conn->Execute($qr); while(!$rr->EOF){ $rwr = $rr->fields; $myDest.= $mySep.$mySepR.$rwr[nome].$mySep3; $rr->MoveNext(); } //sottorubriche $qs="SELECT CMZ_rubriche.nome AS rubN,CMZ_sottorubriche.nome AS srbN FROM CMZ_sottorubriche,CMZ_rubriche WHERE CMZ_rubriche.idr=CMZ_sottorubriche.idr AND (CMZ_sottorubriche.foto=".$rw[id_mag]." OR CMZ_sottorubriche.icona=".$rw[id_mag].") AND CMZ_sottorubriche.cancellato=0 AND CMZ_rubriche.cancellato=0"; $rs = $conn->Execute($qs); while(!$rs->EOF){ $rws = $rs->fields; $myDest.= $mySep.$mySepR.$rws[rubN].$mySep2.$mySepS.$rws[srbN].$mySep3; $rs->MoveNext(); } //articoli $qa="SELECT CMZ_rubriche.nome AS rubN,CMZ_sottorubriche.nome AS srbN,CMZ_articoli.titolo FROM CMZ_allegati,CMZ_articoli,CMZ_sottorubriche,CMZ_rubriche WHERE CMZ_articoli.ida=CMZ_allegati.ida AND CMZ_articoli.idsr=CMZ_sottorubriche.idsr AND CMZ_sottorubriche.idr=CMZ_rubriche.idr AND CMZ_articoli.cancellato=0 AND CMZ_sottorubriche.cancellato=0 AND CMZ_rubriche.cancellato=0 AND CMZ_allegati.id_mag=".$rw[id_mag]; $ra = $conn->Execute($qa); while(!$ra->EOF){ $rwa = $ra->fields; $myDest.= $mySep.$mySepR.$rwa[rubN].$mySep2.$mySepS.$rwa[srbN].$mySep2.$mySepA.$rwa[titolo].$mySep3; $ra->MoveNext(); } //header if($_SESSION['dati']['fotocopertina2']==$rw[id_mag])$myDest.= $mySep.$mySepDG.$cmzLabel['6'].$mySep3; //copertina if($_SESSION['dati']['header2']==$rw[id_mag])$myDest.= $mySep.$mySepDG.$cmzLabel['5'].$mySep3; //immagine opzionale if($_SESSION['dati']['optimg2']==$rw[id_mag])$myDest.= $mySep.$mySepDG.$cmzLabel['34'].$mySep3; //salvo la destinazione $conn->Execute("UPDATE CMZ_magazzino SET destinazione=\"".$myDest."\" WHERE id_mag=".$rw[id_mag]); } } //sessione per il controllo dell'aggiornamento $_SESSION['agg_dest']="ctrl"; } function make_thumbnail($foto,$idx,$imgdir,$propthumb="height",$widthumb=150,$heighthumb=100){ @$imageData = getimagesize("$imgdir/$foto"); $imageType=$imageData[2]; $imageAttr=$imageData[3]; if($imageType==1)$src_img = imagecreatefromgif("$imgdir/$foto"); if($imageType==2)$src_img = imagecreatefromjpeg("$imgdir/$foto"); if($imageType==3)$src_img = imagecreatefrompng("$imgdir/$foto"); if($imageData[2]){ $src_width= imagesx($src_img); $src_height= imagesy($src_img); if($propthumb=="no"){ $dest_width=$widthumb; $dest_height=$heighthumb; } if($propthumb=="height"){//mantenendo fissa l'altezza, cambio la larghezza $dest_height=$heighthumb; $dest_width=round($src_width*($dest_height/$src_height)); } if($propthumb=="width"){//mantenendo fissa la larghezza, cambio l'altezza $dest_width=$widthumb; $dest_height=round($src_height*($dest_width/$src_width)); } $dst_img = imagecreatetruecolor($dest_width,$dest_height); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); if($imageType==1)imagegif($dst_img, "$imgdir/t_$foto"); if($imageType==2)imagejpeg($dst_img, "$imgdir/t_$foto", 100); if($imageType==3)imagepng($dst_img, "$imgdir/t_$foto"); imagedestroy($src_img); imagedestroy($dst_img); return "
$widthumb $heighthumb [$propthumb] $src_height x $src_width Generato da $foto il thumbnail t_$foto di dimensioni $dest_width x $dest_height"; } } function creathumbs($idu,$propthumb,$widthumb,$heighthumb){ global $conn; echo "generazione thumbnails"; $q = "SELECT * FROM CMZ_magazzino WHERE idu=".$idu." AND (nome LIKE '%jpg' || nome LIKE '%gif' || nome LIKE '%png')"; $r = $conn->Execute($q); while(!$r=EOF){ $rw = $r->fields; echo "
Creazione thumbnail per $rw[nome]..."; echo make_thumbnail($rw[nome],$idx,$GLOBALS['dati']['imgdir'],$propthumb,$widthumb,$heighthumb); $r->MoveNext(); } } function update_store($userfile_name,$target_file,$idu){ global $conn; chmod($target_file,0775); //ricerco i parametri del file if(file_exists($target_file)){ $size = filesize($target_file); $ftime = filemtime($target_file); } else echo "non trovo il file $target_file per vederne i parametri"; //controllo che non esista un file con questo nome, se c' updato $q = "SELECT id_mag,idsu FROM CMZ_magazzino WHERE idu=$idu and nome LIKE '$userfile_name'"; $re = $conn->Execute($q); if($re->RecordCount()>0) { $rw = $re->fields; $query = "UPDATE CMZ_magazzino SET nome='$userfile_name',size='$size',time='$ftime' WHERE id_mag=$rw[id_mag]"; $idx = $rw[id_mag]; } else{ //inserimento del nome nel dbfiles //$userfile_name=strtolower($userfile_name); $query="INSERT INTO CMZ_magazzino (nome,idu,size,time,gruppo,idsu) values ('$userfile_name',$idu,'$size','$ftime','".$_GET['selFld']."','".$_SESSION['modifiche']."')"; $e = $conn->Execute($query); $idxR = $conn->Execute("SELECT id_mag FORM CMZ_magazzino ORDER BY id_mag DESC LIMIT 1"); $idxRW = $idxR->fields; $idx = $idxRW[id_mag]; } return $idx; } function getFolderList($idp){ global $conn; $q = "SELECT id_gruppo,nome FROM CMZ_gruppi WHERE idu=".$GLOBALS[idCustUser]." AND padre=".$idp." ORDER BY nome ASC"; $r = $conn->Execute($q); while(!$r->EOF){ $rw = $r->fields; echo "\n

"; echo "\n"; echo "\n".$rw[nome].""; echo "\n

"; echo "\n
"; getFolderList($rw[id_gruppo]); echo "\n
"; $r->MoveNext(); } } function selectFolder($func,$idf=""){ global $conn; global $cmzLabel; $q="SELECT * FROM CMZ_gruppi WHERE idu=".$_SESSION[id_org]." ORDER BY nome"; $r = $conn->Execute($q); //echo $q; if($r->RecordCount()){ $str.= ""; } return $str; } function setFileName($name){ $name = strtolower($name); $name = str_ireplace(array("\'"," "),"_",$name); $name = str_ireplace("'","_",$name); $name = str_ireplace("","a",$name); $name = str_ireplace(array("",""),"e",$name); $name = str_ireplace("","i",$name); $name = str_ireplace("","o",$name); $name = str_ireplace("","u",$name); return $name; } ?>