Index: /trunk/admin/admin.php
===================================================================
--- /trunk/admin/admin.php	(revision 360)
+++ /trunk/admin/admin.php	(revision 361)
@@ -17,5 +17,5 @@
 #$LIMITE=3; //fascia di separazione del maggioritario (15.000 abitanti)
 # tempo di sessione: ini_set('session.gc_maxlifetime','3600');
-global $multicomune,$msglogout,$language;
+global $multicomune,$msglogout,$language,$id_sez;
 
 // Adattamento variabili superglobal
@@ -301,7 +301,6 @@
 $session=$_SESSION['remote'];
 
-$perms=ChiSei($id_cons_gen); #die("qui".$_SESSION['aid']);
-if($perms==0) {logout();} 
-}
+}
+
 
 
@@ -325,5 +324,5 @@
 $adminsuper=$row[0];
 $admincomune=$row[1];
-$adminop=$row[2]; 
+$oper=$row[2]; 
 	
 #if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {
@@ -333,6 +332,14 @@
 		return 64;
 #		$sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='$id_comune'");
-
-	$sth = $dbi->prepare("select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'");
+	elseif($oper) {$msglogout=1; return 0;} # id_cons='$id_cons' and 
+	else {
+		$oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y")));
+		$sql="SELECT id_sez FROM ".$prefix."_ele_operatori where  aid='$aid' and permessi>0 and id_cons in (select t1.id_cons from ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_consultazione as t2 where t1.id_cons_gen=t2.id_cons_gen and t1.id_comune='$id_comune' and t2.data_fine>$oggi)";		
+		$sth = $dbi->prepare("$sql");
+		$sth->execute();	#die("TEST: $sql");	
+		if($sth->rowCount()) {$perms=16; return $perms;}
+		else {$msglogout=1; return 0;}
+	}
+/*	$sth = $dbi->prepare("select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'");
 	$sth->execute();	
 	$row = $sth->fetch(PDO::FETCH_BOTH);	
@@ -340,10 +347,10 @@
 	$sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'");
 		
-	$sth->execute();	
-	$row = $sth->fetch(PDO::FETCH_BOTH);
-		if($row[0]==0) $msglogout=1;
-	if ($sth->rowCount()==1) $perms=$row[0]; else {	$msglogout=1; $perms=0; }
-
-	return $perms;
+	$sth->execute();
+	list($perms)=$sth->fetch(PDO::FETCH_NUM);
+#	$row =  die("test:$sql".$row[0] );
+	if (!$perms) {die("qui: select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'");	$msglogout=1; $perms=0; }
+
+	return $perms; */
 #} else return 0;
 }
@@ -379,4 +386,5 @@
 	elseif ($msglogout==2) echo "<h1 style=\"color:red;\">Nome Utente non presente in archivio</h1><br>";
 	elseif ($msglogout==3) echo "<h1 style=\"color:red;\">Password Errata</h1><br>";
+	elseif ($msglogout==4) echo "<h1 style=\"color:red;\">Accesso non ammesso da cellulare</h1><br>";
     echo "<form name=\"login\" data-ajax=\"false\" method=\"post\" action=\"admin.php\">"
         ."<table class=\"table-menu\">"
@@ -471,9 +479,10 @@
 				$tema='Futura2'; #die( "TEST id_cons:$id_cons:".$_SESSION['aid']);
 				$_SESSION['tema']=$tema;
-			} else logout();
+			} #else {die("TEST: $sql"); logout();}
 		}
 	}
-}
-
+$perms=ChiSei($id_cons_gen); #die("qui".$_SESSION['aid']);
+if($perms==0) {logout();} 
+}
 
 #echo "op:".$param['op']." -- aid:".$_SESSION['aid']."remote:".$_SESSION['remote']."REMOTE:".$_SERVER['REMOTE_ADDR'];
Index: /trunk/admin/aggiornadb.php
===================================================================
--- /trunk/admin/aggiornadb.php	(revision 360)
+++ /trunk/admin/aggiornadb.php	(revision 361)
@@ -98,4 +98,16 @@
 {
 	$sql="alter table `".$prefix."_config` change column `Versione` `versione` int(3)";
+	$ret=aggiorna($sql,$dbi,'',$num);
+}	
+
+if(!controllo($prefix.'__ele_voti_parziale','data',++$num))
+{
+	$sql="ALTER TABLE `".$prefix."_ele_voti_parziale` CHANGE `data` `data` DATE NOT NULL DEFAULT '1900-01-01'";
+	$ret=aggiorna($sql,$dbi,'',$num);
+}	
+
+if(!controllo($prefix.'__ele_rilaff','data',++$num))
+{
+	$sql="ALTER TABLE `".$prefix."_ele_rilaff` CHANGE `data` `data` DATE NOT NULL DEFAULT '1900-01-01'";
 	$ret=aggiorna($sql,$dbi,'',$num);
 }	
