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 |
|
---|
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='';
|
---|
34 | if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='';
|
---|
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='';
|
---|
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;
|
---|
44 | global $prefix,$id_parz,$genere,$fileout,$id_cons;
|
---|
45 | $sql="select solo_gruppo,disgiunto,chiusa from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
46 | $result = $dbi->prepare("$sql");
|
---|
47 | $result->execute();
|
---|
48 | list($flagsg,$disgiunto,$chiusa)=$result->fetch(PDO::FETCH_NUM);
|
---|
49 | if(!$chiusa==1){
|
---|
50 | if (!isset($fileout)) $fileout='';
|
---|
51 | #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
52 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
53 |
|
---|
54 | $salvato=0;
|
---|
55 |
|
---|
56 | ##################
|
---|
57 |
|
---|
58 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
59 | $result = $dbi->prepare("$sql");
|
---|
60 | $result->execute();
|
---|
61 | $ar=$result->fetch(PDO::FETCH_BOTH);
|
---|
62 | $validilista=$validi-$ar['solo_gruppo'];
|
---|
63 | $log_data= date("Y/m/d");
|
---|
64 | $log_ora=getdate(time());
|
---|
65 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
66 |
|
---|
67 | #if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
68 | $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')";
|
---|
69 | $res = $dbi->prepare("$sql");
|
---|
70 | $res->execute();
|
---|
71 | $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' ";
|
---|
72 | $res = $dbi->prepare("$sql");
|
---|
73 | $res->execute();
|
---|
74 | if ($fileout) fwrite($fp,"$sql;\n");
|
---|
75 | ######
|
---|
76 | #include($sql."TEST: scru=$scrutinata");
|
---|
77 | if(isset($scrutinata))
|
---|
78 | {
|
---|
79 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and num_gruppo=0";
|
---|
80 | $res = $dbi->prepare("$sql");
|
---|
81 | $res->execute();
|
---|
82 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and num_lista=0";
|
---|
83 | $res = $dbi->prepare("$sql");
|
---|
84 | $res->execute();
|
---|
85 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez' and num_cand=0";
|
---|
86 | $res = $dbi->prepare("$sql");
|
---|
87 | $res->execute();
|
---|
88 | if($scrutinata==true)
|
---|
89 | {
|
---|
90 | # provare insert dei soli id_cons e id_sez
|
---|
91 | $sql="insert into ".$prefix."_ele_voti_gruppo (id_cons,id_sez,num_gruppo) values('$id_cons','$id_sez',0)";
|
---|
92 | $res = $dbi->prepare("$sql");
|
---|
93 | $res->execute();
|
---|
94 | $sql="insert into ".$prefix."_ele_voti_lista (id_cons,id_sez) values('$id_cons','$id_sez')";
|
---|
95 | $res = $dbi->prepare("$sql");
|
---|
96 | $res->execute();
|
---|
97 | $sql="insert into ".$prefix."_ele_voti_candidati (id_cons,id_sez,num_cand) values('$id_cons','$id_sez',0)";
|
---|
98 | $res = $dbi->prepare("$sql");
|
---|
99 | $res->execute();
|
---|
100 | #
|
---|
101 | }
|
---|
102 | }
|
---|
103 | /*}else{
|
---|
104 | $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')";
|
---|
105 | $res = $dbi->prepare("$sql");
|
---|
106 | $res->execute();
|
---|
107 | $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' ";
|
---|
108 | $res = $dbi->prepare("$sql");
|
---|
109 | $res->execute();
|
---|
110 | if ($fileout) fwrite($fp,"$sql;\n"); */
|
---|
111 | #}
|
---|
112 | include("ele_controlli.php");
|
---|
113 | controllo_voti($id_cons,$id_sez);
|
---|
114 | include("ele_colora_sez.php");
|
---|
115 | if ($fileout) fclose($fp);
|
---|
116 | }
|
---|
117 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
118 | 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");
|
---|
119 | #################################
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 | ?>
|
---|