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 |
|
---|
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 |
|
---|
27 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
|
---|
28 | if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='0';
|
---|
29 | if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='0';
|
---|
30 | if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='';
|
---|
31 | if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='0';
|
---|
32 | if (isset($_GET['voti_u'])) $voti_u=intval($_GET['voti_u']); else $voti_u='0';
|
---|
33 | if (isset($_GET['voti_d'])) $voti_d=intval($_GET['voti_d']); else $voti_d='0';
|
---|
34 | if (isset($_GET['voti_t'])) $voti_t=intval($_GET['voti_t']); else $voti_t='0';
|
---|
35 | if (isset($_GET['orario'])) $orario=addslashes($_GET['orario']); else $orario='';
|
---|
36 | if (isset($_GET['data'])) $data=addslashes($_GET['data']); else $data='01-01-1900';
|
---|
37 | if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='0';
|
---|
38 | if (isset($_GET['id_gruppo'])) $id_gruppo=intval($_GET['id_gruppo']); else $id_gruppo='0';
|
---|
39 | if (isset($_GET['genere'])) $genere=intval($_GET['genere']); else $genere='0';
|
---|
40 | if (isset($_GET['delete'])) $delete=addslashes($_GET['delete']); else $delete='';
|
---|
41 | global $prefix,$id_parz,$tempo,$username,$aid,$dbi,$genere;
|
---|
42 |
|
---|
43 | if (!isset($fileout)) $fileout='';
|
---|
44 | if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
45 |
|
---|
46 | $salvato=0;
|
---|
47 | $query="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$id_comune'";
|
---|
48 | $res = $dbi->prepare("$query");
|
---|
49 | $res->execute();
|
---|
50 | list($id_cons)=$res->fetch(PDO::FETCH_NUM);
|
---|
51 | $query="select id_parz from ".$prefix."_ele_voti_parziale where data='$data' and orario='$orario' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
52 | $res = $dbi->prepare("$query");
|
---|
53 | $res->execute();
|
---|
54 | $righe=$res->rowCount();
|
---|
55 | list($id_parz)=$res->fetch(PDO::FETCH_NUM);
|
---|
56 | if($righe){ #la riga Ú presente e viene aggiorata
|
---|
57 | $arr=$res->fetch(PDO::FETCH_BOTH);
|
---|
58 | $sql="update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u',voti_donne='$voti_d',voti_complessivi='$voti_t' where id_parz='$id_parz'";
|
---|
59 | $compl = $dbi->prepare("$sql");
|
---|
60 | $compl->execute();
|
---|
61 | if($compl->rowCount()) $salvato=1;
|
---|
62 | if($delete=="true"){
|
---|
63 | $sql="delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'";
|
---|
64 | $res = $dbi->prepare("$sql");
|
---|
65 | $res->execute();
|
---|
66 | if($res->rowCount()) $salvato=1;
|
---|
67 | }
|
---|
68 | }else{ # Ú un nuovo inserimento
|
---|
69 | $sql="insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','0','$orario','$data','$voti_u','$voti_d','$voti_t','$id_gruppo')";
|
---|
70 | $res = $dbi->prepare("$sql");
|
---|
71 | $res->execute();
|
---|
72 | if($res->rowCount()) $salvato=1;
|
---|
73 | }
|
---|
74 | if ($fileout) {
|
---|
75 | while (!$fp = fopen($fileout,"a"));
|
---|
76 | fwrite($fp,"$sql;\n");
|
---|
77 | fclose($fp);
|
---|
78 | }
|
---|
79 | if($salvato){
|
---|
80 | $riga=addslashes($sql);
|
---|
81 | $sqlog="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$orario','','$riga','".$prefix."_ele_voti_parziale')";
|
---|
82 | $res = $dbi->prepare("$sqlog");
|
---|
83 | $res->execute();
|
---|
84 | }
|
---|
85 | #controllo_aff($id_cons,$id_sez,$id_parz);
|
---|
86 | include("ele_controlli.php");
|
---|
87 | controllo_aff($id_cons,$id_sez,$id_parz);
|
---|
88 | include("ele_colora_sez.php");
|
---|
89 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
90 |
|
---|
91 | 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&ops=1&do=spoglio");
|
---|
92 |
|
---|
93 |
|
---|
94 | ?>
|
---|