eesyphp/includes/core.php
2020-04-18 00:51:33 +02:00

80 lines
2.1 KiB
PHP

<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
// Root directory path
if (__FILE__ != "") {
$script = __FILE__;
}
else {
// Fallback method : detect path from core.php path
foreach(get_included_files() as $script)
if (basename($script) == 'core.php')
break;
}
$root_dir_path=realpath(dirname($script).'/../');
// Include App's includes and vendor directories to PHP include paths
set_include_path($root_dir_path.'/includes' . PATH_SEPARATOR . get_include_path());
// Load composer autoload.php
require("$root_dir_path/vendor/autoload.php");
// Load configuration
require_once('config.inc.php');
// Check $public_root_url end
if (substr($public_root_url, -1)=='/') {
$public_root_url=substr($public_root_url, 0, -1);
}
// Define upload_tmp_dir
ini_set('upload_tmp_dir',$upload_tmp_dir);
require_once('logging.php');
require_once('functions.php');
// Define session max duration
if (!isset($session_max_duration))
$session_max_duration = (12*60*60); // Default to 12h
ini_set('session.gc_maxlifetime', $session_max_duration);
ini_set('session.cookie_lifetime', $session_max_duration);
// Start session
session_start();
// Init session key
if (!isset($_SESSION['session_key'])) {
$_SESSION['session_key']=uniqid();
}
// Handle session timeout
if ($session_timeout) {
if (!isset($_SESSION['session_last_access'])) {
logging('DEBUG', 'Set initial session last access');
$_SESSION['session_last_access'] = time();
}
elseif ($_SESSION['session_last_access'] > (time() - $session_timeout)) {
logging('DEBUG', 'Session timeout not expired, update session last access (Previous value : '.$_SESSION['session_last_access'].')');
$_SESSION['session_last_access'] = time();
}
else {
logging('INFO', 'Session destroyed due to inactivity');
session_destroy();
}
}
// Nomenclatures
$status_list = array (
'pending' => 'En attente',
'validated' => 'Validé',
'refused' => 'Refusé',
'archived' => 'Archivé',
);
require_once('hooks.php');
require_once('cli.php');
require_once('smarty.php');
require_once('url.php');
require_once('url-helpers.php');
require_once('db.php');