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
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'];
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");
[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
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
[31]48 $tlist='';
[2]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
[256]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);
[336]69 if(isset($row[0])) {
70 $idwid=$row[0];
71 $id = intval($idwid);
72 } else $id=0;
[2]73
74 if (empty($id)) { // inserisce widget db se non esiste
[256]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(); }
[2]78
79
80
81
82
83
84
85 }
86
87 }
88
89 # se non esiste cancella dal db
[256]90 $sql="SELECT * FROM ".$prefix."_ele_widget";
91 $sth = $dbi->prepare("$sql");
92 $sth->execute();
93 $row2 = $sth->fetchAll();
94 foreach($row2 as $row){
[2]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){
[256]101 $sql="DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'";
102 $sth = $dbi->prepare("$sql");
103 $sth->execute();
[2]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
[256]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();
[2]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>";
[256]126 foreach($row2 as $row) {
[2]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\">";
[53]130 echo "<table style=\"border:0.5px solid; width:100%; color: #000000;\"><tr >";
[2]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":"";
[34]140 echo "<b>Posizione :</b><select name=\"pos_or\"><option value=\"0\">Sx<option value=\"1\" $sel>Dx</select>
[2]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
[256]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();
[38]178
[2]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;
[256]199$sql="CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
[2]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`)
[256]207)";
208$sth = $dbi->prepare("$sql");
209$sth->execute();
[2]210
211
212}
213
214
215?>
216
Note: See TracBrowser for help on using the repository browser.