move paths_installed to shared folder CORE #55

This commit is contained in:
Fernando Ontiveros
2025-04-10 01:56:01 +00:00
parent 0e78dccf0f
commit 3a6a219b07
8 changed files with 775 additions and 657 deletions

View File

@@ -16,9 +16,62 @@ class Bootstrap
public static $includeClassPaths = array();
public static $includePaths = array();
protected $relativeIncludePaths = array();
public static $startingTime = 0;
//below here only approved methods
/**
* Function to initialize session settings
*/
public static function initializeSession($config) {
// Start the timer
self::$startingTime = microtime(true);
// Determine session lifetime
$sessionLifetime = isset($config['session.gc_maxlifetime'])
? $config['session.gc_maxlifetime']
: ini_get('session.gc_maxlifetime');
// Default to 1440 seconds (24 minutes) if lifetime is not set
if (is_null($sessionLifetime)) {
$sessionLifetime = 1440;
}
// Set the session garbage collection maximum lifetime
ini_set('session.gc_maxlifetime', $sessionLifetime);
// Configure cookie lifetime based on user agent and configuration
Bootstrap::configureCookieLifetime($sessionLifetime, $config);
// Set cookie security options if REMOTE_USER is not set
if (!array_key_exists('REMOTE_USER', $_SERVER) || empty($_SERVER['REMOTE_USER'])) {
ini_set('session.cookie_httponly', 1);
if (G::is_https()) {
ini_set('session.cookie_secure', 1);
}
}
// Start the session
session_start();
}
/*
* Function to configure cookie lifetime based on user agent
*/
public static function configureCookieLifetime($sessionLifetime, $config) {
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$isIE = preg_match("/msie/i", $userAgent);
$isSafari = preg_match("/safari/i", $userAgent) && !preg_match("/chrome/i", $userAgent);
// Set cookie lifetime based on browser and configuration
if (($isIE && $config['ie_cookie_lifetime'] != 1) ||
($isSafari && $config['safari_cookie_lifetime'] != 1)) {
return; // Do not set cookie lifetime if conditions are not met
}
ini_set('session.cookie_lifetime', $sessionLifetime);
}
/**
* @deprecated 3.2.2, We keep this function only for backwards compatibility because is used in the plugin manager
*/
@@ -247,6 +300,10 @@ class Bootstrap
$file = $filter->xssFilterHard($file);
$downloadFileName = $filter->xssFilterHard($downloadFileName);
//if (DEBUG_TIME_LOG) { // to do: remove comment
self::logTimeByPage();
//}
$browserCacheFilesUid = G::browserCacheFilesGetUid();
if ($browserCacheFilesUid != null) {
@@ -720,16 +777,16 @@ class Bootstrap
*/
public static function logTimeByPage()
{
if (!defined(PATH_DATA)) {
if (!defined('PATH_DATA')) {
return false;
}
$serverAddr = $_SERVER ['SERVER_ADDR'];
global $startingTime;
$endTime = microtime(true);
$time = $endTime - $startingTime;
$fpt = fopen(PATH_DATA . 'log/time.log', 'a');
fwrite($fpt, sprintf("%s.%03d %15s %s %5.3f %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), substr($serverAddr, - 4), $time, $_SERVER ['REQUEST_URI']));
$time = $endTime - self::$startingTime;
Bootstrap::verifyPath(PATH_DATA . 'logs', true);
$fpt = fopen(PATH_DATA . 'logs/time.log', 'a');
fwrite($fpt, sprintf("%s %7.6f %-15s %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), $_SERVER ['REQUEST_URI']));
fclose($fpt);
}