source: trunk/admin/modules/Elezioni/ele_operatori.php@ 430

Last change on this file since 430 was 358, checked in by roby, 3 years ago

Admin: aggiunta la funzione di gestione dello spoglio per la singola sezione tramite tema per cellulari

File size: 8.5 KB
RevLine 
[2]1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Roberto Gigli & Luciano Apolito */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8/* Modulo Operatori */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14
15$perms=ChiSei($id_cons_gen);
16if (($perms<64 or !$id_cons_gen) and $perms!=256) die("(($perms<64 or !$id_cons_gen) and $perms!=256)Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
[257]17$sql="SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
18$res = $dbi->prepare("$sql");
19$res->execute();
20list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
[344]21if (isset($_GET['aid2'])) $aid2=addslashes($param['aid2']); else {if ($perms==256) $aid2='admin'; else $aid2='';}
[2]22if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='';
[344]23if (isset($_GET['do'])) $do=addslashes($param['do']); else $do='';
24if (isset($_GET['name'])) $name=addslashes($param['name']); else $name='';
25if (isset($_GET['email'])) $email=addslashes($param['email']); else $email='';
26if (isset($_GET['passwd'])) $passwd=addslashes($param['passwd']); else $passwd='';
27if (isset($_GET['passwd2'])) $passwd2=addslashes($param['passwd2']); else $passwd2='';
[358]28if (isset($_GET['stato']) && $aid2!='admin') $stato=intval($param['stato']); else $stato=0;
[2]29
30include("modules/Elezioni/funzionidata.php");
31include("modules/Elezioni/ele.php");
32
33/******************************************************/
34/*Funzione di visualizzazione globale */
35/*****************************************************/
36//crea la pagina delle affluenze
37function all() {
38 global $aid, $offset, $prefix, $dbi,$id_cons,$aid2,$id_sede,$id_cons_gen,$mex,$perms;
39 //echo $perms;die();
[358]40
[2]41 $bgcolor1=$_SESSION['bgcolor1'];
42 $id_comune=$_SESSION['id_comune'];
43 $user=$aid;
[257]44 $sql="select descrizione from ".$prefix."_ele_comuni where id_comune=$id_comune";
45 $rescom = $dbi->prepare("$sql");
46 $rescom->execute();
47 list($descr_com) = $rescom->fetch(PDO::FETCH_NUM);
[358]48 $sql="SELECT aid,name,email,adminop FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";
[257]49 $resmod = $dbi->prepare("$sql");
50 $resmod->execute();
[358]51 list ($aid2,$name,$email,$attivo) = $resmod->fetch(PDO::FETCH_NUM);
[2]52 if (isset($_GET['mex'])){
53 echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
54 echo $_GET['mex'];
55 echo "</td></tr></table>";
56 }
[53]57# OpenTable();
58 echo "<table>";
[2]59 $esiste=0;
60 echo "<tr><td>";
61 echo "<form name=\"autorizza\" action=\"admin.php\">";
[53]62 echo "<table style=\"color: #000000;\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
[2]63 echo "<td><b>"._UTENTE."</b></td>";
[257]64 $sql="select aid from ".$prefix."_authors where id_comune='$id_comune' order by aid";
65 $resins = $dbi->prepare("$sql");
66 $resins->execute();
[2]67 echo "</tr><tr align=\"center\">";
68 echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&amp;id_cons_gen=$id_cons_gen&amp;aid2=\">";
[358]69 echo "<select id=\"aid2\" name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
70 echo "<option value=\"\">Nuovo Utente";
[257]71 while(list($utente)=$resins->fetch(PDO::FETCH_NUM)){
[2]72 $sel= ($utente == $aid2) ? "selected":"";
73 echo "<option value=\"$utente\" $sel>$utente";
74 if($utente=="admin") $esiste=1;
75 }
76 echo "</select></td>";
77 echo "</tr></table></form><br><hr>";
[257]78# $sql="SELECT * FROM ".$prefix."_authors where id_cons='$id_cons' and id_comune='$id_comune'";
79# $resmod = $dbi->prepare("$sql");
80# $resmod->execute();
[2]81 echo "<form name=\"modello\" action=\"admin.php\">";
[53]82 echo "<table style=\"color: #000000;\">";
[2]83 if ($perms==256) echo "<tr><td colspan=\"6\">"._NOTAOP." <b>$descr_com</b><hr></td></tr>";
84 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
85 echo "<td><b>"._UTENTE."</b></td>";
86 echo "<td><b>"._PASSWORD."</b></td>";
87 echo "<td><b>"._RIPETI."</b></td>";
88 echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>"
89 ."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>";
[358]90 echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
91
92
[2]93 echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
94 echo "<tr align=\"center\"><td>";
95 echo "<input type=\"hidden\" name=\"op\" value=\"operatori\">"
96 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
97 if ($perms==256 and $aid2==''){
98 if($esiste) $supadm=''; else $supadm='admin';
99 echo "<input name=\"aid2\" value=\"$supadm\"></td>";
100 }else
101 echo "<input name=\"aid2\" value=\"$aid2\"></td>";
102 echo "<td align=\"center\"><input type=password name=\"passwd\" size=\"12\"></td>";
103 echo "<td align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>";
104 echo "<td><input name=\"name\" value=\"$name\"></td>";
[358]105 echo "<td><input name=\"email\" value=\"$email\"></td>";
106 if($attivo==0) {$sel2="selected"; $sel3='';} else {$sel2=''; $sel3="selected";}
107 echo "<td><select name=\"stato\"><option value=\"0\" $sel2>Attivo<option value=\"1\" $sel3>Disattivo<option value=\"2\" >Elimina</select>";
[2]108 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
109 echo "<input type=\"hidden\" name=\"ok\" value=0></td>";
110 if ($aid2) {
111 echo "<td><input type=\"hidden\" name=\"do\" value=\"update\">";
112 echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr>";
113 }else{
114 echo "<td><input type=\"hidden\" name=\"do\" value=\"add\">";
115 echo "<input type=\"submit\" name=\"add\" value=\""._NEW." "._UTENTE."\"></td></tr>";
116 }
117 echo "</table></form><br>";
118
119 CloseTable();
120}
121
[358]122function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato) {
[2]123 global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
124 $perms=ChiSei($id_cons_gen);
[358]125 if($passwd!=$passwd2) {
126 $mex="- Le password non coincidono! -<br>";
127 header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex&stato=$stato");
128 }
[2]129
130 if ($perms!=256) $id_comune=$_SESSION['id_comune'];
131 if ($perms>32 and $aid2) {
132 if ($do == "add") {
133 $sql="select * from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
[257]134 $res = $dbi->prepare("$sql");
135 $res->execute();
136 $max=$res->rowCount();
[358]137 if ($max==0){
138 if ($aid2=='admin') $super='0,1,0,'; else $super = '0,0,0,';
139 $sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."','0',$super'$currentlang')";
[257]140 $res = $dbi->prepare("$sql");
141 $res->execute();
[2]142 if ($perms==256 and $aid2=='admin'){
[257]143 $sql="insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid) values ('0','0','$id_comune','64','$aid2')";
144 $res = $dbi->prepare("$sql");
145 $res->execute();
[358]146 }
147 Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2");
[2]148 }else{
149 $mex='';
150 if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - ";
151 }
152 } elseif ($do == "update") {
[358]153 if($passwd!='') $mexpwd="pwd='".md5($passwd)."',"; else $mexpwd='';
154 if($stato==2){
155 $sql="delete from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
156 $res = $dbi->prepare("$sql");
157 $res->execute();
158 }else{
159 $sql="update ".$prefix."_authors set name='$name', $mexpwd email='$email', adminop='$stato' where id_comune='$id_comune' and aid='$aid2' ";
160 $res = $dbi->prepare("$sql");
161 $res->execute();
162 }
[332]163 $result=$res->rowCount();
[358]164 if($stato!=0){
165 $sql="delete from ".$prefix."_ele_operatori where id_comune='$id_comune' and aid='$aid2' ";
166 $res = $dbi->prepare("$sql");
167 $res->execute();
168 }
[2]169 if (!$result) return;
170 if ($aid2==$aid) $_SESSION['pwd']=md5($passwd);
171 Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
172 }
173 }
174}
175
176
177//****************************
178// switch
179//****************************
[358]180 if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato);
[2]181 ele();
182 all();
183 echo"</td></tr></table>";
184 include("footer.php");
185?>
186
Note: See TracBrowser for help on using the repository browser.