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

Last change on this file since 404 was 362, checked in by roby, 3 years ago

Ritocchi e sistemazioni varie di completamento delle mofifiche precedenti

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