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

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