1 | <?php
|
---|
2 |
|
---|
3 | /************************************************************************/
|
---|
4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
5 | /* by Roberto Gigli & Luciano Apolito */
|
---|
6 | /* http://www.eleonline.it */
|
---|
7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
8 | /************************************************************************/
|
---|
9 | /* Admin */
|
---|
10 | /* Amministrazione */
|
---|
11 | /************************************************************************/
|
---|
12 |
|
---|
13 | /* Descrizione file admin.php =
|
---|
14 | effettua il login o il rilancio alla gestione */
|
---|
15 |
|
---|
16 | define('ADMIN_FILE', true);
|
---|
17 | #$LIMITE=3; //fascia di separazione del maggioritario (15.000 abitanti)
|
---|
18 | # tempo di sessione: ini_set('session.gc_maxlifetime','3600');
|
---|
19 | global $multicomune,$msglogout,$language,$id_sez;
|
---|
20 |
|
---|
21 | // Adattamento variabili superglobal
|
---|
22 | // Versione di php
|
---|
23 | $phpver = phpversion();
|
---|
24 | global $dbi;
|
---|
25 | // converte superglobal se php e' < 4.1.0
|
---|
26 |
|
---|
27 | if ($phpver < '4.1.0') {
|
---|
28 | $_GET = $HTTP_GET_VARS;
|
---|
29 | $_POST = $HTTP_POST_VARS;
|
---|
30 | $_SERVER = $HTTP_SERVER_VARS;
|
---|
31 | $_FILES = $HTTP_POST_FILES;
|
---|
32 | $_ENV = $HTTP_ENV_VARS;
|
---|
33 | if($_SERVER['REQUEST_METHOD'] == "POST") {
|
---|
34 | $_REQUEST = $_POST;
|
---|
35 | } elseif($_SERVER['REQUEST_METHOD'] == "GET") {
|
---|
36 | $_REQUEST = $_GET;
|
---|
37 | }
|
---|
38 | if(isset($HTTP_COOKIE_VARS)) {
|
---|
39 | $_COOKIE = $HTTP_COOKIE_VARS;
|
---|
40 | }
|
---|
41 | if(isset($HTTP_SESSION_VARS)) {
|
---|
42 | $_SESSION = $HTTP_SESSION_VARS;
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
47 | if (isset($param['aid'])) $aid=addslashes($param['aid']); else $aid='';
|
---|
48 | if (isset($param['pwd'])) $pwd2=addslashes($param['pwd']); else $pwd2='';
|
---|
49 | if(isset($param['msglogout'])) $msglogout=intval($param['msglogout']); else $msglogout=0;
|
---|
50 |
|
---|
51 | // Additional security (Union, CLike, XSS)
|
---|
52 |
|
---|
53 | // We want to use the function stripos,
|
---|
54 | // but thats only available since PHP5.
|
---|
55 | // So we cloned the function...
|
---|
56 | if(!function_exists('stripos')) {
|
---|
57 | function stripos_clone($haystack, $needle, $offset=0) {
|
---|
58 | return strpos(strtoupper($haystack), strtoupper($needle), $offset);
|
---|
59 | }
|
---|
60 | } else {
|
---|
61 | // But when this is PHP5, we use the original function
|
---|
62 | function stripos_clone($haystack, $needle, $offset=0) {
|
---|
63 | return stripos($haystack, $needle, $offset=0);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | if(isset($_SERVER['QUERY_STRING']) && (!stripos_clone($_SERVER['QUERY_STRING'], "ad_click") || !stripos_clone($_SERVER['QUERY_STRING'], "url"))) {
|
---|
68 | $queryString = $_SERVER['QUERY_STRING'];
|
---|
69 | if (stripos_clone($queryString,'%20union%20') OR stripos_clone($queryString,'/*') OR stripos_clone($queryString,'*/union/*') OR stripos_clone($queryString,'c2nyaxb0') OR stripos_clone($queryString,'+union+') OR stripos_clone($queryString,'http://') OR (stripos_clone($queryString,'cmd=') AND !stripos_clone($queryString,'&cmd')) OR (stripos_clone($queryString,'exec') AND !stripos_clone($queryString,'execu')) OR stripos_clone($queryString,'concat')) {
|
---|
70 | die('Operazione non consentita');
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | foreach ($_GET as $sec_key => $secvalue) {
|
---|
76 | if ((preg_match("/<[^>]*script*\"?[^>]*>/i",$secvalue)) ||
|
---|
77 | (preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
|
---|
78 | (preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
|
---|
79 | (preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
|
---|
80 | (preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
|
---|
81 | (preg_match("/<[^>]*style*\"?[^>]*>/i", $secvalue)) ||
|
---|
82 | (preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
|
---|
83 | (preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue)) ||
|
---|
84 | (preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) ||
|
---|
85 | (preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) ||
|
---|
86 | (preg_match("/\"/", $secvalue)) ||
|
---|
87 | (preg_match("/inside_mod/i", $sec_key))) {
|
---|
88 | die ("Operazione non consentita");
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | foreach ($_POST as $secvalue) {
|
---|
93 | if ((preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]script*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]*body*\"?[^>]*>/i", $secvalue)) || (preg_match("/<[^>]style*\"?[^>]*>/i", $secvalue))) {
|
---|
94 | die ('Operazione non consentita');
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | // Posting from other servers in not allowed
|
---|
99 | // Fix by Quake
|
---|
100 | // Bug found by PeNdEjO
|
---|
101 |
|
---|
102 | if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
---|
103 | if (isset($_SERVER['HTTP_REFERER'])) {
|
---|
104 | if (!stripos_clone($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
|
---|
105 | die('Posting da un altro server non consentito!');
|
---|
106 | }
|
---|
107 | } else {
|
---|
108 | # die('<b>Attenzione:</b> il tuo browser non puo inviare gli header HTTP_REFERER al website.<br>'.$_SERVER['HTTP_REFERER']);
|
---|
109 | }
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 | //===================================================================
|
---|
119 | session_name('sesadmin');
|
---|
120 | #session_start();//MODIFICHE PER GESTIONE SESSIONI
|
---|
121 | // gestione sessione
|
---|
122 | $a = session_id();
|
---|
123 | if(empty($a)) session_start();
|
---|
124 | #echo "SID: ".SID."<br>session_id(): ".session_id()."<br>COOKIE: ".$_COOKIE["PHPSESSID"];
|
---|
125 |
|
---|
126 | if (file_exists("config.php")){
|
---|
127 | $install="0"; @require_once("config.php");
|
---|
128 | }else{
|
---|
129 | $install="1";
|
---|
130 | }
|
---|
131 |
|
---|
132 | # verifica se effettuata la configurazione
|
---|
133 | if(empty($dbname) || $install=="1") {
|
---|
134 | die("<html><body><div style=\"text-align:center\"><br /><br /><img src=\"modules/Elezioni/images/logo.jpg\" alt=\"Eleonline\" title=\"Eleonline\"><br /><br /><strong>Sembra che <a href='http://www.eleonline.it' title='Eleonline'>Eleonline</a> non sia stato ancora installato.<br /><br />Puoi procedere <a href='../install/index.php'>cliccando qui</a> per iniziare l'installazione</strong></div></body></html>");
|
---|
135 | }
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 | try{
|
---|
141 | $dbi = new PDO("mysql:host=$dbhost;charset=utf8", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
|
---|
142 | $sql = "use $dbname";
|
---|
143 | $dbi->exec($sql);
|
---|
144 | }
|
---|
145 | catch(PDOException $e)
|
---|
146 | {
|
---|
147 | echo $sql . "<br>" . $e->getMessage();
|
---|
148 | }
|
---|
149 | $sth = $dbi->prepare("SET SESSION character_set_connection = 'utf8' ");
|
---|
150 | $sth->execute();
|
---|
151 | $sth = $dbi->prepare("SET SESSION character_set_client = 'utf8' ");
|
---|
152 | $sth->execute();
|
---|
153 | $sth = $dbi->prepare("SET SESSION character_set_database = 'utf8' ");
|
---|
154 | $sth->execute();
|
---|
155 | $sth = $dbi->prepare("SET CHARACTER SET utf8");
|
---|
156 | $sth->execute();
|
---|
157 |
|
---|
158 | $sth = $dbi->prepare("SET NAMES 'utf8'");
|
---|
159 | $sth->execute();
|
---|
160 | $sth = $dbi->prepare("select * from ".$prefix."_config");
|
---|
161 | $sth->execute();
|
---|
162 |
|
---|
163 | # $dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error());
|
---|
164 | # mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error());
|
---|
165 | ## mysql_query("SET NAMES 'utf8'", $dbi);
|
---|
166 | //---10/05/2009 gestione consultazione predefinita
|
---|
167 | $sth = $dbi->prepare("select * from ".$prefix."_config");
|
---|
168 | $sth->execute();
|
---|
169 | $row = $sth->fetch(PDO::FETCH_ASSOC);
|
---|
170 | #$row = $sth->fetchAll();
|
---|
171 | $siteistat=$row['siteistat'];
|
---|
172 | if (!isset($_SESSION['id_comune'])){
|
---|
173 | $_SESSION['sitename']=$row['sitename'];
|
---|
174 | $_SESSION['siteurl']=$row['siteurl'];
|
---|
175 | $_SESSION['site_logo']=$row['site_logo'];
|
---|
176 | $_SESSION['slogan']=$row['slogan'];
|
---|
177 | $_SESSION['startdate']=$row['startdate'];
|
---|
178 | $_SESSION['adminmail']=$row['adminmail'];
|
---|
179 | # if (isset($tema) and $tema=='facebook')
|
---|
180 | # $_SESSION['tema']=$row['tema'];
|
---|
181 | $_SESSION['foot']=$row['foot'];
|
---|
182 | $_SESSION['lang']=$row['language'];
|
---|
183 | $_SESSION['blocco']=$row['blocco'];
|
---|
184 | $_SESSION['testata']=$row['testata'];
|
---|
185 | # $_SESSION['logo']=$row['logo'];
|
---|
186 | $_SESSION['fileout']=$row['fileout'];
|
---|
187 | $_SESSION['copyright']=$row['copyright'];
|
---|
188 | $_SESSION['versione']=$row['versione'];
|
---|
189 | $_SESSION['patch']=$row['patch'];
|
---|
190 | $_SESSION['id_comune']=$row['siteistat'];
|
---|
191 | $_SESSION['multicomune']=$row['multicomune'];
|
---|
192 | $_SESSION['flash']=$row['flash'];
|
---|
193 | $_SESSION['displayerrors']=$row['displayerrors'];
|
---|
194 | $_SESSION['editor']=$row['editor'];
|
---|
195 | $_SESSION['tema_on']=$row['tema_on'];
|
---|
196 | $_SESSION['ed_user']=$row['ed_user'];
|
---|
197 | $multicomune=$row['multicomune'];
|
---|
198 | }
|
---|
199 | //fine
|
---|
200 | if (isset($param['tema'])) $_SESSION['tema']=$param['tema'];
|
---|
201 | if (!isset($_SESSION['tema']))
|
---|
202 | $_SESSION['tema']='default';
|
---|
203 | $tema=$_SESSION['tema'];
|
---|
204 |
|
---|
205 | if (isset($param['aid'])) {
|
---|
206 | if (strlen($aid)>25 ) { die ("Nome utente troppo lungo: $aid"); }
|
---|
207 | if (!isset($param['id_ses']) or $param['id_ses'] != session_id()) logout();
|
---|
208 | if (strstr( $aid," ")) { die ("Gli spazi non sono ammessi nel nome utente: $aid"); }
|
---|
209 | if (isset($_SESSION['aid'])){
|
---|
210 | logout();//se hai gia' una sessione aperta non puoi postare 'aid'
|
---|
211 | }else{
|
---|
212 |
|
---|
213 | // $pwd2=$param['pwd'];
|
---|
214 | $mpwd=md5($pwd2);
|
---|
215 |
|
---|
216 | // se superUserAdmin
|
---|
217 | ########
|
---|
218 | # $sth = $dbi->prepare("select adminsuper from ".$prefix."_authors where aid='$aid' and pwd='$mpwd'");
|
---|
219 | # $sth->execute();
|
---|
220 | # $row = $sth->fetch(PDO::FETCH_ASSOC);
|
---|
221 | if (isset($param['id_comune']) and intval($param['id_comune'])>0) $id_comune=intval($param['id_comune']); else $id_comune=0;;
|
---|
222 | # if ($adminsuper==1) $id_comune2=0; else
|
---|
223 | $id_comune2=$id_comune;
|
---|
224 | $sth = $dbi->prepare("select pwd,adminop,adminsuper,counter,admlanguage from ".$prefix."_authors where aid='$aid' and (id_comune='$id_comune2' or adminsuper='1')");
|
---|
225 | $sth->execute();
|
---|
226 | $esiste=$sth->rowCount();
|
---|
227 | # $adminsuper=$row['adminsuper'];
|
---|
228 | $row = $sth->fetch(PDO::FETCH_ASSOC);
|
---|
229 | if(!$esiste) {
|
---|
230 | $msglogout=2;
|
---|
231 | logout();
|
---|
232 | }else{
|
---|
233 | if ($row['pwd']!=$mpwd) {
|
---|
234 | $msglogout=3;
|
---|
235 | logout();
|
---|
236 | }elseif($row['adminop']==1) {
|
---|
237 | $msglogout=1;
|
---|
238 | logout();
|
---|
239 | }
|
---|
240 | $counter=$row['counter'];
|
---|
241 | $tmplang=$row['admlanguage'];
|
---|
242 | if(strlen($tmplang)==2) $language=$tmplang;
|
---|
243 | $sth = $dbi->prepare("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune2'");
|
---|
244 | $sth->execute();
|
---|
245 | # $row = $sth->fetch(PDO::FETCH_ASSOC);
|
---|
246 | if ($esiste==1) {
|
---|
247 | # $_SESSION['dbi']=$dbi;
|
---|
248 | $_SESSION['aid']="$aid";
|
---|
249 | $_SESSION['pwd']="$mpwd";
|
---|
250 | $_SESSION['lang']="$language";
|
---|
251 | $_SESSION['id_comune']="$id_comune";
|
---|
252 | $_SESSION['prefix']="soraldo";
|
---|
253 | $_SESSION['remote']=$_SERVER['REMOTE_ADDR'];
|
---|
254 | $_SESSION['bgcolor1']='#ffffff';
|
---|
255 | $_SESSION['bgcolor2']='#c5c5c5';
|
---|
256 | if (!isset($op)) $op='consultazione';
|
---|
257 | session_regenerate_id();
|
---|
258 | }
|
---|
259 | }
|
---|
260 | }
|
---|
261 | }else{
|
---|
262 | #$_SESSION['dbi']=$dbi;
|
---|
263 |
|
---|
264 | }
|
---|
265 | if(!isset($_SESSION['BASE'])) $_SESSION['BASE']=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
|
---|
266 | if(!isset($language)) $language=$_SESSION['lang'];
|
---|
267 | if (! isset($_SESSION['lang'])) $_SESSION['lang']=$language;
|
---|
268 | $currentlang=strlen($_SESSION['lang'])==2 ? $_SESSION['lang']: $language;
|
---|
269 |
|
---|
270 | if (isset($_SESSION['aid']))
|
---|
271 | {
|
---|
272 | //lettura sessione
|
---|
273 | $aid=$_SESSION['aid'];
|
---|
274 | #$dbi=$_SESSION['dbi'];
|
---|
275 | $prefix=$_SESSION['prefix'];
|
---|
276 | $id_comune=$_SESSION['id_comune'];
|
---|
277 | if($id_comune==0) $rifcomune='58047'; else $rifcomune=$id_comune;
|
---|
278 | if (isset($_GET['id_cons_gen'])) {$id_cons_gen=intval($_GET['id_cons_gen']);}
|
---|
279 | else {
|
---|
280 | $oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y")));
|
---|
281 | $sql="select t1.id_cons_gen from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune=$id_comune and t1.data_fine>'$oggi' and t2.id_cons in (select id_cons from ".$prefix."_ele_operatori where aid='$aid' and id_sez>0 and permessi>0) limit 0,1";
|
---|
282 | $rese = $dbi->prepare("$sql");
|
---|
283 | $rese->execute();
|
---|
284 | if($rese->rowCount())
|
---|
285 | {list($id_cons_gen)=$rese->fetch(PDO::FETCH_NUM); }
|
---|
286 | else {
|
---|
287 | $sql="SELECT t1.id_cons_gen FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons=t2.id_cons and t2.id_comune='$id_comune'";
|
---|
288 | $sth = $dbi->prepare($sql);
|
---|
289 | $sth->execute();
|
---|
290 | $row = $sth->fetch(PDO::FETCH_BOTH);
|
---|
291 | if($sth->rowCount())
|
---|
292 | $id_cons_gen=$row[0];
|
---|
293 | else
|
---|
294 | $id_cons_gen=0; #die("TEST IN CORSO : idconsgen: $id_cons_gen -- sql:$sql");
|
---|
295 | }
|
---|
296 | }
|
---|
297 | $currentlang=$_SESSION['lang'];
|
---|
298 | #$bgcolor1=$_SESSION['bgcolor1'];
|
---|
299 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
300 | $bgcolor1='#e7e7e7';
|
---|
301 | $session=$_SESSION['remote'];
|
---|
302 |
|
---|
303 | }
|
---|
304 |
|
---|
305 |
|
---|
306 |
|
---|
307 | /*********************************************************/
|
---|
308 | /* Login Function */
|
---|
309 | /*********************************************************/
|
---|
310 | function ChiSei($id_cons_gen){
|
---|
311 | global $dbi, $msglogout;
|
---|
312 |
|
---|
313 | $aid=$_SESSION['aid'];
|
---|
314 | $prefix=$_SESSION['prefix'];
|
---|
315 | $pwd=$_SESSION['pwd'];
|
---|
316 | $id_comune=$_SESSION['id_comune'];
|
---|
317 |
|
---|
318 | $perms=0;
|
---|
319 | $sql="select adminsuper, admincomune, adminop from ".$prefix."_authors where aid='$aid' and pwd='$pwd' and (id_comune='$id_comune' or id_comune=0)";
|
---|
320 | $sth = $dbi->prepare("$sql");
|
---|
321 | $sth->execute();
|
---|
322 | $row = $sth->fetch(PDO::FETCH_BOTH);
|
---|
323 |
|
---|
324 | $adminsuper=$row[0];
|
---|
325 | $admincomune=$row[1];
|
---|
326 | $oper=$row[2];
|
---|
327 |
|
---|
328 | #if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {
|
---|
329 | if ($adminsuper==1)
|
---|
330 | return 256;
|
---|
331 | elseif ($admincomune==1)
|
---|
332 | return 64;
|
---|
333 | # $sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='$id_comune'");
|
---|
334 | elseif($oper) {$msglogout=1; return 0;} # id_cons='$id_cons' and
|
---|
335 | else {
|
---|
336 | $oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y")));
|
---|
337 | $sql="SELECT id_sez FROM ".$prefix."_ele_operatori where aid='$aid' and permessi>0 and id_cons in (select t1.id_cons from ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_consultazione as t2 where t1.id_cons_gen=t2.id_cons_gen and t1.id_comune='$id_comune' and t2.data_fine>$oggi)";
|
---|
338 | $sth = $dbi->prepare("$sql");
|
---|
339 | $sth->execute(); #die("TEST: $sql");
|
---|
340 | if($sth->rowCount()) {$perms=16; return $perms;}
|
---|
341 | else {$msglogout=1; return 0;}
|
---|
342 | }
|
---|
343 | /* $sth = $dbi->prepare("select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'");
|
---|
344 | $sth->execute();
|
---|
345 | $row = $sth->fetch(PDO::FETCH_BOTH);
|
---|
346 | $id_cons=$row[0];
|
---|
347 | $sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'");
|
---|
348 |
|
---|
349 | $sth->execute();
|
---|
350 | list($perms)=$sth->fetch(PDO::FETCH_NUM);
|
---|
351 | # $row = die("test:$sql".$row[0] );
|
---|
352 | if (!$perms) {die("qui: select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'"); $msglogout=1; $perms=0; }
|
---|
353 |
|
---|
354 | return $perms; */
|
---|
355 | #} else return 0;
|
---|
356 | }
|
---|
357 |
|
---|
358 | function OpenTable(){
|
---|
359 | echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" BORDER=\"0\">";
|
---|
360 | }
|
---|
361 |
|
---|
362 | function CloseTable(){
|
---|
363 | echo "</table>";
|
---|
364 | }
|
---|
365 |
|
---|
366 | function login() {
|
---|
367 | global $param,$prefix,$dbi,$multicomune,$siteistat,$language,$tema, $id_cons_gen, $perms, $msglogout;
|
---|
368 | if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
|
---|
369 | if (!isset($id_comune)) $id_comune=0;
|
---|
370 | if(isset($_SESSION['aid'])){
|
---|
371 | session_regenerate_id();
|
---|
372 | }
|
---|
373 | $lang=(isset($_SESSION['lang']) and strlen($_SESSION['lang'])==2) ? $_SESSION['lang']: $language;
|
---|
374 | $id_ses=session_id();
|
---|
375 |
|
---|
376 | //include("modules/Elezioni/language/lang-$lang.php");
|
---|
377 | if($multicomune==''){
|
---|
378 | $sth = $dbi->prepare("select multicomune from ".$prefix."_config");
|
---|
379 | $sth->execute();
|
---|
380 | list($multicomune) = $sth->fetch(PDO::FETCH_NUM);
|
---|
381 | }
|
---|
382 | include ("header.php");
|
---|
383 | echo "<div align=\"middle\"><font class=\"title\"><b>"._GESTIONE."</b></font></center>";
|
---|
384 | echo "<br>"; # method=\"post\"
|
---|
385 | if ($msglogout==1) echo "<h1 style=\"color:red;\">Utente non autorizzato</h1><br>";
|
---|
386 | elseif ($msglogout==2) echo "<h1 style=\"color:red;\">Nome Utente non presente in archivio</h1><br>";
|
---|
387 | elseif ($msglogout==3) echo "<h1 style=\"color:red;\">Password Errata</h1><br>";
|
---|
388 | elseif ($msglogout==4) echo "<h1 style=\"color:red;\">Accesso non ammesso da cellulare</h1><br>";
|
---|
389 | echo "<form name=\"login\" data-ajax=\"false\" method=\"post\" action=\"admin.php\">"
|
---|
390 | ."<table class=\"table-menu\">"
|
---|
391 | ."<tr><td>"._ADMINID."</td>"
|
---|
392 | ."<td><input type=\"text\" NAME=\"aid\" SIZE=\"20\" MAXLENGTH=\"25\"></td></tr>"
|
---|
393 | ."<tr><td>"._PASSWORD."</td>"
|
---|
394 | ."<td><input type=\"password\" NAME=\"pwd\" SIZE=\"20\" MAXLENGTH=\"18\"></td></tr>"
|
---|
395 | ."<tr><td>";
|
---|
396 | // scelta comune
|
---|
397 | if($multicomune=='1'){
|
---|
398 | echo ""._COMUNE."</td><td>";
|
---|
399 | $sql="select * from ".$prefix."_ele_comuni order by descrizione asc";
|
---|
400 | $sth = $dbi->prepare("$sql");
|
---|
401 | $sth->execute();
|
---|
402 | $row = $sth->fetchAll();
|
---|
403 | echo "<select name=\"id_comune\">";
|
---|
404 | foreach($row as $comuni)
|
---|
405 | {$id=$comuni[0];$descrizione=$comuni[1];
|
---|
406 | $sel=($id == $id_comune) ? "selected":"";
|
---|
407 | echo "<option value=\"$id\" $sel>$descrizione";
|
---|
408 | }
|
---|
409 | }else{
|
---|
410 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$siteistat\">";
|
---|
411 | }
|
---|
412 | // echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
413 | if(strlen($lang)==2) echo "<input type=\"hidden\" name=\"language\" value=\"$lang\">";
|
---|
414 | echo "</td></tr><tr><td>";
|
---|
415 | echo "<input type=\"hidden\" name=\"id_ses\" value=\"$id_ses\">";
|
---|
416 | echo "<input type=\"submit\" VALUE=\""._OK."\">"
|
---|
417 | ."</td></tr></table>"
|
---|
418 | ."</form></div>";
|
---|
419 |
|
---|
420 | include ("footer.php");
|
---|
421 | }
|
---|
422 |
|
---|
423 | function logout()
|
---|
424 | {
|
---|
425 | /* $lang=$_SESSION['lang'];
|
---|
426 | $id_comune=$_SESSION['id_comune'];
|
---|
427 | // setcookie ("PHPSESSID", "", time() - 3600);
|
---|
428 | session_cache_expire (0);
|
---|
429 | $_SESSION=array(); //MODIFICHE PER GESTIONE SESSIONI
|
---|
430 | session_unset();
|
---|
431 | session_destroy();
|
---|
432 | Header("Location: admin.php?id_comune=$id_comune&language=$lang");
|
---|
433 | */
|
---|
434 |
|
---|
435 | global $siteistat,$perms,$msglogout;
|
---|
436 | $language=$_SESSION['lang'];
|
---|
437 | $ref="Location: admin.php?";
|
---|
438 | #$ref="Location: https://www.eleonline.it/adminmob/admin.php?";
|
---|
439 | if (isset($_SESSION['id_comune']))
|
---|
440 | $id_comune=$_SESSION['id_comune'];
|
---|
441 | else
|
---|
442 | $id_comune=$siteistat;
|
---|
443 | $ref=$ref."id_comune=".$id_comune;
|
---|
444 |
|
---|
445 | if (isset($_SESSION['lang']))
|
---|
446 | $ref=$ref."&language=$language";
|
---|
447 | $ref.="&msglogout=$msglogout";
|
---|
448 | $_SESSION=array();
|
---|
449 | session_unset();
|
---|
450 | session_destroy();
|
---|
451 | session_cache_expire (0);
|
---|
452 | Header($ref);
|
---|
453 |
|
---|
454 | }
|
---|
455 | #include("TEST tema: $tema--");
|
---|
456 | #include("modules/Elezioni/language/lang-".$_SESSION['lang'].".php");
|
---|
457 | if(isset($id_cons_gen) and isset($id_comune)){
|
---|
458 | if(!isset($id_cons)){
|
---|
459 | # $sql = "SELECT 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'";
|
---|
460 | $sql = "SELECT id_cons from ".$prefix."_ele_comuni where id_comune='$id_comune'";
|
---|
461 | $sth = $dbi->prepare("$sql");
|
---|
462 | $sth->execute();
|
---|
463 | if ($sth->rowCount()) {
|
---|
464 | list($id_cons) = $sth->fetch(PDO::FETCH_NUM);
|
---|
465 | $_SESSION['id_cons']=$id_cons;
|
---|
466 | }
|
---|
467 | }
|
---|
468 | if(isset($id_cons)) {
|
---|
469 | $sql="SELECT id_sez FROM ".$prefix."_ele_operatori where id_sez>0 and aid='$aid' and id_comune=$id_comune";
|
---|
470 | $resmod = $dbi->prepare("$sql");
|
---|
471 | $resmod->execute();
|
---|
472 | list($id_sez) = $resmod->fetch(PDO::FETCH_NUM); #die("qui:$id_sez:$sql");
|
---|
473 | if($id_sez) {
|
---|
474 | $oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y")));
|
---|
475 | $sql="select t1.id_cons_gen,t1.descrizione,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_comune=$id_comune and t1.data_fine>'$oggi' and t2.id_cons in (select id_cons from ".$prefix."_ele_operatori where aid='$aid' and id_sez>0 and permessi>0)";
|
---|
476 | $resmod = $dbi->prepare("$sql");
|
---|
477 | $resmod->execute();
|
---|
478 | if ($resmod->rowCount()>0) {
|
---|
479 | $tema='Futura2'; #die( "TEST id_cons:$id_cons:".$_SESSION['aid']);
|
---|
480 | $_SESSION['tema']=$tema;
|
---|
481 | } #else {die("TEST: $sql"); logout();}
|
---|
482 | }
|
---|
483 | }
|
---|
484 | $perms=ChiSei($id_cons_gen); #die("qui".$_SESSION['aid']);
|
---|
485 | if($perms==0) {logout();}
|
---|
486 | }
|
---|
487 |
|
---|
488 | #echo "op:".$param['op']." -- aid:".$_SESSION['aid']."remote:".$_SESSION['remote']."REMOTE:".$_SERVER['REMOTE_ADDR'];
|
---|
489 | if (isset($param['op'])) $op=addslashes($param['op']); else $op='ele';
|
---|
490 | //if (isset($param['op'])) $op=$param['op']; else $op='ele';
|
---|
491 | #
|
---|
492 | #die("TEST: qui $aid $id_cons $id_sez ".$_SESSION['aid']);
|
---|
493 | if (isset($_SESSION['aid']) AND $_SESSION['remote']==$_SERVER['REMOTE_ADDR']) {
|
---|
494 | if($tema=='Futura2' and $op!='logout')
|
---|
495 | {
|
---|
496 | include("temi/$tema/index.php");
|
---|
497 | }else
|
---|
498 | switch($op) {
|
---|
499 | case "tipo":
|
---|
500 | include("modules/Elezioni/ele_tipi.php");
|
---|
501 | break;
|
---|
502 | case "constipi":
|
---|
503 | include("modules/Elezioni/ele_consultazionitipi.php");
|
---|
504 | break;
|
---|
505 | case "aggiorna":
|
---|
506 | include("modules/Elezioni/aggiorna.php");
|
---|
507 | break;
|
---|
508 | case "parziali":
|
---|
509 | include("modules/Elezioni/ele_parziali.php");
|
---|
510 | break;
|
---|
511 | case "ele":
|
---|
512 | include("modules/Elezioni/ele.php");
|
---|
513 | break;
|
---|
514 | case "consultazione":
|
---|
515 | include("modules/Elezioni/ele_consultazioni.php");
|
---|
516 | break;
|
---|
517 | case "configurazione":
|
---|
518 | include("modules/Elezioni/ele_configurazione.php");
|
---|
519 | break;
|
---|
520 | case "cons_comuni":
|
---|
521 | include("modules/Elezioni/ele_cons_comuni.php");
|
---|
522 | break;
|
---|
523 | case "confconsiglio":
|
---|
524 | include("modules/Elezioni/ele_confcons.php");
|
---|
525 | break;
|
---|
526 | case "inscomuni":
|
---|
527 | include("modules/Elezioni/ele_comuni.php");
|
---|
528 | break;
|
---|
529 | case "oper_admin":
|
---|
530 | include("modules/Elezioni/ele_operatori.php");
|
---|
531 | break;
|
---|
532 | case "inscollegi":
|
---|
533 | include("modules/Elezioni/ele_collegi.php");
|
---|
534 | break;
|
---|
535 | case "associazioni":
|
---|
536 | include("modules/Elezioni/ele_associazioni.php");
|
---|
537 | break;
|
---|
538 | case "operatori":
|
---|
539 | include("modules/Elezioni/ele_operatori.php");
|
---|
540 | break;
|
---|
541 | case "permessi":
|
---|
542 | include("modules/Elezioni/ele_permessi.php");
|
---|
543 | break;
|
---|
544 | case "circo":
|
---|
545 | include("modules/Elezioni/ele_circo.php");
|
---|
546 | break;
|
---|
547 | case "sede":
|
---|
548 | include("modules/Elezioni/ele_sede.php");
|
---|
549 | break;
|
---|
550 | case "sezione":
|
---|
551 | include("modules/Elezioni/ele_sezione.php");
|
---|
552 | break;
|
---|
553 | case "gruppo":
|
---|
554 | include("modules/Elezioni/ele_gruppo.php");
|
---|
555 | break;
|
---|
556 | case "rec_add_aff":
|
---|
557 | include("modules/Elezioni/ele_affluenze.php");
|
---|
558 | break;
|
---|
559 | case "rec_add_mod":
|
---|
560 | include("modules/Elezioni/ele_modelli.php");
|
---|
561 | break;
|
---|
562 | case "upgruppo":
|
---|
563 | include("modules/Elezioni/ele_gruppo.php");
|
---|
564 | break;
|
---|
565 | case "delimggruppo":
|
---|
566 | include("modules/Elezioni/ele_gruppo.php");
|
---|
567 | break;
|
---|
568 | case "lista":
|
---|
569 | include("modules/Elezioni/ele_lista.php");
|
---|
570 | break;
|
---|
571 | case "uplista":
|
---|
572 | include("modules/Elezioni/ele_lista.php");
|
---|
573 | break;
|
---|
574 | case "delimglista":
|
---|
575 | include("modules/Elezioni/ele_lista.php");
|
---|
576 | break;
|
---|
577 | case "candidato":
|
---|
578 | include("modules/Elezioni/ele_candidato.php");
|
---|
579 | break;
|
---|
580 | case "upcandidato":
|
---|
581 | include("modules/Elezioni/ele_candidato.php");
|
---|
582 | break;
|
---|
583 | case "delimgcandidato":
|
---|
584 | include("modules/Elezioni/ele_candidato.php");
|
---|
585 | break;
|
---|
586 |
|
---|
587 | case "voti":
|
---|
588 | include("modules/Elezioni/ele_voti.php");
|
---|
589 | break;
|
---|
590 | case "sezioni_voti":
|
---|
591 | include("modules/Elezioni/ele_voti.php");
|
---|
592 | break;
|
---|
593 | case "rec_voti":
|
---|
594 | include("modules/Elezioni/ele_voti.php");
|
---|
595 | break;
|
---|
596 | case "rec_voti_gruppi":
|
---|
597 | include("modules/Elezioni/ele_voti.php");
|
---|
598 | break;
|
---|
599 | case "rec_add_votanti":
|
---|
600 | include("modules/Elezioni/ele_voti.php");
|
---|
601 | break;
|
---|
602 | case "rec_finale":
|
---|
603 | include("modules/Elezioni/ele_voti.php");
|
---|
604 | break;
|
---|
605 | case "controllo_voti":
|
---|
606 | include("modules/Elezioni/controllo_voti.php");
|
---|
607 | break;
|
---|
608 | case "controllo_votanti":
|
---|
609 | include("modules/Elezioni/controllo_votanti.php");
|
---|
610 | break;
|
---|
611 | case "come":
|
---|
612 | include("modules/Elezioni/ele_come.php");
|
---|
613 | break;
|
---|
614 | case "numeri":
|
---|
615 | include("modules/Elezioni/ele_come.php");
|
---|
616 | break;
|
---|
617 | case "servizi":
|
---|
618 | include("modules/Elezioni/ele_come.php");
|
---|
619 | break;
|
---|
620 | case "link":
|
---|
621 | include("modules/Elezioni/ele_come.php");
|
---|
622 | break;
|
---|
623 | case "conf":
|
---|
624 | include("modules/Elezioni/ele_conf.php");
|
---|
625 | break;
|
---|
626 | case "stampa":
|
---|
627 | include("modules/Elezioni/ele_stampe.php");
|
---|
628 | break;
|
---|
629 | case "cambiopwd":
|
---|
630 | include("modules/Elezioni/ele_pwd.php");
|
---|
631 | break;
|
---|
632 | case "eletti":
|
---|
633 | include("modules/Elezioni/ele_eletti.php");
|
---|
634 | break;
|
---|
635 | case "foto":
|
---|
636 | include("modules/Elezioni/foto.php");
|
---|
637 | break;
|
---|
638 | case "consiglieri":
|
---|
639 | include("modules/Elezioni/ele_consiglieri.php");
|
---|
640 | break;
|
---|
641 | case "backup":
|
---|
642 | include("modules/Elezioni/backup.php");
|
---|
643 | break;
|
---|
644 | case "restore":
|
---|
645 | include("modules/Elezioni/restore.php");
|
---|
646 | break;
|
---|
647 | case "scarica":
|
---|
648 | include("modules/Elezioni/scarica.php");
|
---|
649 | break;
|
---|
650 | case "importa":
|
---|
651 | include("modules/Elezioni/importa.php");
|
---|
652 | break;
|
---|
653 | case "widget":
|
---|
654 | include("modules/Elezioni/ele_widget.php");
|
---|
655 | break;
|
---|
656 | case "riepilogo":
|
---|
657 | include("modules/Elezioni/ele_riepilogo.php");
|
---|
658 | break;
|
---|
659 | case "riepilogovoti":
|
---|
660 | include("modules/Elezioni/ele_riepilogovoti.php");
|
---|
661 | break;
|
---|
662 | case "logout":
|
---|
663 | logout();
|
---|
664 | break;
|
---|
665 | }
|
---|
666 |
|
---|
667 | }else {
|
---|
668 |
|
---|
669 | login();
|
---|
670 |
|
---|
671 | }
|
---|
672 |
|
---|
673 | ?>
|
---|