Index: /trunk/admin/admin.php
===================================================================
--- /trunk/admin/admin.php	(revision 252)
+++ /trunk/admin/admin.php	(revision 253)
@@ -133,35 +133,47 @@
 
 
-
-
-
-		$dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
-		mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
-	mysql_query("SET NAMES 'utf8'", $dbi);
+	try{
+	$dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); 
+     	$sql = "use $dbname";
+    	$dbi->exec($sql);
+        }
+	catch(PDOException $e)
+	{
+	    echo $sql . "<br>" . $e->getMessage();
+	}                                                                                       	
+
+
+
+#		$dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
+#		mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
+##	mysql_query("SET NAMES 'utf8'", $dbi);
 //---10/05/2009  gestione consultazione predefinita
-		$res_config = mysql_query("select * from ".$prefix."_config ",$dbi);
-		list ($sitename,$siteurl,$site_logo,$slogan,$startdate,$adminmail,$tema,$foot,$language,$blocco
-,$testata,$logo,$fileout,$copyright,$versione,$patch,$id_comune,$multicomune,$flash,$displayerrors,$editor,$tema_on,$ed_user) = mysql_fetch_row($res_config);
-		$siteistat=$id_comune;
+	$sth = $dbi->prepare("select * from ".$prefix."_config");
+	$sth->execute();
+	
+	$row = $sth->fetch(PDO::FETCH_ASSOC);	
+#		$res_config = mysql_query("select * from ".$prefix."_config ",$dbi);
+#		list ($sitename,$siteurl,$site_logo,$slogan,$startdate,$adminmail,$tema,$foot,$language,$blocco,$testata,$logo,$fileout,$copyright,$versione,$patch,$id_comune,$multicomune,$flash,$displayerrors,$editor,$tema_on,$ed_user) = ($res_config->fetch());
+		$siteistat=$row['siteistat'];
 if (!isset($_SESSION['id_comune'])){
-	$_SESSION['sitename']=$sitename;
-	$_SESSION['siteurl']=$siteurl;
-	$_SESSION['site_logo']=$site_logo;
-	$_SESSION['slogan']=$slogan;
-	$_SESSION['startdate']=$startdate;
-	$_SESSION['adminmail']=$adminmail;
+	$_SESSION['sitename']=$row['sitename'];
+	$_SESSION['siteurl']=$row['siteurl'];
+	$_SESSION['site_logo']=$row['site_logo'];
+	$_SESSION['slogan']=$row['slogan'];
+	$_SESSION['startdate']=$row['startdate'];
+	$_SESSION['adminmail']=$row['adminmail'];
 	if ($tema=='facebook')
-		$_SESSION['tema']=$tema;
+		$_SESSION['tema']=$row['tema'];
 	else $_SESSION['tema']='default';
-	$_SESSION['foot']=$foot;
-	$_SESSION['lang']=$language;
-	$_SESSION['blocco']=$blocco;
-	$_SESSION['testata']=$testata;
-	$_SESSION['logo']=$logo;
-	$_SESSION['fileout']=$fileout;
-	$_SESSION['copyright']=$copyright;
-	$_SESSION['versione']=$versione;
-	$_SESSION['patch']=$patch;
-	$_SESSION['id_comune']=$id_comune;
+	$_SESSION['foot']=$row['foot'];
+	$_SESSION['lang']=$row['language'];
+	$_SESSION['blocco']=$row['blocco'];
+	$_SESSION['testata']=$row['testata'];
+	$_SESSION['logo']=$row['logo'];
+	$_SESSION['fileout']=$row['fileout'];
+	$_SESSION['copyright']=$row['copyright'];
+	$_SESSION['versione']=$row['versione'];
+	$_SESSION['patch']=$row['patch'];
+	$_SESSION['id_comune']=$row['siteistat'];
 	$_SESSION['multicomune']=$multicomune;
 	$_SESSION['flash']=$flash;
@@ -227,5 +239,5 @@
 $dbi=$_SESSION['dbi'];
 $prefix=$_SESSION['prefix'];
-$id_comune=$_SESSION['id_comune'];
+$id_comune=$_SESSION['id_comune'];die("qui");
 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']);
 else {
Index: /trunk/admin/index.php
===================================================================
--- /trunk/admin/index.php	(revision 252)
+++ /trunk/admin/index.php	(revision 253)
@@ -8,12 +8,21 @@
 /************************************************************************/
 include("config.php");
-		$dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
-		mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
-	mysql_query("SET NAMES 'utf8'", $dbi);
+	try{
+	$dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); 
+     	$sql = "use $dbname";
+    	$dbi->exec($sql);
+        }
+	catch(PDOException $e)
+	{
+	    echo $sql . "<br>" . $e->getMessage();
+	}                                                                                       	
 //---10/05/2009  gestione consultazione predefinita
 //if (!isset($_SESSION['id_comune'])){
-		$res_config = mysql_query("select * from ".$prefix."_config ",$dbi);
-		list ($sitename,$siteurl,$site_logo,$slogan,$startdate,$adminmail,$tema,$foot,$language,$blocco,$testata,$logo,$fileout,$copyright,$versione,$patch,$id_comune) = mysql_fetch_row($res_config);
-		$siteistat=$id_comune;
+	$sth = $dbi->prepare("select * from ".$prefix."_config");
+	$sth->execute();
+	
+	$row = $sth->fetch(PDO::FETCH_ASSOC);
+#		list ($sitename,$siteurl,$site_logo,$slogan,$startdate,$adminmail,$tema,$foot,$language,$blocco,$testata,$logo,$nometestata,$fileout,$copyright,$versione,$patch,$id_comune,$multicomune,$flash,$displayerrors,$gkey,$googlemaps,$editor,$tema_on,$ed_user) = ($res_config->fetch());
+		$siteistat=$row['siteistat'];
 //}
     Header("Location: admin.php?id_comune=$siteistat");
Index: /trunk/admin/modules/Elezioni/ele_voti.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_voti.php	(revision 252)
+++ /trunk/admin/modules/Elezioni/ele_voti.php	(revision 253)
@@ -170,5 +170,5 @@
 					list($validi, $nulli, $bianchi,$contestati,$votinulli,$sologruppo,$validilista,$contestatilista,$votinullilista,$sololista)=mysql_fetch_row($res4);
 					if($validi>0) {
-						if (($validi+$nulli+$bianchi+$contestati+$votinulli+$sololista)==$voti)
+						if (($validi+$nulli+$bianchi+$contestati+$votinulli)==$voti)
 							{$status=2;$ops=(-4+$votog);$val=1;}
 						else {$val=-1;$stret=(4-$votog);}
@@ -187,5 +187,5 @@
 #					list($votigs)=mysql_fetch_row($res4);
 					if($votigs>0) {
-						if (($votigs)==$validi)
+						if (($votigs+$sololista)==$validi)
 							{$status=3;$ops=-3;$gru=1;}
 						else {$gru=-1; $stret=4;}
@@ -209,5 +209,5 @@
 					$sezscru=mysql_num_rows($res4);
 			if($sezscru) {
-					if($genere==4 or $votog) $contrlis= ($validilista==$validi) ? 1:0;
+					if($genere==4 or $votog) $contrlis= ($validilista+$sologruppo==$validi) ? 1:0;
 					else $contrlis=($sologruppo+$validilista+$contestatilista+$votinullilista-$sololista)==$validi ? 1:0;
 					if((($contrlis) and $validilista==$votils) or ($fascia<=$limite and $fascia)) {$status=4;$lis=1;$ops=-4;}
@@ -560,5 +560,5 @@
 		$ele_lista='';
 		if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
-			if(($genere==5 and $fascia<=$limite and $id_conf) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
+			if(($genere==5 and $id_conf and $fascia<=$limite and !isdisgiunto()) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
 				$result = mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1",$dbi);
 				list($id_lista)=mysql_fetch_row($result);
@@ -583,5 +583,5 @@
 			$result = mysql_query("SELECT sum(t1.voti),0,0 from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif",$dbi);
 			list($votisezcand)=mysql_fetch_row($result);
-			if(($fascia>$limite or !$id_conf) or $genere==4)
+			if((($fascia>$limite or isdisgiunto()) or !$id_conf) or $genere==4)
                 $result = mysql_query("SELECT voti,nulli_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);
             else{
@@ -619,5 +619,5 @@
 		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,0,t1.nulli_lista from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
 	else
-		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
+		$result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,solo_lista,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez",$dbi);
 
 // aggiunte le variabili $sgpl e $vnpl per la gestione dei voti 1) al solo presidente per singola lista - 2) al solo presidente per singola lista perché nullo o contestato quello di lista		
@@ -637,5 +637,5 @@
 			$result = mysql_query("SELECT sum(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_lista",$dbi);
 			list($votisezcand)=mysql_fetch_row($result);
-			if($fascia>$limite or !$id_conf)
+			if(($fascia>$limite or isdisgiunto()) or !$id_conf)
                  $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'", $dbi);
             else{
@@ -748,5 +748,5 @@
 		// toglie ai candidati la visual... del solo_gruppo 
 		if(!$votog) {
-		   if (($genere==3 OR $genere==5) and (!$id_lista) and ($fascia>$limite or !$id_conf)) { //gruppo e liste
+		   if (($genere==3 OR $genere==5) and (!$id_lista) and ((isdisgiunto() or $fascia>$limite) or !$id_conf)) { //gruppo e liste
 			echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._VALIDI_LISTA."</b></td><td align=\"center\"><input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"><input name=\"valista\" value=\"$valista\" size=\"5\" style=\"text-align:right\"></td></tr>";
 			echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input name=\"sg\" value=\"$sg\" size=\"5\" style=\"text-align:right\"></td></tr>";
@@ -754,5 +754,5 @@
 	."</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._CONTESTATI_LISTE."</b></td><td align=\"center\"><input  name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\"></td></tr>";
 			
-		   }elseif (($genere==3 OR $genere==5) and !$votoc and ($fascia>$limite or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
+		   }elseif (($genere==3 OR $genere==5) and !$votoc and ((isdisgiunto() or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
 			echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
 		   }
@@ -821,5 +821,5 @@
 		$condizione="id_lista";
 	}
-	if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ($fascia>$limite or !$id_conf)) $y = (count($arg)-4);
+	if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ((isdisgiunto() or $fascia>$limite) or !$id_conf)) $y = (count($arg)-4);
 	else $y=count($arg);#die ("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'");
 	mysql_query("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
@@ -855,5 +855,5 @@
 
 	if(!$votog) {
-	   if ((($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite or !$id_conf)) {
+	   if ((($genere==3) OR ($genere==5)) and !$id_lista and ((isdisgiunto() or $fascia>$limite) or !$id_conf)) {
 			$valista=$arg[$i++]; 
 			$result = mysql_query("update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'",$dbi);
@@ -1105,5 +1105,5 @@
     list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = mysql_fetch_row($result);
     $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
-    $tot_voti=$validi+$tot_nulli+$sg+$conts+$nullis+$sololista;
+    $tot_voti=$validi+$tot_nulli+$conts+$nullis;
 //	."</td><td><input  name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" ---     ."<td><b>"._SOLOLIS."</b></td>"
 
@@ -1178,18 +1178,19 @@
 	$result= mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
 	$ar=mysql_fetch_array($result);
+	$validilista=$validi-$ar['solo_gruppo'];
 	if ($ar['solo_lista'] or !isdisgiunto()) $rigasl=''; else $rigasl=", solo_lista='$sololista'";
 #die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
 	if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
-	mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] contestati_lista:$ar[15]  voti_nulli_lista:$ar[16]','validi_lista=$validi, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')", $dbi);	
+	mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] contestati_lista:$ar[15]  voti_nulli_lista:$ar[16]','validi_lista=$validilista, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')", $dbi);	
 
 /*		$result = mysql_query("update  ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
 		if ($fileout) fwrite($fp,"update  ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez';\n"); */
 		$result = mysql_query("update  ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
-		if ($fileout) fwrite($fp,"update  ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez';\n");
+		if ($fileout) fwrite($fp,"update  ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validilista', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez';\n");
 	}else{
  	mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')", $dbi);	
 	$valista="";
 	if ($ar['validi_lista']){ 
-	  $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista']+$ar['solo_lista'];
+	  $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista'];
 	  $valista=",validi_lista='$tvalista'";
 	}
@@ -1264,10 +1265,10 @@
         $res = mysql_query("SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
     	list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = mysql_fetch_row($res);
-		if ($voti_parz!=$validi and $voti_parz>0){
-			echo "<td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".$validi."</b><br></td>";
+		if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
+			echo "<td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".($validi-$solo_lista)."</b><br></td>";
     	}
 		$res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
 		list($tot) = mysql_fetch_row($res2);
-		if ($validi+$nulli+$bianchi+$contestati+$votinulli+$solo_lista!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
+		if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
 			echo "<td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi+$nulli+$bianchi+$contestati+$votinulli)."</b><br></td>";
     	}
Index: /trunk/admin/temi/facebook/style.css
===================================================================
--- /trunk/admin/temi/facebook/style.css	(revision 252)
+++ /trunk/admin/temi/facebook/style.css	(revision 253)
@@ -87,5 +87,5 @@
 
 div#container{
-    width: 999px;
+    width: 80%;
     margin: 0 auto;   /*centra negli altri browsers*/
     /*text-align: left;  */ /*ripristina l' allineamento*/
Index: /trunk/admin/versione.php
===================================================================
--- /trunk/admin/versione.php	(revision 252)
+++ /trunk/admin/versione.php	(revision 253)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "2.0 rev 252";
+$versione = "2.0 rev 253";
 $version_number = $versione;
-$version = "Eleonline $version_number (<i>Data Release: 16 aprile 2016</i>)";
+$version = "Eleonline $version_number (<i>Data Release: 15 aprile 2017</i>)";
 
 ?> 
Index: /trunk/client/inc/csrf-magic/csrf-magic.php
===================================================================
--- /trunk/client/inc/csrf-magic/csrf-magic.php	(revision 252)
+++ /trunk/client/inc/csrf-magic/csrf-magic.php	(revision 253)
@@ -54,4 +54,6 @@
  */
 $GLOBALS['csrf']['secret'] = '';
+// nota bene: library code should use csrf_get_secret() and not access
+// this global directly
 
 /**
@@ -130,5 +132,5 @@
 
 // Don't edit this!
-$GLOBALS['csrf']['version'] = '1.0.1';
+$GLOBALS['csrf']['version'] = '1.0.4';
 
 /**
@@ -152,5 +154,5 @@
     $name = $GLOBALS['csrf']['input-name'];
     $endslash = $GLOBALS['csrf']['xhtml'] ? ' /' : '';
-    $input = "\n<div><input type='hidden' name='$name' value=\"$tokens\"$endslash></div>";
+    $input = "<input type='hidden' name='$name' value=\"$tokens\"$endslash>";
     $buffer = preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i', '$1' . $input, $buffer);
     if ($GLOBALS['csrf']['frame-breaker']) {
@@ -216,5 +218,6 @@
     if (!$has_cookies && $secret) {
         // :TODO: Harden this against proxy-spoofing attacks
-        $ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']);
+        $IP_ADDRESS = (isset($_SERVER['IP_ADDRESS']) ? $_SERVER['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR']);
+        $ip = ';ip:' . csrf_hash($IP_ADDRESS);
     } else {
         $ip = '';
@@ -241,10 +244,38 @@
 }
 
+function csrf_flattenpost($data) {
+    $ret = array();
+    foreach($data as $n => $v) {
+        $ret = array_merge($ret, csrf_flattenpost2(1, $n, $v));
+    }
+    return $ret;
+}
+function csrf_flattenpost2($level, $key, $data) {
+    if(!is_array($data)) return array($key => $data);
+    $ret = array();
+    foreach($data as $n => $v) {
+        $nk = $level >= 1 ? $key."[$n]" : "[$n]";
+        $ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v));
+    }
+    return $ret;
+}
+
 /**
  * @param $tokens is safe for HTML consumption
  */
 function csrf_callback($tokens) {
+    // (yes, $tokens is safe to echo without escaping)
     header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-    echo "<html><head><title>CSRF check failed</title></head><body>CSRF check failed. Please enable cookies.<br />Debug: ".$tokens."</body></html>
+    $data = '';
+    foreach (csrf_flattenpost($_POST) as $key => $value) {
+        if ($key == $GLOBALS['csrf']['input-name']) continue;
+        $data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />';
+    }
+    echo "<html><head><title>CSRF check failed</title></head>
+        <body>
+        <p>CSRF check failed. Your form session may have expired, or you may not have
+        cookies enabled.</p>
+        <form method='post' action=''>$data<input type='submit' value='Try again' /></form>
+        <p>Debug: $tokens</p></body></html>
 ";
 }
@@ -298,5 +329,6 @@
             if (!empty($_COOKIE)) return false;
             if (!$GLOBALS['csrf']['allow-ip']) return false;
-            return $value === csrf_hash($_SERVER['IP_ADDRESS'], $time);
+            $IP_ADDRESS = (isset($_SERVER['IP_ADDRESS']) ? $_SERVER['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR']);
+            return $value === csrf_hash($IP_ADDRESS, $time);
     }
     return false;
@@ -328,27 +360,4 @@
 function csrf_get_secret() {
     if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret'];
-    // secret by db l.apolito
-    global $prefix,$dbi;
-    # crea campo secret nella tabella _config se non esiste		
-    $campo= mysql_query("SHOW COLUMNS FROM ".$prefix."_config LIKE 'secret' ",$dbi);
-    $esiste=mysql_num_rows($campo);
-	if ($esiste==0) {
-		$result=mysql_query("ALTER TABLE ".$prefix."_config ADD secret VARCHAR(30);",$dbi);
-	}
-
-    $res_secret =  mysql_query("SELECT * FROM ".$prefix."_config" , $dbi);
-    $row = mysql_fetch_array($res_secret);
-    $secret = $row['secret'];	
-    if (isset($secret)){ return $secret;
-
-    }else{
-	$secret = csrf_generate_secret();
-	mysql_query("UPDATE ".$prefix."_config SET secret='$secret'" , $dbi);
-	return $secret;
-    }
-	 return '';
-
-	
-    /* nel caso di registrazione del file 	 			
     $dir = dirname(__FILE__);
     $file = $dir . '/csrf-secret.php';
@@ -358,5 +367,4 @@
         return $secret;
     }
-    	
     if (is_writable($dir)) {
         $secret = csrf_generate_secret();
@@ -367,5 +375,4 @@
     }
     return '';
-    */	
 }
 
@@ -375,5 +382,5 @@
 function csrf_generate_secret($len = 32) {
     $r = '';
-    for ($i = 0; $i < 32; $i++) {
+    for ($i = 0; $i < $len; $i++) {
         $r .= chr(mt_rand(0, 255));
     }
@@ -388,5 +395,5 @@
 function csrf_hash($value, $time = null) {
     if (!$time) $time = time();
-    return sha1($GLOBALS['csrf']['secret'] . $value . $time) . ',' . $time;
+    return sha1(csrf_get_secret() . $value . $time) . ',' . $time;
 }
 
Index: /trunk/client/modules.php
===================================================================
--- /trunk/client/modules.php	(revision 252)
+++ /trunk/client/modules.php	(revision 253)
@@ -99,6 +99,10 @@
 
 
-
-
+$dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, 
+                                                                                                PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));	
+$sql = "use $dbname";
+$dbi->exec($sql);
+
+/*
 
 if(!$dbi = mysql_connect($dbhost, $dbuname, $dbpass)){
@@ -110,5 +114,5 @@
 }
 mysql_query("SET NAMES 'utf8'", $dbi);
-
+*/
 # protezione csrf ottobre 2012 - by l.apolito
 if (file_exists("inc/csrf-magic/csrf-magic.php")) {
@@ -122,6 +126,7 @@
 
 # carica i parametri di default sulla tabella
-$res = mysql_query("SELECT * FROM ".$prefix."_config" , $dbi);
-$row = mysql_fetch_array($res);
+$sql = $dbi->prepare("SELECT * FROM ".$prefix."_config");
+$sql->execute();
+while($riga = $sql->fetchAll(PDO::FETCH_ASSOC)){$row=$riga[0];
 $sitename = stripslashes($row['sitename']);
 $siteurl = $row['siteurl'];
@@ -146,20 +151,19 @@
 $ed_user = $row['ed_user'];
 #tema mobile
-
+}
 
 
 
 # altre config
-$res = mysql_query("SELECT * FROM ".$prefix."_ele_comuni where id_comune='$siteistat' ", $dbi);
-$row = mysql_fetch_array($res);
+$sql = $dbi->prepare("SELECT * FROM ".$prefix."_ele_comuni where id_comune='$siteistat' ");
+$sql->execute();
+$riga = $sql->fetchAll(PDO::FETCH_ASSOC);
+$row=$riga[0];
 $id_cons_pred = intval($row['id_cons']);
 if($id_cons_pred=='0')$id_cons_pred='';
 if(!isset($id_cons_gen)) $id_cons_gen=$id_cons_pred;
 # carica il metodo d'hontd 
-$res = mysql_query("SELECT * FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' ", $dbi);
-$row = mysql_fetch_array($res);
-
-
-
+##$sql = $dbi->prepare("SELECT * FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' ");
+##$sql->execute();
 
 $param=strip_tags(strtolower($_SERVER['REQUEST_METHOD'])) == 'get' ? $_GET : $_POST;
@@ -170,12 +174,14 @@
 $id_cons_bak=intval($param['id_cons_gen']);
 if (isset($param['id_comune'])) $id_combak=intval($param['id_comune']); else $id_combak=$_SESSION['id_comune'];
-$res = mysql_query("SELECT id_cons,id_conf FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_bak' and id_comune='$id_combak'" , $dbi);
-list($id_cons,$hondt) = mysql_fetch_row($res);
+$sql = $dbi->prepare("SELECT id_cons,id_conf FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_bak' and id_comune='$id_combak'");
+$sql->execute();
+$row = $sql->fetchAll(PDO::FETCH_ASSOC);
+$id_cons=$row[1];$hondt=$row[2];
 
 // incluso in consiglieri.php, ma io carico le vecchie variabili per compatibilit'a all'indietro
 if($hondt>=1){
 # proiezione consiglio
-      $res = mysql_query("SELECT * FROM ".$prefix."_ele_conf where id_conf='$hondt'", $dbi);
-      $row = mysql_fetch_array($res);
+      $row = $dbi->exec("SELECT * FROM ".$prefix."_ele_conf where id_conf='$hondt'");
+      
       $descrizione_consiglio = $row['descrizione'];
       $LIMITE = intval($row['limite']);
Index: /trunk/client/modules/Elezioni/grafici.php
===================================================================
--- /trunk/client/modules/Elezioni/grafici.php	(revision 252)
+++ /trunk/client/modules/Elezioni/grafici.php	(revision 253)
@@ -11,4 +11,9 @@
     die ("You can't access this file directly...");
 }
+
+include "pdoquery.php";
+$res=tipocons();
+$descr_cons=$res[1];$tipo_cons=$res[2];$genere=$res[3];$votog=$res[4];$votol=$res[5];$votoc=$res[6];$circo=$res[7];
+die("SELECT t1.descrizione, t1.tipo_cons,t2.genere, t2.voto_g, t2.voto_l, t2.voto_c, t2.circo ($descr_cons,$tipo_cons,$genere,$votog,$votol,$votoc,$circo)");
 
 
@@ -657,5 +662,5 @@
 
 function graf_candidato(){
-global $bgcolor1, $bgcolor5,$bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons, $id_cons,$tipo_cons,$copy,$id_comune,$id_istat,$genere,$votog,$votol,$votoc,$circo,$siteistat;
+global $descr_com, $bgcolor1, $bgcolor5,$bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons, $id_cons,$tipo_cons,$copy,$id_comune,$id_istat,$genere,$votog,$votol,$votoc,$circo,$siteistat;
 
 $logo=verificasimbolo(); // carica_logo da funzioni.php	
@@ -700,5 +705,5 @@
 			while (list($id_lista,$id_cand,$nome,$cognome,$voti)  = mysql_fetch_row($res)){
              			$candidato[$i]=$cognome;
-				$pro[$i]=number_format($voti*100/$tot,2);
+				if ($tot) $pro[$i]=number_format($voti*100/$tot,2); else $pro[$i]=0;
 				// sviluppo tabella dati
 				$e=$i+1;
Index: /trunk/client/modules/Elezioni/gruppo.php
===================================================================
--- /trunk/client/modules/Elezioni/gruppo.php	(revision 252)
+++ /trunk/client/modules/Elezioni/gruppo.php	(revision 253)
@@ -638,5 +638,5 @@
 					$voticompl=$sevaltot+$senultot+$sebiatot+$secontot+$sevnutot;
 					$resvt = mysql_query("SELECT voti from ".$prefix."_ele_voti_$tab15 where id_cons='$id_cons'",$dbi);
-					list($votlt)=mysql_fetch_row($resvt);
+					if($resvt) list($votlt)=mysql_fetch_row($resvt); else $votlt=0;
 					$temp3=arrayperc($tempar,$sevaltot);
 					while (list($key,$voti)= each($temp)) {
@@ -680,5 +680,5 @@
 		}else{
 			$res_lis = mysql_query("SELECT id_gruppo, descrizione,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons order by num_gruppo",$dbi);
-			$numliste=mysql_num_rows($res_lis);
+			if($res_lis) $numliste=mysql_num_rows($res_lis); else $numliste=0;
 
 			if (!isset($offset)) $offset=10;
@@ -695,5 +695,6 @@
 				echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"></input>";			
 				echo ""._SCELTA." "._CONSULTAZIONE.": <select name=\"id_gruppo\">";
-				while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
+				if($res_lis)
+				    while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
 					if (!$id_gruppo) $id_gruppo=$id_rif;
 					$sel = ($id_rif == $id_gruppo) ? "selected=\"selected\"" : "";
@@ -701,5 +702,5 @@
 					for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
 					echo $num_lis.") ".strip_tags(substr($descrizione,0,50))."</option>";
-				}
+				    }
 				echo "</select>";
 				echo "<br />"._VIS_PERC.": <input type=\"checkbox\" name=\"perc\" value=\"true\"";
@@ -724,6 +725,6 @@
 			order by $tab3, t1.num_gruppo
 			", $dbi);
-			$num_sez=mysql_num_rows($res);
-			list($num_gruppo,$descr)= mysql_fetch_row($res_ref);
+			if($res) $num_sez=mysql_num_rows($res); else $num_sez=0;
+			if($res_ref) list($num_gruppo,$descr)= mysql_fetch_row($res_ref); else {$num_gruppo=0;$descr='';}
 			
 			if (!$csv){
@@ -811,10 +812,10 @@
 		$ar[0][5]=_BIANCHI;
 		$ar[0][6]=_CONTESTATI;
-		
-		while (list($num_gruppo,$desc_ref) = mysql_fetch_row($res_ref)){
+		if($res_ref)
+		    while (list($num_gruppo,$desc_ref) = mysql_fetch_row($res_ref)){
 			$ar[0][$i++]= $num_gruppo.") ".$desc_ref;
 			$ar[1][$y++]= "SI";
 			$ar[1][$y++]= "NO";
-		}
+		    }
 		$num_sez++;
 		$tot_si=0;
@@ -824,5 +825,6 @@
 		$tot_bi=0;
 		$tot_co=0;
-		while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati)  = mysql_fetch_row($res)){
+		if($res)
+		    while (list($num_circ,$desc_circ,$num_gruppo,$desc_ref,$simbolo,$si,$no,$validi,$nulli,$bianchi, $contestati)  = mysql_fetch_row($res)){
 			$i=1;
 			$votanti=$validi+$nulli+$bianchi+$contestati;
@@ -852,5 +854,5 @@
 			$ar[$num_circ][$i++]= $perc=='true' ? $contestati."<br /><span class=\"red\"><i>0.00%</i></span>":$contestati;
 			}
-		}
+		    }
 		$i=1;
 		$tot_vo=$tot_va+$tot_nu+$tot_bi+$tot_co;
Index: /trunk/client/modules/Elezioni/index.php
===================================================================
--- /trunk/client/modules/Elezioni/index.php	(revision 252)
+++ /trunk/client/modules/Elezioni/index.php	(revision 253)
@@ -15,5 +15,5 @@
 	$_GET : $_POST;
 
-
+include("pdoquery.php");
 if (isset($param['rss'])) $rss=intval($param['rss']); else $rss='0';
 if (isset($param['xls'])) $xls=intval($param['xls']); else $xls='0';
@@ -24,8 +24,6 @@
 if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else 
 {
-        $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
-        list($id_cons_pred)=mysql_fetch_row($res);
-        $res = mysql_query("SELECT id_cons_gen FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons_pred' ", $dbi);
-        list($id_cons_gen)=mysql_fetch_row($res);
+        $id_cons_gen=dbpredefinita();
+	
 }       
 if (isset($param['op'])) $op=$param['op']; else $op='';
@@ -62,17 +60,17 @@
 $ordine=htmlentities($ordine); 
 
-$res = mysql_query("SELECT id_conf FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$id_comune'" , $dbi);
-list($hondt) = mysql_fetch_row($res);
-
-$sql = "SELECT t3.genere,t1.tipo_cons,t1.descrizione,t2.id_cons_gen 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_gen='$id_cons_gen' and t2.chiusa!='2' ";
-$res = mysql_query("$sql",$dbi);
-$tot=mysql_num_rows($res);
-if ($tot>0 and $id_cons_gen>0) {
-	$sql = "SELECT t3.genere,t1.tipo_cons,t1.descrizione,t2.id_cons_gen 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_gen='$id_cons_gen' and t2.chiusa!='2'";
-}else{
-	$sql = "SELECT t3.genere,t1.tipo_cons,t1.descrizione,t2.id_cons_gen 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.chiusa!='2' order by t1.data_fine desc limit 0,1 ";
-}
-$res = mysql_query("$sql",$dbi);
-if ($res) list($genere,$tipo_cons,$descr_cons,$id_cons_gen) = mysql_fetch_row($res);
+$hondt = dbvalorehondt();
+
+$res=dbselectcons();
+
+$genere=$res['genere'];
+$tipo_cons=$res['tipo_cons'];
+$descr_cons=$res['descrizione'];
+$id_cons_gen=$res['id_cons_gen'];
+echo "descr:$descr_cons";
+
+
+
+##########
 
 if ($tipo_cons!=3) $limite=0;
Index: /trunk/client/modules/Elezioni/language/lang-it.php
===================================================================
--- /trunk/client/modules/Elezioni/language/lang-it.php	(revision 252)
+++ /trunk/client/modules/Elezioni/language/lang-it.php	(revision 253)
@@ -272,4 +272,7 @@
 //global $tipo_cons;
 switch ($tipo_cons){
+	case '':
+		define("_CONSULTAZIONE","Consultazione");
+		break;
 	case 1:
 		define("_SCELTA_CIR","Scegli la Circoscrizione");
Index: /trunk/client/temi/Futura2/config.php
===================================================================
--- /trunk/client/temi/Futura2/config.php	(revision 252)
+++ /trunk/client/temi/Futura2/config.php	(revision 253)
@@ -6,5 +6,5 @@
 # devisualizz errori
 ini_set('display_errors','0');
-
+if(isset($_POST['rss'])) {$rss=intval($_POST['rss']);}
 # verifica cambiamento colore 
 # usata variabile rss gia esistente 
@@ -14,5 +14,12 @@
 elseif($rss==4){$colortheme="d";$_SESSION['colortheme']=$colortheme;}
 elseif($rss==5){$colortheme="e";$_SESSION['colortheme']=$colortheme;}
-elseif($rss==6){$colortheme="f";$_SESSION['colortheme']=$colortheme;}
+elseif($rss==6) {$colortheme="f";$_SESSION['colortheme']=$colortheme;}
+
+$defcolortheme='f';
+if (isset($_SESSION['colortheme'])) $colortheme=$_SESSION['colortheme']; else $colortheme=$defcolortheme;
+#elseif($rss==6){$colortheme="f";$_SESSION['colortheme']=$colortheme;}
+
+#colori
+#f=arancio;e=azzurro-grigio;d=verde;c=rosso;b=azzurro;a=grigio
 
 # verifica se arriva dalle app iphone e android
Index: /trunk/client/temi/Futura2/index.php
===================================================================
--- /trunk/client/temi/Futura2/index.php	(revision 252)
+++ /trunk/client/temi/Futura2/index.php	(revision 253)
@@ -12,7 +12,9 @@
 
 # colore tema mobile
+
+
 include("temi/$tema/config.php");
-$colortheme=$_SESSION['colortheme'];
-if($colortheme=='')$colortheme="c";
+
+#if($colortheme=='')$colortheme="c";
 # descrizione comune
 if(!$id_comune or $id_comune=='') $id_comune=$siteistat;
Index: /trunk/client/temi/Futura2/style.css
===================================================================
--- /trunk/client/temi/Futura2/style.css	(revision 253)
+++ /trunk/client/temi/Futura2/style.css	(revision 253)
@@ -0,0 +1,682 @@
+a:link {
+	text-decoration: none;
+	color: #660033;
+}
+a:visited {
+	text-decoration: none;
+	color: #660000;
+}
+a:hover {
+	color: #CC2222;
+}
+body , html {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 13px;
+	font-style: normal;
+	font-weight: normal;
+	margin-right: 0;
+	margin-left: 0;
+	margin-top: 0;
+	text-align: center;
+	background-color: #FFFFFF;
+	color: #333333;
+}
+
+div#container{
+    
+    width: 75%;
+    margin: auto;   /*centra */
+    
+    }
+
+table {
+	margin-right: auto;
+	margin-left: auto;
+	text-align: left;
+	margin-top: 0px;
+	
+}
+td {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 13px;
+	margin-top: 0px;
+	margin: 0;
+}
+
+hr {
+	color: #000000;
+	background-color: #FFFFFF;
+	border-bottom: 1px dotted #CCCCCC;
+}
+form {
+	
+	font-size: 12px;
+	color: #000066;
+	text-decoration: none;
+	margin-right: 0px;
+	margin-left: 0px;
+	margin-top: 0px;
+	margin-bottom: 0px;
+	width: 100%;
+}
+p {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 13px;
+	padding-right: 8px;
+	padding-bottom: 0px;
+	padding-left: 8px;
+	padding-top: 0px;
+	margin: 2px 2px 4px;
+}
+h1 {
+	font-size: 16px;
+	font-weight: bold;
+	color: #222266;
+	text-decoration: none;
+	border-bottom-width: 1px;
+	border-bottom-style: dotted;
+	border-bottom-color: #222266;
+	margin-top: 6px;
+	margin-bottom: 8px;
+	padding-right: 0px;
+	padding-left: 0px;
+}
+h2 {
+	font-size: 14px;
+	font-weight: bold;
+	color: #660000;
+	text-decoration: none;
+	border-bottom-width: 1px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	margin-top: 9px;
+	margin-bottom: 2px;
+	padding-right: 1px;
+	padding-left: 4px;
+}
+h4 {
+	font-size: 14px;
+	color: #003366;
+	text-decoration: none;
+	background-position: center;
+	bottom: 9px;
+	margin: 20px;
+	text-align: center;
+	border: 1px dotted #666666;
+	padding: 2px;
+	width: auto;
+	background-color: #EEEFEF;
+	font-variant: small-caps;
+}
+h5 {
+	font-size: 14px;
+	font-weight: bold;
+	color: #333333;
+	text-decoration: none;
+	border-bottom-width: 1px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	margin-top: 0px;
+	margin-bottom: 4px;
+	padding-right: 1px;
+	padding-left: 4px;
+	background-color: #EFEFEF;
+	background-position: center;
+	text-align: center;
+}
+h6 {
+	font-size: 12px;
+	font-weight: bold;
+	color: #333333;
+	text-decoration: none;
+	border-bottom-style: dotted;
+	padding-left: 4px;
+	background-position: center;
+	border-bottom-color: #EEEEEE;
+	border-bottom-width: 1px;
+	padding-top: 3px;
+	padding-right: 2px;
+	padding-bottom: 0px;
+	bottom: 9px;
+	margin-top: 1px;
+	margin-bottom: 3px;
+}
+
+
+/* usate per blocco */
+
+.sidebar {
+	
+	text-align:left;
+	margin-top:0px;
+	width: 200px;	
+	border: none;
+	padding: 0px;
+	/*background-color:#b0b0b0;*/
+}
+.sidebar a{
+color:#5D81A6;
+}
+.sidebar a:hover{
+text-decoration: underline;
+/*color:#FFFFFF;*/
+}
+.sidebar a:visited{
+color:#5D81A6;
+}
+
+
+
+.footbar {
+	background-image: url(images/footer.jpg);
+	font-size: 10px;
+	color: #330000;
+	padding-right: 10px;
+	padding-bottom: 2px;
+	padding-left: 8px;
+	padding-top: 2px;
+	height: 24px;
+}
+.modulo {
+	text-decoration: none;
+	border: 1px solid #666699;
+	font-size: 10px;
+}
+.moduloform {
+	text-decoration: none;
+	border: 1px solid #666699;
+	font-size: 13px;
+	text-align: left;
+}
+.modulo-extranet {
+	text-decoration: none;
+	border: 1px dotted #000033;
+	width: 100px;
+	background-color: #FFFFFF;
+	color: #CCCCCC;
+}
+.modulo-button {
+	color: #663366;
+	text-decoration: none;
+	background-color: #FFFFEE;
+	border: 1px solid #660033;
+	width: 50%;
+	text-align: center;
+	font-size: 10px;
+	padding: 3px;
+}
+.modulosmall {
+	font-size: 9px;
+	color: #000066;
+	text-decoration: none;
+	background-color: #FFFFFF;
+	border: 0px;
+	width: 100%;
+	margin: 0px;
+	padding: 2px;
+}
+.modulo-table {
+	font-size: 10px;
+	color: #000066;
+	text-decoration: none;
+	background-color: #FFFFFF;
+	border-top: 1px dotted #000033;
+	border-bottom: 1px dotted #000033;
+	width: 100%;
+}
+.modulo-titolo {
+	font-size: 13px;
+	font-weight: bold;
+	color: #336633;
+	text-decoration: none;
+	border-top: 1px dotted #000033;
+	margin-top: 10px;
+	margin-bottom: 0px;
+	margin-right: 0px;
+	margin-left: 0px;
+	padding: 0px;
+	background-color: #EFEFEF;
+	text-align: left;
+	width: 100%;
+}
+.table-main {
+	border: 1px solid #DEDEDC;
+	font-size: 13px;
+	background-position: center top;
+	padding: 0px;
+	color: #666666;
+	text-align:center;
+	width: 798px;
+}
+
+.table-blocco {
+border: 1px solid #DEDEDC;
+font-size: 10px;
+background-position: center top;
+padding: 0px;
+color: #666666;
+}
+
+					
+
+
+.table-central {
+	border-top-width: 1px;
+	border-right-width: 1px;
+	border-bottom-width: 1px;
+	border-left-width: 1px;
+	border-right-style: dotted;
+	border-left-style: dotted;
+	border-top-color: #CC3300;
+	border-right-color: #CC3300;
+	border-bottom-color: #CC3300;
+	border-left-color: #CC3300;
+	border-top-style: none;
+	border-bottom-style: none;
+	height: 100%;
+	width: 100%;
+	margin: 0px;
+	padding: 8px;
+}
+.table-info {
+	font-size: 10px;
+	padding-right: 4px;
+	padding-bottom: 2px;
+	padding-left: 2px;
+	padding-top: 4px;
+	margin: 2px 2px 4px;
+}
+.table-main-secondary {
+	background-position: center top;
+	border-top: none;
+	border-left: 1px dotted #DEDEDC;
+	border-bottom: none;
+	border-right: none;
+}
+.table-docs {
+	font-size: 9px;
+	padding: 1px;
+	color: #000000;
+	/* margin: 4px 4px 40px;*/
+	border-bottom: thin dotted #666666;
+	text-align:center;
+}
+.omniainternet {
+	font-size: 13px;
+	color: #993366;
+	text-decoration: none;
+	background-position: center;
+	bottom: 5px;
+	margin: 20px;
+	text-align: center;
+	border: 1px dotted #FF6666;
+	padding: 2px;
+	width: auto;
+	background-color: #FFEFEF;
+	font-variant: small-caps;
+}
+.message {
+	font-size: 13px;
+	color: #EE3366;
+	text-decoration: none;
+	background-position: center;
+	bottom: 5px;
+	margin: 10px auto;
+	text-align: left;
+	border: 1px dotted #FF6666;
+	padding: 2px;
+	width: 100%;
+	background-color: #FFFFEF;
+}
+.td-main {
+	
+	border-top: none;
+	border-right: 1px dotted #DEDEDC;
+	border-bottom: none;
+	border-left: 1px dotted #DEDEDC;
+}
+.news {
+	font-size: 10px;
+	border: none;
+	padding-right: 8px;
+	padding-bottom: 0px;
+	padding-left: 8px;
+	padding-top: 0px;
+	color: #330000;
+}
+.headlines {
+	font-size: 10px;
+	color: #333333;
+	text-decoration: none;
+	margin-top: 10px;
+	margin-bottom: 16px;
+	width: 366px;
+	text-align: left;
+	border: 0px dotted #FFFFFF;
+}
+
+
+
+.tavola {
+	background-image: url(images/back.gif);
+	font-size: 13px;
+	border: none;
+	color: #330000;
+}
+
+/* tabelle specifiche */
+	
+.piccolo {
+	BACKGROUND: none; 
+	COLOR: #cccccc; 
+	FONT-SIZE: 10px; 
+	FONT-WEIGHT: normal; 
+	FONT-FAMILY: Verdana, Helvetica; 
+	TEXT-DECORATION: none}
+		
+.table-80 {
+	margin: 0px auto;
+	font-size: 13px;
+	border: none;
+	color: #330000;
+	width: 80%;
+}		
+.table-762 {
+	text-align: center;
+	margin: 0px auto;
+	font-size: 13px;
+	border: none;
+	color: #330000;
+	width: 762px;
+        margin-top: 0px;
+	
+	padding: 0px;
+}		
+.td-image {
+	text-align: center;	
+	border: none;
+	margin: 0px;
+	padding: 0px;
+}
+.image {
+	/*float: center;*/
+	border: none;
+	margin: 0px;
+	padding: 0px;
+}
+
+.td-2 {
+	
+	margin: 0px 0 0 0px;
+		
+	border: none;
+	background-color: #d2d2d2;
+	padding: 0px;
+        FONT-SIZE: 13px; 
+        FONT-FAMILY: Verdana, Helvetica;
+	text-align: center; 
+}			
+.td-5 {
+	
+	margin: 0px 0 0 0px;
+	width: 5%;	
+	border: none;
+	background-color: #d2d2d2;
+	padding: 0px;
+        FONT-SIZE: 13px; 
+        FONT-FAMILY: Verdana, Helvetica;
+	text-align: center; 
+}	
+
+.td-30 {
+	
+	
+	width: 30%;	
+	text-align: left; 
+	
+	
+        FONT-SIZE: 13px; 
+        FONT-FAMILY: Verdana, Helvetica;
+}	
+.td-149 {
+	float: right;
+	margin-top:0px;
+	/*margin: 0px 0 0 0px;*/
+	width: 200px;	
+	border: none;
+	background-color: #d2d2d2;
+	padding: 0px;
+}	
+.td-130 {
+	float: right;
+	margin: 0px 0 0 1px;
+	width: 130px;	
+	border: none;
+	background-color: #d2d2d2;
+	padding: 0px;
+	
+}
+.td-130c {
+	float: right;
+	text-align:left;
+	margin: 0px 0 0 1px;
+	width: 130px;	
+	border: none;
+	
+	padding: 0px;
+}		
+.td-vuoto {
+	
+	
+	width: 100%;	
+	border: none;
+	text-align: left; 
+	
+}
+.td-vuotoc {
+	
+	
+	width: 100%;	
+	border: none;
+	text-align: center; 
+	
+}
+
+.td-89 {
+	
+	
+	width: 89%;	
+	border: none;
+	text-align: left; 
+	
+}
+.td-640 {
+	float: left;
+	margin: 0px 0 0 10px;
+	width: 610px;	
+	border: none;
+	background-color: #ffffff;
+	padding: 0px;
+	text-align: left; 
+}	
+
+
+div#sx{
+    width: 610px;
+    float: left;
+    text-align: left;   
+    }
+
+div#dx{
+    width: 200px;
+    float: right;
+    text-align: left;   
+    }
+
+div#divbutton{
+    width: 798px;
+    
+    text-align: right;      
+    }
+
+
+div#flash{
+    width: 410px;
+    float: left;
+    text-align: left;   
+    }
+
+
+
+.noblocco {
+border: 0px;
+margin-right:0px;
+margin-left:130px;
+text-align: right;
+vertical-align: middle;
+width:18px;
+height:18px;
+}
+
+
+.normal{
+    margin: 0px 0 0 1px;
+    float: left;
+    text-align: left;   
+    }
+
+.stemmapic {
+	/*float: center;*/
+	border: none;
+	margin: 0px;
+	padding: 0px;
+	width:30px;
+	height:30px;
+}		
+.stemma {
+	/*float: center;*/
+	border: none;
+	margin: 0px;
+	padding: 0px;
+	width:50px;
+	height:50px;
+	text-align: center;
+}		
+
+/**********************************************************************BOTTONI W3C*****************************************************/
+
+.w3cbutton3 {
+  margin: 0px 0px 0px 5px;
+  width: 95px;
+  border: 1px solid #6A6A6A;
+  font-family: helvetica,arial,sans-serif;
+  font-size: 10px;
+  float: left;
+}
+
+.w3cbutton3 a {
+  display: block;
+  width: 100%;
+}
+
+.w3cbutton3 a:link, .w3cbutton3 a:visited {
+  background-color: #8CC8C7;
+  color: #2A290B;
+  text-decoration: none;
+}
+
+.w3cbutton3 a:hover {
+  background-color: #C9F4F3;
+  color: #2A290B;
+  text-decoration: none;
+}
+
+.w3cbutton3 span.w3c {
+  font-weight: bold;
+  padding: 0 0.4em;
+  background-color: #FFFFCC;
+  color: #0C479D;
+}
+
+.w3cbutton3 span.spec {
+  color: #333333;
+}
+
+.w3cbutton3 span.specRed {
+  color: #FF0000;
+}
+
+
+/******************** font e backcolor******************************/
+.blu 	{
+	BACKGROUND: none;
+	font-weight: bold; 
+	COLOR: #003366; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica
+}
+
+
+.red 	{
+	BACKGROUND: none; 
+	COLOR: #ff0000; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica
+}
+
+.redbig 	{
+	BACKGROUND: none; 
+	COLOR: #ff0000; 
+	FONT-SIZE: 16px; 
+	FONT-FAMILY: Verdana, Helvetica
+}
+
+.bgw	{
+	BACKGROUND: #ffffff; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica;
+	text-align: center;
+}
+
+.bggray 	{
+	BACKGROUND: #d2d2d2; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica;
+	text-align: center;
+}
+
+.bggray2 	{
+	BACKGROUND: #EFEFEF; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica;
+	text-align: center;
+	}
+
+.bggray3 	{
+	BACKGROUND: #EFEFEF; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica;
+	text-align: left;
+	}
+
+.normale {
+	BACKGROUND: none; 
+	COLOR: #000000; 
+	FONT-SIZE: 12px; 
+	FONT-FAMILY: Verdana, Helvetica;
+	text-align: left;
+}
+
+.nobordo {
+border: 0px;
+text-align: center;
+vertical-align: middle;
+}
+
+.bordo {
+border: 1px solid #ff0000;
+text-align: left;
+vertical-align: middle;
+}
+
+
Index: /trunk/client/versione.php
===================================================================
--- /trunk/client/versione.php	(revision 252)
+++ /trunk/client/versione.php	(revision 253)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "2.0 rev 252";
+$versione = "2.0 rev 253";
 $version_number = $versione;
-$version = "Eleonline $version_number (<i>Data Release: 16 aprile 2016</i>)";
+$version = "Eleonline $version_number (<i>Data Release: 15 aprile 2017</i>)";
 
 
Index: /trunk/install/index.php
===================================================================
--- /trunk/install/index.php	(revision 252)
+++ /trunk/install/index.php	(revision 253)
@@ -96,8 +96,9 @@
 <tr>
 	<td>
-	&nbsp; - supporto MySQL
-	</td>
-	<td align="left">
-	<?php echo function_exists( 'mysql_connect' ) ? '<b><font color="green">Disponibile</font></b>' : '<b><font color="red">Non Disponibile</font></b>';?>
+	&nbsp; - supporto PDO MySQL
+	</td>
+	<td align="left">
+
+	<?php echo (extension_loaded('Pdo_mysql')) ? '<b><font color="green">Disponibile</font></b>' : '<b><font color="red">Non Disponibile</font></b>';?>
 	</td>
 </tr>
@@ -163,5 +164,5 @@
 <?php
 $php_recommended_settings = array(
-array ('Magic Quotes GPC','magic_quotes_gpc','ON'),
+array ('Magic Quotes GPC','magic_quotes_gpc','OFF'),
 array ('Register Globals','register_globals','OFF'),
 array ('Session auto start','session.auto_start','OFF'),
Index: /trunk/install/install2.php
===================================================================
--- /trunk/install/install2.php	(revision 252)
+++ /trunk/install/install2.php	(revision 253)
@@ -26,5 +26,5 @@
 $Capoluogo = mosGetParam( $_POST, 'Capoluogo', '' );
 $Lingua = mosGetParam( $_POST, 'Lingua', '' );
-$Multicomune = mosGetParam( $_POST, 'Multicomune', '' );
+$Multicomune = mosGetParam( $_POST, 'Multicomune', '0' );
 $Replica = mosGetParam( $_POST, 'Replica', '' );
 //tema
@@ -54,48 +54,22 @@
 		db_err ('stepBack','Non avete indicato il prefisso tabelle database.');
 	}
-	
-	$database = new database( $DBhostname, $DBuserName, $DBpassword, '', '', false );
-	$test = $database->getErrorMsg();
-
-	if (!$database->_resource) {
-		db_err ('stepBack2','password ed username inseriti non sono corretti.');
-	}
-
-	// Does this code actually do anything???
-	$configArray['DBhostname'] = $DBhostname;
-	$configArray['DBuserName'] = $DBuserName;
-	$configArray['DBpassword'] = $DBpassword;
-	$configArray['DBname']	 = $DBname;
-	$configArray['DBPrefix']= $DBPrefix;
-
-	$sql = "CREATE DATABASE `$DBname`";
-	$database->setQuery( $sql );
-	$database->query();
-	$test = $database->getErrorNum();
-
-	if ($test != 0 && $test != 1007) {
-		db_err( 'stepBack', 'Avvenuto un errore database: ' . $database->getErrorMsg() );
-	}
-
-	// db is now new or existing, create the db object connector to do the serious work
-	$database = new database( $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix );
-
-	// delete existing mos table if exists
-	$query = "SHOW TABLES FROM `$DBname`";
-	$database->setQuery( $query );
-	$errors = array();
-	if ($tables = $database->loadResultArray()) {
-		foreach ($tables as $table) {
-				$query = "DROP TABLE IF EXISTS `$table`";
-				$database->setQuery( $query );
-				$database->query();
-				if ($database->getErrorNum()) {
-					$errors[$database->getQuery()] = $database->getErrorMsg();
-				}
-		}
-	}
-
-	populate_db( $database, 'eleonline.sql' );
+	try{
+	$database = new PDO("mysql:host=$DBhostname;charset=latin1", $DBuserName, $DBpassword, array(PDO::ATTR_EMULATE_PREPARES => false, 
+                                                                                                PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));	
+	$sql = "CREATE DATABASE IF NOT EXISTS $DBname;
+	CREATE USER `$DBuserName`@'$DBhostname' IDENTIFIED BY '$DBpassword';
+        GRANT ALL ON `$DBname`.* TO `$DBuserName`@'$DBhostname';
+        FLUSH PRIVILEGES;";
+    	$database->exec($sql);
+    	$sql = "use $DBname";
+    	$database->exec($sql);
+	$sql = file_get_contents('sql/eleonline.sql');
+	$qr = $database->exec($sql);
 	$DBcreated = 1;
+	}
+	catch(PDOException $e)
+	{
+	    echo $sql . "<br>" . $e->getMessage();die();
+	}
 }
 
Index: /trunk/install/install3.php
===================================================================
--- /trunk/install/install3.php	(revision 252)
+++ /trunk/install/install3.php	(revision 253)
@@ -19,7 +19,7 @@
 $nomecomune = mosGetParam( $_POST, 'nomecomune', '' ) ;
 $istat =  mosGetParam( $_POST, 'istat', '' ) ;
-$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '' );
+$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '0' );
 $Lingua = mosGetParam( $_POST, 'Lingua', '' );
-$Multicomune = mosGetParam( $_POST, 'Multicomune', '' );
+$Multicomune = mosGetParam( $_POST, 'Multicomune', '0' );
 $Replica = mosGetParam( $_POST, 'Replica', '' );
 
Index: /trunk/install/install4.php
===================================================================
--- /trunk/install/install4.php	(revision 252)
+++ /trunk/install/install4.php	(revision 253)
@@ -25,7 +25,7 @@
 $nomecomune = mosGetParam( $_POST, 'nomecomune', '' ) ;
 $istat =  mosGetParam( $_POST, 'istat', '' ) ;
-$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '' );
+$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '0' );
 $Lingua = mosGetParam( $_POST, 'Lingua', '' );
-$Multicomune = mosGetParam( $_POST, 'Multicomune', '' );
+$Multicomune = mosGetParam( $_POST, 'Multicomune', '0' );
 $Replica = mosGetParam( $_POST, 'Replica', '' );
 
@@ -295,7 +295,8 @@
 
 
-
-	$database = new database( $DBhostname, $DBuserName, $DBpassword, $DBname );
-	$nullDate = $database->getNullDate();
+	$database = new PDO("mysql:host=$DBhostname;charset=latin1", $DBuserName, $DBpassword, array(PDO::ATTR_EMULATE_PREPARES => false, 
+                                                                                                PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));	
+    	$sql = "use $DBname";
+    	$database->exec($sql);
 
 	// create the admin user
@@ -303,26 +304,20 @@
 	//$query = "INSERT INTO {$configArray['DBPrefix']}_authors VALUES ('$adminName', '$adminName', '0', '$adminEmail', '$cryptpass','1','0','0','1','it')";
 	$query = "UPDATE {$configArray['DBPrefix']}_authors SET aid='$adminName', name='$adminName', email='$adminEmail', pwd= '$cryptpass' WHERE aid='suser'";
-	$database->setQuery( $query );
-	$database->query();
+	$database->exec( $query );
 	
 	// create Comune
+	try{
+	$query = "INSERT INTO {$configArray['DBPrefix']}_ele_comuni VALUES ('$istat', '$nomecomune', '','','','','$Limite','$Capoluogo','','','0','')";
+	$database->exec( $query );
+	} catch(PDOException $e) {}
+	$query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', siteurl='$siteUrl', adminmail='$adminEmail', tema='$tema', foot='',language='$Lingua',blocco='$blocco',fileout='$Replica',Versione='3', siteistat='$istat',multicomune='$Multicomune',flash='$flash', tema_on='$sceltatema'   WHERE sitename=''";
 	
-	$query = "INSERT INTO {$configArray['DBPrefix']}_ele_comuni VALUES ('$istat', '$nomecomune', '','','','','$Limite','$Capoluogo','','','')";
-	
-	$database->setQuery( $query );
-	$database->query();
-	
-	$query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', siteurl='$siteUrl', adminmail='$adminEmail', tema='$tema', foot='',language='$Lingua',blocco='$blocco',fileout='$Replica',Versione='2.0 beta', siteistat='$istat',multicomune='$Multicomune',flash='$flash', tema_on='$sceltatema'   WHERE sitename=''";
-	
-
-	$database->setQuery( $query );
-	$database->query();
+	$database->exec( $query );
 
 
 	// touch config table
 	$date = date("F Y");
-	$query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', nukeurl='$siteUrl', startdate='$date', adminmail='$adminEmail', backend_title='$sitename', notify_email='$adminEmail'";
-	$database->setQuery( $query );
-	$database->query();
+	$query = "UPDATE {$configArray['DBPrefix']}_config SET sitename='$sitename', siteurl='$siteUrl', startdate='$date', adminmail='$adminEmail'";
+	$database->exec( $query );
 
 } else {
@@ -407,5 +402,5 @@
 da quella di amministrazione (admin)<br/>
 od anche l'utenza del database pubblico in sola lettura<br/> 
-e altri accorgimenti che riterrai necessarie<br/>
+e altri accorgimenti che riterrai necessari<br/>
 
 
Index: /trunk/install/sql/eleonline.sql
===================================================================
--- /trunk/install/sql/eleonline.sql	(revision 252)
+++ /trunk/install/sql/eleonline.sql	(revision 253)
@@ -100,5 +100,5 @@
 /*!40000 ALTER TABLE `soraldo_config` DISABLE KEYS */;
 LOCK TABLES `soraldo_config` WRITE;
-INSERT INTO `soraldo_config` VALUES ('','http://www.fonte-nuova.it','','Sito istituzionale','Maggio 2009','admin@localhost','facebook','<b>Comune di Menfi</b><br>\r\nvia  - 84023 Menfi (Ag)\r\nTel:  Fax: \r\n<hr>','it','1','','','','Gpl v3',2,0,84023,'1','1','','','0','1','1','Admin');
+INSERT INTO `soraldo_config` VALUES ('','http://www.fonte-nuova.it','','Sito istituzionale','Maggio 2009','admin@localhost','facebook','<b>Comune di Menfi</b><br>\r\nvia  - 84023 Menfi (Ag)\r\nTel:  Fax: \r\n<hr>','it','1','','','','Gpl v3',2,0,84023,'1','1','0','','0','1','1','Admin');
 UNLOCK TABLES;
 /*!40000 ALTER TABLE `soraldo_config` ENABLE KEYS */;
@@ -747,5 +747,5 @@
   `id_cons_gen` int(11) NOT NULL default '0',
   `orario` time NOT NULL default '00:00:00',
-  `data` date NOT NULL default '0000-00-00',
+  `data` date NOT NULL,
   KEY `id_cons_gen` (`id_cons_gen`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -989,5 +989,5 @@
   `id_parz` int(11) NOT NULL auto_increment,
   `orario` time NOT NULL default '00:00:00',
-  `data` date NOT NULL default '0000-00-00',
+  `data` date NOT NULL,
   `voti_uomini` int(7) NOT NULL default '0',
   `voti_donne` int(7) NOT NULL default '0',
