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