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='0';
|
---|
27 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
|
---|
28 | if (isset($_GET['id_cons'])) $id_cons=intval($_GET['id_cons']); else $id_cons='0';
|
---|
29 | if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='0';
|
---|
30 | if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='0';
|
---|
31 | if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='0';
|
---|
32 | if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='0';
|
---|
33 | if (isset($_GET['do'])) $do=intval($_GET['do']); else $do='0';
|
---|
34 | if (isset($_GET['validi'])) $validi=intval($_GET['validi']); else $validi='0';
|
---|
35 | if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='0';
|
---|
36 | if (isset($_GET['bianchi'])) $bianchi=intval($_GET['bianchi']); else $bianchi='0';
|
---|
37 | if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='0';
|
---|
38 | if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='0';
|
---|
39 | if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='0';
|
---|
40 | if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='0';
|
---|
41 | if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='';
|
---|
42 | if (isset($_GET['circo'])) get_magic_quotes_gpc() ? $circo=$_GET['circo']:$circo=addslashes($_GET['circo']); else $circo='';
|
---|
43 |
|
---|
44 | global $prefix,$id_parz,$fileout;
|
---|
45 | $sql="select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
|
---|
46 | $result = $dbi->prepare("$sql");
|
---|
47 | $result->execute();
|
---|
48 | while(list($i)=$result->fetch(PDO::FETCH_BOTH)) {
|
---|
49 | $vot="voti$i";$solo="solog$i";$grupp="num_gruppo$i";
|
---|
50 | if (isset($_GET[$grupp])) $num_gruppo[$i]=intval($_GET[$grupp]); else $num_gruppo[$i]='0';
|
---|
51 | if (isset($_GET[$vot])) $voti[$i]=intval($_GET[$vot]); else $voti[$i]='0';
|
---|
52 | if (isset($_GET[$solo])) $solog[$i]=intval($_GET[$solo]); else $solog[$i]='0';
|
---|
53 |
|
---|
54 | }
|
---|
55 |
|
---|
56 | if (!isset($fileout)) $fileout='';
|
---|
57 | #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
58 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
59 |
|
---|
60 | ##################
|
---|
61 | if($do==1) {
|
---|
62 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
63 | $res = $dbi->prepare("$sql");
|
---|
64 | $res->execute();
|
---|
65 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
66 | $res = $dbi->prepare("$sql");
|
---|
67 | $res->execute();
|
---|
68 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
69 | $res = $dbi->prepare("$sql");
|
---|
70 | $res->execute();
|
---|
71 | $sql="update ".$prefix."_ele_sezioni set validi_lista='',contestati_lista='',voti_nulli_lista='',solo_gruppo='',solo_lista='' where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
72 | $res = $dbi->prepare("$sql");
|
---|
73 | $res->execute();
|
---|
74 | }else{
|
---|
75 | $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
76 | $res = $dbi->prepare("$sql");
|
---|
77 | $res->execute();
|
---|
78 | list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
|
---|
79 | if($disgiunto){
|
---|
80 | }
|
---|
81 | $sql="select num_gruppo from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
82 | $result = $dbi->prepare("$sql");
|
---|
83 | $result->execute();
|
---|
84 | if($result->rowCount()) {
|
---|
85 | while(list($i)=$result->fetch(PDO::FETCH_NUM)){
|
---|
86 | $sql="update ".$prefix."_ele_voti_gruppo set voti='".$voti[$i]."',solo_gruppo='".$solog[$i]."' where id_cons='$id_cons' and id_sez='$id_sez' and num_gruppo='".$num_gruppo[$i]."'";
|
---|
87 | $res = $dbi->prepare("$sql");
|
---|
88 | $res->execute();
|
---|
89 | }
|
---|
90 | }else{
|
---|
91 | $sql="select num_gruppo,id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons'";
|
---|
92 | $result = $dbi->prepare("$sql");
|
---|
93 | $result->execute();
|
---|
94 | while(list($i,$id_gruppo)=$result->fetch(PDO::FETCH_NUM)){
|
---|
95 | $sql="insert into ".$prefix."_ele_voti_gruppo values('$id_cons','$id_gruppo','$id_sez','$i','".$voti[$i]."','".$solog[$i]."')";
|
---|
96 | $res = $dbi->prepare("$sql");
|
---|
97 | $res->execute();
|
---|
98 | }
|
---|
99 |
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | controllo_votig($id_cons,$id_sez,$genere);
|
---|
106 |
|
---|
107 | if ($fileout) fclose($fp);
|
---|
108 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
109 | 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");
|
---|
110 | #################################
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 | function controllo_votig($id_cons,$id_sez,$genere){
|
---|
117 | global $prefix,$dbi,$id_sede,$id_cons_gen;
|
---|
118 | ##############################
|
---|
119 | $err=0; $err2=0;
|
---|
120 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
|
---|
121 | $resref = $dbi->prepare("$sql");
|
---|
122 | $resref->execute();
|
---|
123 | $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez'";
|
---|
124 | $res3 = $dbi->prepare("$sql");
|
---|
125 | $res3->execute();
|
---|
126 | list($voti)=$res3->fetch(PDO::FETCH_NUM);
|
---|
127 | $sql="SELECT validi FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' and id_cons='$id_cons' ";
|
---|
128 | $res2 = $dbi->prepare("$sql");
|
---|
129 | $res2->execute();
|
---|
130 | list($validi) = $res2->fetch(PDO::FETCH_NUM);
|
---|
131 | if($validi) {
|
---|
132 | $status=0;
|
---|
133 | $query="SELECT validi,nulli,bianchi,contestati,voti_nulli,solo_gruppo,validi_lista,contestati_lista,voti_nulli_lista,solo_lista FROM ".$prefix."_ele_sezioni as t1 where t1.id_sez='$id_sez'";
|
---|
134 | $sql="$query";
|
---|
135 | $res4 = $dbi->prepare("$sql");
|
---|
136 | $res4->execute();
|
---|
137 | list($validi, $nulli, $bianchi,$contestati,$votinulli)=$res4->fetch(PDO::FETCH_NUM);
|
---|
138 | if (($validi+$nulli+$bianchi+$contestati+$votinulli)!=$voti)
|
---|
139 | {$err=1;}
|
---|
140 | }
|
---|
141 | $tipo='gruppo';
|
---|
142 | $sql="select id from ".$prefix."_ele_controlli where tipo='$tipo' and id_sez='$id_sez'";
|
---|
143 | $res = $dbi->prepare("$sql");
|
---|
144 | $res->execute();
|
---|
145 | $righe=$res->rowCount();
|
---|
146 | if($righe){
|
---|
147 | if(!$err){
|
---|
148 | $sql="delete from ".$prefix."_ele_controlli where tipo='$tipo' and id='$id_sez' ";
|
---|
149 | $res = $dbi->prepare("$sql");
|
---|
150 | $res->execute();
|
---|
151 | }
|
---|
152 | $err=0;
|
---|
153 | }
|
---|
154 | if($err){
|
---|
155 | $sql="insert into ".$prefix."_ele_controlli value('$id_cons','$id_sez','$tipo','$id_sez')";
|
---|
156 | $res = $dbi->prepare("$sql");
|
---|
157 | $res->execute();
|
---|
158 | }
|
---|
159 | include("ele_colora_sez.php");
|
---|
160 |
|
---|
161 | }
|
---|
162 |
|
---|
163 | ?>
|
---|