source: trunk/admin/modules/Elezioni/ele_configurazione.php@ 254

Last change on this file since 254 was 254, checked in by roby, 7 years ago

adeguata la funzione di installazione al php7

File size: 12.3 KB
RevLine 
[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 gruppo */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14
15// Offset - visualizza il numero di elementi per pagina
16$offset=5;
17
18$aid=$_SESSION['aid'];
19$dbi=$_SESSION['dbi'];
20$prefix=$_SESSION['prefix'];
21$currentlang=$_SESSION['lang'];
22$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
23$id_cons_gen=$param['id_cons_gen'];
24$perms=ChiSei($id_cons_gen);
25if ($perms<32) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
26
27$id_comune=$_SESSION['id_comune'];
28$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);
29list($tipo_cons,$id_cons) = mysql_fetch_row($res);
30
31include("modules/Elezioni/funzionidata.php");
32include("modules/Elezioni/ele.php");
33
34if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
35if (isset($param['min'])) $min=intval($param['min']); else $min=0;
36if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
37if (isset($param['blocco'])) get_magic_quotes_gpc() ?
38$blocco=$param['blocco']:$blocco=addslashes($param['blocco']); else $blocco='';
39if (isset($param['tema2'])) get_magic_quotes_gpc() ? $tema2=$param['tema2']:$tema2=addslashes($param['tema2']); else $tema2='';
40if (isset($param['multicomune'])) get_magic_quotes_gpc() ? $multicomune=$param['multicomune']:$multicomune=addslashes($param['multicomune']); else $multicomune='';
41if (isset($param['fileout'])) get_magic_quotes_gpc() ? $fileout=$param['fileout']:$fileout=addslashes($param['fileout']); else $fileout='';
42if (isset($param['prefix2'])) get_magic_quotes_gpc() ? $prefix2=$param['prefix2']:$prefix2=addslashes($param['prefix2']); else $prefix2='';
43if (isset($param['adminmail'])) get_magic_quotes_gpc() ? $adminmail=$param['adminmail']:$adminmail=addslashes($param['adminmail']); else $adminmail='';
44if (isset($param['siteurl'])) get_magic_quotes_gpc() ? $siteurl=$param['siteurl']:$siteurl=addslashes($param['siteurl']); else $siteurl='';
45if (isset($param['sitename'])) get_magic_quotes_gpc() ? $sitename=$param['sitename']:$sitename=addslashes($param['sitename']); else $sitename='';
46if (isset($param['siteistat'])) get_magic_quotes_gpc() ? $siteistat=$param['siteistat']:$siteistat=addslashes($param['siteistat']); else $siteistat='';
47if (isset($param['language2'])) get_magic_quotes_gpc() ? $language2=$param['language2']:$language2=addslashes($param['language2']); else $language2='';
48if (isset($param['flash2'])) get_magic_quotes_gpc() ? $flash2=$param['flash2']:$flash2=addslashes($param['flash2']); else $flash2='';
49if (isset($param['displayerrors'])) $displayerrors=intval($param['displayerrors']); else $displayerrors='0';
50
51if (isset($param['gkey'])) get_magic_quotes_gpc() ? $gkey=$param['gkey']:$gkey=addslashes($param['gkey']); else $gkey='';
52if (isset($param['ed_user'])) get_magic_quotes_gpc() ? $ed_user=$param['ed_user']:$ed_user=addslashes($param['ed_user']); else $ed_user='';
53if (isset($param['googlemaps'])) $googlemaps=intval($param['googlemaps']); else $googlemaps='0';
54if (isset($param['editor'])) $editor=intval($param['editor']); else $editor='0';
[230]55if (isset($param['tema_on'])) $tema_on=intval($param['tema_on']); else $tema_on='0';
56if (isset($param['help'])) $help=intval($param['help']);
[48]57
[247]58
59
[2]60/******************************************************/
61/*Funzione di visualizzazione globale */
62/*****************************************************/
63 function all() {
[48]64 global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $prefix2, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$tema,$language,$help;
[2]65 global $gkey,$ed_user,$googlemaps,$editor,$tema_on;
66// $restemp = mysql_query("select count(0) from ".$prefix."_ele_conf where tema='$tema'", $dbi);
67// list($numtemp)=mysql_fetch_row($restemp);
68
69
[230]70 if (isset($help)) include("language/$language/ele_configurazione.html");
[2]71
72 //-----------------------visualizza riga superiore per inserimento -
73 echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">"
74 ."<input type=\"hidden\" name=\"op\" value=\"confconsiglio\">";
75 $resl = mysql_query("SELECT * FROM ".$prefix."_config", $dbi);
76 $gru=mysql_fetch_array($resl);
77 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
78 echo "<input type=\"hidden\" name=\"op\" value=\"configurazione\">";
[53]79 echo "<br><table style=\"color: #000000;\">";
[2]80 echo "<tr bgcolor=\"$bgcolor2\"><td colspan=\"4\" align=\"center\"><b>"._CONFIGDEFAULT."</b></td></tr><tr><td>&nbsp</td></tr>";
81 echo "<tr><td>";
82 $sel= ($gru['tema_on']==1) ? "selected":"";
83 echo "<b>"._TEMAATTIVO."</b></td><td><select name=\"tema_on\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
84 echo "<td>";
85 echo "<b>"._TEMA."</b></td>";
[247]86 verificatema(); //funzione alla fine del file
87
[2]88 ##########
[247]89
90
[2]91 $resmod = mysql_query("SELECT tema FROM ".$prefix."_ele_temi order by tema", $dbi);
92
[240]93 echo "<td><select name=\"tema2\">\n";
94
[2]95 while (list($desc) = mysql_fetch_row($resmod)){
96 if (!$gru['tema']) $gru['tema']=$desc;
[240]97 $sel= ($gru['tema']==$desc) ? "selected":"";
98 echo "<option value=\"".$desc."\" $sel>".$desc."\n";
99
[2]100 }
101 echo "</select></td></tr>";
102 $sel= ($gru['blocco']==1) ? "selected":"";
103 echo "<tr><td><b>"._BLOCCO."</b></td><td><select name=\"blocco\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
104 $sel= ($gru['flash']==1) ? "selected":"";
105 echo "<td><b>"._FLASH."</b></td><td><select name=\"flash2\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
106 echo "</tr>";
107 $sel= ($gru['multicomune']==1) ? "selected":"";
108 echo "<tr><td><b>"._MULTICOMUNE."</b></td><td><select name=\"multicomune\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
109// echo "<td><b>"._FILEOUT."</b></td><td><input type=\"text\" name=\"fileout\">".$gru['fileout']."</td>";
110# echo "</tr>"
111# ."<tr><td><b>"._PREFIX."</b></td><td><input type=\"text\" name=\"prefix2\" value=\"".$gru['prefix']."\"></td>"
112 echo "<td><b>"._ADMINMAIL."</b></td><td><input type=\"text\" name=\"adminmail\" value=\"".$gru['adminmail']."\"></td></tr>"
113 ."<tr><td><b>"._SITEURL."</b></td><td><input type=\"text\" name=\"siteurl\" value=\"".$gru['siteurl']."\"></td>";
114 echo"<td><b>"._TESTATA."</b></td>";
[240]115 echo "<td><input type=\"file\" name=\"sitelogo\" size=\"10\"></td><td> </td></tr>";
116
117 echo"<td><b>"._SITENAME."</b></td><td><input type=\"text\" name=\"sitename\" value=\"".$gru['sitename']."\"></td></tr>";
118
[2]119 $resmod = mysql_query("SELECT id_comune,descrizione FROM ".$prefix."_ele_comuni order by descrizione", $dbi);
120 echo "<tr><td><b>"._SITEISTAT."</b></td>";
121 echo "<td><select name=\"siteistat\"><option value=\"\">";
122 while (list($id_comune2,$desc) = mysql_fetch_row($resmod)){
123 if (!$gru['siteistat']) $gru['siteistat']=$id_comune2;
124 $sel= ($gru['siteistat']==$id_comune2) ? "selected":"";
125 echo "<option value=\"".$id_comune2."\" $sel>".$desc;
126 }
127 echo "</select></td>";
128
129##########
130 echo "<td><b>"._LANGUAGE."</b></td><td><input type=\"text\" name=\"language2\" value=\"".$gru['language']."\"></td></tr>";
131 $sel= ($gru['googlemaps']==1) ? "selected":"";
132 echo "<tr><td><b>"._GOOGLEMAPS."</b></td><td><select name=\"googlemaps\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
[240]133 /* tolta la chiave
[2]134 echo "<td><b>"._GKEY."</b></td><td><input type=\"text\" name=\"gkey\" value=\"".$gru['gkey']."\"></td></tr>";
[240]135 */
[2]136 $sel= ($gru['editor']==1) ? "selected":"";
[240]137 echo "<td><b>"._EDITOR."</b></td><td><select name=\"editor\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td></tr>";
138
139 /* echo "<td><b>"._EDUSER."</b></td>";
[2]140 echo "<td><select name=\"ed_user\">";
[240]141
[2]142 $sel=$gru['ed_user']=='Admin'? "selected":"";
143 echo "<option value=\"Admin\" $sel>Admin";
144 $sel=$gru['ed_user']=='User'? "selected":"";
145 echo "<option value=\"User\" $sel>User";
146 $sel=$gru['ed_user']=='Eleonline'? "selected":"";
147 echo "<option value=\"Eleonline\" $sel>Eleonline</td></tr>";
[240]148 */
[2]149
150 echo "<tr>";
151
152# $sel= ($gru['displayerrors']==1) ? "selected":"";
153# echo "<td><b>"._DISPLAYERRORS."</b></td><td><select name=\"displayerrors\"><option value=\"0\">No<option value=\"1\" $sel>Si</select>";
154 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
155 echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
156 echo "</tr>";
157 echo "</table>";
158 echo "</form><br>";
159
160 }
161
162//***********************************************************
163//Funzione di inserimento e gestione dei gruppi
164//************************************************************
165
166function confcons() {
167
168 global $id_cons_gen, $prefix, $dbi, $blocco,$tema2,$multicomune,$fileout,$prefix2,$adminmail,$siteurl,$sitename,$siteistat,$language2,$flash2,$displayerrors;
169 global $gkey,$ed_user,$googlemaps,$editor,$tema_on;
170
171 $aid=$_SESSION['aid'];
172 $perms=ChiSei($id_cons_gen);
173 if ($perms >128) {
174 $stemmablob='';
175 $stemmanome='';
176 $STEMM=$_FILES['sitelogo'];
177 $filestemma=$STEMM['tmp_name'];
178 $nomestemma=$STEMM['name'];
179 $sqlset='';
180 if ($filestemma){
181 $fdstemma = fopen ("$filestemma", "rb");
182 $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
183 fclose ($fdstemma);
184 $stemmablob=addslashes($stemmacontents);
185 $stemmanome=addslashes($nomestemma);
186 }
[230]187#displayerrors='$displayerrors',
[31]188#per il momento non Ú usato: , site_logo='$site_logo'
[240]189 $result = mysql_query("update ".$prefix."_config set sitename='$sitename', testata='$stemmablob', nome_testata='$stemmanome', blocco='$blocco', multicomune='$multicomune', language='$language2', siteistat='$siteistat', adminmail='$adminmail', siteurl='$siteurl', flash='$flash2', tema='$tema2',gkey='$gkey',ed_user='$ed_user',googlemaps='$googlemaps',editor='$editor',tema_on='$tema_on'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
[2]190 if ($tema2=='facebook')
191 $_SESSION['tema']=$tema2;
192 else $_SESSION['tema']='default';
193 Header("Location: admin.php?id_cons_gen=$id_cons_gen");
194
195 }
196}
197
198if ($do and $do="modify")
199 confcons();
200
201ele();
202
203all();
204echo"</td></tr></table>";
205include("footer.php");
206
207
[247]208function verificatema(){
209############# verifica tema - presenti nella dir temi
210global $dbi,$prefix;
211 $tlist='';$files='';
212 $path = "../client/temi";
213 $handle=opendir($path);
214 while ($file = readdir($handle)) {
215 $tlist .= "$file ";
216 }
[2]217
[247]218 closedir($handle);
219 $tlist = explode(" ", $tlist);
220 sort($tlist);
[2]221
[247]222 for ($i=0; $i < sizeof($tlist); $i++) {
223 if ( (preg_match('/^([_0-9a-zA-Z]+)([_0-9a-zA-Z]{3})$/',$tlist[$i])) ) $files=$tlist[$i];
224 if($files!=''){
225 $sql = mysql_query("SELECT id FROM ".$prefix."_ele_temi where tema='$files'", $dbi);
[254]226 if($sql){
227 list($idwid) = mysql_fetch_row($sql);
228 $id = intval($idwid);
229 }
[247]230 if (empty($id)) { // inserisce widget db se non esiste
231 $result = mysql_query("insert into ".$prefix."_ele_temi (id,tema) values ( NULL,'$files')", $dbi);
232 }
233 }
234
235
236
237
238
239
240
241
242 }
243
244 # se non esiste cancella dal db
245 $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_temi", $dbi);
246 while ($row = mysql_fetch_array($sql2)) {
247 $esi=0;
248 for ($i=0; $i < sizeof($tlist); $i++) {
249 $files=$tlist[$i];
250 if($row['tema']==$files) $esi=1;
251 }
252 if($esi!=1){
253 $del=mysql_query("DELETE FROM ".$prefix."_ele_tema WHERE id = '$row[id]'",$dbi);
254 }
255 }
256
257################# fine
258
259}
260
261
262
263
264
265
266
[2]267?>
268
Note: See TracBrowser for help on using the repository browser.