[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 | $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';
|
---|
[310] | 40 | if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='4';
|
---|
[288] | 41 | if (isset($_GET['sololista'])) $sololista=intval($_GET['sololista']); else $sololista='0';
|
---|
[258] | 42 | if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='';
|
---|
[344] | 43 | if (isset($_GET['circo'])) $circo=addslashes($_GET['circo']); else $circo='';
|
---|
[258] | 44 |
|
---|
| 45 | global $prefix,$id_parz,$fileout;
|
---|
[407] | 46 | $sql="SELECT disgiunto,chiusa FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
[338] | 47 | $res = $dbi->prepare("$sql");
|
---|
| 48 | $res->execute();
|
---|
[407] | 49 | list($disgiunto,$chiusa)=$res->fetch(PDO::FETCH_NUM);
|
---|
[415] | 50 | if($chiusa!=1){
|
---|
[407] | 51 | $sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" ;
|
---|
| 52 | $res = $dbi->prepare("$sql");
|
---|
| 53 | $res->execute();
|
---|
| 54 | list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 55 | $sql="SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
|
---|
| 56 | $res = $dbi->prepare("$sql");
|
---|
| 57 | $res->execute();
|
---|
| 58 | list($circo)=$res->fetch(PDO::FETCH_NUM);
|
---|
[338] | 59 |
|
---|
[407] | 60 | if ($circo) $circo="and id_circ=$id_circ"; else $circo='';
|
---|
| 61 | $sql="select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
|
---|
| 62 | $result = $dbi->prepare("$sql");
|
---|
| 63 | $result->execute();
|
---|
| 64 | while(list($i)=$result->fetch(PDO::FETCH_BOTH)) {
|
---|
| 65 | $vot="voti$i";$solo="solog$i";$grupp="num_gruppo$i";
|
---|
| 66 | if (isset($_GET[$grupp])) $num_gruppo[$i]=intval($_GET[$grupp]); else $num_gruppo[$i]='0';
|
---|
| 67 | if (isset($_GET[$vot]) && $_GET[$vot]) $voti[$i]=intval($_GET[$vot]); else $voti[$i]='0';
|
---|
| 68 | if (isset($_GET[$solo])) $solog[$i]=intval($_GET[$solo]); else $solog[$i]='0';
|
---|
[258] | 69 |
|
---|
[407] | 70 | }
|
---|
[258] | 71 |
|
---|
[407] | 72 | if (!isset($fileout)) $fileout='';
|
---|
| 73 | #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
|
---|
| 74 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
[258] | 75 |
|
---|
[407] | 76 | ##################
|
---|
| 77 | if($do==1) {
|
---|
| 78 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
| 79 | $res = $dbi->prepare("$sql");
|
---|
| 80 | $res->execute();
|
---|
| 81 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
| 82 | $res = $dbi->prepare("$sql");
|
---|
| 83 | $res->execute();
|
---|
| 84 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
| 85 | $res = $dbi->prepare("$sql");
|
---|
| 86 | $res->execute();
|
---|
| 87 | $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'";
|
---|
| 88 | $res = $dbi->prepare("$sql");
|
---|
| 89 | $res->execute();
|
---|
| 90 | }else{
|
---|
| 91 | if($disgiunto){
|
---|
[258] | 92 | }
|
---|
[407] | 93 | $sql="update ".$prefix."_ele_sezioni set solo_lista='$sololista' where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
[258] | 94 | $result = $dbi->prepare("$sql");
|
---|
| 95 | $result->execute();
|
---|
[407] | 96 | $sql="select num_gruppo from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
| 97 | $result = $dbi->prepare("$sql");
|
---|
| 98 | $result->execute();
|
---|
| 99 | if($result->rowCount()) {
|
---|
| 100 | while(list($i)=$result->fetch(PDO::FETCH_NUM)){
|
---|
| 101 | $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]."'";
|
---|
| 102 | $res = $dbi->prepare("$sql");
|
---|
| 103 | $res->execute();
|
---|
| 104 | }
|
---|
| 105 | }else{
|
---|
| 106 | $sql="select num_gruppo,id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
|
---|
| 107 | $result = $dbi->prepare("$sql");
|
---|
| 108 | $result->execute();
|
---|
| 109 | while(list($i,$id_gruppo)=$result->fetch(PDO::FETCH_NUM)){
|
---|
| 110 | $sql="insert into ".$prefix."_ele_voti_gruppo values('$id_cons','$id_gruppo','$id_sez','$i','".$voti[$i]."','".$solog[$i]."')";
|
---|
| 111 | $res = $dbi->prepare("$sql");
|
---|
| 112 | $res->execute();
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[258] | 115 | }
|
---|
[407] | 116 | }
|
---|
| 117 | include("ele_controlli.php");
|
---|
| 118 | controllo_votig($id_cons,$id_sez,$genere);
|
---|
| 119 | include("ele_colora_sez.php");
|
---|
| 120 | if ($fileout) fclose($fp);
|
---|
[258] | 121 | }
|
---|
| 122 | $BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
| 123 | 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");
|
---|
[358] | 124 |
|
---|
[258] | 125 | #################################
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | ?>
|
---|