source: trunk/admin/modules/Elezioni/ele_widget.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: 7.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();
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['idw'])) $idw=intval($param['idw']); else $idw='';
37if (isset($param['nome_file'])) get_magic_quotes_gpc() ?
38$nome_file=$param['nome_file']:$nome_file=addslashes($param['nome_file']); else $nome_file='';
39if (isset($param['titolo'])) get_magic_quotes_gpc() ?
40$titolo=$param['titolo']:$titolo=addslashes($param['titolo']); else $titolo='';
41if (isset($param['pos_or'])) $pos_or=intval($param['pos_or']); else $pos_or='';
42if (isset($param['pos_ver'])) $pos_ver=intval($param['pos_ver']); else $pos_ver='';
43if (isset($param['attivo'])) $attivo=intval($param['attivo']); else $attivo='';
44
45
46############# controllo dei widget
47 make_db_widget(); // crea tabella se non esiste
48 $tlist='';
49 $path = "../client/modules/Elezioni/blocchi";
50 $handle=opendir($path);
51 while ($file = readdir($handle)) {
52 $tlist .= "$file ";
53 }
54
55 closedir($handle);
56 $tlist = explode(" ", $tlist);
57 sort($tlist);
58
59 for ($i=0; $i < sizeof($tlist); $i++) {
60 $ext = substr($tlist[$i], strrpos( $tlist[$i], '.' ) + 1 );
61
62 if($ext=="php"){ // verifica estensione php
63 $files=$tlist[$i];
64
65 $sql = "SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'";
66 $sth = $dbi->prepare("$sql");
67 $sth->execute();
68 $row = $sth->fetch(PDO::FETCH_BOTH);
69 if(isset($row[0])) {
70 $idwid=$row[0];
71 $id = intval($idwid);
72 } else $id=0;
73
74 if (empty($id)) { // inserisce widget db se non esiste
75 $sql="insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')";
76 $sth = $dbi->prepare("$sql");
77 $sth->execute(); }
78
79
80
81
82
83
84
85 }
86
87 }
88
89 # se non esiste cancella dal db
90 $sql="SELECT * FROM ".$prefix."_ele_widget";
91 $sth = $dbi->prepare("$sql");
92 $sth->execute();
93 $row2 = $sth->fetchAll();
94 foreach($row2 as $row){
95 $esi=0;
96 for ($i=0; $i < sizeof($tlist); $i++) {
97 $files=$tlist[$i];
98 if($row['nome_file']==$files) $esi=1;
99 }
100 if($esi!=1){
101 $sql="DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'";
102 $sth = $dbi->prepare("$sql");
103 $sth->execute();
104 }
105 }
106
107
108
109/******************************************************/
110/*Funzione di visualizzazione globale */
111/*****************************************************/
112 function all() {
113 global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $prefix2, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$tema;
114
115
116 $sql="SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc";
117 $sth = $dbi->prepare("$sql");
118 $sth->execute();
119 $row2 = $sth->fetchAll();
120
121
122
123
124 echo "<br><table border=\"0\" width=\"100%\">";
125 echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><b>"._CONFIGWIDGET."</b></td></tr></table>";
126 foreach($row2 as $row) {
127 echo "<form name=\"widget\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">";
128 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
129 echo "<input type=\"hidden\" name=\"op\" value=\"widget\">";
130 echo "<table style=\"border:0.5px solid; width:100%; color: #000000;\"><tr >";
131 $idw = intval($row['id']);
132 echo "<input type=\"hidden\" name=\"idw\" value=\"$idw\">";
133 $titolo=$row['titolo'];
134 $nome_file=$row['nome_file'];
135 $pos_or = intval($row['pos_or']);
136 $pos_ver = intval($row['pos_ver']);
137 $attivo = intval($row['attivo']);
138 echo "<td><b> Titolo:</b> <input type=\"text\" name=\"titolo\" value=\"".$titolo."\"></td><td>";
139 $sel= ($row['pos_or']==1) ? "selected":"";
140 echo "<b>Posizione :</b><select name=\"pos_or\"><option value=\"0\">Sx<option value=\"1\" $sel>Dx</select>
141 </td><td>
142
143 <b>Altezza :</b><input type=\"text\" size=\"4\" name=\"pos_ver\" value=\"".$pos_ver."\"></td><td>";
144 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
145
146
147
148 $sel= ($row['attivo']==1) ? "selected":"";
149 echo "<b>"._ATTIVO."</b></td><td><select name=\"attivo\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
150 echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
151 echo "</tr></table>";
152 echo "</form>";
153
154
155 } // while
156
157
158
159
160 }
161
162//***********************************************************
163//Funzione di inserimento e gestione dei gruppi
164//************************************************************
165
166function confcons() {
167
168 global $id_cons_gen, $prefix, $dbi,$idw,$titolo,$pos_or,$pos_ver,$attivo;
169
170
171 $aid=$_SESSION['aid'];
172 $perms=ChiSei($id_cons_gen);
173 if ($perms >128) {
174
175 $sql="update ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'";
176 $sth = $dbi->prepare("$sql");
177 $sth->execute();
178
179 Header("Location: admin.php?id_cons_gen=$id_cons_gen&op=widget");
180
181 }
182}
183
184if ($do and $do="modify")
185 confcons();
186
187ele();
188
189all();
190echo"</td></tr></table>";
191include("footer.php");
192
193//*********************************************************************
194//Funzione crea db se non esiste
195//**********************************************************************
196
197function make_db_widget(){
198global $dbi,$prefix;
199$sql="CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
200 `id` int(10) NOT NULL auto_increment,
201 `nome_file` varchar(255) NOT NULL default '',
202 `titolo` varchar(255) NOT NULL default '',
203 `pos_or` int(1) NOT NULL default '1',
204 `pos_ver` int(3) NOT NULL default '0',
205 `attivo` int(1) NOT NULL default '0',
206 PRIMARY KEY (`id`)
207)";
208$sth = $dbi->prepare("$sql");
209$sth->execute();
210
211
212}
213
214
215?>
216
Note: See TracBrowser for help on using the repository browser.