Convert static Session class to normal session class
All static Session:: calls (except for checking valid session name) are converted to object type. This Object is passed on to Login, Admin Backend and any other class that needs basic session checking
This commit is contained in:
@@ -15,6 +15,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
{
|
{
|
||||||
private static $db;
|
private static $db;
|
||||||
private static $log;
|
private static $log;
|
||||||
|
private static $session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start DB conneciton, setup DB, etc
|
* start DB conneciton, setup DB, etc
|
||||||
@@ -28,6 +29,8 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
'The PgSQL extension is not available.'
|
'The PgSQL extension is not available.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// init session
|
||||||
|
self::$session = new \CoreLibs\Create\Session('ACLLoginTest');
|
||||||
// logger is always needed
|
// logger is always needed
|
||||||
// define basic connection set valid and one invalid
|
// define basic connection set valid and one invalid
|
||||||
self::$log = new \CoreLibs\Debug\Logging([
|
self::$log = new \CoreLibs\Debug\Logging([
|
||||||
@@ -96,7 +99,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
'ACL\Login Tests have not yet been implemented'
|
'ACL\Login Tests have not yet been implemented'
|
||||||
);
|
);
|
||||||
|
|
||||||
$login = new \CoreLibs\ACL\Login(self::$db, self::$log);
|
$login = new \CoreLibs\ACL\Login(self::$db, self::$log, self::$session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ final class CoreLibsCreateSessionTest extends TestCase
|
|||||||
'sessionNameGlobals',
|
'sessionNameGlobals',
|
||||||
'/^\w+$/'
|
'/^\w+$/'
|
||||||
],
|
],
|
||||||
'session constant' => [
|
'session name default' => [
|
||||||
'sessionNameConstant',
|
'',
|
||||||
'c',
|
'd',
|
||||||
'sessionNameConstant',
|
'',
|
||||||
'/^\w+$/'
|
'/^\w+$/'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -64,19 +64,22 @@ final class CoreLibsCreateSessionTest extends TestCase
|
|||||||
$expected_n,
|
$expected_n,
|
||||||
$expected_i
|
$expected_i
|
||||||
): void {
|
): void {
|
||||||
// NEEDS MOCKING
|
/*
|
||||||
/* $session_id = '';
|
// MOCK class for dummy call
|
||||||
|
$session = new \CoreLibs\Create\Session();
|
||||||
|
$session_id = '';
|
||||||
|
unset($GLOBALS['SET_SESSION_NAME']);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'p':
|
case 'p':
|
||||||
$session_id = \CoreLibs\Create\Session::startSession($input);
|
$session_id = $session->startSession($input);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
$GLOBALS['SET_SESSION_NAME'] = $input;
|
$GLOBALS['SET_SESSION_NAME'] = $input;
|
||||||
$session_id = \CoreLibs\Create\Session::startSession();
|
$session_id = $session->startSession();
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'd':
|
||||||
define('SET_SESSION_NAME', $input);
|
$expected_n = ini_get('session.name');
|
||||||
$session_id = \CoreLibs\Create\Session::startSession();
|
$session_id = \$session->startSession();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
@@ -85,11 +88,11 @@ final class CoreLibsCreateSessionTest extends TestCase
|
|||||||
);
|
);
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
$expected_i,
|
$expected_i,
|
||||||
(string)\CoreLibs\Create\Session::getSessionId()
|
(string)$session->getSessionId()
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected_n,
|
$expected_n,
|
||||||
\CoreLibs\Create\Session::getSessionName()
|
$session->getSessionName()
|
||||||
);
|
);
|
||||||
if ($type == 'g') {
|
if ($type == 'g') {
|
||||||
unset($GLOBALS['SET_SESSION_NAME']);
|
unset($GLOBALS['SET_SESSION_NAME']);
|
||||||
|
|||||||
@@ -23,14 +23,12 @@ define('USE_DATABASE', true);
|
|||||||
require 'config.php';
|
require 'config.php';
|
||||||
// override ECHO ALL FALSE
|
// override ECHO ALL FALSE
|
||||||
$ECHO_ALL = true;
|
$ECHO_ALL = true;
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-admin';
|
$LOG_FILE_ID = 'classTest-admin';
|
||||||
|
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
'file_id' => $LOG_FILE_ID,
|
'file_id' => $LOG_FILE_ID,
|
||||||
@@ -49,7 +47,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
$locale['domain'],
|
$locale['domain'],
|
||||||
$locale['path'],
|
$locale['path'],
|
||||||
);
|
);
|
||||||
$backend = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
|
$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-array';
|
$LOG_FILE_ID = 'classTest-array';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-autoloader';
|
$LOG_FILE_ID = 'classTest-autoloader';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-byte';
|
$LOG_FILE_ID = 'classTest-byte';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-colors';
|
$LOG_FILE_ID = 'classTest-colors';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-datetime';
|
$LOG_FILE_ID = 'classTest-datetime';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-email';
|
$LOG_FILE_ID = 'classTest-email';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-encoding';
|
$LOG_FILE_ID = 'classTest-encoding';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-datetime';
|
$LOG_FILE_ID = 'classTest-datetime';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-hash';
|
$LOG_FILE_ID = 'classTest-hash';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-html';
|
$LOG_FILE_ID = 'classTest-html';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-image';
|
$LOG_FILE_ID = 'classTest-image';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-json';
|
$LOG_FILE_ID = 'classTest-json';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-lang';
|
$LOG_FILE_ID = 'classTest-lang';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-login';
|
$LOG_FILE_ID = 'classTest-login';
|
||||||
|
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||||
// init login & backend class
|
// init login & backend class
|
||||||
|
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
'file_id' => $LOG_FILE_ID,
|
'file_id' => $LOG_FILE_ID,
|
||||||
@@ -39,7 +37,7 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
'print_all' => $PRINT_ALL ?? false,
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
]);
|
]);
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
$login = new CoreLibs\ACL\Login($db, $log);
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-math';
|
$LOG_FILE_ID = 'classTest-math';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-mime';
|
$LOG_FILE_ID = 'classTest-mime';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ define('USE_DATABASE', true);
|
|||||||
require 'config.php';
|
require 'config.php';
|
||||||
// override ECHO ALL FALSE
|
// override ECHO ALL FALSE
|
||||||
$ECHO_ALL = true;
|
$ECHO_ALL = true;
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-form';
|
$LOG_FILE_ID = 'classTest-form';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-pass';
|
$LOG_FILE_ID = 'classTest-pass';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ ob_start();
|
|||||||
define('USE_DATABASE', true);
|
define('USE_DATABASE', true);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest';
|
$LOG_FILE_ID = 'classTest';
|
||||||
|
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||||
|
|
||||||
// init login & backend class
|
// init login & backend class
|
||||||
|
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
'file_id' => $LOG_FILE_ID,
|
'file_id' => $LOG_FILE_ID,
|
||||||
@@ -40,14 +38,14 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
'print_all' => $PRINT_ALL ?? false,
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
]);
|
]);
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
$login = new CoreLibs\ACL\Login($db, $log);
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
$l10n = new \CoreLibs\Language\L10n(
|
$l10n = new \CoreLibs\Language\L10n(
|
||||||
$locale['locale'],
|
$locale['locale'],
|
||||||
$locale['domain'],
|
$locale['domain'],
|
||||||
$locale['path'],
|
$locale['path'],
|
||||||
);
|
);
|
||||||
$backend = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
|
$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||||
$backend->db->dbInfo(true);
|
$backend->db->dbInfo(true);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-phpv';
|
$LOG_FILE_ID = 'classTest-phpv';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-randomkey';
|
$LOG_FILE_ID = 'classTest-randomkey';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-readEnvFile';
|
$LOG_FILE_ID = 'classTest-readEnvFile';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-runningtime';
|
$LOG_FILE_ID = 'classTest-runningtime';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
// if (!defined('SET_SESSION_NAME')) {
|
|
||||||
// define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
// }
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-session';
|
$LOG_FILE_ID = 'classTest-session';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
@@ -62,6 +58,7 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
'print_all' => $PRINT_ALL ?? false,
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
]);
|
]);
|
||||||
use CoreLibs\Create\Session;
|
use CoreLibs\Create\Session;
|
||||||
|
$session = new Session();
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SESSION';
|
$PAGE_NAME = 'TEST CLASS: SESSION';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
@@ -76,15 +73,15 @@ $value = 'bar';
|
|||||||
|
|
||||||
foreach (['123', '123-123', '123abc'] as $_session_name) {
|
foreach (['123', '123-123', '123abc'] as $_session_name) {
|
||||||
print "[UNSET] Session Name valid for " . $_session_name . ": "
|
print "[UNSET] Session Name valid for " . $_session_name . ": "
|
||||||
. (Session::checkValidSessionName($_session_name) ? 'Valid' : 'Invalid') . "<br>";
|
. ($session->checkValidSessionName($_session_name) ? 'Valid' : 'Invalid') . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
||||||
|
|
||||||
print "[UNSET] Current session id: " . Session::getSessionId() . "<br>";
|
print "[UNSET] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
print "[UNSET] Current session name: " . Session::getSessionName() . "<br>";
|
print "[UNSET] Current session name: " . $session->getSessionName() . "<br>";
|
||||||
print "[UNSET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
print "[UNSET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
||||||
print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
print "[UNSET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||||
if (isset($_SESSION)) {
|
if (isset($_SESSION)) {
|
||||||
print "[UNSET] _SESSION is: set<br>";
|
print "[UNSET] _SESSION is: set<br>";
|
||||||
} else {
|
} else {
|
||||||
@@ -92,22 +89,22 @@ if (isset($_SESSION)) {
|
|||||||
}
|
}
|
||||||
#
|
#
|
||||||
print "[UNSET] To set session name valid: "
|
print "[UNSET] To set session name valid: "
|
||||||
. (Session::checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "<br>";
|
. ($session->checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "<br>";
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
print "[FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[SET] Current session id: " . $session . "<br>";
|
print "[SET] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
// set again
|
// set again
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[2 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
print "[2 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[2 SET] Current session id: " . $session . "<br>";
|
print "[2 SET] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
print "[SET] Current session id: " . Session::getSessionId() . "<br>";
|
print "[SET] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
print "[SET] Current session name: " . Session::getSessionName() . "<br>";
|
print "[SET] Current session name: " . $session->getSessionName() . "<br>";
|
||||||
print "[SET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
print "[SET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
||||||
print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
print "[SET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||||
if (isset($_SESSION)) {
|
if (isset($_SESSION)) {
|
||||||
print "[SET] _SESSION is: set<br>";
|
print "[SET] _SESSION is: set<br>";
|
||||||
} else {
|
} else {
|
||||||
@@ -117,51 +114,51 @@ if (!isset($_SESSION['counter'])) {
|
|||||||
$_SESSION['counter'] = 0;
|
$_SESSION['counter'] = 0;
|
||||||
}
|
}
|
||||||
$_SESSION['counter']++;
|
$_SESSION['counter']++;
|
||||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
$_SESSION[$var] = $value;
|
$_SESSION[$var] = $value;
|
||||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||||
|
|
||||||
// differnt session name
|
// differnt session name
|
||||||
$session_name = 'class-test-session-ALT';
|
$session_name = 'class-test-session-ALT';
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[3 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
print "[3 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[3 SET] Current session id: " . $session . "<br>";
|
print "[3 SET] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
print "[SET AGAIN] Current session id: " . Session::getSessionId() . "<br>";
|
print "[SET AGAIN] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
|
|
||||||
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "<br>";
|
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "<br>";
|
||||||
|
|
||||||
// close session
|
// close session
|
||||||
Session::writeClose();
|
$session->writeClose();
|
||||||
// will never be written
|
// will never be written
|
||||||
$_SESSION['will_never_be_written'] = 'empty';
|
$_SESSION['will_never_be_written'] = 'empty';
|
||||||
|
|
||||||
// open again
|
// open again
|
||||||
$session_name = 'class-test-session';
|
$session_name = 'class-test-session';
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[4 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
print "[4 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[4 SET] Current session id: " . $session . "<br>";
|
print "[4 SET] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
print "[START AGAIN] Current session id: " . Session::getSessionId() . "<br>";
|
print "[START AGAIN] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
$_SESSION['will_be_written_again'] = 'Full';
|
$_SESSION['will_be_written_again'] = 'Full';
|
||||||
|
|
||||||
// close session
|
// close session
|
||||||
Session::writeClose();
|
$session->writeClose();
|
||||||
// invalid
|
// invalid
|
||||||
$session_name = '123';
|
$session_name = '123';
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[5 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
print "[5 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[5 SET] Current session id: " . $session . "<br>";
|
print "[5 SET] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
print "[BAD NAME] Current session id: " . Session::getSessionId() . "<br>";
|
print "[BAD NAME] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
print "[BAD NAME] Current session name: " . Session::getSessionName() . "<br>";
|
print "[BAD NAME] Current session name: " . $session->getSessionName() . "<br>";
|
||||||
print "[BAD NAME] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
print "[BAD NAME] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
||||||
print "[BAD NAME] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
print "[BAD NAME] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-session.read';
|
$LOG_FILE_ID = 'classTest-session.read';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
@@ -62,6 +58,7 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
'print_all' => $PRINT_ALL ?? false,
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
]);
|
]);
|
||||||
use CoreLibs\Create\Session;
|
use CoreLibs\Create\Session;
|
||||||
|
$session = new Session();
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
@@ -77,28 +74,28 @@ $value = 'bar';
|
|||||||
|
|
||||||
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
||||||
|
|
||||||
print "[UNSET] Current session id: " . Session::getSessionId() . "<br>";
|
print "[UNSET] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
print "[UNSET] Current session name: " . Session::getSessionName() . "<br>";
|
print "[UNSET] Current session name: " . $session->getSessionName() . "<br>";
|
||||||
print "[UNSET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
print "[UNSET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
||||||
print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
print "[UNSET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||||
|
|
||||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
// start
|
// start
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "Session start failed: " . Session::getErrorStr() . "<br>";
|
print "Session start failed: " . $session->getErrorStr() . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "Current session id: " . $session . "<br>";
|
print "Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
// set again
|
// set again
|
||||||
if (false === ($session = Session::startSession($session_name))) {
|
if (false === ($session_id = $session->startSession($session_name))) {
|
||||||
print "[2] Session start failed<br>";
|
print "[2] Session start failed<br>";
|
||||||
} else {
|
} else {
|
||||||
print "[2] Current session id: " . $session . "<br>";
|
print "[2] Current session id: " . $session_id . "<br>";
|
||||||
}
|
}
|
||||||
print "[SET] Current session id: " . Session::getSessionId() . "<br>";
|
print "[SET] Current session id: " . $session->getSessionId() . "<br>";
|
||||||
print "[SET] Current session name: " . Session::getSessionName() . "<br>";
|
print "[SET] Current session name: " . $session->getSessionName() . "<br>";
|
||||||
print "[SET] Current session active: " . (Session::checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
print "[SET] Current session active: " . ($session->checkActiveSession() ? 'Yes' : 'No') . "<br>";
|
||||||
print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
print "[SET] Current session status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ define('USE_DATABASE', true);
|
|||||||
require 'config.php';
|
require 'config.php';
|
||||||
// override ECHO ALL FALSE
|
// override ECHO ALL FALSE
|
||||||
$ECHO_ALL = true;
|
$ECHO_ALL = true;
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-smarty';
|
$LOG_FILE_ID = 'classTest-smarty';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-system';
|
$LOG_FILE_ID = 'classTest-system';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
@@ -50,16 +46,23 @@ print "<body>";
|
|||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
print "System::getHostName():<br>";
|
||||||
print "GETHOSTNAME: " . DgS::printAr(System::getHostName()) . "<br>";
|
print "GETHOSTNAME: " . DgS::printAr(System::getHostName()) . "<br>";
|
||||||
|
print "System::getPageName():<br>";
|
||||||
print "GETPAGENAME(0): " . System::getPageName() . "<br>";
|
print "GETPAGENAME(0): " . System::getPageName() . "<br>";
|
||||||
print "GETPAGENAME(1): " . System::getPageName(System::NO_EXTENSION) . "<br>";
|
print "GETPAGENAME(1): " . System::getPageName(System::NO_EXTENSION) . "<br>";
|
||||||
print "GETPAGENAME(2): " . System::getPageName(System::FULL_PATH) . "<br>";
|
print "GETPAGENAME(2): " . System::getPageName(System::FULL_PATH) . "<br>";
|
||||||
|
print "System::getPageNameArray():<br>";
|
||||||
print "GETPAGENAMEARRAY: " . \CoreLibs\Debug\Support::printAr(System::getPageNameArray()) . "<br>";
|
print "GETPAGENAMEARRAY: " . \CoreLibs\Debug\Support::printAr(System::getPageNameArray()) . "<br>";
|
||||||
// seting errro codes file upload
|
// seting errro codes file upload
|
||||||
|
print "System::fileUploadErrorMessage():<br>";
|
||||||
print "FILEUPLOADERRORMESSAGE(): " . System::fileUploadErrorMessage(-1) . "<br>";
|
print "FILEUPLOADERRORMESSAGE(): " . System::fileUploadErrorMessage(-1) . "<br>";
|
||||||
print "FILEUPLOADERRORMESSAGE(UPLOAD_ERR_CANT_WRITE): "
|
print "FILEUPLOADERRORMESSAGE(UPLOAD_ERR_CANT_WRITE): "
|
||||||
. System::fileUploadErrorMessage(UPLOAD_ERR_CANT_WRITE) . "<br>";
|
. System::fileUploadErrorMessage(UPLOAD_ERR_CANT_WRITE) . "<br>";
|
||||||
|
|
||||||
|
print "System::checkCLI():<br>";
|
||||||
|
print "Are we in an CLI: " . (System::checkCLI() ? 'Yes' : 'No') . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-token';
|
$LOG_FILE_ID = 'classTest-token';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ ob_start();
|
|||||||
define('USE_DATABASE', false);
|
define('USE_DATABASE', false);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name
|
|
||||||
if (!defined('SET_SESSION_NAME')) {
|
|
||||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
|
||||||
}
|
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-uids';
|
$LOG_FILE_ID = 'classTest-uids';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|||||||
@@ -150,8 +150,6 @@ define('SERVER_PATH_HASH', hash('crc32b', BASE));
|
|||||||
define('EDIT_SESSION_NAME', BASE_NAME . 'Admin' . SERVER_NAME_HASH . SERVER_PATH_HASH);
|
define('EDIT_SESSION_NAME', BASE_NAME . 'Admin' . SERVER_NAME_HASH . SERVER_PATH_HASH);
|
||||||
// frontend
|
// frontend
|
||||||
define('SESSION_NAME', BASE_NAME . SERVER_NAME_HASH . SERVER_PATH_HASH);
|
define('SESSION_NAME', BASE_NAME . SERVER_NAME_HASH . SERVER_PATH_HASH);
|
||||||
// SET_SESSION_NAME should be set in the header if a special session name is needed
|
|
||||||
define('SET_SESSION_NAME', SESSION_NAME);
|
|
||||||
|
|
||||||
/************* CACHE/COMPILE IDS *************/
|
/************* CACHE/COMPILE IDS *************/
|
||||||
define('CACHE_ID', 'CACHE_' . BASE_NAME . '_' . SERVER_NAME_HASH);
|
define('CACHE_ID', 'CACHE_' . BASE_NAME . '_' . SERVER_NAME_HASH);
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ if (isset($_POST['action']) && $_POST['action'] != 'download_csv' && !$AJAX_PAGE
|
|||||||
if ($AJAX_PAGE && !$ZIP_STREAM) {
|
if ($AJAX_PAGE && !$ZIP_STREAM) {
|
||||||
header("Content-Type: application/json; charset=UTF-8");
|
header("Content-Type: application/json; charset=UTF-8");
|
||||||
}
|
}
|
||||||
// start session
|
|
||||||
CoreLibs\Create\Session::startSession();
|
|
||||||
//------------------------------ basic variable settings start
|
//------------------------------ basic variable settings start
|
||||||
|
|
||||||
//------------------------------ class init start
|
//------------------------------ class init start
|
||||||
|
// start session
|
||||||
|
$session = new \CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||||
// create logger
|
// create logger
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -71,7 +71,7 @@ if (
|
|||||||
// db config with logger
|
// db config with logger
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
// login & page access check
|
// login & page access check
|
||||||
$login = new CoreLibs\ACL\Login($db, $log);
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
// lang, path, domain
|
// lang, path, domain
|
||||||
// pre auto detect language after login
|
// pre auto detect language after login
|
||||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
@@ -84,7 +84,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
// create smarty object
|
// create smarty object
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||||
// create new Backend class with db and loger attached
|
// create new Backend class with db and loger attached
|
||||||
$cms = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
|
$cms = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||||
// the menu show flag (what menu to show)
|
// the menu show flag (what menu to show)
|
||||||
$cms->menu_show_flag = 'main';
|
$cms->menu_show_flag = 'main';
|
||||||
// db info
|
// db info
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ extract($_POST, EXTR_SKIP);
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name here
|
|
||||||
// $SET_SESSION_NAME = EDIT_SESSION_NAME;
|
|
||||||
// overrride debug flags
|
// overrride debug flags
|
||||||
if (!DEBUG) {
|
if (!DEBUG) {
|
||||||
$DEBUG_ALL = false;
|
$DEBUG_ALL = false;
|
||||||
@@ -45,8 +43,8 @@ if (!DEBUG) {
|
|||||||
|
|
||||||
// should be utf8
|
// should be utf8
|
||||||
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
||||||
// set session
|
// start session
|
||||||
\CoreLibs\Create\Session::startSession(EDIT_SESSION_NAME);
|
$session = new \CoreLibs\Create\Session(EDIT_SESSION_NAME);
|
||||||
// init logger
|
// init logger
|
||||||
$log = new CoreLibs\Debug\Logging([
|
$log = new CoreLibs\Debug\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -60,7 +58,7 @@ $log = new CoreLibs\Debug\Logging([
|
|||||||
// db connection
|
// db connection
|
||||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
// login page
|
// login page
|
||||||
$login = new CoreLibs\ACL\Login($db, $log);
|
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||||
// lang, path, domain
|
// lang, path, domain
|
||||||
// pre auto detect language after login
|
// pre auto detect language after login
|
||||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ declare(strict_types=1);
|
|||||||
namespace CoreLibs\ACL;
|
namespace CoreLibs\ACL;
|
||||||
|
|
||||||
use CoreLibs\Check\Password;
|
use CoreLibs\Check\Password;
|
||||||
use CoreLibs\Create\Session;
|
|
||||||
|
|
||||||
class Login
|
class Login
|
||||||
{
|
{
|
||||||
@@ -162,24 +161,30 @@ class Login
|
|||||||
public $db;
|
public $db;
|
||||||
/** @var \CoreLibs\Language\L10n language */
|
/** @var \CoreLibs\Language\L10n language */
|
||||||
public $l;
|
public $l;
|
||||||
|
/** @var \CoreLibs\Create\Session session class */
|
||||||
|
public $session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor, does ALL, opens db, works through connection checks,
|
* constructor, does ALL, opens db, works through connection checks,
|
||||||
* finishes itself
|
* finishes itself
|
||||||
*
|
*
|
||||||
* @param \CoreLibs\DB\IO $db Database connection class
|
* @param \CoreLibs\DB\IO $db Database connection class
|
||||||
* @param \CoreLibs\Debug\Logging $log Logging class
|
* @param \CoreLibs\Debug\Logging $log Logging class
|
||||||
|
* @param \CoreLibs\Create\Session $session Session interface class
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\DB\IO $db,
|
\CoreLibs\DB\IO $db,
|
||||||
\CoreLibs\Debug\Logging $log
|
\CoreLibs\Debug\Logging $log,
|
||||||
|
\CoreLibs\Create\Session $session
|
||||||
) {
|
) {
|
||||||
|
// attach db class
|
||||||
|
$this->db = $db;
|
||||||
// log login data for this class only
|
// log login data for this class only
|
||||||
$log->setLogPer('class', true);
|
$log->setLogPer('class', true);
|
||||||
// attach logger
|
// attach logger
|
||||||
$this->log = $log;
|
$this->log = $log;
|
||||||
// attach db class
|
// attach session class
|
||||||
$this->db = $db;
|
$this->session = $session;
|
||||||
// set internal page name
|
// set internal page name
|
||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
// set db special errors
|
// set db special errors
|
||||||
@@ -192,12 +197,9 @@ class Login
|
|||||||
// initial the session if there is no session running already
|
// initial the session if there is no session running already
|
||||||
// check if session exists and could be created
|
// check if session exists and could be created
|
||||||
// TODO: move session creation and check to outside?
|
// TODO: move session creation and check to outside?
|
||||||
if (Session::startSession() === false) {
|
if ($this->session->checkActiveSession() === false) {
|
||||||
$this->login_error = 1;
|
$this->login_error = 1;
|
||||||
echo '<b>Session not started or could not be started!</b><br>'
|
echo '<b>No active session found</b>';
|
||||||
. 'Use \'\CoreLibs\Create\Session::startSession();\'.<br>'
|
|
||||||
. 'For less problems with other session, you can set a '
|
|
||||||
. 'session name with \'\CoreLibs\Create\Session::startSession(\'name\');\'.<br>';
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +291,7 @@ class Login
|
|||||||
// ** LANGUAGE SET AFTER LOGIN **
|
// ** LANGUAGE SET AFTER LOGIN **
|
||||||
// set the locale
|
// set the locale
|
||||||
if (
|
if (
|
||||||
Session::getSessionId() !== false &&
|
$this->session->checkActiveSession() === true &&
|
||||||
!empty($_SESSION['DEFAULT_LANG'])
|
!empty($_SESSION['DEFAULT_LANG'])
|
||||||
) {
|
) {
|
||||||
$locale = $_SESSION['DEFAULT_LOCALE'] ?? '';
|
$locale = $_SESSION['DEFAULT_LOCALE'] ?? '';
|
||||||
@@ -1369,7 +1371,7 @@ EOM;
|
|||||||
$q .= "NULL, ";
|
$q .= "NULL, ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$q .= "'" . Session::getSessionId() . "', ";
|
$q .= "'" . $this->session->getSessionId() . "', ";
|
||||||
$q .= "'" . $this->db->dbEscapeString($this->action) . "', ";
|
$q .= "'" . $this->db->dbEscapeString($this->action) . "', ";
|
||||||
$q .= "'" . $this->db->dbEscapeString($this->username) . "', ";
|
$q .= "'" . $this->db->dbEscapeString($this->username) . "', ";
|
||||||
$q .= "NULL, ";
|
$q .= "NULL, ";
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ class Backend
|
|||||||
public $db;
|
public $db;
|
||||||
/** @var \CoreLibs\Language\L10n language */
|
/** @var \CoreLibs\Language\L10n language */
|
||||||
public $l;
|
public $l;
|
||||||
|
/** @var \CoreLibs\Create\Session session class */
|
||||||
|
public $session;
|
||||||
// smarty publics [end processing in smarty class]
|
// smarty publics [end processing in smarty class]
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public $DATA;
|
public $DATA;
|
||||||
@@ -114,23 +116,27 @@ class Backend
|
|||||||
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
||||||
/**
|
/**
|
||||||
* main class constructor
|
* main class constructor
|
||||||
* @param \CoreLibs\DB\IO $db Database connection class
|
* @param \CoreLibs\DB\IO $db Database connection class
|
||||||
* @param \CoreLibs\Debug\Logging $log Logging class
|
* @param \CoreLibs\Debug\Logging $log Logging class
|
||||||
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
* @param \CoreLibs\Create\Session $session Session interface class
|
||||||
* @param array<string,string> $locale locale data read from setLocale
|
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
||||||
|
* @param array<string,string> $locale locale data read from setLocale
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\DB\IO $db,
|
\CoreLibs\DB\IO $db,
|
||||||
\CoreLibs\Debug\Logging $log,
|
\CoreLibs\Debug\Logging $log,
|
||||||
|
\CoreLibs\Create\Session $session,
|
||||||
\CoreLibs\Language\L10n $l10n,
|
\CoreLibs\Language\L10n $l10n,
|
||||||
array $locale
|
array $locale
|
||||||
) {
|
) {
|
||||||
|
// attach db class
|
||||||
|
$this->db = $db;
|
||||||
// set to log not per class
|
// set to log not per class
|
||||||
$log->setLogPer('class', false);
|
$log->setLogPer('class', false);
|
||||||
// attach logger
|
// attach logger
|
||||||
$this->log = $log;
|
$this->log = $log;
|
||||||
// attach db class
|
// attach session class
|
||||||
$this->db = $db;
|
$this->session = $session;
|
||||||
// get the language sub class & init it
|
// get the language sub class & init it
|
||||||
$this->l = $l10n;
|
$this->l = $l10n;
|
||||||
// parse and read, legacy stuff
|
// parse and read, legacy stuff
|
||||||
@@ -232,9 +238,9 @@ class Backend
|
|||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT'] ?? '') . "', "
|
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT'] ?? '') . "', "
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_CHARSET'] ?? '') . "', "
|
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_CHARSET'] ?? '') . "', "
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_ENCODING'] ?? '') . "', "
|
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_ENCODING'] ?? '') . "', "
|
||||||
. (\CoreLibs\Create\Session::getSessionId() === false ?
|
. ($this->session->getSessionId() === false ?
|
||||||
"NULL" :
|
"NULL" :
|
||||||
"'" . \CoreLibs\Create\Session::getSessionId() . "'")
|
"'" . $this->session->getSessionId() . "'")
|
||||||
. ", "
|
. ", "
|
||||||
. "'" . $this->db->dbEscapeString($this->action) . "', "
|
. "'" . $this->db->dbEscapeString($this->action) . "', "
|
||||||
. "'" . $this->db->dbEscapeString($this->action_id) . "', "
|
. "'" . $this->db->dbEscapeString($this->action_id) . "', "
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ class Basic
|
|||||||
// logging interface, Debug\Logging class
|
// logging interface, Debug\Logging class
|
||||||
/** @var \CoreLibs\Debug\Logging */
|
/** @var \CoreLibs\Debug\Logging */
|
||||||
public $log;
|
public $log;
|
||||||
|
/** @var\CoreLibs\Create\Session */
|
||||||
|
public $session;
|
||||||
|
|
||||||
// email valid checks
|
// email valid checks
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
@@ -148,7 +150,7 @@ class Basic
|
|||||||
$this->email_regex_check = \CoreLibs\Check\Email::getEmailRegexCheck();
|
$this->email_regex_check = \CoreLibs\Check\Email::getEmailRegexCheck();
|
||||||
|
|
||||||
// initial the session if there is no session running already
|
// initial the session if there is no session running already
|
||||||
\CoreLibs\Create\Session::startSession($session_name);
|
$this->session = new \CoreLibs\Create\Session($session_name ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* start a php sesseion
|
* start a php sesseion
|
||||||
* name can be given via startSession parameter
|
* name can be given via startSession parameter
|
||||||
* if not set tries to read $SET_SESSION_NAME from global
|
* if not set tries to read $SET_SESSION_NAME from global
|
||||||
* if this is not set tries to read SET_SESSION_NAME constant
|
* else will use default set in php.ini
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
@@ -16,13 +16,29 @@ namespace CoreLibs\Create;
|
|||||||
class Session
|
class Session
|
||||||
{
|
{
|
||||||
/** @var string list for errors*/
|
/** @var string list for errors*/
|
||||||
private static $error_str = '';
|
private $error_str = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init a session
|
* init a session, if array is empty or array does not have session_name set
|
||||||
|
* then no auto init is run
|
||||||
|
*
|
||||||
|
* @param string $session_name if set and not empty, will start session
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(string $session_name = '')
|
||||||
{
|
{
|
||||||
|
if (!empty($session_name)) {
|
||||||
|
$this->startSession($session_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if we are in CLI, we set this, so we can mock this too
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function checkCLI(): bool
|
||||||
|
{
|
||||||
|
return \CoreLibs\Get\System::checkCLI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,9 +46,9 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return string Last error string
|
* @return string Last error string
|
||||||
*/
|
*/
|
||||||
public static function getErrorStr(): string
|
public function getErrorStr(): string
|
||||||
{
|
{
|
||||||
return self::$error_str;
|
return $this->error_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,39 +85,30 @@ class Session
|
|||||||
* @param string|null $session_name
|
* @param string|null $session_name
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public static function startSession(?string $session_name = null)
|
public function startSession(?string $session_name = null)
|
||||||
{
|
{
|
||||||
// we can't start sessions on command line
|
// we can't start sessions on command line
|
||||||
if (\CoreLibs\Get\System::checkCLI()) {
|
if ($this->checkCLI()) {
|
||||||
self::$error_str = '[SESSION] No sessions in php cli';
|
$this->error_str = '[SESSION] No sessions in php cli';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if session are OFF
|
// if session are OFF
|
||||||
if (self::getSessionStatus() === PHP_SESSION_DISABLED) {
|
if ($this->getSessionStatus() === PHP_SESSION_DISABLED) {
|
||||||
self::$error_str = '[SESSION] Sessions are disabled';
|
$this->error_str = '[SESSION] Sessions are disabled';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// session_status
|
// session_status
|
||||||
// initial the session if there is no session running already
|
// initial the session if there is no session running already
|
||||||
if (!self::checkActiveSession()) {
|
if (!$this->checkActiveSession()) {
|
||||||
// if session name is emtpy, check if there is a global set
|
// if session name is emtpy, check if there is a global set
|
||||||
// this is a deprecated fallback
|
// this is a deprecated fallback
|
||||||
$session_name = $session_name ?? $GLOBALS['SET_SESSION_NAME'] ?? '';
|
$session_name = $session_name ?? $GLOBALS['SET_SESSION_NAME'] ?? '';
|
||||||
// check if we have an external session name given, else skip this step
|
// DEPRECTED: constant SET_SESSION_NAME is no longer used
|
||||||
// this is a deprecated fallback
|
|
||||||
if (
|
|
||||||
empty($session_name) &&
|
|
||||||
defined('SET_SESSION_NAME') &&
|
|
||||||
!empty(SET_SESSION_NAME)
|
|
||||||
) {
|
|
||||||
// set the session name for possible later check
|
|
||||||
$session_name = SET_SESSION_NAME;
|
|
||||||
}
|
|
||||||
// if set, set special session name
|
// if set, set special session name
|
||||||
if (!empty($session_name)) {
|
if (!empty($session_name)) {
|
||||||
// invalid session name, abort
|
// invalid session name, abort
|
||||||
if (!self::checkValidSessionName($session_name)) {
|
if (!$this->checkValidSessionName($session_name)) {
|
||||||
self::$error_str = '[SESSION] Invalid session name: ' . $session_name;
|
$this->error_str = '[SESSION] Invalid session name: ' . $session_name;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
session_name($session_name);
|
session_name($session_name);
|
||||||
@@ -110,11 +117,11 @@ class Session
|
|||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
// if we still have no active session
|
// if we still have no active session
|
||||||
if (!self::checkActiveSession()) {
|
if (!$this->checkActiveSession()) {
|
||||||
self::$error_str = '[SESSION] Failed to activate session';
|
$this->error_str = '[SESSION] Failed to activate session';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return self::getSessionId();
|
return $this->getSessionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +129,7 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public static function getSessionId()
|
public function getSessionId()
|
||||||
{
|
{
|
||||||
return session_id();
|
return session_id();
|
||||||
}
|
}
|
||||||
@@ -132,7 +139,7 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public static function getSessionName()
|
public function getSessionName()
|
||||||
{
|
{
|
||||||
return session_name();
|
return session_name();
|
||||||
}
|
}
|
||||||
@@ -143,9 +150,9 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return bool True if there is an active session, else false
|
* @return bool True if there is an active session, else false
|
||||||
*/
|
*/
|
||||||
public static function checkActiveSession(): bool
|
public function checkActiveSession(): bool
|
||||||
{
|
{
|
||||||
if (self::getSessionStatus() === PHP_SESSION_ACTIVE) {
|
if ($this->getSessionStatus() === PHP_SESSION_ACTIVE) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -160,7 +167,7 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return bool True und sucess, false on failure
|
* @return bool True und sucess, false on failure
|
||||||
*/
|
*/
|
||||||
public static function writeClose(): bool
|
public function writeClose(): bool
|
||||||
{
|
{
|
||||||
return session_write_close();
|
return session_write_close();
|
||||||
}
|
}
|
||||||
@@ -175,7 +182,7 @@ class Session
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getSessionStatus(): int
|
public function getSessionStatus(): int
|
||||||
{
|
{
|
||||||
return session_status();
|
return session_status();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user