[261] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /************************************************************************/
|
---|
| 5 | /* Modulo salva affluenze */
|
---|
| 6 | /* Amministrazione */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 | session_name('sesadmin');
|
---|
| 9 | // gestione sessione
|
---|
| 10 | $a = session_id();
|
---|
| 11 | if(empty($a)) session_start();
|
---|
| 12 | if(!$_SESSION['aid'])
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | $aid=$_SESSION['aid'];
|
---|
| 15 | include("../../config.php");
|
---|
| 16 | try{
|
---|
| 17 | $dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
|
---|
| 18 | $sql = "use $dbname";
|
---|
| 19 | $dbi->exec($sql);
|
---|
| 20 | }
|
---|
| 21 | catch(PDOException $e)
|
---|
| 22 | {
|
---|
| 23 | echo $sql . "<br>" . $e->getMessage();
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[352] | 26 | if (isset($_GET['genere'])) $genere=intval($_GET['genere']); else $genere='';
|
---|
| 27 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='';
|
---|
| 28 | if (isset($_GET['id_cons'])) $id_cons=intval($_GET['id_cons']); else $id_cons='';
|
---|
| 29 | if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='';
|
---|
| 30 | if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='';
|
---|
| 31 | if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='';
|
---|
| 32 | if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='';
|
---|
| 33 | if (isset($_GET['validi'])) $validi=intval($_GET['validi']); else $validi='';
|
---|
[344] | 34 | if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='';
|
---|
[352] | 35 | if (isset($_GET['bianchi'])) $bianchi=intval($_GET['bianchi']); else $bianchi='';
|
---|
| 36 | if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='';
|
---|
| 37 | if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='01-01-1900';
|
---|
| 38 | if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='';
|
---|
| 39 | if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='';
|
---|
| 40 | if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='';
|
---|
[394] | 41 | if (isset($_GET['scrutinata'])) {$scrutinata=$_GET['scrutinata']==false ? false : true;}else $scrutinata=false;
|
---|
| 42 | #$_SESSION['scrutinata']=$scrutinata;
|
---|
| 43 | #if(isset($_SESSION['scrutinata'])) $scrutinata=$_SESSION['scrutinata']; #else $scrutinata=false;
|
---|
[261] | 44 | global $prefix,$id_parz,$genere,$fileout,$id_cons;
|
---|
| 45 | if (!isset($fileout)) $fileout='';
|
---|
| 46 | #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
| 47 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
| 48 |
|
---|
| 49 | $salvato=0;
|
---|
| 50 |
|
---|
| 51 | ##################
|
---|
| 52 | $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
| 53 | $result = $dbi->prepare("$sql");
|
---|
| 54 | $result->execute();
|
---|
| 55 | list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
|
---|
| 56 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
| 57 | $result = $dbi->prepare("$sql");
|
---|
| 58 | $result->execute();
|
---|
| 59 | $ar=$result->fetch(PDO::FETCH_BOTH);
|
---|
| 60 | $validilista=$validi-$ar['solo_gruppo'];
|
---|
| 61 | $log_data= date("Y/m/d");
|
---|
| 62 | $log_ora=getdate(time());
|
---|
| 63 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
| 64 |
|
---|
| 65 | #if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
| 66 | $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] ','validi_lista=$validilista, nulli=$nulli,bianchi=$bianchi','_ele_sezioni')";
|
---|
| 67 | $res = $dbi->prepare("$sql");
|
---|
| 68 | $res->execute();
|
---|
| 69 | $sql="update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', nulli='$nulli',bianchi='$bianchi', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
| 70 | $res = $dbi->prepare("$sql");
|
---|
| 71 | $res->execute();
|
---|
| 72 | if ($fileout) fwrite($fp,"$sql;\n");
|
---|
[394] | 73 | ######
|
---|
| 74 | #include($sql."TEST: scru=$scrutinata");
|
---|
| 75 | if(isset($scrutinata))
|
---|
| 76 | {
|
---|
| 77 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and num_gruppo=0";
|
---|
| 78 | $res = $dbi->prepare("$sql");
|
---|
| 79 | $res->execute();
|
---|
| 80 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and num_lista=0";
|
---|
| 81 | $res = $dbi->prepare("$sql");
|
---|
| 82 | $res->execute();
|
---|
| 83 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez' and num_cand=0";
|
---|
| 84 | $res = $dbi->prepare("$sql");
|
---|
| 85 | $res->execute();
|
---|
| 86 | if($scrutinata==true)
|
---|
| 87 | {
|
---|
| 88 | # provare insert dei soli id_cons e id_sez
|
---|
| 89 | $sql="insert into ".$prefix."_ele_voti_gruppo (id_cons,id_sez,num_gruppo) values('$id_cons','$id_sez',0)";
|
---|
| 90 | $res = $dbi->prepare("$sql");
|
---|
| 91 | $res->execute();
|
---|
| 92 | $sql="insert into ".$prefix."_ele_voti_lista (id_cons,id_sez) values('$id_cons','$id_sez')";
|
---|
| 93 | $res = $dbi->prepare("$sql");
|
---|
| 94 | $res->execute();
|
---|
| 95 | $sql="insert into ".$prefix."_ele_voti_candidati (id_cons,id_sez,num_cand) values('$id_cons','$id_sez',0)";
|
---|
| 96 | $res = $dbi->prepare("$sql");
|
---|
| 97 | $res->execute();
|
---|
| 98 | #
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
[261] | 101 | /*}else{
|
---|
| 102 | $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','','','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')";
|
---|
| 103 | $res = $dbi->prepare("$sql");
|
---|
| 104 | $res->execute();
|
---|
| 105 | $sql="update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
| 106 | $res = $dbi->prepare("$sql");
|
---|
| 107 | $res->execute();
|
---|
| 108 | if ($fileout) fwrite($fp,"$sql;\n"); */
|
---|
| 109 | #}
|
---|
[262] | 110 | include("ele_controlli.php");
|
---|
[261] | 111 | controllo_voti($id_cons,$id_sez);
|
---|
[262] | 112 | include("ele_colora_sez.php");
|
---|
[261] | 113 |
|
---|
| 114 | if ($fileout) fclose($fp);
|
---|
| 115 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
| 116 | Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
|
---|
| 117 | #################################
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 |
|
---|
[262] | 123 |
|
---|
[261] | 124 | ?>
|
---|