Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
128 righe
4.2 KiB
128 righe
4.2 KiB
<?php |
|
|
|
/** |
|
* Description of Application |
|
* |
|
* @author Gigi |
|
*/ |
|
class Application extends DataClass { |
|
|
|
const SUCCESS = 1; // controlli ok |
|
const ACCESS_ERR = -1; // errore di accesso (lato WEB => response con messaggio e codice errore in json) |
|
const ACCESS_WS_ERR = -2; // errore di accesso (lato WS => response con exit(0)) |
|
|
|
private $account = null; |
|
private $con = null; |
|
private $conSpid = null; |
|
public $lastEsito = 0; |
|
public $lastMessageError = ''; |
|
|
|
public function __construct() { |
|
return $this->_initApp(); |
|
} |
|
|
|
public function getAccount() { |
|
return $this->account; |
|
} |
|
|
|
public function getCon() { |
|
return $this->con; |
|
} |
|
|
|
public function getConSpid() { |
|
return $this->conSpid; |
|
} |
|
|
|
/* CHECK IP ACCESS */ |
|
|
|
private function _checkIP() { |
|
$response = false; |
|
if (ENABLE_CHECK_IP) { |
|
if (!Utils::access_IP_control() && !Utils::checkCurrentPage('index')) { |
|
if (Utils::checkCurrentPage('_webservice')) { |
|
$this->lastEsito = self::ACCESS_ERR; |
|
$this->lastMessageError = 'Accesso scaduto: si prega di aggiornare la pagina ed effettuare il login al sistema.'; |
|
} else { |
|
Utils::RedirectTo(BASE_HTTP . "logout.php"); |
|
exit(0); |
|
} |
|
} else { |
|
$response = true; |
|
} |
|
} else { |
|
$response = true; |
|
} |
|
return $response; |
|
} |
|
|
|
/* SET DB CONNECTION */ |
|
|
|
private function _checkConnectionDB() { |
|
global $con, $conSpid; |
|
if (!isset($con)) { |
|
$connessione = new Database(DBMS, DB_SERVER, array('DB_USER' => DB_USER, 'DB_PASS' => DB_PASS)); |
|
$this->con = $connessione->db; |
|
} else { |
|
$this->con = $con; |
|
} |
|
|
|
if (!isset($conSpid)) { |
|
$connessioneSpid = new Database(DBMS, DB_SERVER, array('DB_USER' => DB_USER_SPID, 'DB_PASS' => DB_PASS_SPID)); |
|
$this->conSpid = $connessioneSpid->db; |
|
} else { |
|
$this->conSpid = $conSpid; |
|
} |
|
} |
|
|
|
private function _checkModuleAction(){ |
|
global $moduliActionAccessNoControll; |
|
$response = false; |
|
if (isset($_REQUEST["module"]) && isset($_REQUEST["action"])){ |
|
if (isset($moduliActionAccessNoControll[$_REQUEST["module"]])){ |
|
if (in_array($_REQUEST["action"], $moduliActionAccessNoControll[$_REQUEST["module"]])){ |
|
$response = true; |
|
} |
|
} |
|
} |
|
return $response; |
|
} |
|
|
|
private function _initApp() { |
|
global $pageAccessNoControll; |
|
$response = Utils::initDefaultResponse(); |
|
if ($this->_checkIP()) { |
|
session_start([ |
|
'cookie_lifetime' => COOKIE_LIFETIME, |
|
//'gc_maxlifetime' => 120//GC_MAXLIFETIME |
|
]); |
|
if (isset($_SESSION['ID']) && intval($_SESSION['ID']) > 0) { |
|
if (isset($_SESSION['LoggedAccount'])) { |
|
$this->lastEsito = self::SUCCESS; |
|
$this->account = UID_FIREBASE_ADMIN::initUidFirebaseFromSessione(json_decode($_SESSION['LoggedAccount'], true)); |
|
} else { |
|
$this->lastEsito = self::SUCCESS; |
|
$this->account = new UID_FIREBASE_ADMIN(intval($_SESSION['ID'])); |
|
} |
|
} else { |
|
$this->lastEsito = self::SUCCESS; |
|
$this->account = new UID_FIREBASE_ADMIN(); |
|
$currentPageAccess = Utils::getCurrentPageCalled(); |
|
|
|
if (Utils::checkCurrentPage('_webservice') && (!in_array($currentPageAccess, $pageAccessNoControll) || !$this->_checkModuleAction())) { |
|
$this->lastEsito = self::ACCESS_ERR; |
|
$this->lastMessageError = 'Accesso scaduto: si prega di aggiornare la pagina ed effettuare il login al sistema.'; |
|
} else if (!in_array($currentPageAccess, $pageAccessNoControll)) { |
|
Utils::RedirectTo(BASE_HTTP . "login.php"); |
|
exit(0); |
|
} |
|
} |
|
} |
|
|
|
if ($this->lastEsito == self::SUCCESS) { |
|
$this->_checkConnectionDB(); |
|
} |
|
} |
|
|
|
} |
|
|
|
?>
|