source: trunk/admin/modules/Elezioni/salva_voti.php@ 298

Last change on this file since 298 was 262, checked in by roby, 6 years ago
File size: 5.4 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/************************************************************************/
5/* Modulo salva affluenze */
6/* Amministrazione */
7/************************************************************************/
8session_name('sesadmin');
9 // gestione sessione
10$a = session_id();
11if(empty($a)) session_start();
12if(!$_SESSION['aid'])
13 die ("You can't access this file directly...");
14$aid=$_SESSION['aid'];
15include("../../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
26if (isset($_GET['genere'])) get_magic_quotes_gpc() ? $genere=$_GET['genere']:$genere=addslashes($_GET['genere']); else $genere='';
27if (isset($_GET['id_cons_gen'])) get_magic_quotes_gpc() ? $id_cons_gen=$_GET['id_cons_gen']:$id_cons_gen=addslashes($_GET['id_cons_gen']); else $id_cons_gen='';
28if (isset($_GET['id_cons'])) get_magic_quotes_gpc() ? $id_cons=$_GET['id_cons']:$id_cons=addslashes($_GET['id_cons']); else $id_cons='';
29if (isset($_GET['op'])) get_magic_quotes_gpc() ? $op=$_GET['op']:$op=addslashes($_GET['op']); else $op='';
30if (isset($_GET['id_circ'])) get_magic_quotes_gpc() ? $id_circ=$_GET['id_circ']:$id_circ=addslashes($_GET['id_circ']); else $id_circ='';
31if (isset($_GET['id_sez'])) get_magic_quotes_gpc() ? $id_sez=$_GET['id_sez']:$id_sez=addslashes($_GET['id_sez']); else $id_sez='';
32if (isset($_GET['id_sede'])) get_magic_quotes_gpc() ? $id_sede=$_GET['id_sede']:$id_sede=addslashes($_GET['id_sede']); else $id_sede='';
33if (isset($_GET['validi'])) get_magic_quotes_gpc() ? $validi=$_GET['validi']:$validi=addslashes($_GET['validi']); else $validi='';
34if (isset($_GET['nulli'])) get_magic_quotes_gpc() ? $nulli=$_GET['nulli']:$nulli=intval($_GET['nulli']); else $nulli='';
35if (isset($_GET['bianchi'])) get_magic_quotes_gpc() ? $bianchi=$_GET['bianchi']:$bianchi=addslashes($_GET['bianchi']); else $bianchi='';
36if (isset($_GET['contestati'])) get_magic_quotes_gpc() ? $contestati=$_GET['contestati']:$contestati=addslashes($_GET['contestati']); else $contestati='';
37if (isset($_GET['votinulli'])) get_magic_quotes_gpc() ? $votinulli=$_GET['votinulli']:$votinulli=addslashes($_GET['votinulli']); else $votinulli='01-01-1900';
38if (isset($_GET['id_comune'])) get_magic_quotes_gpc() ? $id_comune=$_GET['id_comune']:$id_comune=addslashes($_GET['id_comune']); else $id_comune='';
39if (isset($_GET['ops'])) get_magic_quotes_gpc() ? $ops=$_GET['ops']:$ops=addslashes($_GET['ops']); else $ops='';
40if (isset($_GET['delete'])) get_magic_quotes_gpc() ? $delete=$_GET['delete']:$delete=addslashes($_GET['delete']); else $delete='';
41
42global $prefix,$id_parz,$genere,$fileout,$id_cons;
43if (!isset($fileout)) $fileout='';
44#if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
45if ($fileout) while (!$fp = fopen($fileout,"a"));
46
47$salvato=0;
48
49##################
50$sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
51$result = $dbi->prepare("$sql");
52$result->execute();
53list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
54$sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
55$result = $dbi->prepare("$sql");
56$result->execute();
57$ar=$result->fetch(PDO::FETCH_BOTH);
58$validilista=$validi-$ar['solo_gruppo'];
59$log_data= date("Y/m/d");
60$log_ora=getdate(time());
61$orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
62
63#if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
64 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] ','validi_lista=$validilista, nulli=$nulli,bianchi=$bianchi','_ele_sezioni')";
65 $res = $dbi->prepare("$sql");
66 $res->execute();
67 $sql="update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', nulli='$nulli',bianchi='$bianchi', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
68 $res = $dbi->prepare("$sql");
69 $res->execute();
70 if ($fileout) fwrite($fp,"$sql;\n");
71/*}else{
72 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','','','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')";
73 $res = $dbi->prepare("$sql");
74 $res->execute();
75 $sql="update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
76 $res = $dbi->prepare("$sql");
77 $res->execute();
78 if ($fileout) fwrite($fp,"$sql;\n"); */
79#}
80include("ele_controlli.php");
81controllo_voti($id_cons,$id_sez);
82include("ele_colora_sez.php");
83
84if ($fileout) fclose($fp);
85$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
86Header("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");
87#################################
88
89
90
91
92
93
94?>
Note: See TracBrowser for help on using the repository browser.