source: trunk/admin/modules/Elezioni/ele_widget.php@ 325

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