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='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['id_lista'])) $id_lista=intval($_GET['id_lista']); else $id_lista='0';
|
---|
34 | if (isset($_GET['valista'])) $valista=intval($_GET['valista']); else $valista='0';
|
---|
35 | if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg='0';
|
---|
36 | if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='0';
|
---|
37 | if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='0';
|
---|
38 | if (isset($_GET['update'])) $update=intval($_GET['update']); else $update='0';
|
---|
39 | if (isset($_GET['pwd3'])) $pwd3=intval($_GET['pwd3']); else $pwd3='0';
|
---|
40 | if (isset($_GET['do'])) $do=intval($_GET['do']); else $do='0';
|
---|
41 | if (isset($_GET['valista'])) $validi=intval($_GET['valista']); else $validi='0';
|
---|
42 | if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='0';
|
---|
43 | if (isset($_GET['bianchi'])) $bianchi=intval($_GET['bianchi']); else $bianchi='0';
|
---|
44 | if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='0';
|
---|
45 | if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='0';
|
---|
46 | if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='0';
|
---|
47 | if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='3';
|
---|
48 | if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='0';
|
---|
49 | if (isset($_GET['circo'])) $circo=addslashes($_GET['circo']); else $circo='';
|
---|
50 |
|
---|
51 | global $prefix,$id_parz,$fileout;
|
---|
52 | $sql="SELECT chiusa FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
53 | $res = $dbi->prepare("$sql");
|
---|
54 | $res->execute();
|
---|
55 | list($chiusa)=$res->fetch(PDO::FETCH_NUM);
|
---|
56 | if($chiusa!=1){
|
---|
57 | $sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" ;
|
---|
58 | $res = $dbi->prepare("$sql");
|
---|
59 | $res->execute();
|
---|
60 | list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
61 | $sql="SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
|
---|
62 | $res = $dbi->prepare("$sql");
|
---|
63 | $res->execute();
|
---|
64 | list($circo)=$res->fetch(PDO::FETCH_NUM);
|
---|
65 | if ($circo) $iscirco="and id_circ=$id_circ"; else $iscirco='';
|
---|
66 | if($id_lista){
|
---|
67 | $sql="select num_cand,id_cand from ".$prefix."_ele_candidati where id_cons='$id_cons' and id_lista='$id_lista' ORDER BY num_cand ";
|
---|
68 | $result = $dbi->prepare("$sql");
|
---|
69 | $result->execute();
|
---|
70 | while(list($i,$y)=$result->fetch(PDO::FETCH_NUM)) {
|
---|
71 | $vot="voti$i";$cand="id_cand$i";
|
---|
72 | if (isset($_GET[$cand])) $idcand[$i]=intval($_GET[$cand]); else $idcand[$i]=$y;
|
---|
73 | if (isset($_GET[$vot])) $voti[$i]=intval($_GET[$vot]); else $voti[$i]='0';
|
---|
74 | # if (isset($_GET[$solo])) $solog[$i]=intval($_GET[$solo]); else $solog[$i]='0';
|
---|
75 |
|
---|
76 | }
|
---|
77 | }else{
|
---|
78 | $sql="select num_lista from ".$prefix."_ele_lista where id_cons='$id_cons' $iscirco ORDER BY num_lista ";
|
---|
79 | $result = $dbi->prepare("$sql");
|
---|
80 | $result->execute();
|
---|
81 | $sololiste=0;
|
---|
82 | while(list($i)=$result->fetch(PDO::FETCH_NUM)) {
|
---|
83 | $vot="voti$i";$vnp="vnpl$i";$slp="slpl$i";$idlist="id_lista$i";
|
---|
84 | if (isset($_GET[$vnp])) $vnpl[$i]=intval($_GET[$vnp]); else $vnpl[$i]='0';
|
---|
85 | if (isset($_GET[$vot])) $voti[$i]=intval($_GET[$vot]); else $voti[$i]='0';
|
---|
86 | if (isset($_GET[$slp])) $slpl[$i]=intval($_GET[$slp]); else $slpl[$i]='0';
|
---|
87 | if (isset($_GET[$idlist])) $idlista[$i]=intval($_GET[$idlist]); else $idlista[$i]='0';
|
---|
88 | $sololiste+=$slpl[$i];
|
---|
89 | }
|
---|
90 | }
|
---|
91 | if (!isset($fileout)) $fileout='';
|
---|
92 | #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
93 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
94 |
|
---|
95 | ##################
|
---|
96 | # if($id_lista){
|
---|
97 |
|
---|
98 | #$andlis="and
|
---|
99 | if($pwd3==1) {
|
---|
100 | if($id_lista) $condiz="and id_cand in (select id_cand from ".$prefix."_ele_candidati where id_cons='$id_cons' and id_lista='$id_lista')"; else $condiz='';
|
---|
101 | $sql="delete from ".$prefix."_ele_voti_candidati where id_sez='$id_sez' $condiz";
|
---|
102 | $res = $dbi->prepare("$sql");
|
---|
103 | $res->execute();
|
---|
104 | $sql="delete from ".$prefix."_ele_controlli where tipo='candidato' and id_sez='$id_sez' ";
|
---|
105 | $res = $dbi->prepare("$sql");
|
---|
106 | $res->execute();
|
---|
107 | if(!$id_lista){
|
---|
108 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
109 | $res = $dbi->prepare("$sql");
|
---|
110 | $res->execute();
|
---|
111 | $sql="delete from ".$prefix."_ele_controlli where tipo='lista' and id_sez='$id_sez' ";
|
---|
112 | $res = $dbi->prepare("$sql");
|
---|
113 | $res->execute();
|
---|
114 | $sql="update ".$prefix."_ele_sezioni set validi_lista='0',contestati_lista='0',voti_nulli_lista='0',solo_gruppo='0',solo_lista='0' where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
115 | $res = $dbi->prepare("$sql");
|
---|
116 | $res->execute();
|
---|
117 | }
|
---|
118 |
|
---|
119 | }elseif($id_lista){
|
---|
120 |
|
---|
121 | foreach($idcand as $idkey=>$idc){
|
---|
122 | $sql="select num_cand from ".$prefix."_ele_voti_candidati where id_sez='$id_sez' and id_cand='$idc'";
|
---|
123 | $result = $dbi->prepare("$sql");
|
---|
124 | $result->execute();
|
---|
125 | if($result->rowCount())
|
---|
126 | $sql="update ".$prefix."_ele_voti_candidati set voti='".$voti[$idkey]."' where id_sez='$id_sez' and id_cand='$idc'";
|
---|
127 | else
|
---|
128 | $sql="insert into ".$prefix."_ele_voti_candidati values('$id_cons','$idc','$id_sez','$idkey','".$voti[$idkey]."')";
|
---|
129 | $result = $dbi->prepare("$sql");
|
---|
130 | $result->execute();
|
---|
131 | }
|
---|
132 | }else{
|
---|
133 | $sql="update ".$prefix."_ele_sezioni set validi_lista='$validi',contestati_lista='$contestati',voti_nulli_lista='$votinulli',solo_gruppo='$sg' where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
134 | $res = $dbi->prepare("$sql");
|
---|
135 | $res->execute();
|
---|
136 | $sql="select num_lista,id_lista from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
137 | $result = $dbi->prepare("$sql");
|
---|
138 | $result->execute();
|
---|
139 | if($result->rowCount()){
|
---|
140 | $sql="select num_lista,id_lista from ".$prefix."_ele_lista where id_cons='$id_cons' $iscirco";
|
---|
141 | $result = $dbi->prepare("$sql");
|
---|
142 | $result->execute();
|
---|
143 | while(list($i,$idl)=$result->fetch(PDO::FETCH_NUM)){
|
---|
144 | $sql="update ".$prefix."_ele_voti_lista set num_lista='$i',voti='".$voti[$i]."',nulli_lista='".$vnpl[$i]."',solo_lista='".$slpl[$i]."' where num_lista='$i' and id_sez='$id_sez'";
|
---|
145 | $res = $dbi->prepare("$sql");
|
---|
146 | $res->execute();
|
---|
147 | }
|
---|
148 |
|
---|
149 | }else{
|
---|
150 |
|
---|
151 | $sql="select num_lista,id_lista from ".$prefix."_ele_lista where id_cons='$id_cons' $iscirco";
|
---|
152 | $result = $dbi->prepare("$sql");
|
---|
153 | $result->execute();
|
---|
154 | while(list($i,$idl)=$result->fetch(PDO::FETCH_NUM)){
|
---|
155 | $sql="insert into ".$prefix."_ele_voti_lista values('$id_cons','$idl','$id_sez','$i','".$voti[$i]."','".$vnpl[$i]."','".$slpl[$i]."')";
|
---|
156 | $res = $dbi->prepare("$sql");
|
---|
157 | $res->execute();
|
---|
158 | }
|
---|
159 | }
|
---|
160 | }
|
---|
161 | include("ele_controlli.php");
|
---|
162 | controllo_votil($id_cons,$id_sez,$id_lista);
|
---|
163 | include("ele_colora_sez.php");
|
---|
164 | if ($fileout) fclose($fp);
|
---|
165 | }
|
---|
166 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
167 | 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");
|
---|
168 |
|
---|
169 | #################################
|
---|
170 | ?>
|
---|