Update all class test files in admin with proper named header
This commit is contained in:
@@ -51,10 +51,12 @@ $l10n = new \CoreLibs\Language\L10n(
|
||||
);
|
||||
$backend = new CoreLibs\Admin\Backend($db, $log, $l10n, $locale);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: ADMIN BACKEND</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// set acl, from eg login acl
|
||||
print "SETACL[]: " . $backend->setACL(['EMPTY' => 'EMPTY']) . "<br>";
|
||||
|
||||
@@ -45,10 +45,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
// $_array = new CoreLibs\Combined\ArrayHandler();
|
||||
// $array_class = 'CoreLibs\Combination\ArrayHandler';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ARRAY HANDLER';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// recursive array search
|
||||
$test_array = [
|
||||
|
||||
@@ -32,10 +32,12 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Convert\Byte;
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: AUTOLOADER';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: AUTOLOADER</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$bytes = 10242424;
|
||||
$_bytes = Byte::humanReadableByteFormat($bytes);
|
||||
|
||||
@@ -43,10 +43,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$byte_class = 'CoreLibs\Convert\Byte';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: BYTE CONVERT';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: BYTE CONVERT</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// class
|
||||
$byte = 254779258;
|
||||
|
||||
@@ -44,10 +44,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$color_class = 'CoreLibs\Convert\Colors';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: COLORS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: COLORS</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
|
||||
@@ -36,11 +36,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: CONFIG DIRECT</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><b>CONFIG DIRECT</b></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
|
||||
@@ -36,11 +36,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONFIG LINK';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: CONFIG LINK</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><b>CONFIG LINK</b></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
|
||||
@@ -44,10 +44,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$datetime_class = 'CoreLibs\Combined\DateTime';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DATE/TIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: DATE/TIME</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// class
|
||||
$timestamp = 1622788315.123456;
|
||||
|
||||
@@ -39,10 +39,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: DB</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "LOGFILE NAME: " . $db->log->getSetting('log_file_name') . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getSetting('log_file_id') . "<br>";
|
||||
|
||||
@@ -44,10 +44,12 @@ $debug = new CoreLibs\Debug\Logging([
|
||||
$debug_support_class = 'CoreLibs\Debug\Support';
|
||||
$debug_logging_class = 'CoreLibs\Debug\Logging';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DEBUG';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: DEBUG</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
function test()
|
||||
{
|
||||
|
||||
@@ -43,10 +43,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: HTML/ELEMENTS</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// regex get
|
||||
print "S::GETEMAILREGEX(0): " . Email::getEmailRegex(0) . "<br>";
|
||||
|
||||
@@ -48,10 +48,12 @@ $_chk_enc = new CoreLibs\Check\Encoding();
|
||||
$_con_enc = new CoreLibs\Convert\Encoding();
|
||||
$chk_enc = 'CoreLibs\Check\Encoding';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ENCODING (CHECK/CONVERT/MIME)';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: ENCODING (CHECK/CONVERT/MIME)</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// print "Valid encoding: ".$log->printAr(mb_list_encodings())."<br>";
|
||||
|
||||
|
||||
@@ -42,10 +42,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: FILE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: FILE</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$file = '/some/path/to/some/file.txt';
|
||||
print "GETFILENAMEENDING: $file: " . File::getFilenameEnding($file) . "<br>";
|
||||
|
||||
@@ -45,10 +45,12 @@ $hash_class = 'CoreLibs\Create\Hash';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HASH';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: HASH</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$to_crc = 'Some text block';
|
||||
// static
|
||||
|
||||
@@ -49,10 +49,12 @@ $elements_class = 'CoreLibs\Output\Form\Elements';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: HTML/ELEMENTS</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$string = "Something < = > Other <br> Next line";
|
||||
print "HTMLENT: " . Html::htmlent($string) . ": " . $_html->htmlent($string) . "<br>";
|
||||
|
||||
@@ -46,10 +46,12 @@ $image_class = 'CoreLibs\Output\Image';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: IMAGE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: IMAGE</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// thumb sizes
|
||||
$thumb_width = 250;
|
||||
|
||||
@@ -46,10 +46,12 @@ $json_class = 'CoreLibs\Convert\Json';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: JSON';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: JSON</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$json = '{"foo": "bar"}';
|
||||
$output = Json::jsonConvertToArray($json);
|
||||
|
||||
@@ -29,10 +29,12 @@ if (!defined('SET_SESSION_NAME')) {
|
||||
$LOG_FILE_ID = 'classTest-lang';
|
||||
ob_end_flush();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: LANG';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: LANG</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
use CoreLibs\Language\L10n;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
@@ -42,10 +42,12 @@ $db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$login = new CoreLibs\ACL\Login($db, $log);
|
||||
ob_end_flush();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: LOGIN</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
echo "CHECK PERMISSION: " . ($login->loginCheckPermissions() ? 'OK' : 'BAD') . "<br>";
|
||||
echo "IS ADMIN: " . ($login->loginIsAdmin() ? 'OK' : 'BAD') . "<br>";
|
||||
|
||||
@@ -44,10 +44,12 @@ $math_class = 'CoreLibs\Convert\Math';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: MATH';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: MATH</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "FCEIL: " . $_math->fceil(5.1234567890, 5) . "<br>";
|
||||
print "FLOORP: " . $_math->floorp(5123456, -3) . "<br>";
|
||||
|
||||
@@ -41,10 +41,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$_mime = new CoreLibs\Convert\MimeAppName();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: MIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: MIME</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$mime = 'application/illustrator';
|
||||
print "MIME $mime: " . $_mime->mimeGetAppName($mime) . "<br>";
|
||||
|
||||
@@ -69,10 +69,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: FORM GENERATE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: FORM GENERATE</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "MOBILE PHONE: " . $form->mobile_phone . "<br>";
|
||||
// sets table array to include
|
||||
|
||||
@@ -46,10 +46,12 @@ $password_class = 'CoreLibs\Check\Password';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: PASSWORD';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: PASSWORD</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$password = 'something1234';
|
||||
$enc_password = $_password->passwordSet($password);
|
||||
|
||||
@@ -81,6 +81,7 @@ print '<div><a href="class_test.debug.php">Class Test: DEBUG</a></div>';
|
||||
print '<div><a href="class_test.output.form.php">Class Test: OUTPUT FORM</a></div>';
|
||||
print '<div><a href="class_test.admin.backend.php">Class Test: BACKEND ADMIN CLASS</a></div>';
|
||||
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
|
||||
print '<div><a href="class_test.session.php">Class Test: SESSION</a></div>';
|
||||
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>';
|
||||
print '<div><a href="class_test.login.php">Class Test: LOGIN</a></div>';
|
||||
print '<div><a href="class_test.autoloader.php">Class Test: AUTOLOADER</a></div>';
|
||||
|
||||
@@ -46,10 +46,12 @@ $phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: PHP VERSION';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: PHP VERSION</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$min_version_s = '7';
|
||||
$min_version_ss = '7.1';
|
||||
|
||||
@@ -43,10 +43,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$array_class = 'CoreLibs\Create\RandomKey';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: RANDOM KEY';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: RANDOM KEY</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$key_length = 10;
|
||||
$key_length_b = 5;
|
||||
|
||||
@@ -34,10 +34,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
]);
|
||||
$ref_class = 'CoreLibs\Get\ReadEnvFile';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: READ ENV FILE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: READ ENV FILE</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "ALREADY from config.php: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
||||
|
||||
|
||||
@@ -42,10 +42,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: RUNNING TIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: RUNNING IMTE</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
RunningTime::hrRunningTime();
|
||||
RunningTime::runningTime();
|
||||
|
||||
160
www/admin/class_test.session.php
Normal file
160
www/admin/class_test.session.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = 1;
|
||||
$PRINT_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $status
|
||||
* @return string
|
||||
*/
|
||||
function getSessionStatusString(int $status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case PHP_SESSION_DISABLED:
|
||||
$status = 'PHP_SESSION_DISABLED';
|
||||
break;
|
||||
case PHP_SESSION_NONE:
|
||||
$status = 'PHP_SESSION_NONE';
|
||||
break;
|
||||
case PHP_SESSION_ACTIVE:
|
||||
$status = 'PHP_SESSION_ACTIVE';
|
||||
break;
|
||||
default:
|
||||
$status = '[!] UNDEFINED';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// set session name
|
||||
// if (!defined('SET_SESSION_NAME')) {
|
||||
// define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
// }
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-session';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'file_id' => $LOG_FILE_ID,
|
||||
// add file date
|
||||
'print_file_date' => true,
|
||||
// set debug and print flags
|
||||
'debug_all' => $DEBUG_ALL ?? false,
|
||||
'echo_all' => $ECHO_ALL ?? false,
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
use CoreLibs\Create\Session;
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SESSION';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$session_name = 'class-test-session';
|
||||
$var = 'foo';
|
||||
$value = 'bar';
|
||||
|
||||
foreach (['123', '123-123', '123abc'] as $_session_name) {
|
||||
print "[UNSET] Session Name valid for " . $_session_name . ": "
|
||||
. (Session::checkValidSessionName($_session_name) ? 'Valid' : 'Invalid') . "<br>";
|
||||
}
|
||||
|
||||
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
||||
|
||||
print "[UNSET] Current session id: " . Session::getSessionId() . "<br>";
|
||||
print "[UNSET] Current session name: " . Session::getSessionName() . "<br>";
|
||||
print "[UNSET] Current session active: " . Session::checkActiveSession() . "<br>";
|
||||
print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
||||
if (isset($_SESSION)) {
|
||||
print "[UNSET] _SESSION is: set<br>";
|
||||
} else {
|
||||
print "[UNSET] _SESSION is: not set<br>";
|
||||
}
|
||||
#
|
||||
print "[UNSET] To set session name valid: "
|
||||
. (Session::checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "<br>";
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "[FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "[SET] Current session id: " . $session . "<br>";
|
||||
}
|
||||
// set again
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "[2 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "[2 SET] Current session id: " . $session . "<br>";
|
||||
}
|
||||
print "[SET] Current session id: " . Session::getSessionId() . "<br>";
|
||||
print "[SET] Current session name: " . Session::getSessionName() . "<br>";
|
||||
print "[SET] Current session active: " . Session::checkActiveSession() . "<br>";
|
||||
print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
||||
if (isset($_SESSION)) {
|
||||
print "[SET] _SESSION is: set<br>";
|
||||
} else {
|
||||
print "[SET] _SESSION is: not set<br>";
|
||||
}
|
||||
if (!isset($_SESSION['counter'])) {
|
||||
$_SESSION['counter'] = 0;
|
||||
}
|
||||
$_SESSION['counter']++;
|
||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||
$_SESSION[$var] = $value;
|
||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||
|
||||
// differnt session name
|
||||
$session_name = 'class-test-session-ALT';
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "[3 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "[3 SET] Current session id: " . $session . "<br>";
|
||||
}
|
||||
print "[SET AGAIN] Current session id: " . Session::getSessionId() . "<br>";
|
||||
|
||||
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "<br>";
|
||||
|
||||
// close session
|
||||
Session::writeClose();
|
||||
// will never be written
|
||||
$_SESSION['will_never_be_written'] = 'empty';
|
||||
|
||||
// open again
|
||||
$session_name = 'class-test-session';
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "[4 FAILED] Session start failed: " . Session::getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "[4 SET] Current session id: " . $session . "<br>";
|
||||
}
|
||||
print "[START AGAIN] Current session id: " . Session::getSessionId() . "<br>";
|
||||
$_SESSION['will_be_written_again'] = 'Full';
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
114
www/admin/class_test.session.read.php
Normal file
114
www/admin/class_test.session.read.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = 1;
|
||||
$PRINT_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param int $status
|
||||
* @return string
|
||||
*/
|
||||
function getSessionStatusString(int $status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case PHP_SESSION_DISABLED:
|
||||
$status = 'PHP_SESSION_DISABLED';
|
||||
break;
|
||||
case PHP_SESSION_NONE:
|
||||
$status = 'PHP_SESSION_NONE';
|
||||
break;
|
||||
case PHP_SESSION_ACTIVE:
|
||||
$status = 'PHP_SESSION_ACTIVE';
|
||||
break;
|
||||
default:
|
||||
$status = '[!] UNDEFINED';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
}
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-session.read';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'file_id' => $LOG_FILE_ID,
|
||||
// add file date
|
||||
'print_file_date' => true,
|
||||
// set debug and print flags
|
||||
'debug_all' => $DEBUG_ALL ?? false,
|
||||
'echo_all' => $ECHO_ALL ?? false,
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
use CoreLibs\Create\Session;
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$session_name = 'class-test-session';
|
||||
// $session_name = '';
|
||||
$var = 'foo';
|
||||
$value = 'bar';
|
||||
|
||||
echo "Global session name: " . ($GLOBALS['SET_SESSION_NAME'] ?? '-') . "<br>";
|
||||
|
||||
print "[UNSET] Current session id: " . Session::getSessionId() . "<br>";
|
||||
print "[UNSET] Current session name: " . Session::getSessionName() . "<br>";
|
||||
print "[UNSET] Current session active: " . Session::checkActiveSession() . "<br>";
|
||||
print "[UNSET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
||||
|
||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||
// start
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "Session start failed: " . Session::getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "Current session id: " . $session . "<br>";
|
||||
}
|
||||
// set again
|
||||
$session = Session::startSession($session_name);
|
||||
if ($session === false) {
|
||||
print "[2] Session start failed<br>";
|
||||
} else {
|
||||
print "[2] Current session id: " . $session . "<br>";
|
||||
}
|
||||
print "[SET] Current session id: " . Session::getSessionId() . "<br>";
|
||||
print "[SET] Current session name: " . Session::getSessionName() . "<br>";
|
||||
print "[SET] Current session active: " . Session::checkActiveSession() . "<br>";
|
||||
print "[SET] Current session status: " . getSessionStatusString(Session::getSessionStatus()) . "<br>";
|
||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||
|
||||
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -49,10 +49,12 @@ $l10n = new \CoreLibs\Language\L10n(
|
||||
);
|
||||
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: SMARTY</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$smarty->DATA['JS_DEBUG'] = DEBUG;
|
||||
$smarty->MASTER_TEMPLATE_NAME = 'main_body.tpl';
|
||||
|
||||
@@ -43,10 +43,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SYSTEM';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: SYSTEM</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "GETHOSTNAME: " . DgS::printAr(System::getHostName()) . "<br>";
|
||||
print "GETPAGENAME(0): " . System::getPageName() . "<br>";
|
||||
|
||||
@@ -42,10 +42,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
$_token = new CoreLibs\Output\Form\Token();
|
||||
$token_class = 'CoreLibs\Output\Form\Token';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: FORM TOKEN';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: FORM TOKEN</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$token = 'test_form_token';
|
||||
$token_id = $_token->setFormToken($token);
|
||||
|
||||
@@ -43,10 +43,12 @@ $_uids = new CoreLibs\Create\Uids();
|
||||
use CoreLibs\Create\Uids;
|
||||
$uids_class = 'CoreLibs\Create\Uids';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: UIDS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: UIDS</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
// class
|
||||
print "UUIDV4: " . $_uids->uuidv4() . "<br>";
|
||||
|
||||
@@ -36,11 +36,12 @@ $log = new CoreLibs\Debug\Logging([
|
||||
'print_all' => $PRINT_ALL ?? false,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT SUB';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS: CONFIG DIRECT SUB</title><head>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="../class_test.php">Class Test Master</a></div>';
|
||||
print '<div><b>CONFIG DIRECT SUB</b></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
|
||||
Reference in New Issue
Block a user