Index: /trunk/admin/footer.php
===================================================================
--- /trunk/admin/footer.php	(revision 255)
+++ /trunk/admin/footer.php	(revision 256)
@@ -12,5 +12,5 @@
     die();
 }
-echo "</td></tr><tr><td>";
+echo "</td></tr><tr><td colspan=\"2\">";
 include("versione.php");
 
Index: /trunk/admin/modules/Elezioni/backup.php
===================================================================
--- /trunk/admin/modules/Elezioni/backup.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/backup.php	(revision 256)
@@ -5,6 +5,9 @@
 if (isset($param['id_comune']))
 	 $id_comune2=intval($param['id_comune']);
-$result = mysql_query("select descrizione from ".$prefix."_ele_consultazione  where id_cons_gen='$id_cons_gen2'", $dbi);
-list($nomeFile) = mysql_fetch_row($result);
+$sql="select descrizione from ".$prefix."_ele_consultazione  where id_cons_gen='$id_cons_gen2'";
+$sth = $dbi->prepare("$sql");
+$sth->execute();	
+$row = $sth->fetch(PDO::FETCH_BOTH);
+$nomeFile=$row[0];
 #$nomeFile="backup";
 header( 'Content-Type: application/octet-stream' );
Index: /trunk/admin/modules/Elezioni/controllo_votanti.php
===================================================================
--- /trunk/admin/modules/Elezioni/controllo_votanti.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/controllo_votanti.php	(revision 256)
@@ -24,8 +24,17 @@
 $perms=ChiSei($id_cons_gen);
 if ($perms<16 or !$id_cons_gen) die("$perms ".$_SESSION['id_comune'].$_SESSION['aid'].";Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
-$res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
-list($tipo_cons,$id_cons) = mysql_fetch_row($res);
-$res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
-	list($genere) = mysql_fetch_row($res);
+
+	$sql="SELECT t1.descrizione,t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+$descr_consultazione=$row[0];
+$tipo_cons=$row[1];
+$id_cons=$row[2];
+	$sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);	
+	$genere = $row[0];
 if (isset($param['ops'])) get_magic_quotes_gpc() ? $ops=$param['ops']:$ops=addslashes($param['ops']); else $ops='';
 if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
@@ -54,9 +63,15 @@
 		if (!IsSet($num_ref)) { 
 			$num_ref=1;
-			$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-			$num_refs= mysql_num_rows($resg); //quante pagine?
-		}
-		$resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
-		list($idg,$numg) = mysql_fetch_row($resg);
+			$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();
+			$num_refs= $sth->rowCount(); //quante pagine?
+		}
+			$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();
+			$row = $sth->fetch(PDO::FETCH_BOTH);	
+			$idg=$row[0];
+			$numg=$row[1];
 		$id_gruppo=$idg;
 		$cond= "and id_gruppo=$id_gruppo";
@@ -64,7 +79,9 @@
 	}
 	$i=1;
-	$res = mysql_query("SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
-	while ($linka[$i++] = mysql_fetch_array($res));
-	$num_sez = mysql_num_rows($res); //numero totale delle sezioni
+	$sql"SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	while ($linka[$i++] = $sth->fetch(PDO::FETCH_BOTH));
+	$num_sez = $sth->rowCount(); //numero totale delle sezioni
 	$tot_compl=0;$tot_u=0;$tot_d=0;
 //	$ar['riga1'][0]="<hr>";
@@ -85,13 +102,26 @@
 	$ar['perc'][1]=" ";
 //	$ar['riga2'][1]="<hr>";
-		$resuo = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
-		list($ultora,$ultdata)=mysql_fetch_row($resuo);
-
-	$resril = mysql_query("SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
-	$num_ril= mysql_num_rows($resril);  //numero delle rilevazioni previste
+	$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	$row = $sth->fetch(PDO::FETCH_BOTH);	
+	$ultora=$row[0];
+	$ultdata=$row[1];
+
+	$sql = "SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
+	$resril = $dbi->prepare("$sql");
+	$resril->execute();	
+	$num_ril = $resril->rowCount();  //numero delle rilevazioni previste
 	echo "\n<table border=\"0\" width=\"100%\"  align=\"center\">";
 	echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
-	$ressomma = mysql_query("SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario", $dbi);
-	while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
+	$sql="SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
+	while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
+		$data=$row[0];
+		$ora=$row[1];
+		$somma=$row[2];
+		$votiu=$row[3];
+		$votid=$row[4];
 		$perc_u='';$perc_d='';$perc_c='';
 #		if($votiu or $votid)
@@ -107,6 +137,8 @@
 	}
 	$ud=0;$ora_rif="";
-	while (list($data1,$ora1) = mysql_fetch_row($resril)) 
+	while ($row2 = $resril->fetch(PDO::FETCH_BOTH)) 
 	{
+		$data1=$row2[0];
+		$ora1=$row2[1];
 		$ud++;	
 		list($hour, $minute, $second) = explode(":", $ora1);
@@ -115,6 +147,8 @@
 		if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
 		echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
-		$resaff = mysql_query("SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond", $dbi);
-		list($num_scr) = mysql_fetch_row($resaff);  //numero delle sezioni inserite
+		$sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond";
+		$resaff = $dbi->prepare("$sql");
+		$resaff->execute();
+		$num_scr=$resaff->rowCount(); //numero delle sezioni inserite
 		echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
 		if ($ud==$num_ril) echo "<br>\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">"._UOMINI."</td><td width=\"30%\">"._DONNE."</td><td>"._COMPLESSIVI."</td></tr></table>\n";
@@ -142,7 +176,15 @@
 	}
 	}
-	$resvoti = mysql_query("SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez", $dbi);
+	$sql="SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
 	$ud=0;
-	while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
+	while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
+		$data=$row[0];
+		$ora=$row[1];
+		$numsez=$row[2];
+		$uomini=$row[3];
+		$donne=$row[4];
+		$complessivi=$row[5];
 		if ($ora_rif=="$data.$ora")
 			$ar[$numsez][$data.$ora]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">$uomini</td><td width=\"30%\">$donne</td><td>$complessivi</td></tr></table>\n";