@@ -361,4 +373,64 @@
 $ret=aggiorna_index($tab,$ind,$dbi,$sql2,++$num);
 
-
+echo "<br>Modifica Charset del database<br>";
+#$sql="ALTER DATABASE $dbname CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'";
+#$res = $dbi->prepare("$sql");
+#$res->execute();
+# alter table $table DEFAULT CHARSET=utf8 COLLATE utf8_general_ci
+$sql="SELECT table_name,column_name,column_default,column_type,is_nullable FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbname' and (character_set_name='latin1' or collation_name like 'latin%')";
+$res = $dbi->prepare("$sql");
+$res->execute();
+$tab='';
+while(list($nometab,$campo,$def,$tipo,$nul)=$res->fetch(PDO::FETCH_NUM)) {
+	if($tab!=$nometab){
+		$sql="alter table $nometab DEFAULT CHARSET=utf8 COLLATE utf8_general_ci";
+		try{
+			$res2 = $dbi->prepare("$sql");
+			$res2->execute();
+        }
+		catch(PDOException $e)
+		{
+			die( $sql . "<br>" . $e->getMessage());
+		} 
+		$tab=$nometab; echo "Tabella: $nometab<br>";
+	}
+	if($def!='') $default="DEFAULT '$def'"; else $default='';
+	if($nul=='NO') $nullable='NOT NULL'; else $nullable='NULL';
+	$sql="ALTER TABLE $nometab CHANGE $campo $campo $tipo CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' $nullable $default;"; 	
+	echo "-- $campo<br>";
+	try{
+			$res2 = $dbi->prepare("$sql");
+			$res2->execute();
+        }
+		catch(PDOException $e)
+		{
+			$default="DEFAULT $def";
+			$sql="ALTER TABLE $nometab CHANGE $campo $campo $tipo CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' $nullable $default;"; 	
+			try{
+					$res2 = $dbi->prepare("$sql");
+					$res2->execute();
+				}
+				catch(PDOException $e)
+				{
+					die( $sql . "<br>" . $e->getMessage());
+				} 
+		}
+}
+ $sql="SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA = '$dbname' and table_collation like 'latin%'";
+ $res = $dbi->prepare("$sql");
+ $res->execute();
+$tab='';
+while(list($nometab)=$res->fetch(PDO::FETCH_NUM)) {
+		$sql="alter table $nometab DEFAULT CHARSET=utf8 COLLATE utf8_general_ci";
+		try{
+	echo "Tabella: $nometab <br>";
+			$res2 = $dbi->prepare("$sql");
+			$res2->execute();
+        }
+		catch(PDOException $e)
+		{
+			die( $sql . "<br>" . $e->getMessage());
+		} 
+}
+echo "<br><br>";
 ?>
Index: /trunk/admin/modules/Elezioni/ele_spoglio.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_spoglio.php	(revision 360)
+++ /trunk/admin/modules/Elezioni/ele_spoglio.php	(revision 361)
@@ -592,5 +592,5 @@
 				}elseif(!$errcolor && $numrec) $errcolor="style=\"background-color: #99CC33;\""; 
 				echo "<td align=\"center\" $errcolor><b> $num_lista </b></td>"
-				."<td align=\"left\"  onClick=\"vai_lista('id_rif$i');\"><b>$descr_lista</b></td>";
+				."<td align=\"left\" style=\"cursor: pointer;\" onClick=\"vai_lista('id_rif$i');\"><b>$descr_lista</b></td>";
 ##				$cond_sele="and id_lista=$id_lista3";
 				echo "<td align=\"right\"><input  name=\"voti$i\" value=\"".$voti."\" size=\"7\" onfocus=\"select();\" style=\"text-align:right; $bordcolor;\"><input id=\"id_rif$i\" type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\">";
Index: /trunk/admin/modules/Elezioni/ele_voti.php
===================================================================
--- /trunk/admin/modules/Elezioni/ele_voti.php	(revision 360)
+++ /trunk/admin/modules/Elezioni/ele_voti.php	(revision 361)
@@ -91,9 +91,9 @@
 
 
-		if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
+		if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore"); 
 		list($id_circ)=$res->fetch(PDO::FETCH_NUM);
 		$_SESSION['id_circ']=$id_circ;
 	}
