[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 Comuni */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 | if (!defined('ADMIN_FILE')) {
|
---|
| 12 | die ("You can't access this file directly...");
|
---|
| 13 | }
|
---|
| 14 | #foreach($_FILES as $key=>$val) echo $key;die();
|
---|
| 15 | $aid=$_SESSION['aid'];
|
---|
| 16 | $dbi=$_SESSION['dbi'];
|
---|
| 17 | $prefix=$_SESSION['prefix'];
|
---|
| 18 | $id_comune=$_SESSION['id_comune'];
|
---|
| 19 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 20 | $id_cons_gen=intval($param['id_cons_gen']);
|
---|
| 21 | $perms=ChiSei(0);
|
---|
| 22 | //if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 23 | if ($perms!=256) die("$perms Non hai i permessi per inserire dati!");
|
---|
| 24 | if (isset($param['desc'])) get_magic_quotes_gpc() ? $desc=$param['desc']:$desc=addslashes($param['desc']); else $desc='';
|
---|
| 25 | if (isset($param['indirizzo'])) get_magic_quotes_gpc() ? $indirizzo=$param['indirizzo']:$indirizzo=addslashes($param['indirizzo']); else $indirizzo='';
|
---|
| 26 | if (isset($param['centralino'])) get_magic_quotes_gpc() ? $centralino=$param['centralino']:$centralino=addslashes($param['centralino']); else $centralino='';
|
---|
| 27 | if (isset($param['fax'])) get_magic_quotes_gpc() ? $fax=$param['fax']:$fax=addslashes($param['fax']); else $fax='';
|
---|
| 28 | if (isset($param['email'])) get_magic_quotes_gpc() ? $email=$param['email']:$email=addslashes($param['email']); else $email='';
|
---|
| 29 | if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
|
---|
| 30 | if (isset($param['min'])) $min=intval($param['min']); else $min='';
|
---|
| 31 | if (isset($param['ok'])) $ok=addslashes($param['ok']); else $ok='';
|
---|
[96] | 32 | if (isset($param['fascia'])) $fasciatmp=intval($param['fascia']); else $fasciatmp=0;
|
---|
[2] | 33 | if (isset($param['prov'])) $prov=intval($param['prov']); else $prov=0;
|
---|
| 34 | if (isset($param['simbolo'])) get_magic_quotes_gpc() ? $simbolo=$param['simbolo']:$simbolo=addslashes($param['simbolo']); else $simbolo='';
|
---|
| 35 | if (isset($param['cerca'])) get_magic_quotes_gpc() ? $cerca=$param['cerca']:$cerca=addslashes($param['cerca']); else $cerca='';
|
---|
| 36 |
|
---|
| 37 | $res = mysql_query("SELECT t1.tipo_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_comune='$id_comune' " , $dbi);
|
---|
| 38 | list($tipo_cons) = mysql_fetch_row($res);
|
---|
| 39 | $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
|
---|
| 40 | list($genere) = mysql_fetch_row($res);
|
---|
| 41 | include("modules/Elezioni/funzionidata.php");
|
---|
| 42 | include("modules/Elezioni/ele.php");
|
---|
| 43 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 44 |
|
---|
| 45 | $offset=15;
|
---|
| 46 | if (!isset($min)) $min=0;
|
---|
| 47 |
|
---|
| 48 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | /******************************************************/
|
---|
| 53 | /*Funzione di visualizzazione globale */
|
---|
| 54 | /*****************************************************/
|
---|
| 55 | //crea la pagina delle affluenze
|
---|
| 56 | function all() {
|
---|
[96] | 57 | global $bgcolor1, $bgcolor2, $prefix, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$email,$fasciatmp,$prov,$id_comune2,$id_cons_gen,$cerca;
|
---|
[189] | 58 | if( !isset($id_conf) ) $id_conf=1;
|
---|
[2] | 59 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
| 60 | echo "function controllo_id() {\n";
|
---|
| 61 | echo "var is_num = /^[0-9]+$/;";
|
---|
| 62 | echo "if (document.modello.id_comune2.value.match(is_num)) \n return true;\n";
|
---|
| 63 | echo "else {\n";
|
---|
| 64 | echo "document.modello.id_comune2.bgColor=\"#FF0000\" \n";
|
---|
| 65 | echo "alert ('"._COD_NV."!')\n return false; \n";
|
---|
| 66 | echo "}\n";
|
---|
| 67 | echo "}\n//-->\n";
|
---|
| 68 | echo "</script>\n";
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | $resmod = mysql_query("SELECT id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo FROM ".$prefix."_ele_comuni where descrizione like '$cerca%' order by descrizione", $dbi);
|
---|
| 72 | echo "<table width=\"100%\"><tr><td bgcolor=\"$bgcolor2\"> <form name=\"cerca\" action=\"admin.php\">"
|
---|
| 73 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 74 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 75 | echo "<table>";
|
---|
| 76 | echo "<tr><td><b>"._FILTRO."</b><input name=\"cerca\"></td>";
|
---|
| 77 | echo "<td><input type=\"submit\" name=\"invia\" value=\""._OK."\"></td></tr></table></form></td></tr></table>";
|
---|
| 78 |
|
---|
| 79 | echo "<form name=\"modello\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\" onSubmit=\"return controllo_id()\">"
|
---|
| 80 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 81 | echo "<table width=\"100%\"><tr>";
|
---|
| 82 | echo "<td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td><td><input type=\"file\" name=\"stemma\" size=\"10\"></td>";
|
---|
| 83 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
|
---|
| 84 | if ($desc)
|
---|
| 85 | echo "<td><input type=\"hidden\" name=\"id_comune2\" value=\"$id_comune2\">$id_comune2</td>";
|
---|
| 86 | else
|
---|
| 87 | echo "<td><input name=\"id_comune2\" value=\"$id_comune2\" size=\"4\"></td>";
|
---|
| 88 | echo "</tr>";
|
---|
| 89 | $sel[1]='';$sel[2]='';$sel[3]='';$sel[4]='';$sel[5]='';$sel[6]='';$sel[7]='';$sel[8]='';$sel[9]='';
|
---|
[96] | 90 | $sel[$fasciatmp]='selected';
|
---|
[2] | 91 | if($prov==1) $selpv='selected'; else $selpv='';
|
---|
| 92 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._PROV."</b></td><td><select name=\"prov\"> <option value=\"0\">No<option value=\"1\" $selpv>Si</select></td>";
|
---|
[125] | 93 | echo "<td bgcolor=\"$bgcolor1\"><b>"._DESCR."</b></td><td><input name=\"desc\" value=\"".stripslashes($desc)."\"></td></tr>";
|
---|
| 94 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._INDIRIZZO."</b></td><td><input name=\"indirizzo\" value=\"".stripslashes($indirizzo)."\"></td>";
|
---|
[2] | 95 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CENTRALINO."</b></td><td><input name=\"centralino\" value=\"$centralino\" size=\"6\"></td></tr>";
|
---|
[184] | 96 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._FASCIA."</b></td><td><select name=\"fascia\">";
|
---|
| 97 | $descr2="<";
|
---|
[189] | 98 | $resopt1 = mysql_query("select id_fascia, abitanti from ".$prefix."_ele_fasce where id_conf=1 order by id_fascia", $dbi);
|
---|
[184] | 99 | while(list($id,$descr)=mysql_fetch_row($resopt1)){
|
---|
| 100 | $selid= ($id == $fasciatmp) ? "selected":"";
|
---|
| 101 |
|
---|
| 102 | echo "<option value=\"$id\" $selid>$descr2 $descr";
|
---|
| 103 | $descr2="$descr -";
|
---|
| 104 | }
|
---|
| 105 | echo "</select></td>";
|
---|
| 106 |
|
---|
[2] | 107 | echo "<td bgcolor=\"$bgcolor1\"><b>"._FAX."</b></td><td><input name=\"fax\" value=\"$fax\" size=\"6\"></td></tr>";
|
---|
| 108 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td><td><input name=\"email\" value=\"$email\"></td>";
|
---|
| 109 | echo "<td></td><td><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 110 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 111 | if ($desc) {
|
---|
| 112 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 113 | echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
|
---|
| 114 | }else{
|
---|
| 115 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
| 116 | echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
|
---|
| 117 | }
|
---|
| 118 | $i=1;
|
---|
| 119 | ####
|
---|
| 120 | echo "</table><hr>";
|
---|
| 121 | echo "<table><tr><td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td>";
|
---|
| 122 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
|
---|
| 123 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._PROV."</b></td>";
|
---|
| 124 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DESCR."</b></td>"
|
---|
| 125 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
|
---|
| 126 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._CENTRALINO."</b></td>";
|
---|
| 127 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FAX."</b></td>";
|
---|
| 128 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._EMAIL."</b></td>";
|
---|
| 129 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td></tr>";
|
---|
| 130 |
|
---|
| 131 | ####
|
---|
[96] | 132 | while (list($id_comune2,$desc,$indirizzo,$centralino,$fax,$email,$fasciatmp,$prov,$simbolo) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
|
---|
[2] | 133 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 134 | if (!$simbolo) $simbolo="nulla.jpg";
|
---|
| 135 | $valprov= $prov==0 ? 'No':'Si';
|
---|
| 136 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
| 137 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 138 | echo "<input type=\"hidden\" name=\"do\" value=\"delete\">";
|
---|
| 139 | echo "<input type=\"hidden\" name=\"desc\" value=\"$desc\">";
|
---|
| 140 | echo "<tr align=\"left\" bgcolor=\"$bgcolor1\">";
|
---|
| 141 | echo "<td align=\"center\">
|
---|
| 142 | <img src=\"admin.php?op=foto&id_comune=$id_comune2&prefix=$prefix\" width=\"50\" heigth=\"50\"></td>";
|
---|
| 143 |
|
---|
| 144 | echo "<td width=\"32\"><b>$id_comune2</b></td>";
|
---|
| 145 | echo "<td width=\"32\"><b>$valprov</b></td>";
|
---|
| 146 | echo "<td><b>$desc</b></td>";
|
---|
| 147 | echo "<td><b>$indirizzo</b></td>";
|
---|
| 148 | echo "<td><b>$centralino</b></td>";
|
---|
| 149 | echo "<td><b>$fax</b></td>";
|
---|
| 150 | echo "<td><b>".substr($email,0,15)."...</b></td>";
|
---|
[189] | 151 | $resopt1 = mysql_query("select abitanti from ".$prefix."_ele_fasce where id_fascia=$fasciatmp and id_conf=$id_conf", $dbi);
|
---|
[184] | 152 | list($tmpfascia)=mysql_fetch_row($resopt1);
|
---|
| 153 | $fasciaref=$fasciatmp-1;
|
---|
[189] | 154 | $resopt1 = mysql_query("select abitanti from ".$prefix."_ele_fasce where id_fascia=$fasciaref and id_conf=$id_conf", $dbi);
|
---|
[184] | 155 | if(mysql_num_rows($resopt1)==0) $valfascia="< $tmpfascia";
|
---|
| 156 | else
|
---|
| 157 | {
|
---|
| 158 | list($tmp2fascia)=mysql_fetch_row($resopt1);
|
---|
| 159 | $valfascia="$tmp2fascia - $tmpfascia";
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /*
|
---|
[96] | 163 | switch ($fasciatmp) {
|
---|
[2] | 164 | case '0': $valfascia="-"; break;
|
---|
| 165 | case '1': $valfascia="< 3.000"; break;
|
---|
| 166 | case '2': $valfascia="3.001-10.000"; break;
|
---|
| 167 | case '3':$valfascia="10.001-15.000"; break;
|
---|
| 168 | case '4':$valfascia="15.001-30.000"; break;
|
---|
| 169 | case '5':$valfascia="30.001-100.000"; break;
|
---|
| 170 | case '6':$valfascia="100.001-250.000"; break;
|
---|
| 171 | case '7':$valfascia="250.001-500.000"; break;
|
---|
| 172 | case '8':$valfascia="500.001-1000.000"; break;
|
---|
| 173 | case '9': $valfascia=" >1.000.000"; break;
|
---|
[184] | 174 | } */
|
---|
[2] | 175 | echo "<td><b>$valfascia</b></td>";
|
---|
| 176 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 177 | echo "</td><td nowrap>[<a
|
---|
[96] | 178 | href=\"admin.php?op=inscomuni&desc=$desc&id_comune2=$id_comune2&indirizzo=$indirizzo&centralino=$centralino&fax=$fax&email=$email&fascia=$fasciatmp&prov=$prov&id_cons_gen=$id_cons_gen\"><img align=\"center\" src=\"modules/Elezioni/images/edit.gif\"
|
---|
[2] | 179 | border=\"0\"> "._EDIT."</a>]";
|
---|
| 180 | echo "</tr></form>";
|
---|
| 181 | $i++;
|
---|
| 182 | }
|
---|
| 183 | echo "</table>";
|
---|
| 184 | CloseTable();
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[96] | 187 | function comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune,$fasciatmp,$prov,$simbolo) {
|
---|
[2] | 188 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons_gen,$genere;
|
---|
| 189 | /* if ($do == "delete") {
|
---|
| 190 | if ($ok !="1") {
|
---|
| 191 | // ele($id_cons);operatori
|
---|
| 192 | echo "<center><br><br>"._DOMCANCELLA." "._COMUNE." $desc ?<br>";
|
---|
| 193 | echo "[ <a href=\"admin.php?op=inscomuni&id_comune=$id_comune&desc=$desc\">"._NO."</a> ] - [<a href=\"admin.php?op=inscomuni&do=delete&desc=$desc&id_comune=$id_comune&ok=1\">"._YES."</a> ]";
|
---|
| 194 | }else{
|
---|
| 195 | $result = sql_query("delete from ".$prefix."_ele_comuni where id_comune='$id_comune'", $dbi) || die("<br><br>Errore di eliminazione: ".mysql_error());
|
---|
| 196 | if (!$result) return;
|
---|
| 197 | Header("Location: admin.php?op=inscomuni&id_comune=$id_comune");
|
---|
| 198 | }
|
---|
| 199 | }else*/
|
---|
| 200 | $_SESSION['id_comune']=$id_comune;
|
---|
| 201 | if ($do == "add") {
|
---|
| 202 | if ($desc) {
|
---|
| 203 | $stemmablob='';
|
---|
| 204 | $stemmanome='';
|
---|
| 205 | $STEMM=$_FILES['stemma'];
|
---|
| 206 | $filestemma=$STEMM['tmp_name'];
|
---|
| 207 | $nomestemma=$STEMM['name'];
|
---|
| 208 | $sqlset='';
|
---|
| 209 | if ($filestemma){
|
---|
| 210 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
| 211 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
| 212 | fclose ($fdstemma);
|
---|
| 213 | $stemmablob=addslashes($stemmacontents);
|
---|
| 214 | $stemmanome=addslashes($nomestemma);
|
---|
| 215 | }
|
---|
[96] | 216 | $result = mysql_query("insert into ".$prefix."_ele_comuni (id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo,stemma) values ('$id_comune','$desc','$indirizzo','$centralino','$fax','$email','$fasciatmp','$prov','$stemmanome','$stemmablob')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
[2] | 217 | Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
|
---|
| 218 | } else {
|
---|
| 219 | OpenTable();
|
---|
| 220 | echo "<center>"._GESTIONE." "._OPERATORI." desc=$desc; ";
|
---|
| 221 | echo "<br><br><a href=\"admin.php?op=inscomuni&id_comune=$id_comune\">"._IMM." "._OPERATORI."</a></center>";
|
---|
| 222 | CloseTable();
|
---|
| 223 | }
|
---|
| 224 | }else if ($do == "update") {
|
---|
| 225 | $stemmablob='';
|
---|
| 226 | $stemmanome='';
|
---|
| 227 | $STEMM=$_FILES['stemma'];
|
---|
| 228 | $filestemma=$STEMM['tmp_name'];
|
---|
| 229 | $nomestemma=$STEMM['name'];
|
---|
| 230 | $sqlset='';
|
---|
| 231 | if ($filestemma){
|
---|
| 232 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
| 233 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
| 234 | fclose ($fdstemma);
|
---|
| 235 | $stemmablob=addslashes($stemmacontents);
|
---|
| 236 | $stemmanome=addslashes($nomestemma);
|
---|
| 237 | $cond=", simbolo='$stemmanome', stemma='$stemmablob'";
|
---|
| 238 | } else {$cond='';$stemmanome=''; $stemmablob='';}
|
---|
[96] | 239 | $result = mysql_query("update ".$prefix."_ele_comuni set descrizione='$desc' , indirizzo='$indirizzo', centralino='$centralino', fax='$fax', email='$email', fascia='$fasciatmp',capoluogo='$prov' $cond where id_comune='$id_comune'", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
[2] | 240 | Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
| 245 |
|
---|
| 246 | if ($do)
|
---|
[96] | 247 | comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune2,$fasciatmp,$prov,$simbolo);
|
---|
[2] | 248 | ele();
|
---|
| 249 | all();
|
---|
| 250 | include("footer.php");
|
---|
| 251 |
|
---|
| 252 | ?>
|
---|
| 253 |
|
---|