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 | /************************************************************************/
|
---|
11 | if (!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;
|
---|
17 |
|
---|
18 | $aid=$_SESSION['aid'];
|
---|
19 | $dbi=$_SESSION['dbi'];
|
---|
20 | $prefix=$_SESSION['prefix'];
|
---|
21 | $currentlang=$_SESSION['lang'];
|
---|
22 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
23 | $id_cons_gen=$param['id_cons_gen'];
|
---|
24 | $perms=ChiSei($id_cons_gen);
|
---|
25 | if ($perms<32) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
26 |
|
---|
27 | $id_comune=$_SESSION['id_comune'];
|
---|
28 | $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);
|
---|
29 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
30 |
|
---|
31 | include("modules/Elezioni/funzionidata.php");
|
---|
32 | include("modules/Elezioni/ele.php");
|
---|
33 |
|
---|
34 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
35 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
36 | if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
|
---|
37 | if (isset($param['idw'])) $idw=intval($param['idw']); else $idw='';
|
---|
38 | if (isset($param['nome_file'])) get_magic_quotes_gpc() ?
|
---|
39 | $nome_file=$param['nome_file']:$nome_file=addslashes($param['nome_file']); else $nome_file='';
|
---|
40 | if (isset($param['titolo'])) get_magic_quotes_gpc() ?
|
---|
41 | $titolo=$param['titolo']:$titolo=addslashes($param['titolo']); else $titolo='';
|
---|
42 | if (isset($param['pos_or'])) $pos_or=intval($param['pos_or']); else $pos_or='';
|
---|
43 | if (isset($param['pos_ver'])) $pos_ver=intval($param['pos_ver']); else $pos_ver='';
|
---|
44 | if (isset($param['attivo'])) $attivo=intval($param['attivo']); else $attivo='';
|
---|
45 |
|
---|
46 |
|
---|
47 | ############# controllo dei widget
|
---|
48 | make_db_widget(); // crea tabella se non esiste
|
---|
49 | $tlist='';
|
---|
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 |
|
---|
66 | $sql = mysql_query("SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'", $dbi);
|
---|
67 | list($idwid) = mysql_fetch_row($sql);
|
---|
68 | $id = intval($idwid);
|
---|
69 |
|
---|
70 |
|
---|
71 | if (empty($id)) { // inserisce widget db se non esiste
|
---|
72 | $result = mysql_query("insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')", $dbi);
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 | }
|
---|
82 |
|
---|
83 | }
|
---|
84 |
|
---|
85 | # se non esiste cancella dal db
|
---|
86 | $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_widget", $dbi);
|
---|
87 | while ($row = mysql_fetch_array($sql2)) {
|
---|
88 | $esi=0;
|
---|
89 | for ($i=0; $i < sizeof($tlist); $i++) {
|
---|
90 | $files=$tlist[$i];
|
---|
91 | if($row['nome_file']==$files) $esi=1;
|
---|
92 | }
|
---|
93 | if($esi!=1){
|
---|
94 | $del=mysql_query("DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'",$dbi);
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 | /******************************************************/
|
---|
101 | /*Funzione di visualizzazione globale */
|
---|
102 | /*****************************************************/
|
---|
103 | function all() {
|
---|
104 | global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $prefix2, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$tema;
|
---|
105 |
|
---|
106 |
|
---|
107 | $result = mysql_query("SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc", $dbi);
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 | echo "<br><table border=\"0\" width=\"100%\">";
|
---|
114 | echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><b>"._CONFIGWIDGET."</b></td></tr></table>";
|
---|
115 |
|
---|
116 | while ($row = mysql_fetch_array($result)) {
|
---|
117 | echo "<form name=\"widget\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">";
|
---|
118 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
119 | echo "<input type=\"hidden\" name=\"op\" value=\"widget\">";
|
---|
120 | echo "<table style=\"border:0.5px solid; width:100%;\"><tr >";
|
---|
121 | $idw = intval($row['id']);
|
---|
122 | echo "<input type=\"hidden\" name=\"idw\" value=\"$idw\">";
|
---|
123 | $titolo=$row['titolo'];
|
---|
124 | $nome_file=$row['nome_file'];
|
---|
125 | $pos_or = intval($row['pos_or']);
|
---|
126 | $pos_ver = intval($row['pos_ver']);
|
---|
127 | $attivo = intval($row['attivo']);
|
---|
128 | echo "<td><b> Titolo:</b> <input type=\"text\" name=\"titolo\" value=\"".$titolo."\"></td><td>";
|
---|
129 | $sel= ($row['pos_or']==1) ? "selected":"";
|
---|
130 | echo "<b>Posizione :</b><select name=\"pos_or\"><option value=\"0\">Sx<option value=\"1\" $sel>Dx</select>
|
---|
131 | </td><td>
|
---|
132 |
|
---|
133 | <b>Altezza :</b><input type=\"text\" size=\"4\" name=\"pos_ver\" value=\"".$pos_ver."\"></td><td>";
|
---|
134 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | $sel= ($row['attivo']==1) ? "selected":"";
|
---|
139 | echo "<b>"._ATTIVO."</b></td><td><select name=\"attivo\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td>";
|
---|
140 | echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
|
---|
141 | echo "</tr></table>";
|
---|
142 | echo "</form>";
|
---|
143 |
|
---|
144 |
|
---|
145 | } // while
|
---|
146 |
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 | }
|
---|
151 |
|
---|
152 | //***********************************************************
|
---|
153 | //Funzione di inserimento e gestione dei gruppi
|
---|
154 | //************************************************************
|
---|
155 |
|
---|
156 | function confcons() {
|
---|
157 |
|
---|
158 | global $id_cons_gen, $prefix, $dbi,$idw,$titolo,$pos_or,$pos_ver,$attivo;
|
---|
159 |
|
---|
160 |
|
---|
161 | $aid=$_SESSION['aid'];
|
---|
162 | $perms=ChiSei($id_cons_gen);
|
---|
163 | if ($perms >128) {
|
---|
164 |
|
---|
165 | $result = mysql_query("update ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
|
---|
166 | if ($tema2=='facebook')
|
---|
167 | $_SESSION['tema']=$tema2;
|
---|
168 | else $_SESSION['tema']='default';
|
---|
169 | Header("Location: admin.php?id_cons_gen=$id_cons_gen&op=widget");
|
---|
170 |
|
---|
171 | }
|
---|
172 | }
|
---|
173 |
|
---|
174 | if ($do and $do="modify")
|
---|
175 | confcons();
|
---|
176 |
|
---|
177 | ele();
|
---|
178 |
|
---|
179 | all();
|
---|
180 | echo"</td></tr></table>";
|
---|
181 | include("footer.php");
|
---|
182 |
|
---|
183 | //*********************************************************************
|
---|
184 | //Funzione crea db se non esiste
|
---|
185 | //**********************************************************************
|
---|
186 |
|
---|
187 | function make_db_widget(){
|
---|
188 | global $dbi,$prefix;
|
---|
189 | $result = mysql_query("CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
|
---|
190 | `id` int(10) NOT NULL auto_increment,
|
---|
191 | `nome_file` varchar(255) NOT NULL default '',
|
---|
192 | `titolo` varchar(255) NOT NULL default '',
|
---|
193 | `pos_or` int(1) NOT NULL default '1',
|
---|
194 | `pos_ver` int(3) NOT NULL default '0',
|
---|
195 | `attivo` int(1) NOT NULL default '0',
|
---|
196 | PRIMARY KEY (`id`)
|
---|
197 | )",$dbi);
|
---|
198 |
|
---|
199 |
|
---|
200 | }
|
---|
201 |
|
---|
202 |
|
---|
203 | ?>
|
---|
204 |
|
---|