[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 Permessi */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 |
|
---|
| 12 | if (!defined('ADMIN_FILE')) {
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 17 | $id_cons_gen=$param['id_cons_gen'];
|
---|
| 18 |
|
---|
| 19 | $perms=ChiSei($id_cons_gen);
|
---|
| 20 | if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati ($perms)($id_cons_gen), o non hai scelto la consultazione!");
|
---|
| 21 | $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);
|
---|
| 22 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
| 23 | if (isset($param['aid2'])) get_magic_quotes_gpc() ? $aid2=$param['aid2']:$aid2=addslashes($param['aid2']); else $aid2='';
|
---|
| 24 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
|
---|
| 25 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
| 26 | if (isset($param['permessi'])) get_magic_quotes_gpc() ? $permessi=$param['permessi']:$permessi=addslashes($param['permessi']); else $permessi='';
|
---|
| 27 | if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
|
---|
| 28 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
|
---|
| 29 | if (isset($param['mex'])) get_magic_quotes_gpc() ? $mex=$param['mex']:$mex=addslashes($param['mex']); else $mex='';
|
---|
| 30 |
|
---|
| 31 | include("modules/Elezioni/funzionidata.php");
|
---|
| 32 | include("modules/Elezioni/ele.php");
|
---|
| 33 |
|
---|
| 34 | /******************************************************/
|
---|
| 35 | /*Funzione di visualizzazione globale */
|
---|
| 36 | /*****************************************************/
|
---|
| 37 | //crea la pagina delle affluenze
|
---|
| 38 | function all() {
|
---|
| 39 | global $adminop,$adminsuper,$admincomune,$aid, $offset, $prefix, $dbi,$id_cons,$aid2,$permessi,$id_sede,$id_cons_gen,$id_comune,$mex;
|
---|
| 40 | $bgcolor1=$_SESSION['bgcolor1'];
|
---|
| 41 | if (isset($mex)){
|
---|
| 42 | echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
|
---|
| 43 | echo $mex;
|
---|
| 44 | echo "</td></tr></table>";
|
---|
| 45 | }
|
---|
| 46 | OpenTable();
|
---|
| 47 | $resmod = mysql_query("SELECT * FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid", $dbi);
|
---|
| 48 |
|
---|
| 49 | echo "<br><table><tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 50 | echo "<td><b>"._UTENTE."</b></td>"
|
---|
| 51 | ."<td bgcolor=\"$bgcolor1\"><b>"._SEDE."</b></td>"
|
---|
| 52 | ."<td bgcolor=\"$bgcolor1\"><b>"._PERMESSI."</b></td>";
|
---|
| 53 | echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | $restmp = mysql_query("SELECT aid FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid", $dbi);
|
---|
| 58 | if($restmp) {
|
---|
| 59 | $listmp='';$virg='';
|
---|
| 60 | while (list($artmp) = mysql_fetch_row($restmp)){ //elenco degli operatori gia' autorizzati
|
---|
| 61 | $listmp .= $virg."'".$artmp."'";
|
---|
| 62 | $virg=',';
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | if (!$listmp) $listmp="''";
|
---|
| 67 | $resins = mysql_query("select aid from ".$prefix."_authors where id_comune=$id_comune and (admincomune=1 and aid not in ($listmp)) order by aid",$dbi); // operatori registrati ma non ancora autorizzati
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | echo "<form name=\"autorizza\" action=\"admin.php\">"
|
---|
| 71 | ."<input type=\"hidden\" name=\"op\" value=\"permessi\">";
|
---|
| 72 | echo "<tr align=\"center\">";
|
---|
| 73 | echo "<td><select name=\"aid2\">";
|
---|
| 74 | echo "<option value=\"\">";
|
---|
| 75 | if($resins) {
|
---|
| 76 | while(list($utente)=mysql_fetch_row($resins)){
|
---|
| 77 | echo "<option value=\"$utente\">$utente";
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 | echo "</select></td>";
|
---|
| 81 | $ressede = mysql_query("SELECT id_sede, indirizzo from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
|
---|
| 82 | echo "<td><select name=\"id_sede\">";
|
---|
| 83 | echo "<option value=\"0\"> "._TUTTESEDI;
|
---|
| 84 | if($ressede)
|
---|
| 85 | while(list($id,$descr)=mysql_fetch_row($ressede)){
|
---|
| 86 | $sel= ($id == $id_sede) ? "selected":"";
|
---|
| 87 | $arr[$id]=$descr;
|
---|
| 88 | echo "<option value=\"$id\" $sel>$descr";
|
---|
| 89 | }
|
---|
| 90 | echo "</select></td>";
|
---|
| 91 | echo "<td><select name=\"permessi\">";
|
---|
| 92 | if(!isset($permessi)) $permessi=16;
|
---|
| 93 | $sel=($permessi==32) ? "selected":"";
|
---|
| 94 | echo "<option value=\"32\" $sel>"._IMPOSTA_DATI;
|
---|
| 95 | $sel=($permessi==16) ? "selected":"";
|
---|
| 96 | echo "<option value=\"16\" $sel>"._INSERISCE_DATI;
|
---|
| 97 | $sel=($permessi==0) ? "selected":"";
|
---|
| 98 | echo "<option value=\"0\" $sel>"._SOSPESO;
|
---|
| 99 | echo "</select></td>";
|
---|
| 100 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 101 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 102 | echo "<input type=\"hidden\" name=\"do\" value=\"autorizza\">";
|
---|
| 103 | echo "<td><input type=\"submit\" name=\"add\" value=\""._AGGIUNGI."\"></td></tr></form></table>";
|
---|
| 104 | echo "<br><hr><br><table>";
|
---|
| 105 | if($resmod){
|
---|
| 106 | $i=1;
|
---|
| 107 | while (list($id_cons2,$id_sede2,$id_comunetemp,$perm,$utente) = mysql_fetch_row($resmod)){
|
---|
| 108 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 109 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
| 110 | ."<input type=\"hidden\" name=\"op\" value=\"permessi\">";
|
---|
| 111 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 112 | echo "<input type=\"hidden\" name=\"aid2\" value=\"$utente\">";
|
---|
| 113 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 114 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 115 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 116 | echo "<td align=\"center\" width=\"32\"><b>$utente</b></td>";
|
---|
| 117 | $ressede = mysql_query("SELECT id_sede, indirizzo from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
|
---|
| 118 | echo "<td><select name=\"id_sede\">";
|
---|
| 119 | echo "<option value=\"0\"> "._TUTTESEDI;
|
---|
| 120 | while(list($id,$descr)=mysql_fetch_row($ressede)){
|
---|
| 121 | $sel= ($id == $id_sede2) ? "selected":"";
|
---|
| 122 | $arr[$id]=$descr;
|
---|
| 123 | echo "<option value=\"$id\" $sel>$descr";
|
---|
| 124 | }
|
---|
| 125 | echo "</select></td>";
|
---|
| 126 | echo "<td><select name=\"permessi\">";
|
---|
| 127 | if(!isset($perm)) $perm=16;
|
---|
| 128 | $sel=($perm==32) ? "selected":"";
|
---|
| 129 | echo "<option value=\"32\" $sel>"._IMPOSTA_DATI;
|
---|
| 130 | $sel=($perm==16) ? "selected":"";
|
---|
| 131 | echo "<option value=\"16\" $sel>"._INSERISCE_DATI;
|
---|
| 132 | $sel=($perm==0) ? "selected":"";
|
---|
| 133 | echo "<option value=\"0\" $sel>"._SOSPESO;
|
---|
| 134 | echo "</select></td>";
|
---|
| 135 | echo "<td><input type=\"submit\" name=\"add\" value=\""._OK."\"></td></tr></form>";
|
---|
| 136 | $i++;
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | echo "</table>";
|
---|
| 140 | CloseTable();
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | function permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune) {
|
---|
| 144 | global $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
|
---|
| 145 | $perms=ChiSei($id_cons_gen);
|
---|
| 146 | if ($perms!=256) $id_comune=$_SESSION['id_comune'];
|
---|
| 147 | if ($perms>32 and $permessi<$perms and $aid2) {
|
---|
| 148 | if ($do == "autorizza") {
|
---|
| 149 | $result = mysql_query("insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid) values ('$id_cons','$id_sede','$id_comune','$permessi','$aid2')", $dbi)||die("Errore 1301: Non e' stato possibile inserire l'utente!".mysql_error());
|
---|
| 150 | Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
|
---|
| 151 | } elseif ($do == "update") {
|
---|
| 152 | $result = mysql_query("update ".$prefix."_ele_operatori set id_sede='$id_sede' , permessi='$permessi' where id_cons='$id_cons' and aid='$aid2' ", $dbi);
|
---|
| 153 | if (!$result) return;
|
---|
| 154 | Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | //****************************
|
---|
| 161 | // switch
|
---|
| 162 | //****************************
|
---|
| 163 | if ($do) permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune);
|
---|
| 164 | ele();
|
---|
| 165 | all();
|
---|
| 166 | include("footer.php");
|
---|
| 167 | ?>
|
---|
| 168 |
|
---|