-	$sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'";
+	$sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'"; 
 $result = $dbi->prepare("$sql");
 $result->execute();
@@ -307,12 +307,16 @@
 $rese->execute();
 $id_comune=$_SESSION['id_comune'];
-$bordoa='';
-$bordog='';
-$bordol=''; 
+$bordoini="style='cursor: pointer;";
+$errbordoa='';
+$errbordog='';
+$errbordol='';
 while (list($tipo)=$rese->fetch(PDO::FETCH_NUM)) {
-	if ($tipo=='affluenze') $bordoa="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
-	if ($tipo=='gruppo' or $tipo=='referendum') $bordog="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
-	if ($tipo=='lista') $bordol="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
-}
+	if ($tipo=='affluenze') $errbordoa="border: 6px solid; border-color: rgb(255, 0, 0);";
+	if ($tipo=='gruppo' or $tipo=='referendum') $errbordog="border: 6px solid; border-color: rgb(255, 0, 0);";
+	if ($tipo=='lista') $errbordol="border: 6px solid; border-color: rgb(255, 0, 0);";
+}
+$bordoa=$bordoini.$errbordoa."'";
+$bordog=$bordoini.$errbordog."'";
+$bordol=$bordoini.$errbordol."'";
 echo "<SCRIPT type=\"text/javascript\">\n";
 echo "function vai_scelta(idrif){\n";
Index: /trunk/admin/temi/Futura2/index.php
===================================================================
--- /trunk/admin/temi/Futura2/index.php	(revision 360)
+++ /trunk/admin/temi/Futura2/index.php	(revision 361)
@@ -32,5 +32,9 @@
 
 list($id_sez) = $res->fetch(PDO::FETCH_NUM);#include("TEST:$id_sez:$sql:");
+if (!$id_sez) { 
+	$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-18);
+	Header("Location: ".$BASE."admin.php?op=logout&msglogout=4");
 
+}
 if(isset($row[0])) {
 	$tipo_cons=$row[0]; $descr_cons=$row[1]; $id_cons_gen=$row[2];
@@ -109,12 +113,16 @@
 $rese = $dbi->prepare("$sql");
 $rese->execute();
-$bordoa='';
-$bordog='';
-$bordol=''; 
+$bordoini="style='cursor: pointer;";
+$errbordoa='';
+$errbordog='';
+$errbordol='';
 while (list($tipo)=$rese->fetch(PDO::FETCH_NUM)) {
-	if ($tipo=='affluenze') $bordoa="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
-	if ($tipo=='gruppo' or $tipo=='referendum') $bordog="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
-	if ($tipo=='lista') $bordol="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
+	if ($tipo=='affluenze') $errbordoa="border: 6px solid; border-color: rgb(255, 0, 0);";
+	if ($tipo=='gruppo' or $tipo=='referendum') $errbordog="border: 6px solid; border-color: rgb(255, 0, 0);";
+	if ($tipo=='lista') $errbordol="border: 6px solid; border-color: rgb(255, 0, 0);";
 }
+$bordoa=$bordoini.$errbordoa."'";
+$bordog=$bordoini.$errbordog."'";
+$bordol=$bordoini.$errbordol."'";
 if($rese->rowCount()) $segna="style=\"background-color: #dd0000;\""; else $segna='';
 if($ops=="4" ) {$bgcolorg="yellow"; $tcolorg='blue';} else {$bgcolorg="grey"; $tcolorg='white';} #$active_gruppo=" class=\"ui-btn-active\""; else $active_gruppo='';
Index: /trunk/admin/versione.php
===================================================================
--- /trunk/admin/versione.php	(revision 360)
+++ /trunk/admin/versione.php	(revision 361)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "3.0 rev 360";
+$versione = "3.0 rev 361";
 $version_number = $versione;
-$datarel = "14 marzo 2022";
+$datarel = "17 marzo 2022";
 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
 
Index: /trunk/client/versione.php
===================================================================
--- /trunk/client/versione.php	(revision 360)
+++ /trunk/client/versione.php	(revision 361)
@@ -1,7 +1,7 @@
 <?php
 
-$versione = "3.0 rev 360";
+$versione = "3.0 rev 361";
 $version_number = $versione;
-$datarel = "14 marzo 2022";
+$datarel = "17 marzo 2022";
 $version = "Eleonline $version_number (<i>Data Release: $datarel</i>)";
 
