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

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

Segue modifiche per la compatibilità php7.x

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