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 | /************************************************************************/
|
---|
11 | if (!defined('ADMIN_FILE')) {
|
---|
12 | die ("You can't access this file directly...");
|
---|
13 | }
|
---|
14 |
|
---|
15 | $perms=ChiSei($id_cons_gen);
|
---|
16 | if (($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!");
|
---|
17 | $res = mysql_query("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'" , $dbi);
|
---|
18 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
19 | if (isset($_GET['aid2'])) get_magic_quotes_gpc() ? $aid2=$param['aid2']:$aid2=addslashes($param['aid2']); else {if ($perms==256) $aid2='admin'; else $aid2='';}
|
---|
20 | if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='';
|
---|
21 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
22 | if (isset($_GET['name'])) get_magic_quotes_gpc() ? $name=$param['name']:$name=addslashes($param['name']); else $name='';
|
---|
23 | if (isset($_GET['email'])) get_magic_quotes_gpc() ? $email=$param['email']:$email=addslashes($param['email']); else $email='';
|
---|
24 | if (isset($_GET['passwd'])) get_magic_quotes_gpc() ? $passwd=$param['passwd']:$passwd=addslashes($param['passwd']); else $passwd='';
|
---|
25 | if (isset($_GET['passwd2'])) get_magic_quotes_gpc() ? $passwd2=$param['passwd2']:$passwd2=addslashes($param['passwd2']); else $passwd2='';
|
---|
26 |
|
---|
27 | include("modules/Elezioni/funzionidata.php");
|
---|
28 | include("modules/Elezioni/ele.php");
|
---|
29 |
|
---|
30 | /******************************************************/
|
---|
31 | /*Funzione di visualizzazione globale */
|
---|
32 | /*****************************************************/
|
---|
33 | //crea la pagina delle affluenze
|
---|
34 | function all() {
|
---|
35 | global $aid, $offset, $prefix, $dbi,$id_cons,$aid2,$id_sede,$id_cons_gen,$mex,$perms;
|
---|
36 | //echo $perms;die();
|
---|
37 | $bgcolor1=$_SESSION['bgcolor1'];
|
---|
38 | $id_comune=$_SESSION['id_comune'];
|
---|
39 | $user=$aid;
|
---|
40 | $rescom = mysql_query("select descrizione from ".$prefix."_ele_comuni where id_comune=$id_comune",$dbi);
|
---|
41 | list($descr_com) = mysql_fetch_row($rescom);
|
---|
42 | $resmod = mysql_query("SELECT aid,name,email FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'", $dbi);
|
---|
43 | list ($aid2,$name,$email) = mysql_fetch_row($resmod);
|
---|
44 | if (isset($_GET['mex'])){
|
---|
45 | echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
|
---|
46 | echo $_GET['mex'];
|
---|
47 | echo "</td></tr></table>";
|
---|
48 | }
|
---|
49 | # OpenTable();
|
---|
50 | echo "<table>";
|
---|
51 | $esiste=0;
|
---|
52 | echo "<tr><td>";
|
---|
53 | echo "<form name=\"autorizza\" action=\"admin.php\">";
|
---|
54 | echo "<table style=\"color: #000000;\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
55 | echo "<td><b>"._UTENTE."</b></td>";
|
---|
56 | $resins = mysql_query("select aid from ".$prefix."_authors where id_comune='$id_comune' order by aid",$dbi);
|
---|
57 | echo "</tr><tr align=\"center\">";
|
---|
58 | echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=\">";
|
---|
59 | echo "<select name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
|
---|
60 | echo "<option value=\"\">";
|
---|
61 | while(list($utente)=mysql_fetch_row($resins)){
|
---|
62 | $sel= ($utente == $aid2) ? "selected":"";
|
---|
63 | echo "<option value=\"$utente\" $sel>$utente";
|
---|
64 | if($utente=="admin") $esiste=1;
|
---|
65 | }
|
---|
66 | echo "</select></td>";
|
---|
67 | echo "</tr></table></form><br><hr>";
|
---|
68 | $resmod = mysql_query("SELECT * FROM ".$prefix."_authors where id_cons='$id_cons' and id_comune='$id_comune'", $dbi);
|
---|
69 | echo "<form name=\"modello\" action=\"admin.php\">";
|
---|
70 | echo "<table style=\"color: #000000;\">";
|
---|
71 | if ($perms==256) echo "<tr><td colspan=\"6\">"._NOTAOP." <b>$descr_com</b><hr></td></tr>";
|
---|
72 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
73 | echo "<td><b>"._UTENTE."</b></td>";
|
---|
74 | echo "<td><b>"._PASSWORD."</b></td>";
|
---|
75 | echo "<td><b>"._RIPETI."</b></td>";
|
---|
76 | echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>"
|
---|
77 | ."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>";
|
---|
78 | echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
79 | echo "<tr align=\"center\"><td>";
|
---|
80 | echo "<input type=\"hidden\" name=\"op\" value=\"operatori\">"
|
---|
81 | ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
82 | if ($perms==256 and $aid2==''){
|
---|
83 | if($esiste) $supadm=''; else $supadm='admin';
|
---|
84 | echo "<input name=\"aid2\" value=\"$supadm\"></td>";
|
---|
85 | }else
|
---|
86 | echo "<input name=\"aid2\" value=\"$aid2\"></td>";
|
---|
87 | echo "<td align=\"center\"><input type=password name=\"passwd\" size=\"12\"></td>";
|
---|
88 | echo "<td align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>";
|
---|
89 | echo "<td><input name=\"name\" value=\"$name\"></td>";
|
---|
90 | echo "<td><input name=\"email\" value=\"$email\">";
|
---|
91 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
92 | echo "<input type=\"hidden\" name=\"ok\" value=0></td>";
|
---|
93 | if ($aid2) {
|
---|
94 | echo "<td><input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
95 | echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr>";
|
---|
96 | }else{
|
---|
97 | echo "<td><input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
98 | echo "<input type=\"submit\" name=\"add\" value=\""._NEW." "._UTENTE."\"></td></tr>";
|
---|
99 | }
|
---|
100 | echo "</table></form><br>";
|
---|
101 |
|
---|
102 | CloseTable();
|
---|
103 | }
|
---|
104 |
|
---|
105 | function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune) {
|
---|
106 | global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
|
---|
107 | $perms=ChiSei($id_cons_gen);
|
---|
108 |
|
---|
109 | if ($perms!=256) $id_comune=$_SESSION['id_comune'];
|
---|
110 | if ($perms>32 and $aid2) {
|
---|
111 | if ($do == "add") {
|
---|
112 | $sql="select * from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
|
---|
113 | $res=mysql_query($sql,$dbi);
|
---|
114 | $max=mysql_num_rows($res);
|
---|
115 | if ($passwd==$passwd2 and $max==0){
|
---|
116 | if ($aid2=='admin') $super='1,0,0,'; else $super = '0,1,0,';
|
---|
117 | $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')";
|
---|
118 | $result = mysql_query($sql, $dbi)||die("Errore 1301: Non e' stato possibile inserire l'utente!<br>$sql<br>".mysql_error());
|
---|
119 | if ($perms==256 and $aid2=='admin'){
|
---|
120 | $result = mysql_query("insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid) values ('0','0','$id_comune','64','$aid2')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
121 | }
|
---|
122 | Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
|
---|
123 | }else{
|
---|
124 | $mex='';
|
---|
125 | if($passwd!=$passwd2) $mex="- Le password non coincidono! -<br>";
|
---|
126 | if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - ";
|
---|
127 | header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex");
|
---|
128 | }
|
---|
129 | } elseif ($do == "update") {
|
---|
130 | $result = mysql_query("update ".$prefix."_authors set name='$name',pwd='".md5($passwd)."', email='$email' where id_comune='$id_comune' and aid='$aid2' ", $dbi);
|
---|
131 | if (!$result) return;
|
---|
132 | if ($aid2==$aid) $_SESSION['pwd']=md5($passwd);
|
---|
133 | Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
|
---|
134 | }
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | //****************************
|
---|
140 | // switch
|
---|
141 | //****************************
|
---|
142 | if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune);
|
---|
143 | ele();
|
---|
144 | all();
|
---|
145 | echo"</td></tr></table>";
|
---|
146 | include("footer.php");
|
---|
147 | ?>
|
---|
148 |
|
---|