prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); if(isset($row[0])) { $idwid=$row[0]; $id = intval($idwid); } else $id=0; if (empty($id)) { // inserisce widget db se non esiste $sql="insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')"; $sth = $dbi->prepare("$sql"); $sth->execute(); } } } # se non esiste cancella dal db $sql="SELECT * FROM ".$prefix."_ele_widget"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row2 = $sth->fetchAll(); foreach($row2 as $row){ $esi=0; for ($i=0; $i < sizeof($tlist); $i++) { $files=$tlist[$i]; if($row['nome_file']==$files) $esi=1; } if($esi!=1){ $sql="DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'"; $sth = $dbi->prepare("$sql"); $sth->execute(); } } /******************************************************/ /*Funzione di visualizzazione globale */ /*****************************************************/ function all() { global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $prefix2, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$tema; $sql="SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row2 = $sth->fetchAll(); echo "
"; echo "
"._CONFIGWIDGET."
"; foreach($row2 as $row) { echo "
"; echo ""; echo ""; echo ""; $idw = intval($row['id']); echo ""; $titolo=$row['titolo']; $nome_file=$row['nome_file']; $pos_or = intval($row['pos_or']); $pos_ver = intval($row['pos_ver']); $attivo = intval($row['attivo']); echo ""; echo ""; echo "
Titolo: "; $sel= ($row['pos_or']==1) ? "selected":""; echo "Posizione : Altezza :"; echo ""; $sel= ($row['attivo']==1) ? "selected":""; echo ""._ATTIVO."
"; echo "
"; } // while } //*********************************************************** //Funzione di inserimento e gestione dei gruppi //************************************************************ function confcons() { global $id_cons_gen, $prefix, $dbi,$idw,$titolo,$pos_or,$pos_ver,$attivo; $aid=$_SESSION['aid']; $perms=ChiSei($id_cons_gen); if ($perms >128) { $sql="update ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'"; $sth = $dbi->prepare("$sql"); $sth->execute(); Header("Location: admin.php?id_cons_gen=$id_cons_gen&op=widget"); } } if ($do and $do="modify") confcons(); ele(); all(); echo""; include("footer.php"); //********************************************************************* //Funzione crea db se non esiste //********************************************************************** function make_db_widget(){ global $dbi,$prefix; $sql="CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget ( `id` int(10) NOT NULL auto_increment, `nome_file` varchar(255) NOT NULL default '', `titolo` varchar(255) NOT NULL default '', `pos_or` int(1) NOT NULL default '1', `pos_ver` int(3) NOT NULL default '0', `attivo` int(1) NOT NULL default '0', PRIMARY KEY (`id`) )"; $sth = $dbi->prepare("$sql"); $sth->execute(); } ?>