[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 | /************************************************************************/
|
---|
| 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 | $esiste=0;
|
---|
| 51 | echo "<tr><td>";
|
---|
| 52 | echo "<form name=\"autorizza\" action=\"admin.php\">";
|
---|
| 53 | echo "<table><tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 54 | echo "<td><b>"._UTENTE."</b></td>";
|
---|
| 55 | $resins = mysql_query("select aid from ".$prefix."_authors where id_comune='$id_comune' order by aid",$dbi);
|
---|
| 56 | echo "</tr><tr align=\"center\">";
|
---|
| 57 | echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=\">";
|
---|
| 58 | echo "<select name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
|
---|
| 59 | echo "<option value=\"\">";
|
---|
| 60 | while(list($utente)=mysql_fetch_row($resins)){
|
---|
| 61 | $sel= ($utente == $aid2) ? "selected":"";
|
---|
| 62 | echo "<option value=\"$utente\" $sel>$utente";
|
---|
| 63 | if($utente=="admin") $esiste=1;
|
---|
| 64 | }
|
---|
| 65 | echo "</select></td>";
|
---|
| 66 | echo "</tr></table></form><br><hr>";
|
---|
| 67 | $resmod = mysql_query("SELECT * FROM ".$prefix."_authors where id_cons='$id_cons' and id_comune='$id_comune'", $dbi);
|
---|
| 68 | echo "<form name=\"modello\" action=\"admin.php\">";
|
---|
| 69 | echo "<table>";
|
---|
| 70 | if ($perms==256) echo "<tr><td colspan=\"6\">"._NOTAOP." <b>$descr_com</b><hr></td></tr>";
|
---|
| 71 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 72 | echo "<td><b>"._UTENTE."</b></td>";
|
---|
| 73 | echo "<td><b>"._PASSWORD."</b></td>";
|
---|
| 74 | echo "<td><b>"._RIPETI."</b></td>";
|
---|
| 75 | echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>"
|
---|
| 76 | ."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>";
|
---|
| 77 | echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
| 78 | echo "<tr align=\"center\"><td>";
|
---|
| 79 | echo "<input type=\"hidden\" name=\"op\" value=\"operatori\">"
|
---|
| 80 | ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
| 81 | if ($perms==256 and $aid2==''){
|
---|
| 82 | if($esiste) $supadm=''; else $supadm='admin';
|
---|
| 83 | echo "<input name=\"aid2\" value=\"$supadm\"></td>";
|
---|
| 84 | }else
|
---|
| 85 | echo "<input name=\"aid2\" value=\"$aid2\"></td>";
|
---|
| 86 | echo "<td align=\"center\"><input type=password name=\"passwd\" size=\"12\"></td>";
|
---|
| 87 | echo "<td align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>";
|
---|
| 88 | echo "<td><input name=\"name\" value=\"$name\"></td>";
|
---|
| 89 | echo "<td><input name=\"email\" value=\"$email\">";
|
---|
| 90 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 91 | echo "<input type=\"hidden\" name=\"ok\" value=0></td>";
|
---|
| 92 | if ($aid2) {
|
---|
| 93 | echo "<td><input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 94 | echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr>";
|
---|
| 95 | }else{
|
---|
| 96 | echo "<td><input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
| 97 | echo "<input type=\"submit\" name=\"add\" value=\""._NEW." "._UTENTE."\"></td></tr>";
|
---|
| 98 | }
|
---|
| 99 | echo "</table></form><br>";
|
---|
| 100 |
|
---|
| 101 | CloseTable();
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune) {
|
---|
| 105 | global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
|
---|
| 106 | $perms=ChiSei($id_cons_gen);
|
---|
| 107 |
|
---|
| 108 | if ($perms!=256) $id_comune=$_SESSION['id_comune'];
|
---|
| 109 | if ($perms>32 and $aid2) {
|
---|
| 110 | if ($do == "add") {
|
---|
| 111 | $sql="select * from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
|
---|
| 112 | $res=mysql_query($sql,$dbi);
|
---|
| 113 | $max=mysql_num_rows($res);
|
---|
| 114 | if ($passwd==$passwd2 and $max==0){
|
---|
| 115 | if ($aid2=='admin') $super='1,0,0,'; else $super = '0,1,0,';
|
---|
| 116 | $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')";
|
---|
| 117 | $result = mysql_query($sql, $dbi)||die("Errore 1301: Non e' stato possibile inserire l'utente!<br>$sql<br>".mysql_error());
|
---|
| 118 | if ($perms==256 and $aid2=='admin'){
|
---|
| 119 | $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());
|
---|
| 120 | }
|
---|
| 121 | Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
|
---|
| 122 | }else{
|
---|
| 123 | $mex='';
|
---|
| 124 | if($passwd!=$passwd2) $mex="- Le password non coincidono! -<br>";
|
---|
| 125 | if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - ";
|
---|
| 126 | header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex");
|
---|
| 127 | }
|
---|
| 128 | } elseif ($do == "update") {
|
---|
| 129 | $result = mysql_query("update ".$prefix."_authors set name='$name',pwd='".md5($passwd)."', email='$email' where id_comune='$id_comune' and aid='$aid2' ", $dbi);
|
---|
| 130 | if (!$result) return;
|
---|
| 131 | if ($aid2==$aid) $_SESSION['pwd']=md5($passwd);
|
---|
| 132 | Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | //****************************
|
---|
| 139 | // switch
|
---|
| 140 | //****************************
|
---|
| 141 | if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune);
|
---|
| 142 | ele();
|
---|
| 143 | all();
|
---|
| 144 | echo"</td></tr></table>";
|
---|
| 145 | include("footer.php");
|
---|
| 146 | ?>
|
---|
| 147 |
|
---|