Index: /trunk/admin/modules/Elezioni/controllo_voti.php
===================================================================
--- /trunk/admin/modules/Elezioni/controllo_voti.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/controllo_voti.php	(revision 256)
@@ -26,9 +26,14 @@
 $perms=ChiSei($id_cons_gen);
 if ($perms<16 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
-$res = mysql_query("SELECT t1.tipo_cons,t2.id_cons,t2.solo_gruppo,t2.disgiunto FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
-list($tipo_cons,$id_cons,$dettnulli,$disgiunto) = mysql_fetch_row($res);
-$res = mysql_query("SELECT genere,voto_g,voto_l FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
-	list($genere,$votog,$votol) = mysql_fetch_row($res);
-
+	$sql="SELECT t1.tipo_cons,t2.id_cons,t2.solo_gruppo,t2.disgiunto FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	list($tipo_cons,$id_cons,$dettnulli,$disgiunto) = explode($row);
+	$sql="SELECT genere,voto_g,voto_l FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	list($genere,$votog,$votol) = explode($row);
 include("modules/Elezioni/funzionidata.php");
 include("modules/Elezioni/ele.php");
@@ -44,12 +49,18 @@
  
     global $prefix, $dbi,$fascia,$limite;
-	$res = mysql_query("SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
-	list($totm,$totf) = mysql_fetch_row($res);
+	$sql="SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	list($totm,$totf) =  explode($row);
 	$totel=$totm+$totf;
 	if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina 
 	if (!IsSet($num_ref)) { 
 		$num_ref=1;
-		$resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-		$num_refs= mysql_num_rows($resg); //quante pagine?
+		$sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();	
+		$row = $sth->fetch(PDO::FETCH_BOTH);
+		$num_refs= $sth->rowCount(); //quante pagine?
 	}
 	if((($genere!=4) and $pag==0 and !$votog) or $genere==1 or $genere==2){ //diverso da liste a piu' candidati
@@ -59,10 +70,15 @@
 	}
 	OpenTable();
-	$resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
-	list($idg,$numg) = mysql_fetch_row($resg);
-	$res = mysql_query("SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
-	$num_sez = mysql_num_rows($res); //quante sezioni?
+		$sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();	
+		$row = $sth->fetch(PDO::FETCH_BOTH);
+		list($idg,$numg) = explode($row);
+		$sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();
+		$num_sez = $sth->rowCount();  //quante sezioni?
 for ($i=1;$i<=$num_sez;$i++){
-		$sezione[$i]=mysql_fetch_array($res, 3); //inizializza l'array delle sezioni
+		$sezione[$i]== $sth->fetch(PDO::FETCH_BOTH); //inizializza l'array delle sezioni
 		$ar[$i]=0;
 	}
@@ -88,6 +104,7 @@
 		$riga1= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZSCR." "._CONSULTAZIONE." N. ".$numg."</td></tr></table></td></tr>\n";
 	}
-	$res = mysql_query("$tab ", $dbi);
-	$num_scr = mysql_num_rows($res);
+	$sth = $dbi->prepare("$tab ");
+			$sth->execute();
+	$num_scr = $sth->rowCount(); 
 	$riga2= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZIONI." $num_scr "._SU." $num_sez</td></tr></table></td></tr>\n";//sezioni scrutinate
 	$riga2 .= "<tr><td>\n<table border=\"0\" width=\"100%\"  align=\"center\">";
@@ -106,11 +123,11 @@
 //		$riga3 .= "<td><b>"._PREFLIS."</b></td>";
     	$riga3 .= "<td><b>"._STATO."</b></td></tr>\n";
-	$res = mysql_query("$tab ", $dbi);//die($tab);
-	$num_scr = mysql_num_rows($res);
 	$righe= "";
 	$scrutinate=1;
 //	if ($genere>1 and $pag==1) $ops=3;
 	$tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;$tgrup_pref=0;$tot_voti_nulli=0;$tot_val_lista=0;$tot_vot_nul_lis=0;$tot_cont_lis=0;$tot_solog=0;$tot_solol=0;$errors=0;
-	while (list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$voti_nulli,$val_lista,$vot_nul_lis,$cont_lis,$solog,$solol) = mysql_fetch_row($res)){
+	while (	$row = $sth->fetch(PDO::FETCH_BOTH)){
+//controllare
+	list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$voti_nulli,$val_lista,$vot_nul_lis,$cont_lis,$solog,$solol) = explode($row);
 	// inserimento numeri di sez non scrutinate
 		while ($scrutinate < $num) { 
@@ -121,12 +138,17 @@
 	// fine inserimento	
 		if (($genere==2 or $genere==3 or $genere==5) and !$votog and !$dettnulli) {
-			$respref = mysql_query("select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id'", $dbi);
-			list ($gruppref) = mysql_fetch_row($respref); 
+			$sql="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id'";
+			$sth2 = $dbi->prepare("$sql");
+			$sth2->execute();	
+			$row2 = $sth2->fetch(PDO::FETCH_BOTH);
+			list ($gruppref) = explode($row2);
 			$tgrup_pref += $gruppref;
 		}
 		$tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
 		if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
-		$res2 = mysql_query($tab2, $dbi);
-		list($votid,$votiu,$voti) = mysql_fetch_row($res2);
+			$sth2 = $dbi->prepare("$tab2");
+			$sth2->execute();	
+			$row2 = $sth2->fetch(PDO::FETCH_BOTH);
+			list($votid,$votiu,$voti) = explode($row2);
 //		$voti=$votiu+$votid;
 		
@@ -161,6 +183,9 @@
 		if($genere==5 and !$votog) #$validi+$nulli+$bianchi+$vcont+$vn 
 			if($pag==0 and !$votog or $fascia<=$limite) {$controllo1=$validi+$nulli+$bianchi+$contestati+$voti_nulli;} else { $controllo1=$val_lista+$nulli+$bianchi+$contestati+$voti_nulli+$cont_lis+$vot_nul_lis+$solog;$controllo2=$si+$no-$solol+$cont_lis+$vot_nul_lis;}
-		$cerr=mysql_query("select stato_lis from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id'", $dbi);
-		list($crlis)=mysql_fetch_row($cerr);
+			$sth2 = $dbi->prepare("select stato_lis from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id'");
+			$sth2->execute();	
+			$row2 = $sth2->fetch(PDO::FETCH_BOTH);
+			list($crlis) = explode($row2);
+
 		if ($voti==$controllo1 and $validi==$controllo2 and !$g_err and $crlis!=-1){
 			$righe .= "<td>"._OK."</td></tr>\n";
Index: /trunk/admin/modules/Elezioni/ele.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele.php	(revision 256)
@@ -64,11 +64,7 @@
 	$bgcolor1='#e7e7e7';
 	$row=descr_comune();$descr_comu=$row['descrizione'];
-#	$sqlcomu="select descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'";
-#	$res = mysql_query($sqlcomu);
-#	list($descr_comu)=mysql_fetch_row($res);
-	$sqlcomu="select fascia from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
-	$res = mysql_query($sqlcomu);
-	if ($res)
-	list($fascia)=mysql_fetch_row($res);
+
+	$row=daticonscom();
+	if ($row['fascia']) $fascia=$row['fascia'];
 	else
 	$fascia=0;
@@ -109,18 +105,24 @@
 	// controllo delle opzioni utilizzabili: sono quelle che hanno genitori in quella precedente
 	// esempio si possono inserire i candidati solo se prima sono state inserite le liste
-	$resq = mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons", $dbi);
-	if ($resq) list($nrcirco)=mysql_fetch_row($resq); else $nrcirco=0;
-	$resq = mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
-	if ($resq) list($nrsede)=mysql_fetch_row($resq); else $nrsede=0;
-	$resq = mysql_query("select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
-	if ($resq) list($nrgruppo)=mysql_fetch_row($resq); else $nrgruppo=0;
-	$resq = mysql_query("select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons", $dbi);
-	if ($resq) list($nrlista)=mysql_fetch_row($resq); else $nrlista=0;
-	$resq = mysql_query("SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons", $dbi);
-	if ($resq) list($nraff)=mysql_fetch_row($resq); else $nraff=0;
+	$sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrcirco=$row[0];}
+	catch(PDOException $e) {$nrcirco=0; }  	
+	$sql="select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrsede=$row[0];}
+	catch(PDOException $e) {$nrsede=0; }  	
+	$sql="select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrgruppo=$row[0];}
+	catch(PDOException $e) {$nrgruppo=0; }  	
+	$sql = "select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrlista=$row[0];}
+	catch(PDOException $e) {$nrlista=0; }  	
+	$sql = "SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $nraff=$row[0];}
+	catch(PDOException $e) {$nraff=0; }  	
 	if ($genere==0) $tmpval='voti_ref'; else $tmpval='sezioni';
-	$resq = mysql_query("SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons", $dbi);
-	if ($resq) list($nrvoti)=mysql_fetch_row($resq); else $nrvoti=0;
-	unset($resq);
+	$sql = "SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons";
+	try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrvoti=$row[0];}
+	catch(PDOException $e) {$nrvoti=0; }  	
+	unset($row);
 	if ($perms==256) // il superuser puo' scegliere il comune su cui lavorare
 	{
@@ -178,5 +180,5 @@
 
 		<a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen\">$bullet"._AFFLUENZE."</a><br>
-		<a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a><br/>
+		<a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a><br>
 		<a href=\"http://www.eleonline.it/portal/segnala.php?tmp=test123\" target=\"_blank\">$bullet_red <b>"._SEGNALA."</b></a>
 		</td></tr>";
Index: /trunk/admin/modules/Elezioni/ele_affluenze.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_affluenze.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele_affluenze.php	(revision 256)
@@ -135,5 +135,5 @@
 		$sth = $dbi->prepare("$sql");
 		$sth->execute();	
-		$row = $sth->fetchAll();
+#		$row = $sth->fetchAll();
 		$tipo= $sth->rowCount(); 
 		if(($tipo==0) and ($dadata <= $cdata) and ($adata >= $cdata)){
Index: /trunk/admin/modules/Elezioni/ele_associazioni.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 256)
@@ -71,5 +71,4 @@
      echo "} \n"; 
      echo "else document.getElementById('trspunta').style.visibility='visible' \n"; 
-#     echo "if (document.getElementById('chiusa').options[3].selected==false) { \n"; 
      echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n"; 
      echo "document.getElementById('add').value=\""._MODIFY."\" \n"; 
@@ -124,5 +123,4 @@
 	echo "<table width=\"100%\" border=\"3\">";
 	echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
-#	echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
 	echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
@@ -135,18 +133,8 @@
 	echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
 	echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
-#	echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
 	echo "</tr>";
 	echo "<tr align=\"center\"><td>";
 	echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
 	echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
-#	$ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
-#	if ($num_coll=mysql_num_rows($ressede)){
-#		echo "<td><select name=\"id_collegio\">";
-#		while(list($id,$descr_coll)=mysql_fetch_row($ressede)){
-#			$sel= ($id == $id_collegio) ? "selected":"";
-#			echo "<option value=\"$id\" $sel>$descr_coll";
-#		}
-#		echo "</select></td>";
-#	} else echo "<td></td>";
 	$rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
 	echo "<td>";
@@ -241,5 +229,4 @@
 		echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
 		echo "<tr><td colspan=\"5\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov1\">"._SPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_cons()\"></label></fieldset></td></tr>";
-# <div  id=\"trspunta\" style=\"visibility:hidden\">   </div>
 		echo "<tr id=\"trspunta\" style=\"visibility:hidden\"><td colspan=\"4\"><fieldset><legend>"._SPUNTALABEL2."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd4\" name=\"pwd4\" value=\"1\" onclick=\"javascript:del_cons()\"></label></fieldset>";
 	}else{
@@ -249,8 +236,6 @@
 	$i=0;
 	echo "</td></tr></table></form>";
-############
 	echo "<hr><br><table width=\"100%\" border=\"3\">";
 	echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."TEST:$id_cons_comu</b></td>";
-#	echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
 	echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
@@ -263,11 +248,6 @@
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
-#	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SG."</b></td>";
-	echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</td></tr>";
-###############
-
-#	if ($num_coll>0)
-#	$resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
-#	else
+	echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</b></td></tr>";
+
 	$resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
 	while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
@@ -276,9 +256,35 @@
 		$i++;
 		$bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
-		if($tipo_cons==3) echo "<tr><td colspan=\"8\">"; else echo "<tr><td colspan=\"8\">";
+		echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
+		echo "<td><b>$descr_cons</b></td>";
+		echo "<td><b>$descr_comu</b></td>";
+		echo "<td><b>$preferenze2</b></td>";
+		$stato['0']=_ATTIVA;
+		$stato['1']=_CHIUSA;
+		$stato['2']=_NULLA;
+		echo "<td><b>".$stato[$chiusa]."</b></td>";
+		if($tipo_cons==3){
+			echo "<td><b>".$descr_conf."</b></td>";
+			$rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
+			$inffascia=0;
+			if (mysql_num_rows($rescomu)==0) echo "<td></td>";
+			while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
+				$sel='';
+				if ($id == $fasciacom) 
+					echo "<td>$inffascia - $abitanti</td>";
+				$inffascia=$abitanti;
+			}
+
+		}
+		if ($vismf2==0) $sel=_NO; else $sel=_SI;
+		echo "<td>$sel</td>";
+		if ($sg2==0) $sel=_NO; else $sel=_SI;
+		echo "<td>$sel</td>";
+		if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
+		echo "<td>$sel</td>";
+		echo "<td>";
 		echo "<form name=\"modello$i\" action=\"admin.php\">"
-			."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
-//		echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
-#		echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
+		."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
+		echo "<input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\">";
 		echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
 		echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
@@ -287,39 +293,9 @@
 		echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
 		echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
-		echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
-		echo "<td width=\"15%\"><b>$descr_cons</b></td>";
-		echo "<td width=\"20%\"><b>$descr_comu</b></td>";
-		echo "<td width=\"10%\"><b>$preferenze2</b></td>";
-		$stato['0']=_ATTIVA;
-		$stato['1']=_CHIUSA;
-		$stato['2']=_NULLA;
-		echo "<td  width=\"10%\"><b>".$stato[$chiusa]."</b></td>";
-		if($tipo_cons==3){
-			echo "<td width=\"20%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
-			$rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
-			$inffascia=0;
-			while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
-				$sel='';
-				if ($id == $fasciacom) 
-					echo "<td width=\"20%\">$inffascia - $abitanti</td>";
-				$inffascia=$abitanti;
-			}
-
-		}
-		if ($vismf2==0) $sel=_NO; else $sel=_SI;
-		echo "<td width=\"10%\">$sel</td>";
-		if ($sg2==0) $sel=_NO; else $sel=_SI;
-		echo "<td width=\"10%\">$sel</td>";
-		if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
-		echo "<td width=\"10%\">$sel</td>";
-#		if ($sg==0) $sel=_NO; else $sel=_SI;
-#		echo "<td width=\"10%\">$sel</td>";
-		echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
-			."</td></tr></table></form></td></tr>\n";
-	}
-		echo "</table></td></tr>";
-		echo "</table></td></tr>";
+		echo "<input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
+			."</form></td></tr>\n";
+	}
+		echo "</table></td></tr></table>";
 	CloseTable();
-#	echo "</div>";
 	}
 
@@ -386,5 +362,4 @@
 
 
-#	die ("do:$do - id_cons:$id_cons_comu - idcomune:$id_comune - new: $idcomunenew");
 	
 //****************************
Index: /trunk/admin/modules/Elezioni/ele_configurazione.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_configurazione.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele_configurazione.php	(revision 256)
@@ -15,7 +15,6 @@
 // Offset - visualizza il numero di elementi per pagina
 $offset=5;
-
+global $dbi;
 $aid=$_SESSION['aid'];
-$dbi=$_SESSION['dbi'];
 $prefix=$_SESSION['prefix'];
 $currentlang=$_SESSION['lang'];
@@ -26,9 +25,9 @@
 
 $id_comune=$_SESSION['id_comune'];
+
+include("modules/Elezioni/funzionidata.php");
+include("modules/Elezioni/ele.php");
 $row=cur_cons();
 $tipo_cons=$row[0];$id_cons=$row[1];
-
-include("modules/Elezioni/funzionidata.php");
-include("modules/Elezioni/ele.php");
 
 if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
@@ -73,6 +72,8 @@
 	echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">"
 	."<input type=\"hidden\" name=\"op\" value=\"confconsiglio\">";
-	$resl = mysql_query("SELECT * FROM ".$prefix."_config", $dbi);
-	$gru=mysql_fetch_array($resl);
+	$sql="SELECT * FROM ".$prefix."_config";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$gru = $sth->fetch(PDO::FETCH_BOTH);	
 	echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
 	echo "<input type=\"hidden\" name=\"op\" value=\"configurazione\">";
@@ -89,9 +90,10 @@
 
 	
-	$resmod = mysql_query("SELECT tema FROM ".$prefix."_ele_temi order by tema", $dbi);
-
+	$sql="SELECT tema FROM ".$prefix."_ele_temi order by tema";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
 	echo "<td><select name=\"tema2\">\n";
-
-	while (list($desc) = mysql_fetch_row($resmod)){
+	foreach($row as $com) {$desc=$com[0];
 			if (!$gru['tema']) $gru['tema']=$desc;
 				$sel= ($gru['tema']==$desc) ? "selected":"";
@@ -117,8 +119,12 @@
 	echo"<td><b>"._SITENAME."</b></td><td><input type=\"text\" name=\"sitename\" value=\"".$gru['sitename']."\"></td></tr>";
 
-	$resmod = mysql_query("SELECT id_comune,descrizione FROM ".$prefix."_ele_comuni order by descrizione", $dbi);
+	$sql = "SELECT id_comune,descrizione FROM ".$prefix."_ele_comuni order by descrizione";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
 	echo "<tr><td><b>"._SITEISTAT."</b></td>";
 	echo "<td><select name=\"siteistat\"><option value=\"\">";
-	while (list($id_comune2,$desc) = mysql_fetch_row($resmod)){
+	foreach($row as $com)
+	{$id_comune2=$com[0];$desc=$com[1];
 			if (!$gru['siteistat']) $gru['siteistat']=$id_comune2;
 			$sel= ($gru['siteistat']==$id_comune2) ? "selected":"";
@@ -187,5 +193,7 @@
 #displayerrors='$displayerrors', 
 #per il momento non Ãš usato: , site_logo='$site_logo'
-		$result = mysql_query("update  ".$prefix."_config set sitename='$sitename', testata='$stemmablob', nome_testata='$stemmanome', blocco='$blocco', multicomune='$multicomune', language='$language2', siteistat='$siteistat', adminmail='$adminmail', siteurl='$siteurl', flash='$flash2', tema='$tema2',gkey='$gkey',ed_user='$ed_user',googlemaps='$googlemaps',editor='$editor',tema_on='$tema_on'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
+	$sql = "update  ".$prefix."_config set sitename='$sitename', testata='$stemmablob', nome_testata='$stemmanome', blocco='$blocco', multicomune='$multicomune', language='$language2', siteistat='$siteistat', adminmail='$adminmail', siteurl='$siteurl', flash='$flash2', tema='$tema2',gkey='$gkey',ed_user='$ed_user',googlemaps='$googlemaps',editor='$editor',tema_on='$tema_on'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();
 	if ($tema2=='facebook')
 		$_SESSION['tema']=$tema2;
@@ -223,13 +231,16 @@
 		if ( (preg_match('/^([_0-9a-zA-Z]+)([_0-9a-zA-Z]{3})$/',$tlist[$i])) ) $files=$tlist[$i];
 		   if($files!=''){
-		    	$sql = mysql_query("SELECT id FROM ".$prefix."_ele_temi where tema='$files'", $dbi);
-				if($sql){
-					list($idwid) = mysql_fetch_row($sql);
-					$id = intval($idwid);
-				}
+		    	$sql = "SELECT id FROM ".$prefix."_ele_temi where tema='$files'";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();
+				$row = $sth->fetch(PDO::FETCH_BOTH);
+				$id = intval($row[0]);
+				
 			if (empty($id)) { // inserisce widget db se non esiste
-			$result = mysql_query("insert into ".$prefix."_ele_temi (id,tema) values ( NULL,'$files')", $dbi);
+				$sql="insert into ".$prefix."_ele_temi (id,tema) values ( NULL,'$files')";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();
 	          }
-		}
+			}
 		  
 		  
@@ -243,6 +254,9 @@
  
 		  # se non esiste cancella dal db
-		  $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_temi", $dbi);
-		  while ($row = mysql_fetch_array($sql2)) {
+		$sql = "SELECT * FROM ".$prefix."_ele_temi";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();
+		$sql2 = $sth->fetch(PDO::FETCH_BOTH);
+		foreach($sql2 as $row){
 			$esi=0;
 			for ($i=0; $i < sizeof($tlist); $i++) {
@@ -251,5 +265,7 @@
 			}
 			if($esi!=1){
-			      $del=mysql_query("DELETE FROM ".$prefix."_ele_tema WHERE id = '$row[id]'",$dbi);
+			    $sql="DELETE FROM ".$prefix."_ele_temi WHERE id = '$row[id]'";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();
 		      }
 		}
Index: /trunk/admin/modules/Elezioni/ele_cons_comuni.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_cons_comuni.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele_cons_comuni.php	(revision 256)
@@ -13,6 +13,6 @@
 }
 
+global $dbi;
 $aid=$_SESSION['aid'];
-$dbi=$_SESSION['dbi'];
 $prefix=$_SESSION['prefix'];
 if($param)
@@ -23,8 +23,9 @@
 $perms=ChiSei(0);
 if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
-$res = mysql_query("SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' " , $dbi);
-list($tipo_cons,$descr_cons) = mysql_fetch_row($res);
 include("modules/Elezioni/funzionidata.php");
 include("modules/Elezioni/ele.php");
+$row=descr_cons();
+$tipo_cons=$row[0];$descr_cons=$row[2];
+
 if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
 if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
@@ -48,9 +49,11 @@
 
 	if (isset($help)) include("language/$language/ele_cons_comuni.html");
-
+	$row=descr_comune();
 	$res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi);
-	if (isset($res)) list($idpred) = mysql_fetch_row($res); else $idpred='';
-	$res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
-	$max = mysql_num_rows($res);
+	if (count($row)) $idpred = $row[2]; else $idpred='';
+#	$res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
+	$row=elenco_cons_comune();
+	
+	$max = count($row);
 	echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>";
 	echo "<form name=\"imppred\" action=\"admin.php\">";
@@ -58,5 +61,5 @@
    	."&nbsp;<b>"._CONSPRED."</b>&nbsp;</td><td><select name=\"predefinita\">";
 	echo "<option value=\"\">";
-	while($arr=mysql_fetch_array($res,3)){
+	foreach($row as $arr){
 		$sel='';
 		if (($idpred))
@@ -77,10 +80,17 @@
 	."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>"
 	."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
-	$result = mysql_query("select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset", $dbi);
+	$sql = "select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
 	$i=0;
-	while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) {
+	foreach($row as $arr) {
+		$chiusa=$arr[0];$id_cons2=$arr[1];$idconsgen2=$arr[2]; $descr_cons=$arr[3]; $data_inizio=$arr[4]; $data_fine=$arr[5];$tipo=$arr[6];
 		$bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
-		$ressez = mysql_query("select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'", $dbi);
-		list($somma)=mysql_fetch_row($ressez);
+		$sql = "select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'";
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();	
+		$row = $sth->fetch(PDO::FETCH_BOTH);
+		$somma=$row[0];
 		$data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
 		echo "<tr bgcolor=\"$bgcolor1\" align=\"center\" ><td align=\"left\" ><a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$idconsgen2\"><b>$descr_cons</b></a></td>"
@@ -141,42 +151,80 @@
 if ($perms>32) {
 	$sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune";
-	$res=mysql_query("$sql",$dbi);
-	list($id_consulta)=mysql_fetch_row($res);
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	$id_consulta=$row[0];
 	$sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen";
-	$res=mysql_query("$sql",$dbi);
-	list($descr_cons2)=mysql_fetch_row($res);
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+		
+	$descr_cons2=$row[0];
 	if ($do == "add") {
 		if ($id_cons2) {
 			// copia circoscrizione
-			$res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi);
-			while (list($id,$idcirc,$num,$des2)=mysql_fetch_row($res)){
-			$des=addslashes($des2);
- $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi);
-list($contr_circ)=mysql_fetch_row($resconnew);
-if (! $contr_circ){
-				mysql_query("insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')", $dbi) || die("Impossibile inserire i dati delle circoscrizioni! ".mysql_error());
-}
-				$res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi);
-				list($id_circ)=mysql_fetch_row($res0);
+			$sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();	
+			$row = $sth->fetchAll();
+			foreach($row as $arr){
+				$id=$arr[0];$idcirc=$arr[1];$num=$arr[2];$des2=$arr[3];
+				$des=addslashes($des2);
+				$sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();	
+				$row = $sth->fetch(PDO::FETCH_BOTH);
+				$contr_circ=$row[0];
+				if (! $contr_circ){
+					sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')";
+					$sth = $dbi->prepare("$sql");
+					$sth->execute();	
+
+				}
+				$sql="select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();	
+				$row = $sth->fetch(PDO::FETCH_BOTH);
+				$id_circ=$row[0];
 				// copia sede
-				$res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi);
-				while(list($id1,$idsede1,$idcirc1,$ind2,$tel,$tel2,$fax,$resp,$mappa2,$filemappa2)=mysql_fetch_row($res1)){
+				$sql="select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();	
+				$row = $sth->fetchAll();
+				foreach($row as $row2) {
+					$id1=$row2[0];$idsede1=$row2[1];$idcirc1=$row2[2];$ind2=$row2[3];$tel=$row2[4];$tel2=$row2[5];$fax=$row2[6];$resp=$row2[7];$mappa2=$row2[8];$filemappa2=$row2[9];
 					$filemappa=addslashes($filemappa2);
 					$mappa=addslashes($mappa2);
 					$ind=addslashes($ind2);
- $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi);
-list($contr_sed)=mysql_fetch_row($ressednew);
-if (! $contr_sed){
-					mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')", $dbi) || die("Impossibile inserire i dati delle sedi! ".mysql_error());
-}
-					$res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi);
+					$sql="select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'";
+					$sth = $dbi->prepare("$sql");
+					$sth->execute();	
+					$row = $sth->fetch(PDO::FETCH_BOTH);
+					$contr_sed=$row[0];
+					if (! $contr_sed){
+						$sql="insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')";
+						$sth = $dbi->prepare("$sql");
+						$sth->execute();	
+					}
+					$sql"select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'";
 					list($id_sede)=mysql_fetch_row($res2);
+					$sth = $dbi->prepare("$sql");
+					$sth->execute();	
+					$row = $sth->fetch(PDO::FETCH_BOTH);
+					$id_sede=$row[0];
 					//copia sezione
-					$res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi);
-					while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3,
-						$bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){
+					$sql="select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1";
+					$sth = $dbi->prepare("$sql");
+					$sth->execute();	
+					$row = $sth->fetchAll();
+					foreach($row as $arr2)
+					{
+						$id3=$arr2[0];$idsez3=$arr2[1];$idsede3=$arr2[2];$numero=$arr2[3];$maschi3=$arr2[4];$femmine3=$arr2[5];$validi3=$arr2[6];$nulli3=$arr2[7];
+						$bianchi3=$arr2[8];$contest3=$arr2[9];$sg3,$aut_m=$arr2[10];$aut_f=$arr2[11];
 						if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')";
 						else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
-						mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error());
+						$sth = $dbi->prepare("$sql");
+						$sth->execute();	
+
 					}
 				}
@@ -191,5 +239,8 @@
 			echo "[ <a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&amp;do=elettori&amp;id_cons_gen=$id_cons_gen&amp;id_cons2=$id_cons2&amp;ok=1\">"._YES."</a> ]";exit;
 		}else{
-		$result = mysql_query("update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez", $dbi);
+		$sql="update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez";
+		$sth = $dbi->prepare("$sql");
+		$result=$sth->execute();	
+
 		if (!$result) return;
 		Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
@@ -198,8 +249,14 @@
 	if ($do == "update") {
 		if ($predefinita) 
-			$result = mysql_query("update  ".$prefix."_ele_comuni set  id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi);
-		else
-			$result = mysql_query("update  ".$prefix."_ele_cons_comune set  chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi);
-		if (!$result) return;
+		{
+			$sql="update  ".$prefix."_ele_comuni set  id_cons='$predefinita' WHERE id_comune='$id_comune'";
+			$sth = $dbi->prepare("$sql");
+			$result=$sth->execute();	
+		}else{
+			$sql"update  ".$prefix."_ele_cons_comune set  chiusa='$chiusa' WHERE id_cons2='$id_cons2'";
+			$sth = $dbi->prepare("$sql");
+			$result=$sth->execute();	
+		}
+			if (!$result) return;
 		Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
    	} 
Index: /trunk/admin/modules/Elezioni/ele_widget.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_widget.php	(revision 255)
+++ /trunk/admin/modules/Elezioni/ele_widget.php	(revision 256)
@@ -15,7 +15,6 @@
 // Offset - visualizza il numero di elementi per pagina
 $offset=5;
-
+global $dbi;
 $aid=$_SESSION['aid'];
-$dbi=$_SESSION['dbi'];
 $prefix=$_SESSION['prefix'];
 $currentlang=$_SESSION['lang'];
@@ -26,9 +25,10 @@
 
 $id_comune=$_SESSION['id_comune'];
-$res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune' " , $dbi);
-list($tipo_cons,$id_cons) = mysql_fetch_row($res);
+#$res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune' " , $dbi);
 
 include("modules/Elezioni/funzionidata.php");
 include("modules/Elezioni/ele.php");
+$row=cur_cons();
+$tipo_cons=$row[0];$id_cons=$row[1];
 
 if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
@@ -64,12 +64,15 @@
 		    $files=$tlist[$i];
 		   
-		    $sql = mysql_query("SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'", $dbi);
-		    list($idwid) = mysql_fetch_row($sql);
+		    $sql = "SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'";
+			$sth = $dbi->prepare("$sql");
+			$sth->execute();
+			$row = $sth->fetch(PDO::FETCH_BOTH);
+		    $idwid=$row[0];
 		    $id = intval($idwid);
 
-
 		    if (empty($id)) { // inserisce widget db se non esiste
-			$result = mysql_query("insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')", $dbi);
-	          }
+			$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();	          }
 		  
 		  
@@ -84,6 +87,9 @@
  
 		  # se non esiste cancella dal db
-		  $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_widget", $dbi);
-		  while ($row = mysql_fetch_array($sql2)) {
+		  $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++) {
@@ -92,5 +98,7 @@
 			}
 			if($esi!=1){
-			      $del=mysql_query("DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'",$dbi);
+			    $sql="DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'";
+				$sth = $dbi->prepare("$sql");
+				$sth->execute();	
 		      }
 		}
@@ -105,6 +113,8 @@
 
 	
-	$result = mysql_query("SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc", $dbi);
-	
+	$sql="SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row2 = $sth->fetchAll();	
 	
 
@@ -113,6 +123,5 @@
 	echo "<br><table border=\"0\" width=\"100%\">";
 	echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><b>"._CONFIGWIDGET."</b></td></tr></table>";
-	
-	while ($row = mysql_fetch_array($result)) {
+	foreach($row2 as $row) {
 	    echo "<form name=\"widget\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">";
 	    echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
@@ -163,5 +172,7 @@
 	if ($perms >128) {
 				
-		$result = mysql_query("update  ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
+		$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");
@@ -185,5 +196,5 @@
 function make_db_widget(){
 global $dbi,$prefix;
-$result = mysql_query("CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
+$sql="CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
   `id` int(10) NOT NULL auto_increment,
   `nome_file` varchar(255) NOT NULL default '',
@@ -193,5 +204,7 @@
  `attivo` int(1) NOT NULL default '0',
   PRIMARY KEY  (`id`)
-)",$dbi);
+)";
+$sth = $dbi->prepare("$sql");
+$sth->execute();
 
 
Index: /trunk/admin/modules/Elezioni/query.sql
===================================================================
--- /trunk/admin/modules/Elezioni/query.sql	(revision 256)
+++ /trunk/admin/modules/Elezioni/query.sql	(revision 256)
@@ -0,0 +1,193 @@
+<?php
+
+if (!defined('ADMIN_FILE')) {
+    die ("You can't access this file directly...");
+}
+
+function getaffluenze()
+{
+	global $dbi,$prefix, $id_cons_gen;
+	$sql = "SELECT * FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return ($row);
+}
+
+function daticonsultazione()
+{
+	global $dbi,$prefix, $id_cons_gen;
+	$sql = "SELECT * FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	return ($row);
+
+
+}
+
+function daticonscom()
+{
+	global $dbi,$prefix, $id_cons;
+	$sql = "SELECT * FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	return ($row);
+
+
+}
+
+function datitipo($tipo,$lang)
+{
+	global $dbi,$prefix;
+	$sql = "SELECT * FROM ".$prefix."_ele_tipo where tipo_cons='$tipo' and lingua='$lang'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return ($row);
+
+
+}
+
+
+function setconsultazione()
+{
+global $prefix,$dbi,$perms,$id_comune,$espandi,$id_cons_gen,$aid,$id_cons,$limite;
+
+if ($id_cons_gen) {
+	if ($id_comune and $perms<256)
+		$sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen'";
+	else
+		$sql = "SELECT t1.tipo_cons,t1.descrizione,t1.id_cons_gen FROM ".$prefix."_ele_consultazione as t1 where  t1.id_cons_gen='$id_cons_gen'";
+}else{
+	if($perms>128)
+		$sql = "SELECT tipo_cons,descrizione,id_cons_gen FROM ".$prefix."_ele_consultazione order by data_fine desc limit 0,1 ";
+	else
+		$sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_operatori as t3 where t3.id_comune=$id_comune and t3.id_comune=t2.id_comune and t1.id_cons_gen=t2.id_cons_gen and t2.chiusa='0' and (t3.id_cons=t2.id_cons or t3.id_cons=0) and t3.permessi>0 and t3.aid='$aid' order by t1.data_fine desc limit 0,1 ";
+}
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	$espandi=0;
+
+	if ($sth->rowCount()) $id_cons_gen=$row[2];
+#		list($tipo_cons,$descr_cons,$id_cons_gen) = mysql_fetch_row($res);
+	
+		$sql = "SELECT t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row2 = $sth->fetchAll();
+    if ($row2) $id_cons = $row2['id_cons']; 
+	else	$espandi=1;
+	if(!isset($tipo_cons))$tipo_cons=0;
+	if(!isset($id_cons))$id_cons=0;
+
+	$sql="SELECT t1.limite FROM ".$prefix."_ele_conf as t1 left join ".$prefix."_ele_cons_comune as t2 on t1.id_conf=t2.id_conf where t2.id_cons='$id_cons'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row2 = $sth->fetchAll();
+	$limite=$row2[0];
+	return($row);
+}
+
+function elenco_cons()
+{
+global $perms,$dbi,$prefix,$currentlang,$aid,$id_comune;
+	if ($perms<128) { 
+		$sql="select t3.id_cons, t2.descrizione,t4.genere, t2.id_cons_gen, t3.chiusa from ".$prefix."_ele_operatori as t1, ".$prefix."_ele_consultazione as t2, ".$prefix."_ele_cons_comune as t3, ".$prefix."_ele_tipo as t4 where t4.lingua='$currentlang' and t2.tipo_cons=t4.tipo_cons and t1.aid='$aid' and t3.id_cons_gen=t2.id_cons_gen and (t1.id_cons=t3.id_cons or t1.permessi=64) and t1.id_comune=t3.id_comune and t1.id_comune=$id_comune and t3.chiusa='0' order by t2.data_inizio desc";
+	}else{
+		$sql="SELECT '', t1.descrizione,t2.genere, t1.id_cons_gen,'' FROM ".$prefix."_ele_consultazione as t1,".$prefix."_ele_tipo as t2 where t2.lingua='$currentlang' and t1.tipo_cons=t2.tipo_cons order by t1.data_inizio desc";
+	}
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);	
+}
+
+function elenco_comuni()
+{
+global $dbi,$prefix;
+	$sql="select * from ".$prefix."_ele_comuni order by descrizione asc";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);	
+
+}
+
+function elenco_consultazioni()
+{
+global $dbi,$prefix;
+	$sql="select * from ".$prefix."_ele_consultazione order by descrizione asc";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);	
+
+}
+
+function elenco_cons_comune()
+{
+$sql="SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' ";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);	
+}
+
+function elenco_tipi()
+{
+global $dbi,$prefix,$language,$currentlang;
+	$sql="SELECT * FROM ".$prefix."_ele_tipo where lingua='$currentlang'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);	
+
+}
+
+function descr_comune()
+{
+global $dbi,$prefix,$id_comune;
+	$sql="select id_comune,descrizione,id_cons from ".$prefix."_ele_comuni where id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	return($row);	
+
+}
+
+function descr_cons()
+{
+global $dbi,$prefix,$id_cons_gen;
+	$sql="SELECT t1.tipo_cons,t2.genere,t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' ";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	return($row);	
+
+}
+
+function cur_cons()
+{
+global $dbi,$prefix,$id_cons_gen,$id_comune;
+	$sql="SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+	return($row);	
+
+}
+
+function tipocons()
+{
+global $dbi,$prefix,$tipo_cons,$currentlang;
+	$sql="SELECT genere,voto_g,voto_l,voto_c,circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetchAll();
+	return($row);
+}
+
+?>
Index: /trunk/admin/temi/default/index.php
===================================================================
--- /trunk/admin/temi/default/index.php	(revision 255)
+++ /trunk/admin/temi/default/index.php	(revision 256)
@@ -10,11 +10,18 @@
 $bgcolor="#b0b0b0";
 $nometema=$tema;
+
 function testata($tema){
 global $nometema,$id_comune,$id_cons_gen,$aid,$dbi,$prefix;
 $nometema=$tema;
-$res_com = mysql_query("SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune'",$dbi);
-$res_cons = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'",$dbi);
-list($descr_comune) = mysql_fetch_row($res_com);
-list($descr_consultazione) = mysql_fetch_row($res_cons);
+	$sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+$descr_consultazione=$row[0];
+$sql="select descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'";
+	$sth = $dbi->prepare("$sql");
+	$sth->execute();	
+	$row = $sth->fetch(PDO::FETCH_BOTH);
+$descr_comune=$row[0];
 
 echo "<div class=\"container\"><table width=\"95%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"table-main\">
Index: /trunk/client/temi/Futura2/index.php
===================================================================
--- /trunk/client/temi/Futura2/index.php	(revision 255)
+++ /trunk/client/temi/Futura2/index.php	(revision 256)
@@ -207,5 +207,5 @@
 ####################################### menu risultati
 function risultati(){ 
-global $id_comune,$id_cons_gen,$genere,$tipo_cons,$colortheme;
+global $id_comune,$id_cons_gen,$genere,$tipo_cons,$colortheme,$votoc;
 echo '<div data-role="content" data-theme="'.$colortheme.'">
 <a href="modules.php?op=affluenze_all&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">Affluenze</a>
@@ -215,5 +215,5 @@
 	if($genere==3  OR $genere==5) 
 		echo '<a href="modules.php?op=liste_mob&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" " data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">'._LISTA.'</a>';
-        if(($genere==3 OR $genere==5) and $tipo_cons!="1" or $tipo_cons>="11") 
+        if(($genere==3 OR $genere==5) and !$votoc) 
 		echo '<a href="modules.php?op=candidato_mob&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" " data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">'._CANDIDATO.'</a>';
 
Index: /trunk/sql/aggiornamento-2.0_2017-04-28.sql
===================================================================
--- /trunk/sql/aggiornamento-2.0_2017-04-28.sql	(revision 256)
+++ /trunk/sql/aggiornamento-2.0_2017-04-28.sql	(revision 256)
@@ -0,0 +1,3 @@
+alter table `soraldo_ele_voti_lista` add column `solo_lista` int(7) default 0;
+ALTER TABLE `soraldo_ele_cons_comune` ADD COLUMN `disgiunto` enum('0', '1') NOT NULL default '0';
+alter table `soraldo_ele_voti_lista` add column `nulli_lista` int(7) default 0 after `voti`;
Index: /trunk/sql/aggiornamento-2.0_2018-01-18.sql
===================================================================
--- /trunk/sql/aggiornamento-2.0_2018-01-18.sql	(revision 256)
+++ /trunk/sql/aggiornamento-2.0_2018-01-18.sql	(revision 256)
@@ -0,0 +1,50 @@
+--
+-- Database: `eleonline`
+--
+
+
+DROP TABLE IF EXISTS `soraldo_ele_tipo`;
+-- --------------------------------------------------------
+
+--
+-- Struttura della tabella `soraldo_ele_tipo`
+--
+
+CREATE TABLE IF NOT EXISTS `soraldo_ele_tipo` (
+  `tipo_cons` int(11) NOT NULL DEFAULT '0',
+  `descrizione` varchar(30) DEFAULT NULL,
+  `lingua` varchar(2) NOT NULL DEFAULT '0',
+  `genere` tinyint(4) NOT NULL DEFAULT '0',
+  `voto_g` enum('0','1') NOT NULL DEFAULT '0',
+  `voto_l` enum('0','1') NOT NULL DEFAULT '0',
+  `voto_c` enum('0','1') NOT NULL DEFAULT '0',
+  `circo` enum('0','1') NOT NULL DEFAULT '0',
+  PRIMARY KEY (`tipo_cons`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Dump dei dati per la tabella `soraldo_ele_tipo`
+--
+
+INSERT INTO `soraldo_ele_tipo` (`tipo_cons`, `descrizione`, `lingua`, `genere`, `voto_g`, `voto_l`, `voto_c`, `circo`) VALUES
+(1, 'PROVINCIALI', 'it', 3, '0', '0', '0', '0'),
+(2, 'REFERENDUM', 'it', 0, '0', '0', '0', '0'),
+(3, 'COMUNALI', 'it', 5, '0', '0', '0', '0'),
+(4, 'CIRCOSCRIZIONALI', 'it', 5, '0', '0', '0', '1'),
+(5, 'BALLOTTAGGIO COMUNALI', 'it', 1, '0', '0', '0', '0'),
+(6, 'CAMERA', 'it', 2, '0', '0', '0', '0'),
+(7, 'SENATO', 'it', 2, '0', '0', '0', '0'),
+(8, 'EUROPEE', 'it', 4, '1', '0', '0', '0'),
+(9, 'REGIONALI', 'it', 5, '0', '0', '0', '0'),
+(10, 'SENATO CON GRUPPI', 'it', 5, '1', '0', '1', '0'),
+(11, 'CAMERA CON GRUPPI', 'it', 5, '1', '0', '1', '0'),
+(12, 'PROVINCIALI CON COLLEGI', 'it', 3, '0', '0', '0', '1'),
+(13, 'BALLOTTAGGIO PROVINCIALI', 'it', 1, '0', '0', '0', '0'),
+(14, 'EUROPEE CON COLLEGI', 'it', 4, '0', '0', '0', '1'),
+(15, 'CAMERA CON GRUPPI E COLLEGI', 'it', 5, '1', '0', '1', '1'),
+(16, 'SENATO CON GRUPPI E COLLEGI', 'it', 5, '1', '0', '1', '1'),
+(17, 'REGIONALI CON COLLEGI', 'it', 5, '0', '0', '0', '1'),
+(18, 'CAMERA - Rosatellum 2.0', 'it', 5, '0', '0', '1', '0'),
+(19, 'SENATO - Rosatellum 2.0', 'it', 5, '0', '0', '1', '0');
+
+
