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=intval($param['id_cons_gen']);
|
---|
24 | $perms=ChiSei($id_cons_gen);
|
---|
25 | if ($perms<32 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
26 | $id_comune=$_SESSION['id_comune'];
|
---|
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);
|
---|
28 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
29 |
|
---|
30 | include("modules/Elezioni/funzionidata.php");
|
---|
31 | include("modules/Elezioni/ele.php");
|
---|
32 |
|
---|
33 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
34 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
35 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
|
---|
36 | if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
|
---|
37 | if (isset($param['id_circ'])) {$id_circ=intval($param['id_circ']); $_SESSION['id_circ']=$id_circ;} else
|
---|
38 | if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='';
|
---|
39 | if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
|
---|
40 | if (isset($param['num_gruppo'])) $num_gruppo=intval($param['num_gruppo']); else $num_gruppo='';
|
---|
41 | if (isset($param['descr_gruppo'])) get_magic_quotes_gpc() ? $descr_gruppo=$param['descr_gruppo']:$descr_gruppo=addslashes($param['descr_gruppo']); else $descr_gruppo='';
|
---|
42 | if (isset($param['simbolo'])) get_magic_quotes_gpc() ? $simbolo=$param['simbolo']:$simbolo=addslashes($param['simbolo']); else $simbolo='';
|
---|
43 | if (isset($param['delsimb'])) get_magic_quotes_gpc() ? $delsimb=$param['delsimb']:$delsimb=addslashes($param['delsimb']);
|
---|
44 | if (isset($param['delprog'])) get_magic_quotes_gpc() ? $delprog=$param['delprog']:$delprog=addslashes($param['delprog']);
|
---|
45 | /******************************************************/
|
---|
46 | /*Funzione di visualizzazione globale */
|
---|
47 | /*****************************************************/
|
---|
48 | function all() {
|
---|
49 | global $delsimb,$delprog,$tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$id_circ,$do,$id_gruppo;
|
---|
50 | $res = mysql_query("SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'", $dbi);
|
---|
51 | list($cons_circ)= mysql_fetch_row($res);
|
---|
52 | if($cons_circ)
|
---|
53 | {
|
---|
54 | echo "<form name=\"circo\" action=\"admin.php\" method=\"post\">";
|
---|
55 | echo "<br><table border=\"1\" width=\"50%\" ><tr bgcolor=\"$bgcolor1\"><td>"._SCEGLI_CIRCO.": </td>";
|
---|
56 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons'", $dbi);
|
---|
57 | echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=gruppo&id_cons_gen=$id_cons_gen&id_circ=\">";
|
---|
58 | echo "<td><select name=\"id_circ\" onChange=\"top.location.href=this.form.pag.value+this.form.id_circ.options[this.form.id_circ.selectedIndex].value;return false\">";
|
---|
59 | echo "<option value=\"\">";
|
---|
60 | while($arr=mysql_fetch_array($res,3)){
|
---|
61 | if (!$id_circ) $id_circ=$arr['id_circ'];
|
---|
62 | $sel= ($arr['id_circ'] == $id_circ) ? "selected":"";
|
---|
63 | echo "<option value=\"".$arr['id_circ']."\" $sel>".$arr['descrizione'];
|
---|
64 | }
|
---|
65 | echo "</select></td></tr></table></form>";
|
---|
66 | }
|
---|
67 | echo "<center><font class=\"title\"><b>"._GRUPPO."</b></font><br>";
|
---|
68 |
|
---|
69 | echo "<table border=\"0\" width=\"100%\"><tr bgcolor=\"$bgcolor1\"><td colspan=\"5\">";
|
---|
70 | echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" action=\"admin.php\" method=\"post\">"
|
---|
71 | ."<input type=\"hidden\" name=\"op\" value=\"gruppo\">";
|
---|
72 | echo "<table><tr>"
|
---|
73 | ."<td align=\"center\"width=\"5%\"><b>"._NUM."</b></td>"
|
---|
74 | ."<td align=\"center\"><b>"._DESCR."</b></td>"
|
---|
75 | ."<td align=\"center\"width=\"5%\"><b>"._SIMBOLO."</b>";
|
---|
76 | if ($do=='modify')
|
---|
77 | echo "<br><input type=\"checkbox\" name=\"delsimb\" value=\"false\"> "._DELETE;
|
---|
78 | echo "</td>";
|
---|
79 |
|
---|
80 | if ($tipo_cons!=2) {
|
---|
81 | echo "<td align=\"center\"width=\"5%\"><b>"._PROGRAM."</b>";
|
---|
82 | if ($do=='modify')
|
---|
83 | echo "<br><input type=\"checkbox\" name=\"delprog\" value=\"false\"> "._DELETE;
|
---|
84 | echo "</td>";
|
---|
85 | }
|
---|
86 | echo "<td align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
87 | //-----------------------visualizza riga superiore per inserimento -
|
---|
88 | $circo= $cons_circ==1 ? "and id_circ='$id_circ'":"";
|
---|
89 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
|
---|
90 | $max = mysql_num_rows($res);
|
---|
91 | $nuovo_gruppo=$max+1;
|
---|
92 | echo "<tr><td>";
|
---|
93 | if ($do=='modify') {
|
---|
94 | $resl = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
95 | $gru=mysql_fetch_array($resl);
|
---|
96 | $nuovo_gruppo=$gru['num_gruppo'];
|
---|
97 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
98 | }else{
|
---|
99 | $gru['id_gruppo']='';$gru['descrizione']='';
|
---|
100 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
101 | }
|
---|
102 |
|
---|
103 | //-----------------------fine visualizza riga superiore per inserimento -
|
---|
104 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
105 | ."<input type=\"hidden\" name=\"id_gruppo\" value=\"".$gru['id_gruppo']."\">"
|
---|
106 | ."<input type=\"text\" name=\"num_gruppo\" value=\"$nuovo_gruppo\" size=\"5\"></td>"
|
---|
107 | ."<td><input type=\"text\" name=\"descr_gruppo\" value=\"".$gru['descrizione']."\"></td>";
|
---|
108 | echo "<td><input type=\"file\" name=\"stemma\" size=\"5\"></td>"; //file=$gru[simbolo]
|
---|
109 | if ($tipo_cons!=2)
|
---|
110 | echo "<td><input type=\"file\" name=\"programma\" size=\"5\">";
|
---|
111 | echo "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
112 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
113 | echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">";
|
---|
114 | echo "<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
|
---|
115 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
116 | ."<input type=\"hidden\" name=\"min\" value=\"$min\"></td>";
|
---|
117 | if ($do=='modify')
|
---|
118 | echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
|
---|
119 | else
|
---|
120 | echo "<td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td>";
|
---|
121 | echo "</tr></table></form>";
|
---|
122 | echo "</td></tr>";
|
---|
123 |
|
---|
124 |
|
---|
125 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
|
---|
126 | $max = mysql_num_rows($res);
|
---|
127 | $result = mysql_query("select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo LIMIT $min,$offset", $dbi);
|
---|
128 | while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo,,, $prognome) = mysql_fetch_row($result)) {
|
---|
129 | $restemp = mysql_query("select count(0) from ".$prefix."_ele_lista where id_gruppo='$id_gruppo'", $dbi);
|
---|
130 | list($numtemp)=mysql_fetch_row($restemp);
|
---|
131 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
132 | if (!$simbolo) $simbolo="nulla.jpg";
|
---|
133 | echo "<tr bgcolor=\"$bgcolor1\"><td align=\"center\"><b>$num_gruppo</b></td>"
|
---|
134 | ."<td align=\"left\"><b>$descr_gruppo</b></td>";
|
---|
135 | echo "<td align=\"center\"><b>
|
---|
136 | <img src=\"admin.php?op=foto&id_gruppo=$id_gruppo\" width=\"50\" height=\"50\" alt=\"foto\"></b></td>";
|
---|
137 | if ($tipo_cons!=2)
|
---|
138 | echo "<td>$prognome</td>";
|
---|
139 | echo "<td align=\"center\" nowrap>";
|
---|
140 | echo "[<a
|
---|
141 | href=\"admin.php?op=gruppo&do=modify&id_gruppo=$id_gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ&min=$min\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
142 | border=\"0\" align=\"middle\" alt=\"edit\"> "._EDIT."</a>]";
|
---|
143 | if (!$numtemp)
|
---|
144 | echo "[<a href=\"admin.php?op=gruppo&do=delete&id_gruppo=$id_gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ&descr_gruppo=$descr_gruppo&min=$min\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"middle\" alt=\"delete\"></a>]";
|
---|
145 | else
|
---|
146 | echo " ["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"middle\" alt=\"delete\">]";
|
---|
147 | echo "</td></tr>";
|
---|
148 | }
|
---|
149 | echo "</table></center>";
|
---|
150 |
|
---|
151 | // #'Pagina precedente' e 'Pagina Successiva'
|
---|
152 |
|
---|
153 | echo"<table align=\"center\" width=\"100%\" ><tr>";
|
---|
154 | $prev=$min-$offset;
|
---|
155 | if ($prev>=0) {
|
---|
156 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=gruppo&id_gruppo=$id_gruppo&id_cons_gen=$id_cons_gen&id_comune=$id_comune&min=$prev\">";
|
---|
157 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
158 | }
|
---|
159 |
|
---|
160 | $next=$min+$offset;
|
---|
161 | if ($next>=($offset-1)) {
|
---|
162 | if($next>=$max) $next = $max;
|
---|
163 | else {
|
---|
164 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=gruppo&id_gruppo=$id_gruppo&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
165 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
166 | }
|
---|
167 | }
|
---|
168 | echo "</tr></table><br>";
|
---|
169 |
|
---|
170 | }
|
---|
171 |
|
---|
172 | //***********************************************************
|
---|
173 | //Funzione di inserimento e gestione dei gruppi
|
---|
174 | //************************************************************
|
---|
175 |
|
---|
176 | function gruppo($ok, $do,$id_gruppo,$num_gruppo,$descr_gruppo, $simbolo,$id_circ) {
|
---|
177 | global $delsimb,$delprog,$prefix, $dbi, $id_cons,$simbolo2,$genere,$id_cons_gen,$id_comune,$min;
|
---|
178 | $aid=$_SESSION['aid'];
|
---|
179 | $perms=ChiSei($id_cons_gen);
|
---|
180 | if ($perms >16) {
|
---|
181 | if ($do == "delete") {
|
---|
182 | if ($ok !="1") {
|
---|
183 | ele();
|
---|
184 | echo "<center><br><br>"._DOMCANCELLA." "._GRUPPO." $descr_gruppo ?<br>";
|
---|
185 | echo "[ <a href=\"admin.php?op=gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ\">"._NO."</a> ] - [<a href=\"admin.php?op=gruppo&do=delete&id_gruppo=$id_gruppo&id_cons_gen=$id_cons_gen&id_comune=$id_comune&min=$min&ok=1\">"._YES."</a> ]";exit;
|
---|
186 | }else{
|
---|
187 | $reslis = mysql_query("select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo'", $dbi);
|
---|
188 | while (list($idlst)=mysql_fetch_row($reslis)){
|
---|
189 | $rescan = mysql_query("select id_cand from ".$prefix."_ele_candidato where id_lista='$idlst'", $dbi);
|
---|
190 | while (list($idcnd)=mysql_fetch_row($rescan)){
|
---|
191 | mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cand='$idcnd'");
|
---|
192 | mysql_query("delete from ".$prefix."_ele_candidati where id_cand='$idcnd'");
|
---|
193 | }
|
---|
194 | mysql_query("delete from ".$prefix."_ele_voti_lista where id_lista='$idlst'");
|
---|
195 | mysql_query("delete from ".$prefix."_ele_lista where id_lista='$idlst'");
|
---|
196 | }
|
---|
197 | $result = mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
198 | $result = mysql_query("delete from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
199 | if (!$result) return;
|
---|
200 | Header("Location: admin.php?op=gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ&min=$min");
|
---|
201 | }
|
---|
202 | } elseif ($do == "add") {
|
---|
203 | if ($descr_gruppo) {
|
---|
204 | $stemmablob='';
|
---|
205 | $stemmanome='';
|
---|
206 | $STEMM=$_FILES['stemma'];
|
---|
207 | $filestemma=$STEMM['tmp_name'];
|
---|
208 | $nomestemma=$STEMM['name'];
|
---|
209 | if ($filestemma){
|
---|
210 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
211 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
212 | fclose ($fdstemma);
|
---|
213 | $stemmablob=addslashes($stemmacontents);
|
---|
214 | $stemmanome=addslashes($nomestemma);
|
---|
215 | }
|
---|
216 |
|
---|
217 | $progblob='';
|
---|
218 | $prognome='';
|
---|
219 | $PROG=$_FILES['programma'];
|
---|
220 | $fileprog=$PROG['tmp_name'];
|
---|
221 | $nomeprog=$PROG['name'];
|
---|
222 | if ($fileprog){
|
---|
223 | $fdprog = fopen ("$fileprog", "rb");
|
---|
224 | $progcontents = fread ($fdprog, filesize ("$fileprog"));
|
---|
225 | fclose ($fdprog);
|
---|
226 | $progblob=addslashes($progcontents);
|
---|
227 | $prognome=addslashes($nomeprog );
|
---|
228 | }
|
---|
229 | $result = mysql_query("insert into ".$prefix."_ele_gruppo (id_cons,id_gruppo,num_gruppo,descrizione,simbolo,stemma,id_circ,prognome,programma) values ('$id_cons','$id_gruppo','$num_gruppo','$descr_gruppo','$stemmanome','$stemmablob','$id_circ','$prognome','$progblob')", $dbi);
|
---|
230 | if (!$result) return;
|
---|
231 | Header("Location: admin.php?op=gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ&min=$min");
|
---|
232 | } else {
|
---|
233 | ele();
|
---|
234 | OpenTable();
|
---|
235 | echo "<center>"._GESTIONE." "._GRUPPO." ";
|
---|
236 | echo "<br><br><a href=\"admin.php?op=gruppo&id_cons_gen=$id_cons_gen&min=$min\">"._IMM." "._GRUPPO."</a></center>";
|
---|
237 | CloseTable();
|
---|
238 | }
|
---|
239 | } elseif ($do == "update") {
|
---|
240 | $progblob='';
|
---|
241 | $prognome='';
|
---|
242 | $PROG=$_FILES['programma'];
|
---|
243 | $fileprog=$PROG['tmp_name'];
|
---|
244 | $nomeprog=$PROG['name'];
|
---|
245 | if ($fileprog){
|
---|
246 | $fdprog = fopen ("$fileprog", "rb");
|
---|
247 | $progcontents = fread ($fdprog, filesize ("$fileprog"));
|
---|
248 | fclose ($fdprog);
|
---|
249 | $progblob=addslashes($progcontents);
|
---|
250 | $prognome=addslashes($nomeprog );
|
---|
251 | $cond=", prognome='$prognome', programma='$progblob'";
|
---|
252 | } else {
|
---|
253 | if ( $delprog=='false') $cond=", prognome='', programma=''";
|
---|
254 | else $cond='';
|
---|
255 | }
|
---|
256 |
|
---|
257 |
|
---|
258 |
|
---|
259 | $stemmablob='';
|
---|
260 | $stemmanome='';
|
---|
261 | $STEMM=$_FILES['stemma'];
|
---|
262 | $filestemma=$STEMM['tmp_name'];
|
---|
263 | $nomestemma=$STEMM['name'];
|
---|
264 | if ($filestemma){
|
---|
265 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
266 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
267 | fclose ($fdstemma);
|
---|
268 | $stemmablob=addslashes($stemmacontents);
|
---|
269 | $stemmanome=addslashes($nomestemma);
|
---|
270 | $cond2=", simbolo='$stemmanome', stemma='$stemmablob'";
|
---|
271 | } else {
|
---|
272 | if ( $delsimb=='false') $cond2=", simbolo='', stemma=''";
|
---|
273 | else $cond2='';
|
---|
274 | }
|
---|
275 | $result = mysql_query("update ".$prefix."_ele_gruppo set num_gruppo='$num_gruppo' , descrizione='$descr_gruppo' $cond $cond2 where id_gruppo='$id_gruppo' ", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
|
---|
276 | Header("Location: admin.php?op=gruppo&id_cons_gen=$id_cons_gen&id_circ=$id_circ&min=$min");
|
---|
277 | }
|
---|
278 |
|
---|
279 | }
|
---|
280 | }
|
---|
281 |
|
---|
282 | if ($do and $do!="modify")
|
---|
283 | gruppo($ok, $do,$id_gruppo,$num_gruppo,$descr_gruppo,$simbolo, $id_circ);
|
---|
284 | ele();
|
---|
285 | all();
|
---|
286 | echo"</td></tr></table>";
|
---|
287 | include("footer.php");
|
---|
288 |
|
---|
289 |
|
---|
290 |
|
---|
291 |
|
---|
292 | ?>
|
---|