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

Last change on this file since 336 was 336, checked in by roby, 4 years ago

Admin: prime modifiche per compatibilità con php 7.4

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