Changeset 358 for trunk/admin/admin.php
- Timestamp:
- Feb 22, 2022, 10:40:08 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/admin.php
r344 r358 17 17 #$LIMITE=3; //fascia di separazione del maggioritario (15.000 abitanti) 18 18 # tempo di sessione: ini_set('session.gc_maxlifetime','3600'); 19 global $multicomune ;19 global $multicomune,$msglogout; 20 20 21 21 // Adattamento variabili superglobal … … 46 46 $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST; 47 47 if (isset($param['aid'])) $aid=addslashes($param['aid']); else $aid=''; 48 if (isset($param['pwd'])) $pwd2=addslashes($param['pwd']); else $pwd2=''; 48 if (isset($param['pwd'])) $pwd2=addslashes($param['pwd']); else $pwd2=''; 49 if(isset($param['msglogout'])) $msglogout=intval($param['msglogout']); else $msglogout=0; 50 49 51 // Additional security (Union, CLike, XSS) 50 52 … … 163 165 $_SESSION['startdate']=$row['startdate']; 164 166 $_SESSION['adminmail']=$row['adminmail']; 165 if (isset($tema) and $tema=='facebook') 166 $_SESSION['tema']=$row['tema']; 167 else $_SESSION['tema']='default'; 167 # if (isset($tema) and $tema=='facebook') 168 # $_SESSION['tema']=$row['tema']; 168 169 $_SESSION['foot']=$row['foot']; 169 170 $_SESSION['lang']=$row['language']; … … 185 186 } 186 187 //fine 188 if (isset($param['tema'])) $_SESSION['tema']=$param['tema']; 189 if (!isset($_SESSION['tema'])) 190 $_SESSION['tema']='default'; 191 $tema=$_SESSION['tema']; 192 187 193 if (isset($param['aid'])) { 188 194 if (strlen($aid)>25 ) { die ("Nome utente troppo lungo: $aid"); } 189 195 if (!isset($param['id_ses']) or $param['id_ses'] != session_id()) logout(); 190 196 if (strstr( $aid," ")) { die ("Gli spazi non sono ammessi nel nome utente: $aid"); } 191 if (isset($_SESSION['aid'])){ 197 if (isset($_SESSION['aid'])){ 192 198 logout();//se hai gia' una sessione aperta non puoi postare 'aid' 193 199 }else{ 194 200 195 196 // $pwd2=$param['pwd']; 197 $mpwd=md5($pwd2); 198 199 // se superUserAdmin 200 ######## 201 $sth = $dbi->prepare("select adminsuper from ".$prefix."_authors where aid='$aid' and pwd='$mpwd'"); 202 $sth->execute(); 203 $row = $sth->fetch(PDO::FETCH_ASSOC); 204 $adminsuper=$row['adminsuper']; 205 if ($adminsuper==1) $id_comune='0'; 206 elseif (is_numeric($param['id_comune']) and intval($param['id_comune'])>0) $id_comune=intval($param['id_comune']); 207 $sth = $dbi->prepare("select counter,admlanguage from ".$prefix."_authors where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune'"); 208 $sth->execute(); 209 $esiste=$sth->rowCount(); 210 211 212 if ($esiste){ 213 $row = $sth->fetch(PDO::FETCH_ASSOC); 201 // $pwd2=$param['pwd']; 202 $mpwd=md5($pwd2); 203 204 // se superUserAdmin 205 ######## 206 # $sth = $dbi->prepare("select adminsuper from ".$prefix."_authors where aid='$aid' and pwd='$mpwd'"); 207 # $sth->execute(); 208 # $row = $sth->fetch(PDO::FETCH_ASSOC); 209 if (isset($param['id_comune']) and intval($param['id_comune'])>0) $id_comune=intval($param['id_comune']); else $id_comune=0;; 210 # if ($adminsuper==1) $id_comune2=0; else 211 $id_comune2=$id_comune; 212 $sth = $dbi->prepare("select pwd,adminop,adminsuper,counter,admlanguage from ".$prefix."_authors where aid='$aid' and (id_comune='$id_comune2' or adminsuper='1')"); 213 $sth->execute(); 214 $esiste=$sth->rowCount(); 215 # $adminsuper=$row['adminsuper']; 216 $row = $sth->fetch(PDO::FETCH_ASSOC); 217 if(!$esiste) { 218 $msglogout=2; 219 logout(); 220 }else{ 221 if ($row['pwd']!=$mpwd) { 222 $msglogout=3; 223 logout(); 224 }elseif($row['adminop']==1) { 225 $msglogout=1; 226 logout(); 227 } 214 228 $counter=$row['counter']; 215 229 $tmplang=$row['admlanguage']; 216 $counter+=1;217 230 if(strlen($tmplang)==2) $language=$tmplang; 218 $sth = $dbi->prepare("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune '");231 $sth = $dbi->prepare("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune2'"); 219 232 $sth->execute(); 220 # $row = $sth->fetch(PDO::FETCH_ASSOC); 221 233 # $row = $sth->fetch(PDO::FETCH_ASSOC); 222 234 if ($esiste==1) { 223 235 # $_SESSION['dbi']=$dbi; … … 239 251 240 252 } 253 if(!isset($_SESSION['BASE'])) $_SESSION['BASE']=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16); 254 if(!isset($language)) $language=$_SESSION['lang']; 241 255 if (! isset($_SESSION['lang'])) $_SESSION['lang']=$language; 242 256 $currentlang=strlen($_SESSION['lang'])==2 ? $_SESSION['lang']: $language; 243 if (isset($_SESSION['aid'])) 257 258 if (isset($_SESSION['aid'])) 244 259 { 245 260 //lettura sessione … … 248 263 $prefix=$_SESSION['prefix']; 249 264 $id_comune=$_SESSION['id_comune']; 265 if($id_comune==0) $rifcomune='58047'; else $rifcomune=$id_comune; 250 266 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); 251 267 else { 252 $sth = $dbi->prepare("select id_cons_gen from ".$prefix."_ele_cons_comune where preferita='1' and (id_comune='$id_comune' or id_comune=0)"); 268 $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'"; 269 $sth = $dbi->prepare($sql); 253 270 $sth->execute(); 254 271 $row = $sth->fetch(PDO::FETCH_BOTH); … … 256 273 $id_cons_gen=$row[0]; 257 274 else 258 $id_cons_gen=0; 275 $id_cons_gen=0; #die("TEST IN CORSO : idconsgen: $id_cons_gen -- sql:select id_cons_gen from ".$prefix."_ele_cons_comune where preferita='1' and (id_comune='$id_comune' or id_comune=0)"); 259 276 } 260 277 $currentlang=$_SESSION['lang']; 261 $bgcolor1=$_SESSION['bgcolor1'];278 #$bgcolor1=$_SESSION['bgcolor1']; 262 279 $bgcolor2=$_SESSION['bgcolor2']; 263 280 $bgcolor1='#e7e7e7'; … … 265 282 266 283 $perms=ChiSei($id_cons_gen); 284 if($perms==0) logout(); 267 285 } 268 286 … … 272 290 /*********************************************************/ 273 291 function ChiSei($id_cons_gen){ 274 global $dbi ;292 global $dbi, $msglogout; 275 293 276 294 $aid=$_SESSION['aid']; … … 290 308 $adminop=$row[2]; 291 309 292 if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {310 #if (($adminsuper==1 || $admincomune==1 || $adminop==1)) { 293 311 if ($adminsuper==1) 294 312 return 256; 295 elseif ($adminop==1){ 296 $sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='$id_comune'"); 297 }elseif ($admincomune==1) { 313 elseif ($admincomune==1){ 314 return 64; 315 # $sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='0' and aid='$aid' and id_comune='$id_comune'"); 316 }else{ 298 317 $sth = $dbi->prepare("select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'"); 299 $sth->execute(); 300 $row = $sth->fetch(PDO::FETCH_BOTH); 301 302 $id_cons=$row[0]; 318 $sth->execute(); 319 $row = $sth->fetch(PDO::FETCH_BOTH); 320 $id_cons=$row[0]; 303 321 $sth = $dbi->prepare("select permessi from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid' and id_comune='$id_comune'"); 304 } 305 306 $sth->execute(); 307 $row = $sth->fetch(PDO::FETCH_BOTH); 308 309 if ($sth->rowCount()==1) $perms=$row[0]; else $perms=0; 322 } 323 $sth->execute(); 324 $row = $sth->fetch(PDO::FETCH_BOTH); 325 if($row[0]==0) $msglogout=1; 326 if ($sth->rowCount()==1) $perms=$row[0]; else { $msglogout=1; $perms=0; } 310 327 return $perms; 311 } else return 0;328 #} else return 0; 312 329 } 313 330 … … 321 338 322 339 function login() { 323 global $param,$prefix,$dbi,$multicomune,$siteistat,$language,$tema; 324 $lang=strlen($_SESSION['lang'])==2 ? $_SESSION['lang']: $language; 340 global $param,$prefix,$dbi,$multicomune,$siteistat,$language,$tema, $id_cons_gen, $perms, $msglogout; 325 341 if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']); 326 342 if (!isset($id_comune)) $id_comune=0; 327 session_regenerate_id(); 343 if(isset($_SESSION['aid'])){ 344 session_regenerate_id(); 345 } 346 $lang=(isset($_SESSION['lang']) and strlen($_SESSION['lang'])==2) ? $_SESSION['lang']: $language; 328 347 $id_ses=session_id(); 329 #die("test:$tema"); 348 330 349 //include("modules/Elezioni/language/lang-$lang.php"); 350 if($multicomune==''){ 351 $sth = $dbi->prepare("select multicomune from ".$prefix."_config"); 352 $sth->execute(); 353 list($multicomune) = $sth->fetch(PDO::FETCH_NUM); 354 } 331 355 include ("header.php"); 332 356 echo "<div align=\"middle\"><font class=\"title\"><b>"._GESTIONE."</b></font></center>"; 333 echo "<br>"; # method=\"post\" 334 echo "<form name=\"login\" method=\"post\" action=\"admin.php\">" 357 echo "<br>"; # method=\"post\" 358 if ($msglogout==1) echo "<h1 style=\"color:red;\">Utente non autorizzato</h1><br>"; 359 elseif ($msglogout==2) echo "<h1 style=\"color:red;\">Nome Utente non presente in archivio</h1><br>"; 360 elseif ($msglogout==3) echo "<h1 style=\"color:red;\">Password Errata</h1><br>"; 361 echo "<form name=\"login\" data-ajax=\"false\" method=\"post\" action=\"admin.php\">" 335 362 ."<table class=\"table-menu\">" 336 363 ."<tr><td>"._ADMINID."</td>" … … 377 404 Header("Location: admin.php?id_comune=$id_comune&language=$lang"); 378 405 */ 379 global $siteistat ;406 global $siteistat,$perms,$msglogout; 380 407 381 408 $ref="Location: admin.php?"; 409 #$ref="Location: https://www.eleonline.it/adminmob/admin.php?"; 382 410 if (isset($_SESSION['id_comune'])) 383 411 $id_comune=$_SESSION['id_comune']; … … 388 416 if (isset($_SESSION['lang'])) 389 417 $ref=$ref."&language=".$_SESSION['lang']; 390 418 $ref.="&msglogout=$msglogout"; 391 419 $_SESSION=array(); 392 420 session_unset(); … … 396 424 397 425 } 398 399 426 #include("TEST tema: $tema--"); 427 #include("modules/Elezioni/language/lang-".$_SESSION['lang'].".php"); 428 if(isset($id_cons_gen) and isset($id_comune)){ 429 if(!isset($id_cons)){ 430 # $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'"; 431 $sql = "SELECT id_cons from ".$prefix."_ele_comuni where id_comune='$id_comune'"; 432 $sth = $dbi->prepare("$sql"); 433 $sth->execute(); 434 if ($sth->rowCount()) list($id_cons) = $sth->fetch(PDO::FETCH_NUM); 435 $_SESSION['id_cons']=$id_cons; 436 } 437 if(isset($id_cons)) { 438 $sql="SELECT id_sez FROM ".$prefix."_ele_operatori where id_cons=$id_cons and aid='$aid' and id_comune=$id_comune"; 439 $resmod = $dbi->prepare("$sql"); 440 $resmod->execute(); 441 list($id_sez) = $resmod->fetch(PDO::FETCH_NUM); 442 if($id_sez) $tema='Futura2';#die( "TEST id_cons:$id_cons:"); 443 $_SESSION['tema']=$tema; 444 } 445 } 400 446 #echo "op:".$param['op']." -- aid:".$_SESSION['aid']."remote:".$_SESSION['remote']."REMOTE:".$_SERVER['REMOTE_ADDR']; 401 447 if (isset($param['op'])) $op=addslashes($param['op']); else $op='ele'; 402 448 //if (isset($param['op'])) $op=$param['op']; else $op='ele'; 449 #die( "OP: $op"); 403 450 if (isset($_SESSION['aid']) AND $_SESSION['remote']==$_SERVER['REMOTE_ADDR']) { 451 if($tema=='Futura2' and $op!='logout') 452 { 453 include("temi/$tema/index.php"); 454 testata(); 455 }else 404 456 switch($op) { 405 457 case "tipo":
Note:
See TracChangeset
for help on using the changeset viewer.