Changeset 358 for trunk/admin/admin.php


Ignore:
Timestamp:
Feb 22, 2022, 10:40:08 PM (2 years ago)
Author:
roby
Message:

Admin: aggiunta la funzione di gestione dello spoglio per la singola sezione tramite tema per cellulari

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/admin.php

    r344 r358  
    1717#$LIMITE=3; //fascia di separazione del maggioritario (15.000 abitanti)
    1818# tempo di sessione: ini_set('session.gc_maxlifetime','3600');
    19 global $multicomune;
     19global $multicomune,$msglogout;
    2020
    2121// Adattamento variabili superglobal
     
    4646$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
    4747if (isset($param['aid'])) $aid=addslashes($param['aid']); else $aid='';
    48 if (isset($param['pwd'])) $pwd2=addslashes($param['pwd']); else $pwd2='';
     48if (isset($param['pwd'])) $pwd2=addslashes($param['pwd']); else $pwd2='';
     49if(isset($param['msglogout'])) $msglogout=intval($param['msglogout']); else $msglogout=0;
     50 
    4951// Additional security (Union, CLike, XSS)
    5052
     
    163165        $_SESSION['startdate']=$row['startdate'];
    164166        $_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'];
    168169        $_SESSION['foot']=$row['foot'];
    169170        $_SESSION['lang']=$row['language'];
     
    185186}
    186187//fine
     188        if (isset($param['tema'])) $_SESSION['tema']=$param['tema'];
     189        if (!isset($_SESSION['tema']))
     190                $_SESSION['tema']='default';
     191        $tema=$_SESSION['tema'];
     192
    187193if (isset($param['aid'])) {
    188         if (strlen($aid)>25 ) { die ("Nome utente troppo lungo: $aid"); }       
     194    if (strlen($aid)>25 ) { die ("Nome utente troppo lungo: $aid"); }   
    189195        if (!isset($param['id_ses']) or $param['id_ses'] != session_id()) logout();
    190196        if (strstr( $aid," ")) { die ("Gli spazi non sono ammessi nel nome utente: $aid"); }
    191         if (isset($_SESSION['aid'])){
     197        if (isset($_SESSION['aid'])){ 
    192198                logout();//se hai gia' una sessione aperta non puoi postare 'aid'
    193199        }else{
    194200               
    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                        }                               
    214228                        $counter=$row['counter'];
    215229                        $tmplang=$row['admlanguage'];
    216                         $counter+=1;
    217230                        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'");
    219232                        $sth->execute();       
    220 #                       $row = $sth->fetch(PDO::FETCH_ASSOC);   
    221                        
     233#                       $row = $sth->fetch(PDO::FETCH_ASSOC);                           
    222234                        if ($esiste==1) {
    223235#                               $_SESSION['dbi']=$dbi;
     
    239251
    240252}
     253if(!isset($_SESSION['BASE'])) $_SESSION['BASE']=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
     254if(!isset($language)) $language=$_SESSION['lang'];
    241255if (! isset($_SESSION['lang'])) $_SESSION['lang']=$language;
    242256$currentlang=strlen($_SESSION['lang'])==2 ? $_SESSION['lang']: $language;
    243 if (isset($_SESSION['aid']))
     257
     258if (isset($_SESSION['aid']))
    244259{
    245260//lettura sessione
     
    248263$prefix=$_SESSION['prefix'];
    249264$id_comune=$_SESSION['id_comune'];
     265if($id_comune==0) $rifcomune='58047'; else $rifcomune=$id_comune;
    250266if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']);
    251267else {
    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);
    253270                        $sth->execute();       
    254271                        $row = $sth->fetch(PDO::FETCH_BOTH);
     
    256273                                $id_cons_gen=$row[0];
    257274                        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)");
    259276}
    260277$currentlang=$_SESSION['lang'];
    261 $bgcolor1=$_SESSION['bgcolor1'];
     278#$bgcolor1=$_SESSION['bgcolor1'];
    262279$bgcolor2=$_SESSION['bgcolor2'];
    263280$bgcolor1='#e7e7e7';
     
    265282
    266283$perms=ChiSei($id_cons_gen);
     284if($perms==0) logout();
    267285}
    268286
     
    272290/*********************************************************/
    273291function ChiSei($id_cons_gen){
    274 global $dbi;
     292global $dbi, $msglogout;
    275293
    276294$aid=$_SESSION['aid'];
     
    290308$adminop=$row[2];
    291309
    292 if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {
     310#if (($adminsuper==1 || $admincomune==1 || $adminop==1)) {
    293311        if ($adminsuper==1)
    294312                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{
    298317                $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];
    303321                $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; }
    310327        return $perms;
    311 } else return 0;
     328#} else return 0;
    312329}
    313330
     
    321338
    322339function 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;
    325341    if (isset($param['id_comune'])) $id_comune=intval($param['id_comune']);
    326342    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;
    328347    $id_ses=session_id();
    329 #die("test:$tema");
     348
    330349    //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        }
    331355    include ("header.php");
    332356    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\">"
    335362        ."<table class=\"table-menu\">"
    336363        ."<tr><td>"._ADMINID."</td>"
     
    377404        Header("Location: admin.php?id_comune=$id_comune&language=$lang");
    378405*/
    379 global $siteistat;
     406global $siteistat,$perms,$msglogout;
    380407
    381408$ref="Location: admin.php?";
     409#$ref="Location: https://www.eleonline.it/adminmob/admin.php?";
    382410if (isset($_SESSION['id_comune']))
    383411$id_comune=$_SESSION['id_comune'];
     
    388416if (isset($_SESSION['lang']))
    389417$ref=$ref."&language=".$_SESSION['lang'];
    390 
     418$ref.="&msglogout=$msglogout";
    391419$_SESSION=array(); 
    392420session_unset();
     
    396424
    397425}
    398 
    399 
     426#include("TEST tema: $tema--");
     427#include("modules/Elezioni/language/lang-".$_SESSION['lang'].".php");
     428if(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}
    400446#echo "op:".$param['op']." -- aid:".$_SESSION['aid']."remote:".$_SESSION['remote']."REMOTE:".$_SERVER['REMOTE_ADDR'];
    401447if (isset($param['op'])) $op=addslashes($param['op']); else $op='ele';
    402448//if (isset($param['op'])) $op=$param['op']; else $op='ele';
     449#die( "OP: $op");
    403450if (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
    404456switch($op) {
    405457    case "tipo":
Note: See TracChangeset for help on using the changeset viewer.