[258] | 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';
|
---|
[344] | 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';
|
---|
[258] | 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';
|
---|
[262] | 39 | if (isset($_GET['genere'])) $genere=intval($_GET['genere']); else $genere='0';
|
---|
[344] | 40 | if (isset($_GET['delete'])) $delete=addslashes($_GET['delete']); else $delete='';
|
---|
[258] | 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 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
| 51 | list($id_cons)=$res->fetch(PDO::FETCH_NUM);
|
---|
| 52 | $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'";
|
---|
| 53 | $res = $dbi->prepare("$query");
|
---|
| 54 | $res->execute();
|
---|
| 55 | $righe=$res->rowCount();
|
---|
| 56 | list($id_parz)=$res->fetch(PDO::FETCH_NUM);
|
---|
| 57 | if($righe){ #la riga Ú presente e viene aggiorata
|
---|
| 58 | $arr=$res->fetch(PDO::FETCH_BOTH);
|
---|
| 59 | $sql="update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u',voti_donne='$voti_d',voti_complessivi='$voti_t' where id_parz='$id_parz'";
|
---|
| 60 | $compl = $dbi->prepare("$sql");
|
---|
| 61 | $compl->execute();
|
---|
| 62 | if($compl->rowCount()) $salvato=1;
|
---|
| 63 | if($delete=="true"){
|
---|
| 64 | $sql="delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'";
|
---|
| 65 | $res = $dbi->prepare("$sql");
|
---|
| 66 | $res->execute();
|
---|
| 67 | if($res->rowCount()) $salvato=1;
|
---|
| 68 | }
|
---|
| 69 | }else{ # Ú un nuovo inserimento
|
---|
[307] | 70 | $sql="insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','0','$orario','$data','$voti_u','$voti_d','$voti_t','$id_gruppo')";
|
---|
[258] | 71 | $res = $dbi->prepare("$sql");
|
---|
| 72 | $res->execute();
|
---|
| 73 | if($res->rowCount()) $salvato=1;
|
---|
| 74 | }
|
---|
| 75 | if ($fileout) {
|
---|
| 76 | while (!$fp = fopen($fileout,"a"));
|
---|
| 77 | fwrite($fp,"$sql;\n");
|
---|
| 78 | fclose($fp);
|
---|
| 79 | }
|
---|
| 80 | if($salvato){
|
---|
| 81 | $riga=addslashes($sql);
|
---|
| 82 | $sqlog="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$orario','','$riga','".$prefix."_ele_voti_parziale')";
|
---|
| 83 | $res = $dbi->prepare("$sqlog");
|
---|
| 84 | $res->execute();
|
---|
| 85 | }
|
---|
[262] | 86 | #controllo_aff($id_cons,$id_sez,$id_parz);
|
---|
| 87 | include("ele_controlli.php");
|
---|
| 88 | controllo_aff($id_cons,$id_sez,$id_parz);
|
---|
| 89 | include("ele_colora_sez.php");
|
---|
[258] | 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 | ?>
|
---|