Merge branch 'NewFeatures' into phpstan-strict
@@ -6,14 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -29,43 +22,63 @@ $SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
ob_end_flush();
|
||||
|
||||
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db config with logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
$l10n = new \CoreLibs\Language\L10n(
|
||||
$locale['locale'],
|
||||
$locale['domain'],
|
||||
$locale['path'],
|
||||
SITE_LOCALE,
|
||||
SITE_DOMAIN,
|
||||
BASE . INCLUDES . LOCALE,
|
||||
SITE_ENCODING
|
||||
);
|
||||
$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||
$backend = new CoreLibs\Admin\Backend(
|
||||
$db,
|
||||
$log,
|
||||
$session,
|
||||
$l10n,
|
||||
DEFAULT_ACL_LEVEL
|
||||
);
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>";
|
||||
print "ADBEDITLOG: " . $backend->adbEditLog('CLASSTEST-ADMIN', 'Some info stirng') . "<br>";
|
||||
print "ADBTOPMENU(0): " . \CoreLibs\Debug\Support::printAr($backend->adbTopMenu()) . "<br>";
|
||||
print "ADBMSG: " . $backend->adbMsg('info', 'Message: %1$d', [1]) . "<br>";
|
||||
print "Messaes: " . \CoreLibs\Debug\Support::printAr($backend->messages) . "<br>";
|
||||
print "ADBPRINTDATETIME:<br>" . $backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test') . "<br>";
|
||||
print "SETACL[]: <br>";
|
||||
$backend->setACL(['EMPTY' => 'EMPTY']);
|
||||
print "ADBEDITLOG: <br>";
|
||||
$backend->adbEditLog('CLASSTEST-ADMIN-BINARY', 'Some info string', 'BINARY');
|
||||
$backend->adbEditLog('CLASSTEST-ADMIN-ZLIB', 'Some info string', 'ZLIB');
|
||||
$backend->adbEditLog('CLASSTEST-ADMIN-SERIAL', 'Some info string', 'SERIAL');
|
||||
$backend->adbEditLog('CLASSTEST-ADMIN-INVALID', 'Some info string', 'INVALID');
|
||||
// test with various
|
||||
$backend->action = 'TEST ACTION';
|
||||
$backend->action_id = 'TEST ACTION ID';
|
||||
$backend->action_yes = 'TEST ACTION YES';
|
||||
$backend->action_flag = 'TEST ACTION FLAG';
|
||||
$backend->action_menu = 'TEST ACTION MENU';
|
||||
$backend->action_loaded = 'TEST ACTION LOADED';
|
||||
$backend->action_value = 'TEST ACTION VALUE';
|
||||
$backend->action_type = 'TEST ACTION TYPE';
|
||||
$backend->action_error = 'TEST ACTION ERROR';
|
||||
$backend->adbEditLog('CLASSTEST-ADMIN-JSON', [
|
||||
"_GET" => $_GET,
|
||||
"_POST" => $_POST,
|
||||
], 'JSON');
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
print "ADBTOPMENU(0): " . Support::printAr($backend->adbTopMenu(CONTENT_PATH)) . "<br>";
|
||||
print "ADBMSG: <br>";
|
||||
$backend->adbMsg('info', 'Message: %1$d', [1]);
|
||||
print "Messaes: " . Support::printAr($backend->messages) . "<br>";
|
||||
print "ADBPRINTDATETIME:<br>" . $backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test') . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,23 +20,20 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Combined\ArrayHandler;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
use CoreLibs\Convert\SetVarType;
|
||||
// use PHPUnit\Framework\Constraint\ArrayHasKey;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// $_array = new CoreLibs\Combined\ArrayHandler();
|
||||
// $array_class = 'CoreLibs\Combination\ArrayHandler';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ARRAY HANDLER';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -92,7 +82,9 @@ $array_3 = [
|
||||
]
|
||||
];
|
||||
// recusrice merge
|
||||
print "ARRAYMERGERECURSIVE: " . DgS::printAr(ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3)) . "<br>";
|
||||
print "ARRAYMERGERECURSIVE: " . DgS::printAr(SetVarType::setArray(
|
||||
ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3)
|
||||
)) . "<br>";
|
||||
// array difference
|
||||
$array_left = [
|
||||
'same' => 'data',
|
||||
@@ -104,7 +96,9 @@ $array_right = [
|
||||
];
|
||||
print "ARRAYDIFF: " . DgS::printAr(ArrayHandler::arrayDiff($array_left, $array_right)) . "<br>";
|
||||
// in array check
|
||||
print "INARRAYANY([1,3], [array]): " . DgS::printAr(ArrayHandler::inArrayAny([1, 3], $array_2)) . "<br>";
|
||||
print "INARRAYANY([1,3], [array]): " . DgS::printAr(SetVarType::setArray(
|
||||
ArrayHandler::inArrayAny([1, 3], $array_2)
|
||||
)) . "<br>";
|
||||
// flatten array
|
||||
print "FLATTENARRAY: " . DgS::printAr(ArrayHandler::flattenArray($test_array)) . "<br>";
|
||||
print "FLATTENARRAYKEY: " . DgS::printAr(ArrayHandler::flattenArrayKey($test_array)) . "<br>";
|
||||
@@ -114,10 +108,10 @@ print "ARRAYFLATFORKEY: " . DgS::printAr(ArrayHandler::arrayFlatForKey($test_arr
|
||||
/**
|
||||
* attach key/value to an array so it becomes nested
|
||||
*
|
||||
* @param string $pre Attach to new (empty for new root node)
|
||||
* @param string $cur New node
|
||||
* @param array $node Previous created array
|
||||
* @return array Updated array
|
||||
* @param string $pre Attach to new (empty for new root node)
|
||||
* @param string $cur New node
|
||||
* @param array<mixed> $node Previous created array
|
||||
* @return array<mixed> Updated array
|
||||
*/
|
||||
function rec(string $pre, string $cur, array $node = [])
|
||||
{
|
||||
@@ -146,6 +140,38 @@ function rec(string $pre, string $cur, array $node = [])
|
||||
return $node;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'image' => 'foo',
|
||||
'element' => 'w-1',
|
||||
'rotate' => 360,
|
||||
'html' => [
|
||||
'image' => 'bar',
|
||||
'result_image' => 'baz',
|
||||
'rule' => 'wrong'
|
||||
],
|
||||
[
|
||||
'image' => 'large'
|
||||
],
|
||||
[
|
||||
'nothing' => 'wrong'
|
||||
],
|
||||
'nest' => [
|
||||
'nust' => [
|
||||
'nist' => [
|
||||
'foo' => 'bar',
|
||||
'image' => 'long, long'
|
||||
]
|
||||
]
|
||||
],
|
||||
's' => [
|
||||
'image' => 'path?'
|
||||
],
|
||||
];
|
||||
|
||||
$search = ['image', 'result_image', 'nothing', 'EMPTY'];
|
||||
$result = ArrayHandler::arraySearchKey($data, $search);
|
||||
print "ARRAYSEARCHKEY: Search: " . DgS::printAr($search) . ", Found: " . DgS::printAr($result) . "<br>";
|
||||
|
||||
// $test = [
|
||||
// 'A' => [
|
||||
// 'B' => [],
|
||||
@@ -211,8 +237,21 @@ $flag = false;
|
||||
$output = \CoreLibs\Combined\ArrayHandler::genAssocArray($db_array, $key, $value, $flag);
|
||||
print "OUTPUT: " . \CoreLibs\Debug\Support::printAr($output) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "<hr>";
|
||||
$array = [
|
||||
'a' => 'First',
|
||||
'b' => 'Second',
|
||||
'c' => 'Third',
|
||||
];
|
||||
|
||||
foreach (array_keys($array) as $search) {
|
||||
print "Result[" . $search . "]: "
|
||||
. "next: " . DgS::printAr(ArrayHandler::arrayGetNextKey($array, $search)) . ", "
|
||||
. "prev: " . DgS::printAr(ArrayHandler::arrayGetPrevKey($array, $search))
|
||||
. "<br>";
|
||||
}
|
||||
print "Key not exists: " . DgS::printAr(ArrayHandler::arrayGetNextKey($array, 'z')) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
// basic class test file
|
||||
@@ -30,7 +23,7 @@ use CoreLibs\Convert\Byte;
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: AUTOLOADER';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,21 +20,16 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Convert\Byte;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$byte_class = 'CoreLibs\Convert\Byte';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: BYTE CONVERT';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -106,9 +94,6 @@ foreach ($bytes as $byte) {
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,20 +21,15 @@ ob_end_flush();
|
||||
use CoreLibs\Check\Colors;
|
||||
// use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CHECK COLORS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -111,13 +99,10 @@ echo "<hr>";
|
||||
try {
|
||||
$check = Colors::validateColor('#ab12cd', 99);
|
||||
print "No Exception";
|
||||
} catch (\Exception $e) {
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "ERROR: " . $e->getCode() . ": " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
42
www/admin/class_test.class-calls.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest_class_calls';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CLASS CALLS';
|
||||
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>';
|
||||
|
||||
$test = new \TestCalls\Test($db, $log);
|
||||
|
||||
$test->testDbCall();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,20 +18,15 @@ require '../configs/config.php';
|
||||
$LOG_FILE_ID = 'classTest-config-direct';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -47,13 +35,10 @@ print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
print "ROOT: " . ROOT . "<br>";
|
||||
print "BASE NAME: " . BASE_NAME . "<br>";
|
||||
echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "<br>";
|
||||
echo "Config path prefix: " . ($CONFIG_PATH_PREFIX ?? '') . "<br>";
|
||||
print "DB Name: " . DB_CONFIG_NAME . "<br>";
|
||||
print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,20 +18,15 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-config-link';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONFIG LINK';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -47,13 +35,10 @@ print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
print "ROOT: " . ROOT . "<br>";
|
||||
print "BASE NAME: " . BASE_NAME . "<br>";
|
||||
echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "<br>";
|
||||
echo "Config path prefix: " . ($CONFIG_PATH_PREFIX ?? '') . "<br>";
|
||||
print "DB Name: " . DB_CONFIG_NAME . "<br>";
|
||||
print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,22 +20,18 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Convert\Colors;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
use CoreLibs\Convert\SetVarType;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$color_class = 'CoreLibs\Convert\Colors';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONVERT COLORS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -50,8 +39,18 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
// A(out of bounds)
|
||||
print "C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: " . CoreLibs\Convert\Colors::rgb2hex(-1, -1, -1) . "<br>";
|
||||
print "\$C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: " . $color_class::rgb2hex(-1, -1, -1) . "<br>";
|
||||
try {
|
||||
print "C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: "
|
||||
. CoreLibs\Convert\Colors::rgb2hex(-1, -1, -1) . "<br>";
|
||||
} catch (\LengthException $e) {
|
||||
print "*Exception: " . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
try {
|
||||
print "\$C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: "
|
||||
. $color_class::rgb2hex(-1, -1, -1) . "<br>";
|
||||
} catch (\LengthException $e) {
|
||||
print "**Exception: " . $e->getMessage() . "<br><pre>" . print_r($e, true) . "</pre><br>";
|
||||
}
|
||||
// B(valid)
|
||||
$rgb = [10, 20, 30];
|
||||
$hex = '#0a141e';
|
||||
@@ -59,24 +58,40 @@ $hsb = [210, 67, 12];
|
||||
$hsb_f = [210.5, 67.5, 12.5];
|
||||
$hsl = [210, 50, 7.8];
|
||||
print "S::COLOR rgb->hex: $rgb[0], $rgb[1], $rgb[2]: " . Colors::rgb2hex($rgb[0], $rgb[1], $rgb[2]) . "<br>";
|
||||
print "S::COLOR hex->rgb: $hex: " . DgS::printAr(Colors::hex2rgb($hex)) . "<br>";
|
||||
print "C::S/COLOR rgb->hext: $hex: " . DgS::printAr(CoreLibs\Convert\Colors::hex2rgb($hex)) . "<br>";
|
||||
print "S::COLOR hex->rgb: $hex: " . DgS::printAr(SetVarType::setArray(
|
||||
Colors::hex2rgb($hex)
|
||||
)) . "<br>";
|
||||
print "C::S/COLOR rgb->hext: $hex: " . DgS::printAr(SetVarType::setArray(
|
||||
CoreLibs\Convert\Colors::hex2rgb($hex)
|
||||
)) . "<br>";
|
||||
// C(to hsb/hsl)
|
||||
print "S::COLOR rgb->hsb: $rgb[0], $rgb[1], $rgb[2]: "
|
||||
. DgS::printAr(Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2])) . "<br>";
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2])
|
||||
)) . "<br>";
|
||||
print "S::COLOR rgb->hsl: $rgb[0], $rgb[1], $rgb[2]: "
|
||||
. DgS::printAr(Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2])) . "<br>";
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2])
|
||||
)) . "<br>";
|
||||
// D(from hsb/hsl) Note that param 2 + 3 is always 0-100 divided
|
||||
print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: "
|
||||
. DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])) . "<br>";
|
||||
print "S::COLOR hsb_f->rgb: $hsb_f[0], $hsb_f[1], $hsb_f[2]: "
|
||||
. DgS::printAr(Colors::hsb2rgb($hsb_f[0], $hsb_f[1], $hsb_f[2])) . "<br>";
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])
|
||||
)) . "<br>";
|
||||
print "S::COLOR hsb_f->rgb: $hsb_f[0], $hsb_f[1], $hsb_f[2]: "
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::hsb2rgb($hsb_f[0], $hsb_f[1], $hsb_f[2])
|
||||
)) . "<br>";
|
||||
print "S::COLOR hsl->rgb: $hsl[0], $hsl[1], $hsl[2]: "
|
||||
. DgS::printAr(Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2])) . "<br>";
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2])
|
||||
)) . "<br>";
|
||||
|
||||
$hsb = [0, 0, 5];
|
||||
print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: "
|
||||
. DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])) . "<br>";
|
||||
. DgS::printAr(SetVarType::setArray(
|
||||
Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])
|
||||
)) . "<br>";
|
||||
|
||||
// Random text
|
||||
$h = rand(0, 359);
|
||||
@@ -84,14 +99,11 @@ $s = rand(15, 70);
|
||||
$b = 100;
|
||||
$l = 50;
|
||||
print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "<br>";
|
||||
print "RANDOM hsb->rgb: <pre>" . DgS::printAr(Colors::hsb2rgb($h, $s, $b)) . "</pre><br>";
|
||||
print "RANDOM hsl->rgb: <pre>" . DgS::printAr(Colors::hsl2rgb($h, $s, $l)) . "</pre><br>";
|
||||
print "RANDOM hsb->rgb: <pre>" . DgS::printAr(SetVarType::setArray(Colors::hsb2rgb($h, $s, $b))) . "</pre><br>";
|
||||
print "RANDOM hsl->rgb: <pre>" . DgS::printAr(SetVarType::setArray(Colors::hsl2rgb($h, $s, $l))) . "</pre><br>";
|
||||
|
||||
// TODO: run compare check input must match output
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// will be overwritten in config.master.php depending on location
|
||||
$DEBUG_ALL_OVERRIDE = true; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$ECHO_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -32,22 +23,17 @@ $ECHO_ALL = true;
|
||||
use CoreLibs\Create\Email;
|
||||
use CoreLibs\Convert\Html;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'echo_all' => $ECHO_ALL,
|
||||
'print_all' => $PRINT_ALL,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CREATE EMAIL';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -136,9 +122,6 @@ $status = Email::sendEmail(
|
||||
);
|
||||
print "SENDING D: " . $status . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,21 +21,16 @@ ob_end_flush();
|
||||
use CoreLibs\Combined\DateTime;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$datetime_class = 'CoreLibs\Combined\DateTime';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DATE/TIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -63,10 +51,7 @@ if (round($timestamp, 4) == DateTime::stringToTime($time_string)) {
|
||||
} else {
|
||||
print "REVERSE TRIME STRING DO NOT MATCH<br>";
|
||||
}
|
||||
print "ZERO TIME STRING: " . DateTime::timeStringFormat(0, true) . "<br>";
|
||||
print "ZERO TIME STRING: " . DateTime::timeStringFormat(0.0, true) . "<br>";
|
||||
print "ZERO TIME STRING: " . DateTime::timeStringFormat(1.005, true) . "<br>";
|
||||
|
||||
print "<hr>";
|
||||
$timestamps = [
|
||||
1622788315.123456,
|
||||
-1622788315.456789
|
||||
@@ -76,6 +61,159 @@ foreach ($timestamps as $timestamp) {
|
||||
print "DATESTRINGFORMAT(sm:1:0): $timestamp: " . DateTime::dateStringFormat($timestamp, true) . "<br>";
|
||||
print "DATESTRINGFORMAT(sm:1:1): $timestamp: " . DateTime::dateStringFormat($timestamp, true, true) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
// $interval = 0;
|
||||
// $interval = 1000000;
|
||||
// $interval = 123456;
|
||||
// $interval = 3600;
|
||||
$interval = 3601;
|
||||
// $interval = 86400;
|
||||
// $interval = 86401;
|
||||
// $interval = (86400 * 606) + 16434.5;
|
||||
// $interval = 1.5;
|
||||
// $interval = 123456;
|
||||
// $interval = 120.1;
|
||||
// $interval = 1641515890;
|
||||
// $interval = 0.123456;
|
||||
// $interval = 1641515890;
|
||||
// $interval = 999999999999999999;
|
||||
// $interval = 60;
|
||||
try {
|
||||
// print "Test-DEP: [$interval] "
|
||||
// . intervalStringFormatDeprecated(
|
||||
// $interval,
|
||||
// truncate_after: '',
|
||||
// natural_seperator: false,
|
||||
// name_space_seperator: false,
|
||||
// show_microseconds: true,
|
||||
// short_time_name: true,
|
||||
// skip_last_zero: true,
|
||||
// skip_zero: false,
|
||||
// show_only_days: false,
|
||||
// auto_fix_microseconds: false,
|
||||
// truncate_nanoseconds: false,
|
||||
// truncate_zero_seconds_if_microseconds: true,
|
||||
// )
|
||||
// // . " => "
|
||||
// // . DateTime::intervalStringFormat($interval)
|
||||
// . "<br>";
|
||||
print "Test-ACT: [$interval] "
|
||||
. DateTime::intervalStringFormat(
|
||||
$interval,
|
||||
truncate_after: '',
|
||||
natural_seperator: false,
|
||||
name_space_seperator: false,
|
||||
show_microseconds: true,
|
||||
short_time_name: true,
|
||||
skip_last_zero: true,
|
||||
skip_zero: false,
|
||||
show_only_days: false,
|
||||
auto_fix_microseconds: false,
|
||||
truncate_nanoseconds: false,
|
||||
truncate_zero_seconds_if_microseconds: true,
|
||||
)
|
||||
. " => "
|
||||
. DateTime::intervalStringFormat($interval)
|
||||
. "<br>";
|
||||
print "DEFAULT-DEP: " . intervalStringFormatDeprecated($interval) . "<br>";
|
||||
print "DEFAULT-ACT: " . DateTime::intervalStringFormat($interval) . "<br>";
|
||||
$show_micro = true;
|
||||
// print "COMPATIBLE Test-DEP: " .
|
||||
// intervalStringFormatDeprecated(
|
||||
// $interval,
|
||||
// show_microseconds: $show_micro,
|
||||
// show_only_days: true,
|
||||
// skip_zero: false,
|
||||
// skip_last_zero: false,
|
||||
// truncate_nanoseconds: true,
|
||||
// truncate_zero_seconds_if_microseconds: false
|
||||
// ) . "<br>";
|
||||
print "COMPATIBLE Test-ACT: " .
|
||||
DateTime::intervalStringFormat(
|
||||
$interval,
|
||||
show_microseconds: $show_micro,
|
||||
show_only_days: true,
|
||||
skip_zero: false,
|
||||
skip_last_zero: false,
|
||||
truncate_nanoseconds: true,
|
||||
truncate_zero_seconds_if_microseconds: false
|
||||
) . "<br>";
|
||||
print "ORIGINAL: " . DateTime::timeStringFormat($interval, $show_micro) . "<br>";
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "ERROR: " . $e->getMessage() . "<br><pre>" . $e . "</pre><br>";
|
||||
} catch (\LengthException $e) {
|
||||
print "ERROR interval: " . $e->getMessage() . "<br><pre>" . $e . "</pre><br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$intervals = [
|
||||
['i' => 0, 'sm' => true],
|
||||
['i' => 0.0, 'sm' => true],
|
||||
['i' => 1.5, 'sm' => true],
|
||||
['i' => 1.05, 'sm' => true],
|
||||
['i' => 1.005, 'sm' => true],
|
||||
['i' => 1.0005, 'sm' => true],
|
||||
];
|
||||
foreach ($intervals as $int) {
|
||||
$info = 'ts:' . $int['i'] . '|' . 'sm:' . $int['sm'];
|
||||
print "[tsf] ZERO TIME STRING [$info]: "
|
||||
. DateTime::timeStringFormat($int['i'], $int['sm']) . "<br>";
|
||||
print "[isf] ZERO TIME STRING [$info]: "
|
||||
. DateTime::intervalStringFormat($int['i'], show_microseconds:$int['sm']) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$intervals = [
|
||||
[
|
||||
'i' => 788315.123456,
|
||||
'truncate_after' => '',
|
||||
'natural_seperator' => false,
|
||||
'name_space_seperator' => false,
|
||||
'show_microseconds' => true,
|
||||
'short_time_name' => true,
|
||||
'skip_last_zero' => false,
|
||||
'skip_zero' => true,
|
||||
'show_only_days' => false,
|
||||
'auto_fix_microseconds' => false,
|
||||
'truncate_nanoseconds' => false
|
||||
],
|
||||
[
|
||||
'i' => 788315.123456,
|
||||
'truncate_after' => '',
|
||||
'natural_seperator' => true,
|
||||
'name_space_seperator' => true,
|
||||
'show_microseconds' => true,
|
||||
'short_time_name' => true,
|
||||
'skip_last_zero' => false,
|
||||
'skip_zero' => true,
|
||||
'show_only_days' => false,
|
||||
'auto_fix_microseconds' => false,
|
||||
'truncate_nanoseconds' => false
|
||||
],
|
||||
];
|
||||
foreach ($intervals as $int) {
|
||||
$info = $int['i'];
|
||||
try {
|
||||
print "INTRVALSTRINGFORMAT(sm:0): $info: "
|
||||
. DateTime::intervalStringFormat(
|
||||
$int['i'],
|
||||
truncate_after: (string)$int['truncate_after'],
|
||||
natural_seperator: $int['natural_seperator'],
|
||||
name_space_seperator: $int['name_space_seperator'],
|
||||
show_microseconds: $int['show_microseconds'],
|
||||
short_time_name: $int['short_time_name'],
|
||||
skip_last_zero: $int['skip_last_zero'],
|
||||
skip_zero: $int['skip_zero'],
|
||||
show_only_days: $int['show_only_days'],
|
||||
auto_fix_microseconds: $int['auto_fix_microseconds'],
|
||||
truncate_nanoseconds: $int['truncate_nanoseconds'],
|
||||
) . "<br>";
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "ERROR: " . $e->getMessage() . "<br><pre>" . $e . "</pre><br>";
|
||||
} catch (\LengthException $e) {
|
||||
print "ERROR interval: " . $e->getMessage() . "<br><pre>" . $e . "</pre><br>";
|
||||
}
|
||||
}
|
||||
print "<hr>";
|
||||
// convert and reverste tests
|
||||
$intervals = [
|
||||
788315.123456,
|
||||
-123.456
|
||||
@@ -86,6 +224,7 @@ foreach ($intervals as $interval) {
|
||||
print "TIMESTRINGFORMAT(sm:1): $interval: " . $reverse_interval . "<br>";
|
||||
print "STRINGTOTIME: $reverse_interval: " . DateTime::stringToTime($reverse_interval) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$check_dates = [
|
||||
'2021-05-01',
|
||||
'2021-05-40'
|
||||
@@ -93,6 +232,7 @@ $check_dates = [
|
||||
foreach ($check_dates as $check_date) {
|
||||
print "CHECKDATE: $check_date: " . (string)DateTime::checkDate($check_date) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$check_datetimes = [
|
||||
'2021-05-01',
|
||||
'2021-05-40',
|
||||
@@ -103,6 +243,7 @@ $check_datetimes = [
|
||||
foreach ($check_datetimes as $check_datetime) {
|
||||
print "CHECKDATETIME: $check_datetime: " . (string)DateTime::checkDateTime($check_datetime) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$compare_dates = [
|
||||
[ '2021-05-01', '2021-05-02', ],
|
||||
[ '2021-05-02', '2021-05-01', ],
|
||||
@@ -114,6 +255,7 @@ foreach ($compare_dates as $compare_date) {
|
||||
print "COMPAREDATE: $compare_date[0] = $compare_date[1]: "
|
||||
. (string)DateTime::compareDate($compare_date[0], $compare_date[1]) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$compare_datetimes = [
|
||||
[ '2021-05-01', '2021-05-02', ],
|
||||
[ '2021-05-02', '2021-05-01', ],
|
||||
@@ -126,6 +268,7 @@ foreach ($compare_datetimes as $compare_datetime) {
|
||||
print "COMPAREDATE: $compare_datetime[0] = $compare_datetime[1]: "
|
||||
. (string)DateTime::compareDateTime($compare_datetime[0], $compare_datetime[1]) . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
$compare_dates = [
|
||||
[ '2021-05-01', '2021-05-10', ],
|
||||
[ '2021-05-10', '2021-05-01', ],
|
||||
@@ -138,7 +281,7 @@ foreach ($compare_dates as $compare_date) {
|
||||
print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: "
|
||||
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], true)) . "<br>";
|
||||
}
|
||||
|
||||
print "<hr>";
|
||||
// test date conversion
|
||||
$dow = 2;
|
||||
print "DOW[$dow]: " . DateTime::setWeekdayNameFromIsoDow($dow) . "<br>";
|
||||
@@ -154,10 +297,261 @@ $date = '2022-70-242';
|
||||
print "DATE-dow[$date];invalid: " . DateTime::setWeekdayNameFromDate($date) . "<br>";
|
||||
print "DATE-dow[$date],long;invalid: " . DateTime::setWeekdayNameFromDate($date, true) . "<br>";
|
||||
print "DOW-date[$date];invalid: " . DateTime::setWeekdayNumberFromDate($date) . "<br>";
|
||||
print "<hr>";
|
||||
// check date range includes a weekend
|
||||
// does not:
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-05';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-10';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-31';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-01';
|
||||
$end_date = '2023-07-03';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
/**
|
||||
* DEPREACTED, original rewrite, do not use
|
||||
*
|
||||
* update timeStringFormat with year and month support
|
||||
*
|
||||
* The following flags have to be set to be timeStringFormat compatible.
|
||||
* Not that on seconds overflow this method will throw an exception, timeStringFormat returned -1s
|
||||
* show_only_days: true,
|
||||
* skip_zero: false,
|
||||
* skip_last_zero: false,
|
||||
* truncate_nanoseconds: true,
|
||||
* truncate_zero_seconds_if_microseconds: false
|
||||
*
|
||||
* @param int|float $seconds Seconds to convert, maxium 6 decimals,
|
||||
* else \UnexpectedValueException will be thrown
|
||||
* if days too large or years too large \LengthException is thrown
|
||||
* @param string $truncate_after [=''] Truncate after which time name, will not round, hard end
|
||||
* values are parts names or interval short names (y, d, f, ...)
|
||||
* if illegal value \UnexpectedValueException is thrown
|
||||
* @param bool $natural_seperator [=false] use ',' and 'and', if off use space
|
||||
* @param bool $name_space_seperator [=false] add a space between the number and the time name
|
||||
* @param bool $show_microseconds [=true] show microseconds
|
||||
* @param bool $short_time_name [=true] use the short time names (eg s instead of seconds)
|
||||
* @param bool $skip_last_zero [=true] skip all trailing zero values, eg 5m 0s => 5m
|
||||
* @param bool $skip_zero [=true] do not show zero values anywhere, eg 1h 0m 20s => 1h 20s
|
||||
* @param bool $show_only_days [=false] do not show years or months, show only days
|
||||
* if truncate after is set to year or month
|
||||
* throws \UnexpectedValueException
|
||||
* @param bool $auto_fix_microseconds [=false] if the micro seconds decimals are more than 6, round them
|
||||
* on defaul throw \UnexpectedValueException
|
||||
* @param bool $truncate_nanoseconds [=false] if microseconds decimals >3 then normal we show 123.4ms
|
||||
* cut the .4 is set to true
|
||||
* @param bool $truncate_zero_seconds_if_microseconds [=true] if we have 0.123 seconds then if true no seconds
|
||||
* will be shown
|
||||
* @return string
|
||||
* @throws \UnexpectedValueException if seconds has more than 6 decimals
|
||||
* if truncate has an illegal value
|
||||
* if truncate is set to year or month and show_only_days is turned on
|
||||
* @throws \LengthException if seconds is too large and show_days_only is selected and days is negetive
|
||||
* or if years is negativ
|
||||
*/
|
||||
function intervalStringFormatDeprecated(
|
||||
int|float $seconds,
|
||||
string $truncate_after = '',
|
||||
bool $natural_seperator = false,
|
||||
bool $name_space_seperator = false,
|
||||
bool $show_microseconds = true,
|
||||
bool $short_time_name = true,
|
||||
bool $skip_last_zero = true,
|
||||
bool $skip_zero = true,
|
||||
bool $show_only_days = false,
|
||||
bool $auto_fix_microseconds = false,
|
||||
bool $truncate_nanoseconds = false,
|
||||
bool $truncate_zero_seconds_if_microseconds = true,
|
||||
): string {
|
||||
// auto fix long seconds, else \UnexpectedValueException will be thrown on error
|
||||
// check if we have float and -> round to 6
|
||||
if ($auto_fix_microseconds === true && is_float($seconds)) {
|
||||
$seconds = round($seconds, 6);
|
||||
}
|
||||
// flag negative + set abs
|
||||
$negative = $seconds < 0 ? '-' : '';
|
||||
$seconds = abs($seconds);
|
||||
// create base time
|
||||
$date_now = new \DateTime("@0");
|
||||
try {
|
||||
$date_seconds = new \DateTime("@$seconds");
|
||||
} catch (\Exception $e) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Seconds value is invalid, too large or more than six decimals: ' . $seconds,
|
||||
1,
|
||||
$e
|
||||
);
|
||||
}
|
||||
$interval = date_diff($date_now, $date_seconds);
|
||||
// if show_only_days and negative but input postive alert that this has to be done in y/m/d ...
|
||||
if ($interval->y < 0) {
|
||||
throw new \LengthException('Input seconds value is too large for years output: ' . $seconds, 2);
|
||||
} elseif ($interval->days < 0 && $show_only_days === true) {
|
||||
throw new \LengthException('Input seconds value is too large for days output: ' . $seconds, 3);
|
||||
}
|
||||
// array order is important, small too large
|
||||
$parts = [
|
||||
'microseconds' => 'f',
|
||||
'seconds' => 's', 'minutes' => 'i', 'hours' => 'h',
|
||||
'days' => 'd', 'months' => 'm', 'years' => 'y',
|
||||
];
|
||||
$short_name = [
|
||||
'years' => 'y', 'months' => 'm', 'days' => 'd',
|
||||
'hours' => 'h', 'minutes' => 'm', 'seconds' => 's',
|
||||
'microseconds' => 'ms'
|
||||
];
|
||||
$skip = false;
|
||||
if (!empty($truncate_after)) {
|
||||
// if truncate after not in key or value in parts
|
||||
if (!in_array($truncate_after, array_keys($parts)) && !in_array($truncate_after, array_values($parts))) {
|
||||
throw new \UnexpectedValueException(
|
||||
'truncate_after has an invalid value: ' . $truncate_after,
|
||||
4
|
||||
);
|
||||
}
|
||||
// if truncate after is y or m and we have show_only_days, throw exception
|
||||
if ($show_only_days === true && in_array($truncate_after, ['y', 'years', 'm', 'months'])) {
|
||||
throw new \UnexpectedValueException(
|
||||
'If show_only_days is turned on, the truncate_after cannot be years or months: '
|
||||
. $truncate_after,
|
||||
5
|
||||
);
|
||||
}
|
||||
$skip = true;
|
||||
}
|
||||
$formatted = [];
|
||||
$zero_list = [];
|
||||
$zero_last_list = [];
|
||||
$add_zero_seconds = false;
|
||||
foreach ($parts as $time_name => $part) {
|
||||
// end for micro seconds
|
||||
if ($show_microseconds === false && $time_name == 'microseconds') {
|
||||
continue;
|
||||
}
|
||||
// skip at this time position
|
||||
if ($part == $truncate_after || $truncate_after == $time_name) {
|
||||
$skip = false;
|
||||
}
|
||||
if ($skip === true) {
|
||||
continue;
|
||||
}
|
||||
if ($show_only_days === true && $part == 'd') {
|
||||
$value = $interval->days;
|
||||
$skip = true;
|
||||
} else {
|
||||
/** @phan-suppress-next-line PhanUndeclaredProperty */
|
||||
$value = $interval->$part;
|
||||
}
|
||||
if ($value == 0 && $skip_last_zero === true) {
|
||||
continue;
|
||||
}
|
||||
// print "-> V: $value | $part, $time_name | I: " . is_int($value) . " | F: " . is_float($value)
|
||||
// . " | " . ($value != 0 ? 'Not zero' : 'ZERO') . "<br>";
|
||||
// var_dump($skip_last_zero);
|
||||
if ($value != 0 || $skip_zero === false || $skip_last_zero === false) {
|
||||
if ($part == 'f') {
|
||||
if ($truncate_nanoseconds === true) {
|
||||
$value = round($value, 3);
|
||||
}
|
||||
$value *= 1000;
|
||||
// anything above that is nano seconds?
|
||||
}
|
||||
// on first hit turn off (full off)
|
||||
if ($value) {
|
||||
$skip_last_zero = null;
|
||||
} elseif ($skip_last_zero === false) {
|
||||
$zero_last_list[] = $part;
|
||||
}
|
||||
// build format
|
||||
$format = "$value";
|
||||
if ($name_space_seperator) {
|
||||
$format .= " ";
|
||||
}
|
||||
if ($short_time_name) {
|
||||
$format .= $short_name[$time_name];
|
||||
} elseif ($value == 1) {
|
||||
$format .= substr($time_name, 0, -1);
|
||||
} else {
|
||||
$format .= $time_name;
|
||||
}
|
||||
$formatted[] = $format;
|
||||
}
|
||||
// if we have 0 value, but only for skip zero condition
|
||||
if ($skip_zero === false) {
|
||||
if ($value == 0) {
|
||||
$zero_list[] = $part;
|
||||
} else {
|
||||
$zero_list = [];
|
||||
}
|
||||
}
|
||||
if (
|
||||
$part == 's' && $value == 0 &&
|
||||
$show_microseconds === true &&
|
||||
$truncate_zero_seconds_if_microseconds === false
|
||||
) {
|
||||
$add_zero_seconds = true;
|
||||
}
|
||||
}
|
||||
// if there is a zero list, strip that from the beginning, this is done always
|
||||
if (count($zero_list)) {
|
||||
// strip
|
||||
$formatted = array_slice($formatted, 0, count($zero_list) * -1);
|
||||
} elseif (count($zero_last_list) == count($formatted)) {
|
||||
// if we have all skip empty last, then we do not have any value
|
||||
$formatted = [];
|
||||
}
|
||||
$formatted = array_reverse($formatted);
|
||||
// print "=> F: " . print_r($formatted, true)
|
||||
// . " | Z: " . print_r($zero_list, true)
|
||||
// . " | ZL: " . print_r($zero_last_list, true)
|
||||
// . "<br>";
|
||||
if (count($formatted) == 0) {
|
||||
// if we have truncate on, then we assume nothing was found
|
||||
$str = "0";
|
||||
if ($name_space_seperator) {
|
||||
$str .= " ";
|
||||
}
|
||||
// if truncate is on, we assume we found nothing
|
||||
if (!empty($truncate_after)) {
|
||||
if (in_array($truncate_after, array_values($parts))) {
|
||||
$truncate_after = array_flip($parts)[$truncate_after];
|
||||
}
|
||||
$str .= ($short_time_name ? $short_name[$truncate_after] : $truncate_after);
|
||||
} else {
|
||||
$str .= ($short_time_name ? $short_name['seconds'] : 'seconds');
|
||||
}
|
||||
return $str;
|
||||
} elseif (count($formatted) == 1) {
|
||||
return $negative .
|
||||
($add_zero_seconds ?
|
||||
'0'
|
||||
. ($name_space_seperator ? ' ' : '')
|
||||
. ($short_time_name ? $short_name['seconds'] : 'seconds')
|
||||
. ' '
|
||||
: ''
|
||||
)
|
||||
. $formatted[0];
|
||||
} elseif ($natural_seperator === false) {
|
||||
return $negative . implode(' ', $formatted);
|
||||
} else {
|
||||
$str = implode(', ', array_slice($formatted, 0, -1));
|
||||
if (!empty($formatted[count($formatted) - 1])) {
|
||||
$str .= ' and ' . $formatted[count($formatted) - 1];
|
||||
}
|
||||
return $negative . $str;
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -15,24 +15,18 @@ ob_start();
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-db';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Debug\Support;
|
||||
use CoreLibs\Debug\RunningTime;
|
||||
use CoreLibs\Convert\SetVarType;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
@@ -40,14 +34,14 @@ $db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB dbReturn';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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><a href="class_test.db.php">Class Test DB</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>";
|
||||
print "LOGFILE NAME: " . $db->log->getLogFile() . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getLogFileId() . "<br>";
|
||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||
|
||||
// DB client encoding
|
||||
@@ -62,23 +56,45 @@ print "<b>dbReturn CACHE tests</b><br>";
|
||||
$db->dbExec("DELETE FROM test_db_return");
|
||||
$db->dbExec("INSERT INTO test_db_return (uid, data) VALUES ('A1', 'Test A'), ('B1', 'Test B')");
|
||||
// read query to use
|
||||
$q_db_ret = "SELECT * FROM test_db_return ORDER BY uid";
|
||||
$q_db_ret = <<<SQL
|
||||
SELECT * FROM test_db_return ORDER BY uid
|
||||
SQL;
|
||||
|
||||
RunningTime::hrRunningTime();
|
||||
|
||||
$cache_flag = '[DEFAULT] NO_CACHE (0)';
|
||||
print "dbReturn '" . $cache_flag . "'/Default: " . $q_db_ret . "<br>";
|
||||
// Do twice
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$res = $db->dbReturn($q_db_ret);
|
||||
print $i . ") " . $cache_flag . ": "
|
||||
. "res: " . (is_bool($res) ?
|
||||
"<b>Bool:</b> " . Support::prBl($res) :
|
||||
(is_array($res) ?
|
||||
"Array: " . Support::prBl(is_array($res)) : '{-}')
|
||||
) . ", "
|
||||
. "cursor_ext: <pre>" . Support::printAr(
|
||||
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||
) . "</pre>";
|
||||
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||
}
|
||||
print "<hr>";
|
||||
|
||||
$cache_flag = 'USE_CACHE (0)';
|
||||
print "dbReturn '" . $cache_flag . "'/Default: " . $q_db_ret . "<br>";
|
||||
// SINGLE read on multi row return
|
||||
// Do twice
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$res = $db->dbReturn($q_db_ret);
|
||||
$res = $db->dbReturn($q_db_ret, $db::USE_CACHE);
|
||||
print $i . ") " . $cache_flag . ": "
|
||||
. "res: " . (is_bool($res) ?
|
||||
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||
"<b>Bool:</b> " . Support::prBl($res) :
|
||||
(is_array($res) ?
|
||||
"Array: " . $db->log->prBl(is_array($res)) : '{-}')
|
||||
"Array: " . Support::prBl(is_array($res)) : '{-}')
|
||||
) . ", "
|
||||
. "cursor_ext: <pre>" . Support::printAr($db->dbGetCursorExt($q_db_ret)) . "</pre>";
|
||||
. "cursor_ext: <pre>" . Support::printAr(
|
||||
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||
) . "</pre>";
|
||||
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||
}
|
||||
// reset all read data
|
||||
@@ -91,11 +107,13 @@ for ($i = 1; $i <= 6; $i++) {
|
||||
$res = $db->dbReturn($q_db_ret, $db::READ_NEW);
|
||||
print $i . ") " . $cache_flag . ": "
|
||||
. "res: " . (is_bool($res) ?
|
||||
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||
"<b>Bool:</b> " . Support::prBl($res) :
|
||||
(is_array($res) ?
|
||||
"Array: " . $db->log->prBl(is_array($res)) : '{-}')
|
||||
"Array: " . Support::prBl(is_array($res)) : '{-}')
|
||||
) . ", "
|
||||
. "cursor_ext: <pre>" . Support::printAr($db->dbGetCursorExt($q_db_ret)) . "</pre>";
|
||||
. "cursor_ext: <pre>" . Support::printAr(
|
||||
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||
) . "</pre>";
|
||||
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||
}
|
||||
// reset all read data
|
||||
@@ -108,11 +126,13 @@ for ($i = 1; $i <= 6; $i++) {
|
||||
$res = $db->dbReturn($q_db_ret, $db::CLEAR_CACHE);
|
||||
print $i . ") " . $cache_flag . ": "
|
||||
. "res: " . (is_bool($res) ?
|
||||
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||
"<b>Bool:</b> " . Support::prBl($res) :
|
||||
(is_array($res) ?
|
||||
"Array: " . $db->log->prBl(is_array($res)) : '{-}')
|
||||
"Array: " . Support::prBl(is_array($res)) : '{-}')
|
||||
) . ", "
|
||||
. "cursor_ext: <pre>" . Support::printAr($db->dbGetCursorExt($q_db_ret)) . "</pre>";
|
||||
. "cursor_ext: <pre>" . Support::printAr(
|
||||
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||
) . "</pre>";
|
||||
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||
}
|
||||
// reset all read data
|
||||
@@ -125,11 +145,13 @@ for ($i = 1; $i <= 6; $i++) {
|
||||
$res = $db->dbReturn($q_db_ret, $db::NO_CACHE);
|
||||
print $i . ") " . $cache_flag . ": "
|
||||
. "res: " . (is_bool($res) ?
|
||||
"<b>Bool:</b> " . $db->log->prBl($res) :
|
||||
"<b>Bool:</b> " . Support::prBl($res) :
|
||||
(is_array($res) ?
|
||||
"Array: " . $db->log->prBl(is_array($res)) : '{-}')
|
||||
"Array: " . Support::prBl(is_array($res)) : '{-}')
|
||||
) . ", "
|
||||
. "cursor_ext: <pre>" . Support::printAr($db->dbGetCursorExt($q_db_ret)) . "</pre>";
|
||||
. "cursor_ext: <pre>" . Support::printAr(
|
||||
SetVarType::setArray($db->dbGetCursorExt($q_db_ret))
|
||||
) . "</pre>";
|
||||
print "Run time: " . RunningTime::hrRunningTime() . "<br>";
|
||||
}
|
||||
// reset all data
|
||||
@@ -137,4 +159,15 @@ $db->dbCacheReset($q_db_ret);
|
||||
print "<br>";
|
||||
print "Overall Run time: " . RunningTime::hrRunningTimeFromStart() . "<br>";
|
||||
|
||||
print "<br>";
|
||||
print "PARAM TEST RUN<br>";
|
||||
// PARAM
|
||||
$q_db_ret = <<<SQL
|
||||
SELECT * FROM test_db_return WHERE uid = $1
|
||||
SQL;
|
||||
|
||||
while (is_array($res = $db->dbReturnParams($q_db_ret, ['A1'], $db::NO_CACHE, true))) {
|
||||
print "ROW: " . Support::printAr($res) . "<br>";
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -15,8 +15,6 @@ ob_start();
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-db';
|
||||
ob_end_flush();
|
||||
@@ -24,16 +22,12 @@ ob_end_flush();
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
use CoreLibs\DB\IO as DbIo;
|
||||
use CoreLibs\Debug\Support;
|
||||
use CoreLibs\Convert\SetVarType;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
@@ -41,14 +35,17 @@ $db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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><a href="class_test.db.type.php">Class Test DB row type convert to PHP type</a></div>';
|
||||
print '<div><a href="class_test.db.query-placeholder.php">Class Test DB Query Placeholder convert</a></div>';
|
||||
print '<div><a href="class_test.db.dbReturn.php">Class Test DB dbReturn</a></div>';
|
||||
print '<div><a href="class_test.db.single.php">Class Test DB Single Query tests</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>";
|
||||
print "LOGFILE NAME: " . $db->log->getLogFile() . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getLogFileId() . "<br>";
|
||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||
echo "DB_CONFIG_SET constant: <pre>" . print_r(DB_CONFIG, true) . "</pre><br>";
|
||||
|
||||
@@ -56,13 +53,17 @@ echo "DB_CONFIG_SET constant: <pre>" . print_r(DB_CONFIG, true) . "</pre><br>";
|
||||
print "DB client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||
print "DB search path: " . $db->dbGetSchema() . "<br>";
|
||||
|
||||
$to_db_version = '13.6';
|
||||
$to_db_version = '15.2';
|
||||
print "VERSION DB: " . $db->dbVersion() . "<br>";
|
||||
print "VERSION LONG DB: " . $db->dbVersionInfo('server', false) . "<br>";
|
||||
print "VERSION NUMERIC DB: " . $db->dbVersionNumeric() . "<br>";
|
||||
print "SERVER ENCODING: " . $db->dbVersionInfo('server_encoding') . "<br>";
|
||||
print "ALL PG VERSION PARAMETERS: <pre>" . print_r($db->dbVersionInfoParameters(), true) . "</pre><br>";
|
||||
print "ALL OUTPUT [TEST]: <pre>" . print_r(pg_version($db->dbGetDbh()), true) . "</pre><br>";
|
||||
if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
||||
print "ALL OUTPUT [TEST]: <pre>" . print_r(pg_version($dbh), true) . "</pre><br>";
|
||||
} else {
|
||||
print "NO DB HANDLER<br>";
|
||||
}
|
||||
print "DB Version smaller $to_db_version: " . $db->dbCompareVersion('<' . $to_db_version) . "<br>";
|
||||
print "DB Version smaller than $to_db_version: " . $db->dbCompareVersion('<=' . $to_db_version) . "<br>";
|
||||
print "DB Version equal $to_db_version: " . $db->dbCompareVersion('=' . $to_db_version) . "<br>";
|
||||
@@ -73,6 +74,44 @@ $db->dbSetEncoding('SJIS');
|
||||
print "ENCODING TEST: " . $db->dbVersionInfo('client_encoding') . "/" . $db->dbGetEncoding() . "<br>";
|
||||
$db->dbResetEncoding();
|
||||
|
||||
// empty calls, none of the below should fail
|
||||
//
|
||||
$db->dbGetCursor();
|
||||
//
|
||||
$db->dbGetCursorExt();
|
||||
//
|
||||
$db->dbGetCursorPos('SELECT foo', ['bar']);
|
||||
//
|
||||
$db->dbGetCursorNumRows('SELECT foo', ['bar']);
|
||||
//
|
||||
$db->dbGetInsertPKName();
|
||||
//
|
||||
$db->dbGetInsertPK();
|
||||
//
|
||||
$db->dbGetReturningExt();
|
||||
$db->dbGetReturningExt('foo');
|
||||
$db->dbGetReturningExt('foo', 0);
|
||||
$db->dbGetReturningExt(pos:0);
|
||||
//
|
||||
$db->dbGetReturningArray();
|
||||
//
|
||||
$db->dbGetNumRows();
|
||||
//
|
||||
$db->dbGetNumFields();
|
||||
//
|
||||
$db->dbGetFieldNames();
|
||||
//
|
||||
$db->dbGetFieldTypes();
|
||||
//
|
||||
$db->dbGetFieldNameTypes();
|
||||
//
|
||||
$db->dbGetFieldName(0);
|
||||
//
|
||||
$db->dbGetFieldType(0);
|
||||
$db->dbGetFieldType('foo');
|
||||
//
|
||||
$db->dbGetPrepareCursorValue('foo', 'bar');
|
||||
|
||||
// TEST CACHE READS
|
||||
|
||||
$res = $db->dbReturn("SELECT * FROM max_test");
|
||||
@@ -108,7 +147,11 @@ print "<br>";
|
||||
|
||||
print "<pre>";
|
||||
|
||||
print "SOCKET: " . pg_socket($db->dbGetDbh()) . "<br>";
|
||||
if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
||||
print "SOCKET: " . pg_socket($dbh) . "<br>";
|
||||
} else {
|
||||
print "NO SOCKET<br>";
|
||||
}
|
||||
|
||||
// truncate test_foo table before testing
|
||||
print "<b>TRUNCATE test_foo</b><br>";
|
||||
@@ -123,7 +166,7 @@ $status = $db->dbExec("INSERT INTO test_foo (test, number_a) VALUES "
|
||||
print "DIRECT INSERT STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "DB OBJECT: <pre>" . print_r($status, true) . "</pre>| "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
@@ -132,19 +175,19 @@ var_dump($db->dbGetReturningExt());
|
||||
|
||||
// same as above but use an EOM string
|
||||
$some_time = time();
|
||||
$query = <<<EOM
|
||||
$query = <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test, number_a
|
||||
) VALUES (
|
||||
'EOM FOO TEST $some_time', 1
|
||||
)
|
||||
RETURNING test, number_a
|
||||
EOM;
|
||||
SQL;
|
||||
$status = $db->dbExec($query);
|
||||
print "EOM STRING DIRECT INSERT STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "DB OBJECT: <pre>" . print_r($status, true) . "</pre>| "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
@@ -156,51 +199,249 @@ var_dump($db->dbGetReturningExt());
|
||||
$last_insert_pk = $db->dbGetInsertPK();
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: "
|
||||
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
||||
. "WHERE test_foo_id = " . $last_insert_pk), true) . "<br>";
|
||||
$q = <<<EOM
|
||||
SELECT
|
||||
test_foo_id, test
|
||||
FROM test_foo
|
||||
WHERE test_foo_id = $last_insert_pk;
|
||||
EOM;
|
||||
print "EOM READ OF PREVIOUS INSERTED: " . print_r($db->dbReturnRow($q), true) . "<br>";
|
||||
. "WHERE test_foo_id = " . (int)$last_insert_pk), true) . "<br>";
|
||||
$__last_insert_pk = (int)$last_insert_pk;
|
||||
$query = <<<SQL
|
||||
SELECT
|
||||
test_foo_id, test
|
||||
FROM test_foo
|
||||
WHERE test_foo_id = $__last_insert_pk;
|
||||
SQL;
|
||||
print "EOM READ OF PREVIOUS INSERTED: " . print_r($db->dbReturnRow($query), true) . "<br>";
|
||||
print "LAST ERROR: " . $db->dbGetLastError() . "<br>";
|
||||
print "<br>";
|
||||
$query = <<<SQL
|
||||
SELECT
|
||||
test_foo_id, test
|
||||
FROM test_foo
|
||||
WHERE test_foo_id = $1;
|
||||
SQL;
|
||||
print "RETURN ROW PARAMS: " . print_r(
|
||||
$db->dbReturnRowParams(
|
||||
$query,
|
||||
[$__last_insert_pk]
|
||||
),
|
||||
true
|
||||
) . "<br>";
|
||||
|
||||
// PREPARED INSERT
|
||||
$db->dbPrepare("ins_test_foo", "INSERT INTO test_foo (test) VALUES ($1) RETURNING test");
|
||||
$status = $db->dbExecute("ins_test_foo", ['BAR TEST ' . time()]);
|
||||
print "PREPARE INSERT[ins_test_foo] STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetPrepareCursorValue('ins_test_foo', 'query') . " |<br>"
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: "
|
||||
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
||||
. "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||
. "WHERE test_foo_id = " . (int)$db->dbGetInsertPK()), true) . "<br>";
|
||||
|
||||
print "PREPARE CURSOR RETURN:<br>";
|
||||
foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) {
|
||||
print "KEY: " . $key . ': ' . $db->dbGetPrepareCursorValue('ins_test_foo', $key) . "<br>";
|
||||
}
|
||||
|
||||
$query = <<<EOM
|
||||
INSERT INTO test_foo (
|
||||
test
|
||||
$query = <<<SQL
|
||||
INSERT INTO
|
||||
test_foo
|
||||
(
|
||||
test, string_a
|
||||
) VALUES (
|
||||
$1
|
||||
$1, '$2'
|
||||
)
|
||||
RETURNING test
|
||||
EOM;
|
||||
RETURNING test, string_a
|
||||
SQL;
|
||||
$db->dbPrepare("ins_test_foo_eom", $query);
|
||||
$status = $db->dbExecute("ins_test_foo_eom", ['EOM BAR TEST ' . time()]);
|
||||
print "EOM STRING PREPARE INSERT[ins_test_foo_eom] STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetPrepareCursorValue('ins_test_foo_eom', 'query') . " |<br>"
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
echo "<b>*</b><br>";
|
||||
$status = $db->dbExecParams($query, ['EOM BAR TEST PARAMS ' . time()]);
|
||||
print "EOM STRING EXEC PARAMS INSERT STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
// I/S Query
|
||||
$query_insert = <<<SQL
|
||||
INSERT INTO
|
||||
test_foo
|
||||
(
|
||||
test, some_bool, string_a, number_a, number_a_numeric,
|
||||
some_time, some_timestamp, json_string
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5,
|
||||
$6, $7, $8
|
||||
)
|
||||
RETURNING test
|
||||
SQL;
|
||||
$query_select = <<<SQL
|
||||
SELECT
|
||||
test, some_bool, string_a, number_a, number_a_numeric,
|
||||
some_time, some_time, some_timestamp, json_string
|
||||
FROM
|
||||
test_foo
|
||||
WHERE
|
||||
test_foo_id = $1
|
||||
SQL;
|
||||
// A
|
||||
$status = $db->dbExecParams(
|
||||
$query_insert,
|
||||
[
|
||||
'EOM BAR TEST PARAMS MULTI ' . time(),
|
||||
true,
|
||||
'string a',
|
||||
1,
|
||||
1.5,
|
||||
'1h',
|
||||
'2023-01-01 12:12:12',
|
||||
json_encode(['a' => 'b', 'c' => 1])
|
||||
]
|
||||
);
|
||||
$__last_insert_id = $db->dbGetInsertPK();
|
||||
echo "<b>*</b><br>";
|
||||
print "EOM STRING EXEC PARAMS MULTI INSERT STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
print "EOM STRING EXEC RETURN TEST: " . print_r(
|
||||
$db->dbReturnRowParams(
|
||||
$query_select,
|
||||
[$__last_insert_id]
|
||||
)
|
||||
) . "<br>";
|
||||
// B
|
||||
$status = $db->dbExecParams(
|
||||
$query_insert,
|
||||
[
|
||||
'EOM BAR TEST PARAMS MULTI NULL ' . time(),
|
||||
true,
|
||||
'string a',
|
||||
null,
|
||||
null,
|
||||
'1h',
|
||||
null,
|
||||
null
|
||||
]
|
||||
);
|
||||
$__last_insert_id = $db->dbGetInsertPK();
|
||||
echo "<b>*</b><br>";
|
||||
print "EOM STRING EXEC PARAMS MULTI NULL INSERT STATUS: "
|
||||
. Support::printToString($status) . " |<br>"
|
||||
. " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true)
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
print "EOM STRING EXEC RETURN TEST: " . print_r(
|
||||
$db->dbReturnRowParams(
|
||||
$query_select,
|
||||
[$__last_insert_id]
|
||||
)
|
||||
) . "<br>";
|
||||
// params > 10 for debug
|
||||
// error catcher
|
||||
$query_insert = <<<SQL
|
||||
INSERT INTO many_columns (
|
||||
col_01_int,
|
||||
col_01, col_02, col_03, col_04, col_05, col_06, col_07, col_08, col_09,
|
||||
col_10, col_11, col_12, col_02_int
|
||||
) VALUES (
|
||||
1,
|
||||
$1, $2, $3, $4, $5, $6, $7, $8, $9,
|
||||
$10, $11, $12, $13
|
||||
)
|
||||
RETURNING
|
||||
many_columns_id,
|
||||
col_01_int,
|
||||
col_01, col_02, col_03, col_04, col_05, col_06, col_07, col_08, col_09,
|
||||
col_10, col_11, col_12, col_02_int
|
||||
SQL;
|
||||
// will fail with "NULL" string on int
|
||||
$query_params = [
|
||||
'col 1', 'col 2', 'col 3', 'col 4', 'col 5', 'col 6', 'col 7', 'col 8',
|
||||
'col 9',
|
||||
'col 10', 'col 11', 'col 12', "NULL"
|
||||
];
|
||||
$status = $db->dbExecParams($query_insert, $query_params);
|
||||
echo "<b>*</b><br>";
|
||||
echo "EOM STRING WITH MORE THAN 10 PARAMETERS: "
|
||||
. Support::printToString($query_params) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " |<br>"
|
||||
. "RETURNING EXT: <pre>" . print_r($db->dbGetReturningExt(), true) . "</pre> |<br>"
|
||||
. "RETURNING RETURN: <pre>" . print_r($db->dbGetReturningArray(), true) . "</pre> |<br>"
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
echo "<hr>";
|
||||
// binary insert tests
|
||||
$filename = $db->dbEscapeLiteral('class_test.db.php');
|
||||
$rand_bin_uid = $db->dbEscapeLiteral(\CoreLibs\Create\Uids::uniqIdShort());
|
||||
$binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
||||
$query = <<<SQL
|
||||
INSERT INTO binary_test (
|
||||
filename, uid, binary_data
|
||||
) VALUES (
|
||||
$filename, $rand_bin_uid, '$binary_data'
|
||||
)
|
||||
SQL;
|
||||
$status = $db->dbExec($query);
|
||||
$__last_insert_id = $db->dbGetInsertPK();
|
||||
print "BINARY DATA INSERT: "
|
||||
. Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " |<br>"
|
||||
. "RETURNING EXT: <pre>" . print_r($db->dbGetReturningExt(), true) . "</pre> |<br>"
|
||||
. "RETURNING RETURN: <pre>" . print_r($db->dbGetReturningArray(), true) . "</pre> |<br>"
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
|
||||
echo "<b>*</b><br>";
|
||||
$query = <<<SQL
|
||||
INSERT INTO binary_test (
|
||||
filename, uid, binary_data
|
||||
) VALUES (
|
||||
$1, $2, $3
|
||||
)
|
||||
SQL;
|
||||
// $binary_data is dbEscapedBytea!
|
||||
$uniqid = \CoreLibs\Create\Uids::uniqIdShort();
|
||||
$status = $db->dbExecParams($query, [
|
||||
'class_test.db.php', $uniqid, $binary_data
|
||||
]);
|
||||
$__last_insert_id = $db->dbGetInsertPK();
|
||||
print "BINARY DATA INSERT PARAMS: "
|
||||
. Support::printToString($status) . " |<br>"
|
||||
. " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true)
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
print "BINARY READER: ";
|
||||
$query = <<<SQL
|
||||
SELECT
|
||||
filename, uid, binary_data
|
||||
FROM
|
||||
binary_test
|
||||
WHERE
|
||||
uid = $1
|
||||
SQL;
|
||||
$res = $db->dbReturnRowParams($query, [$uniqid]);
|
||||
if (is_array($res)) {
|
||||
var_dump($res);
|
||||
$file = $db->dbUnescapeBytea($res['binary_data']);
|
||||
// var_dump($file);
|
||||
} else {
|
||||
print "Execute error";
|
||||
}
|
||||
echo "<hr>";
|
||||
|
||||
// returning test with multiple entries
|
||||
// $status = $db->db_exec(
|
||||
// "INSERT INTO test_foo (test) VALUES "
|
||||
@@ -226,7 +467,7 @@ print "DIRECT MULTIPLE INSERT WITH RETURN STATUS: " . Support::printToString($st
|
||||
$t_1 = time();
|
||||
$t_2 = time();
|
||||
$t_3 = time();
|
||||
$query = <<<EOM
|
||||
$query = <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test
|
||||
) VALUES
|
||||
@@ -234,7 +475,7 @@ INSERT INTO test_foo (
|
||||
('EOM BAR 2 $t_2'),
|
||||
('EOM BAR 3 $t_3')
|
||||
RETURNING test_foo_id, test
|
||||
EOM;
|
||||
SQL;
|
||||
$status = $db->dbExec($query);
|
||||
print "EOM STRING DIRECT MULTIPLE INSERT WITH RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
@@ -247,59 +488,84 @@ print "EOM STRING DIRECT MULTIPLE INSERT WITH RETURN STATUS: " . Support::printT
|
||||
$status = $db->dbExec("INSERT INTO test_foo (test) VALUES ('FOO; TEST " . time() . "')");
|
||||
print "DIRECT INSERT NO RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
$last_insert_pk = $db->dbGetInsertPK();
|
||||
|
||||
// is_array read test
|
||||
$q = "SELECT test_foo_id, test FROM test_foo WHERE test_foo_id = " . $last_insert_pk;
|
||||
$q = "SELECT test_foo_id, test FROM test_foo WHERE test_foo_id = " . (int)$last_insert_pk;
|
||||
if (is_array($s_res = $db->dbReturnRow($q)) && !empty($s_res['test'])) {
|
||||
print "WE HAVE DATA FOR: " . $last_insert_pk . " WITH: " . $s_res['test'] . "<br>";
|
||||
print "WE HAVE DATA FOR: " . Support::printToString($last_insert_pk) . " WITH: " . $s_res['test'] . "<br>";
|
||||
}
|
||||
|
||||
// UPDATE WITH RETURNING
|
||||
$status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT' "
|
||||
. "WHERE test_foo_id = " . $last_insert_pk . " RETURNING test");
|
||||
print "UPDATE WITH PK " . $last_insert_pk
|
||||
$status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT', string_a = '" . (string)rand(1, 100) . "' "
|
||||
. "WHERE test_foo_id = " . (int)$last_insert_pk . " RETURNING test_foo.test, string_a");
|
||||
print "UPDATE WITH PK " . Support::printToString($last_insert_pk)
|
||||
. " RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
// UPDATE BUT EOM STYLE
|
||||
$status = $db->dbExecParams(
|
||||
<<<SQL
|
||||
UPDATE
|
||||
test_foo
|
||||
SET
|
||||
test = ?,
|
||||
string_a = ?
|
||||
WHERE
|
||||
tset_foo_id = ?
|
||||
RETURNING
|
||||
test_foo.test, string_a
|
||||
SQL,
|
||||
['SOMETHING DIFFERENT EOM', (string)rand(1, 100)]
|
||||
);
|
||||
print "UPDATE EOM WITH PK " . Support::printToString($last_insert_pk)
|
||||
. " RETURN STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
// a stand alone insert?
|
||||
$db->dbExec("INSERT INTO test_foo (test) VALUES ('STAND ALONE')");
|
||||
|
||||
// INSERT WITH NO RETURNING
|
||||
$status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITHOUT DATA', 456)");
|
||||
print "INSERT WITH NO PRIMARY KEY NO RETURNING STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
$status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITH DATA', 123) RETURNING type, integer");
|
||||
print "INSERT WITH NO PRIMARY KEY WITH RETURNING STATUS: " . Support::printToString($status) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
print "</pre>";
|
||||
|
||||
print "<b>PREPARE QUERIES</b><br>";
|
||||
// READ PREPARE
|
||||
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
||||
. "number_a_numeric, some_time "
|
||||
. "FROM test_foo "
|
||||
. "WHERE test = $1 "
|
||||
. "ORDER BY test_foo_id DESC LIMIT 5";
|
||||
$q_prep = <<<SQL
|
||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||
number_a_numeric, some_time
|
||||
FROM test_foo
|
||||
WHERE test = $1
|
||||
ORDER BY test_foo_id DESC LIMIT 5
|
||||
SQL;
|
||||
if ($db->dbPrepare('sel_test_foo', $q_prep) === false) {
|
||||
print "Error in sel_test_foo prepare<br>";
|
||||
} else {
|
||||
$max_rows = 6;
|
||||
// do not run this in dbFetchArray directly as
|
||||
// dbFetchArray(dbExecute(...))
|
||||
// this will end in an endless loop
|
||||
$cursor = $db->dbExecute('sel_test_foo', []);
|
||||
$i = 1;
|
||||
while (($res = $db->dbFetchArray($cursor, true)) !== false) {
|
||||
$cursor = $db->dbExecute('sel_test_foo', ['SOMETHING DIFFERENT']);
|
||||
while (is_array($res = $db->dbFetchArray($cursor, true))) {
|
||||
print "DB PREP EXEC FETCH ARR: " . $i . ": <pre>" . print_r($res, true) . "</pre><br>";
|
||||
$i++;
|
||||
}
|
||||
@@ -312,43 +578,140 @@ if ($db->dbPrepare('sel_test_foo', $q_prep) === false) {
|
||||
. "<pre>" . print_r($db->dbGetCombinedErrorHistory(), true) . "</pre><br>";
|
||||
}
|
||||
|
||||
// sel test with ANY () type
|
||||
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
||||
. "number_a_numeric, some_time "
|
||||
. "FROM test_foo "
|
||||
. "WHERE test = ANY($1) "
|
||||
. "ORDER BY test_foo_id DESC LIMIT 5";
|
||||
if ($db->dbPrepare('sel_test_foo_any', $q_prep) === false) {
|
||||
print "Error in sel_test_foo_any prepare<br>";
|
||||
} else {
|
||||
// do not run this in dbFetchArray directly as
|
||||
// dbFetchArray(dbExecute(...))
|
||||
// this will end in an endless loop
|
||||
$values = [
|
||||
'SOMETHING DIFFERENT',
|
||||
'STAND ALONE',
|
||||
'I DO NOT EXIST'
|
||||
];
|
||||
$query_value = '{'
|
||||
. join(',', $values)
|
||||
. '}';
|
||||
print "Read: $query_value<br>";
|
||||
$cursor = $db->dbExecute('sel_test_foo_any', [
|
||||
$query_value
|
||||
]);
|
||||
$i = 1;
|
||||
while (($res = $db->dbFetchArray($cursor, true)) !== false) {
|
||||
print "DB PREP EXEC FETCH ANY ARR: " . $i . ": <pre>" . print_r($res, true) . "</pre><br>";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<hr>";
|
||||
print "EOM STYLE STRINGS<br>";
|
||||
$test_bar = $db->dbEscapeLiteral('SOMETHING DIFFERENT');
|
||||
// Test EOM block
|
||||
$q = <<<EOM
|
||||
$q = <<<SQL
|
||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||
-- comment
|
||||
number_a_numeric, some_time
|
||||
FROM test_foo
|
||||
WHERE test = $test_bar
|
||||
ORDER BY test_foo_id DESC LIMIT 5
|
||||
EOM;
|
||||
SQL;
|
||||
while (is_array($res = $db->dbReturn($q))) {
|
||||
print "ROW: <pre>" . print_r($res, true) . "</pre><br>";
|
||||
}
|
||||
echo "<hr>";
|
||||
print "DB RETURN PARAMS<br>";
|
||||
$q = <<<SQL
|
||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||
-- comment
|
||||
number_a_numeric, some_time
|
||||
FROM test_foo
|
||||
WHERE test = $1
|
||||
ORDER BY test_foo_id DESC LIMIT 5
|
||||
SQL;
|
||||
while (
|
||||
is_array($res = $db->dbReturnParams($q, ['SOMETHING DIFFERENT']))
|
||||
) {
|
||||
print "ROW: <pre>" . print_r($res, true) . "</pre><br>";
|
||||
}
|
||||
echo "<hr>";
|
||||
|
||||
print "DB RETURN PARAMS LIKE<br>";
|
||||
$q = <<<SQL
|
||||
SELECT
|
||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
||||
FROM test_foo
|
||||
WHERE string_a LIKE $1;
|
||||
SQL;
|
||||
while (
|
||||
is_array($res = $db->dbReturnParams($q, ['%string%']))
|
||||
) {
|
||||
print "ROW: <pre>" . print_r($res, true) . "</pre><br>";
|
||||
}
|
||||
echo "<hr>";
|
||||
|
||||
print "DB RETURN PARAMS ANY<br>";
|
||||
$q = <<<SQL
|
||||
SELECT
|
||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
||||
FROM test_foo
|
||||
WHERE string_a = ANY($1);
|
||||
SQL;
|
||||
$query_value = '{'
|
||||
. join(',', ['string a'])
|
||||
. '}';
|
||||
while (
|
||||
is_array($res = $db->dbReturnParams($q, [$query_value]))
|
||||
) {
|
||||
print "ROW: <pre>" . print_r($res, true) . "</pre><br>";
|
||||
}
|
||||
echo "<hr>";
|
||||
|
||||
print "COMPOSITE ELEMENT READ<br>";
|
||||
$res = $db->dbReturnRow("SELECT item, count, (item).name, (item).price, (item).supplier_id FROM on_hand");
|
||||
print "ROW: <pre>" . print_r($res) . "</pre>";
|
||||
var_dump($res);
|
||||
print "Field Name/Types: <pre>" . print_r($db->dbGetFieldNameTypes(), true) . "</pre>";
|
||||
echo "<hr>";
|
||||
|
||||
// NOTE: try to replacate connection still exists if script is run a second time
|
||||
// open pg bouncer connection
|
||||
$db_pgb = new CoreLibs\DB\IO($DB_CONFIG['test_pgbouncer'], $log);
|
||||
$db_pgb = new CoreLibs\DB\IO($DB_CONFIG['test_pgbouncer'] ?? [], $log);
|
||||
print "[PGB] DBINFO: " . $db_pgb->dbInfo() . "<br>";
|
||||
if ($db->dbPrepare('pgb_sel_test_foo', $q_prep) === false) {
|
||||
print "[PGB] [1] Error in pgb_sel_test_foo prepare<br>";
|
||||
print "[PGB] [1] Warning in pgb_sel_test_foo prepare<br>";
|
||||
} else {
|
||||
print "[PGB] [1] pgb_sel_test_foo prepare OK<br>";
|
||||
}
|
||||
// second prepare
|
||||
if ($db->dbPrepare('pgb_sel_test_foo', $q_prep) === false) {
|
||||
print "[PGB] [2] Error in pgb_sel_test_foo prepare<br>";
|
||||
print "[PGB] [2] Warning in pgb_sel_test_foo prepare<br>";
|
||||
} else {
|
||||
print "[PGB] [2] pgb_sel_test_foo prepare OK<br>";
|
||||
}
|
||||
// same statment name, different query
|
||||
if (
|
||||
$db->dbPrepare('pgb_sel_test_foo', <<<SQL
|
||||
SELECT * FROM test_foo WHERE test = $1
|
||||
ORDER BY test_foo_id DESC LIMIT 5
|
||||
SQL) === false
|
||||
) {
|
||||
print "[PGB] [3] Error in pgb_sel_test_foo prepare<br>";
|
||||
} else {
|
||||
print "[PGB] [3] pgb_sel_test_foo prepare OK<br>";
|
||||
}
|
||||
$db_pgb->dbClose();
|
||||
|
||||
# db write class test
|
||||
$table = 'test_foo';
|
||||
print "TABLE META DATA: " . DgS::printAr($db->dbShowTableMetaData($table)) . "<br>";
|
||||
print "TABLE META DATA: " . DgS::printAr(SetVarType::setArray(
|
||||
$db->dbShowTableMetaData($table)
|
||||
)) . "<br>";
|
||||
// insert first, then use primary key to update
|
||||
$primary_key = ''; # unset
|
||||
$db_write_table = ['test', 'string_a', 'number_a', 'some_bool'];
|
||||
@@ -371,7 +734,7 @@ $data = [
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
(int)$primary_key,
|
||||
$table,
|
||||
$object_fields_not_touch,
|
||||
$object_fields_not_update,
|
||||
@@ -383,7 +746,7 @@ $data = [
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
(int)$primary_key,
|
||||
$table,
|
||||
$object_fields_not_touch,
|
||||
$object_fields_not_update,
|
||||
@@ -395,7 +758,7 @@ $data = [
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
(int)$primary_key,
|
||||
$table,
|
||||
$object_fields_not_touch,
|
||||
$object_fields_not_update,
|
||||
@@ -406,7 +769,18 @@ print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got p
|
||||
// return Array Test
|
||||
$query = "SELECT type, sdate, integer FROM foobar";
|
||||
$data = $db->dbReturnArray($query, true);
|
||||
print "Rows: " . $db->dbGetNumRows() . ", Full foobar list: <br><pre>" . print_r($data, true) . "</pre><br>";
|
||||
print "RETURN ARRAY: " . $db->dbGetNumRows() . ", Full foobar list: <br><pre>" . print_r($data, true) . "</pre><br>";
|
||||
$query = <<<SQL
|
||||
SELECT
|
||||
type, sdate
|
||||
FROM
|
||||
foobar
|
||||
WHERE
|
||||
type = $1
|
||||
SQL;
|
||||
$data = $db->dbReturnArrayParams($query, ['schmalz'], true);
|
||||
print "RETURN ARRAY PARAMS: " . $db->dbGetNumRows() . ", Full foobar list: <br><pre>"
|
||||
. print_r($data, true) . "</pre><br>";
|
||||
|
||||
// trigger a warning
|
||||
print "<b>WARNING NEXT</b><br>";
|
||||
@@ -500,30 +874,27 @@ while (($ret = $db->dbCheckAsync()) === true)
|
||||
// search path check
|
||||
$q = "SHOW search_path";
|
||||
$cursor = $db->dbExec($q);
|
||||
$data = $db->dbFetchArray($cursor)['search_path'];
|
||||
$data = $db->dbFetchArray($cursor)['search_path'] ?? '';
|
||||
print "RETURN DATA FOR search_path: " . $data . "<br>";
|
||||
// print "RETURN DATA FOR search_path: " . DgS::printAr($data) . "<br>";
|
||||
// insert something into test.schema_test and see if we get the PK back
|
||||
$status = $db->dbExec(
|
||||
"INSERT INTO test.schema_test (contents, id) VALUES "
|
||||
. "('TIME: " . time() . "', " . rand(1, 10) . ")"
|
||||
. "('TIME: " . (string)time() . "', " . (string)rand(1, 10) . ")"
|
||||
);
|
||||
print "OTHER SCHEMA INSERT STATUS: "
|
||||
. Support::printToString($status)
|
||||
. " | PK NAME: " . $db->dbGetInsertPKName()
|
||||
. ", PRIMARY KEY: " . $db->dbGetInsertPK() . "<br>";
|
||||
. ", PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . "<br>";
|
||||
|
||||
print "<b>NULL TEST DB READ</b><br>";
|
||||
$q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'";
|
||||
$res = $db->dbReturnRow($q);
|
||||
var_dump($res);
|
||||
print "RES: " . DgS::printAr($res) . "<br>";
|
||||
print "RES: " . DgS::printAr(SetVarType::setArray($res)) . "<br>";
|
||||
print "ISSET: " . isset($res['null_varchar']) . "<br>";
|
||||
print "EMPTY: " . empty($res['null_varchar']) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
210
www/admin/class_test.db.query-placeholder.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// turn on all error reporting
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-db-query-placeholder';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Debug\Support;
|
||||
// use CoreLibs\DB\Support\ConvertPlaceholder;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDER';
|
||||
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>';
|
||||
|
||||
print "LOGFILE NAME: " . $db->log->getLogFile() . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getLogFileId() . "<br>";
|
||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||
// DB client encoding
|
||||
print "DB client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||
print "DB search path: " . $db->dbGetSchema() . "<br>";
|
||||
|
||||
$to_db_version = '15.2';
|
||||
print "VERSION DB: " . $db->dbVersion() . "<br>";
|
||||
print "SERVER ENCODING: " . $db->dbVersionInfo('server_encoding') . "<br>";
|
||||
if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
||||
print "ALL OUTPUT [TEST]: <pre>" . print_r(pg_version($dbh), true) . "</pre><br>";
|
||||
} else {
|
||||
print "NO DB HANDLER<br>";
|
||||
}
|
||||
// turn on debug replace for placeholders
|
||||
$db->dbSetDebugReplacePlaceholder(true);
|
||||
|
||||
print "<b>TRUNCATE test_foo</b><br>";
|
||||
$db->dbExec("TRUNCATE test_foo");
|
||||
|
||||
$uniqid = \CoreLibs\Create\Uids::uniqIdShort();
|
||||
$binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
||||
$query_params = [
|
||||
$uniqid,
|
||||
true,
|
||||
'STRING A',
|
||||
2,
|
||||
2.5,
|
||||
1,
|
||||
date('H:m:s'),
|
||||
date('Y-m-d H:i:s'),
|
||||
json_encode(['a' => 'string', 'b' => 1, 'c' => 1.5, 'f' => true, 'g' => ['a', 1, 1.5]]),
|
||||
null,
|
||||
'{"a", "b"}',
|
||||
'{1,2}',
|
||||
'{"(array Text A, 5, 8.8)","(array Text B, 10, 15.2)"}',
|
||||
'("Text", 4, 6.3)',
|
||||
$binary_data
|
||||
];
|
||||
|
||||
$query_insert = <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
||||
some_time, some_timestamp, json_string, null_var,
|
||||
array_char_1, array_int_1,
|
||||
array_composite,
|
||||
composite_item,
|
||||
some_binary
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6,
|
||||
$7, $8, $9, $10,
|
||||
$11, $12,
|
||||
$13,
|
||||
$14,
|
||||
$15
|
||||
)
|
||||
RETURNING
|
||||
test_foo_id,
|
||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
||||
some_time, some_timestamp, json_string, null_var,
|
||||
array_char_1, array_int_1,
|
||||
array_composite,
|
||||
composite_item,
|
||||
some_binary
|
||||
SQL;
|
||||
$status = $db->dbExecParams($query_insert, $query_params);
|
||||
echo "<b>*</b><br>";
|
||||
echo "INSERT ALL COLUMN TYPES: "
|
||||
. Support::printToString($query_params) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " |<br>"
|
||||
. "RETURNING EXT: <pre>" . print_r($db->dbGetReturningExt(), true) . "</pre> |<br>"
|
||||
. "RETURNING RETURN: <pre>" . print_r($db->dbGetReturningArray(), true) . "<pre> |<br>"
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
echo "<hr>";
|
||||
|
||||
// test connectors: = , <> () for query detection
|
||||
|
||||
// convert placeholder tests
|
||||
// ? -> $n
|
||||
// :name -> $n
|
||||
|
||||
// other way around (just visual)
|
||||
$test_queries = [
|
||||
'skip' => [
|
||||
'query' => <<<SQL
|
||||
SELECT test, string_a, number_a
|
||||
FROM test_foo
|
||||
SQL,
|
||||
'params' => [],
|
||||
'direction' => 'pg',
|
||||
],
|
||||
'a?' => [
|
||||
'query' => <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test, string_a, number_a
|
||||
) VALUES (
|
||||
?, ?, ?
|
||||
)
|
||||
SQL,
|
||||
'params' => [\CoreLibs\Create\Uids::uniqIdShort(), 'string A-1', 1234],
|
||||
'direction' => 'pg',
|
||||
],
|
||||
'b:' => [
|
||||
'query' => <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test, string_a, number_a
|
||||
) VALUES (
|
||||
:test, :string_a, :number_a
|
||||
)
|
||||
SQL,
|
||||
'params' => [
|
||||
':test' => \CoreLibs\Create\Uids::uniqIdShort(),
|
||||
':string_a' => 'string B-1',
|
||||
':number_a' => 5678
|
||||
],
|
||||
'direction' => 'pg',
|
||||
],
|
||||
];
|
||||
|
||||
$db->dbSetConvertPlaceholder(true);
|
||||
foreach ($test_queries as $info => $data) {
|
||||
$query = $data['query'];
|
||||
$params = $data['params'];
|
||||
$direction = $data['direction'];
|
||||
// print "[$info] Convert: "
|
||||
// . Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params, $direction))
|
||||
// . "<br>";
|
||||
if ($db->dbCheckQueryForSelect($query)) {
|
||||
$row = $db->dbReturnRowParams($query, $params);
|
||||
print "[$info] SELECT: " . Support::prAr($row) . "<br>";
|
||||
} else {
|
||||
$db->dbExecParams($query, $params);
|
||||
}
|
||||
print "[$info] " . Support::printAr($db->dbGetPlaceholderConverted()) . "<br>";
|
||||
echo "<hr>";
|
||||
}
|
||||
|
||||
echo "dbReturn read: <br>";
|
||||
while (
|
||||
is_array($res = $db->dbReturnParams(
|
||||
<<<SQL
|
||||
SELECT test, string_a, number_a
|
||||
FROM test_foo
|
||||
WHERE string_a = ?
|
||||
SQL,
|
||||
['string A-1']
|
||||
))
|
||||
) {
|
||||
print "RES: " . Support::prAr($res) . "<br>";
|
||||
}
|
||||
|
||||
print "CursorExt: " . Support::prAr($db->dbGetCursorExt(<<<SQL
|
||||
SELECT test, string_a, number_a
|
||||
FROM test_foo
|
||||
WHERE string_a = ?
|
||||
SQL, ['string A-1']));
|
||||
|
||||
$res = $db->dbReturnRowParams(<<<SQL
|
||||
SELECT test, string_a, number_a
|
||||
FROM test_foo
|
||||
WHERE string_a = $1
|
||||
SQL, []);
|
||||
print "PL: " . Support::PrAr($db->dbGetPlaceholderConverted()) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
$db->log->debug('DEBUGEND', '==================================== [END]');
|
||||
|
||||
// __END__
|
||||
72
www/admin/class_test.db.single.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// turn on all error reporting
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-db-query-placeholders';
|
||||
ob_end_flush();
|
||||
|
||||
// use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDERS';
|
||||
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>';
|
||||
|
||||
print "LOGFILE NAME: " . $db->log->getLogFile() . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getLogFileId() . "<br>";
|
||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||
// DB client encoding
|
||||
print "DB client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||
print "DB search path: " . $db->dbGetSchema() . "<br>";
|
||||
|
||||
$to_db_version = '15.2';
|
||||
print "VERSION DB: " . $db->dbVersion() . "<br>";
|
||||
print "SERVER ENCODING: " . $db->dbVersionInfo('server_encoding') . "<br>";
|
||||
if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
||||
print "ALL OUTPUT [TEST]: <pre>" . print_r(pg_version($dbh), true) . "</pre><br>";
|
||||
} else {
|
||||
print "NO DB HANDLER<br>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param \CoreLibs\DB\IO $dbc
|
||||
* @return void
|
||||
*/
|
||||
function testDBS(\CoreLibs\DB\IO $dbc): void
|
||||
{
|
||||
echo "Int call<br>";
|
||||
$dbc->dbReturnRow("SELECT test FROM test_foo LIMIT 1");
|
||||
}
|
||||
|
||||
testDBS($db);
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
171
www/admin/class_test.db.types.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// turn on all error reporting
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-db-types';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Debug\Support;
|
||||
use CoreLibs\DB\Options\Convert;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// db connection and attach logger
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$db->log->debug('START', '=============================>');
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DB COLUMN TYPES';
|
||||
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>';
|
||||
|
||||
print "LOGFILE NAME: " . $db->log->getLogFile() . "<br>";
|
||||
print "LOGFILE ID: " . $db->log->getLogFileId() . "<br>";
|
||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||
// DB client encoding
|
||||
print "DB client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||
print "DB search path: " . $db->dbGetSchema() . "<br>";
|
||||
|
||||
$to_db_version = '15.2';
|
||||
print "VERSION DB: " . $db->dbVersion() . "<br>";
|
||||
print "SERVER ENCODING: " . $db->dbVersionInfo('server_encoding') . "<br>";
|
||||
if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
||||
print "ALL OUTPUT [TEST]: <pre>" . print_r(pg_version($dbh), true) . "</pre><br>";
|
||||
} else {
|
||||
print "NO DB HANDLER<br>";
|
||||
}
|
||||
|
||||
print "<b>TRUNCATE test_foo</b><br>";
|
||||
$db->dbExec("TRUNCATE test_foo");
|
||||
|
||||
/* $q = <<<SQL
|
||||
INSERT INTO test_foo (test, array_composite) VALUES ('C', '{"(a,1,1.5)","(b,2,2.5)"}')
|
||||
SQL;
|
||||
$db->dbExecParams($q);
|
||||
pg_query($db->dbGetDbh(), $q);
|
||||
$q = <<<SQL
|
||||
INSERT INTO test_foo (test, array_composite) VALUES ($1, $2)
|
||||
SQL;
|
||||
// $db->dbExecParams($q, ['D', '{"(a b,1,1.5)","(c,3,4.5)"}']);
|
||||
$db->dbExecParams($q, ['D', '{"(array Text A, 5, 8.8)","(array Text B, 10, 15.2)"}']);
|
||||
*/
|
||||
$uniqid = \CoreLibs\Create\Uids::uniqIdShort();
|
||||
$binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
||||
$query_params = [
|
||||
$uniqid,
|
||||
true,
|
||||
'STRING A',
|
||||
2,
|
||||
2.5,
|
||||
1,
|
||||
date('H:m:s'),
|
||||
date('Y-m-d H:i:s'),
|
||||
json_encode(['a' => 'string', 'b' => 1, 'c' => 1.5, 'f' => true, 'g' => ['a', 1, 1.5]]),
|
||||
null,
|
||||
'{"a", "b"}',
|
||||
'{1,2}',
|
||||
'{"(array Text A, 5, 8.8)","(array Text B, 10, 15.2)"}',
|
||||
'("Text", 4, 6.3)',
|
||||
$binary_data
|
||||
];
|
||||
|
||||
$query_insert = <<<SQL
|
||||
INSERT INTO test_foo (
|
||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
||||
some_time, some_timestamp, json_string, null_var,
|
||||
array_char_1, array_int_1,
|
||||
array_composite,
|
||||
composite_item,
|
||||
some_binary
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6,
|
||||
$7, $8, $9, $10,
|
||||
$11, $12,
|
||||
$13,
|
||||
$14,
|
||||
$15
|
||||
)
|
||||
RETURNING
|
||||
test_foo_id,
|
||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
||||
some_time, some_timestamp, json_string, null_var,
|
||||
array_char_1, array_int_1,
|
||||
array_composite,
|
||||
composite_item,
|
||||
some_binary
|
||||
SQL;
|
||||
$status = $db->dbExecParams($query_insert, $query_params);
|
||||
echo "<b>*</b><br>";
|
||||
echo "INSERT ALL COLUMN TYPES: "
|
||||
. Support::printToString($query_params) . " |<br>"
|
||||
. "QUERY: " . $db->dbGetQuery() . " |<br>"
|
||||
. "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " |<br>"
|
||||
. "RETURNING EXT: <pre>" . print_r($db->dbGetReturningExt(), true) . "</pre> |<br>"
|
||||
. "RETURNING RETURN: <pre>" . print_r($db->dbGetReturningArray(), true) . "<pre> |<br>"
|
||||
. "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||
echo "<hr>";
|
||||
|
||||
$query_select = <<<SQL
|
||||
SELECT
|
||||
test_foo_id,
|
||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
||||
number_real, number_double, number_numeric_3, number_serial,
|
||||
some_time, some_timestamp, json_string, null_var,
|
||||
array_char_1, array_char_2, array_int_1, array_int_2, array_composite,
|
||||
composite_item, (composite_item).*,
|
||||
some_binary
|
||||
FROM
|
||||
test_foo
|
||||
WHERE
|
||||
test = $1;
|
||||
SQL;
|
||||
$res = $db->dbReturnRowParams($query_select, [$uniqid]);
|
||||
// auto switch:
|
||||
// ^int
|
||||
// bool
|
||||
// with flags:
|
||||
// json(b) => array
|
||||
// bytes => string? or resource?
|
||||
// numeric => float (can have precision cut)
|
||||
$pos = 0;
|
||||
$name = '';
|
||||
if (is_array($res)) {
|
||||
$cursor = $db->dbGetCursor();
|
||||
var_dump($res);
|
||||
print "Field Name/Types: <pre>" . print_r($db->dbGetFieldNameTypes(), true) . "</pre>";
|
||||
print "Get type for: 'number_a':" . $db->dbGetFieldType('number_a') . "<br>";
|
||||
print "Get type for: 0: " . $db->dbGetFieldType(0) . "<br>";
|
||||
print "Get name for: 0: " . $db->dbGetFieldName(0) . "<br>";
|
||||
}
|
||||
|
||||
$db->dbSetConvertFlag(Convert::on);
|
||||
$db->dbSetConvertFlag(Convert::json);
|
||||
$db->dbSetConvertFlag(Convert::numeric);
|
||||
$db->dbSetConvertFlag(Convert::bytea);
|
||||
$res = $db->dbReturnRowParams($query_select, [$uniqid]);
|
||||
if (is_array($res)) {
|
||||
var_dump($res);
|
||||
}
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -7,15 +7,12 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
// all the settings are overruled by config
|
||||
$DEBUG_ALL_OVERRIDE = true; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = false;
|
||||
$ECHO_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -34,7 +31,7 @@ $ECHO_ALL = true;
|
||||
use CoreLibs\Debug\Support as DebugSupport;
|
||||
use CoreLibs\Debug\FileWriter;
|
||||
|
||||
$debug = new CoreLibs\Debug\Logging([
|
||||
$debug = new CoreLibs\Debug\LoggingLegacy([
|
||||
'log_folder' => BASE . LOG,
|
||||
'file_id' => $LOG_FILE_ID,
|
||||
'debug_all' => $DEBUG_ALL,
|
||||
@@ -42,21 +39,31 @@ $debug = new CoreLibs\Debug\Logging([
|
||||
'echo_all' => $ECHO_ALL,
|
||||
]);
|
||||
$debug_support_class = 'CoreLibs\Debug\Support';
|
||||
$debug_logging_class = 'CoreLibs\Debug\Logging';
|
||||
$debug_logging_class = 'CoreLibs\Debug\LoggingLegacy';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: DEBUG';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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()
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function test(): ?string
|
||||
{
|
||||
return DebugSupport::getCallerMethod(1);
|
||||
}
|
||||
|
||||
function test2()
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return array<mixed>
|
||||
*/
|
||||
function test2(): array
|
||||
{
|
||||
return DebugSupport::getCallerMethodList(1);
|
||||
}
|
||||
@@ -64,16 +71,43 @@ function test2()
|
||||
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "<br>";
|
||||
print "S::GETCALLERMETHOD: " . test() . "<br>";
|
||||
print "S::GETCALLERMETHODLIST: <pre>" . print_r(test2(), true) . "</pre><br>";
|
||||
// printAr
|
||||
print "S::PRINTAR: " . DebugSupport::printAr(['Foo', 'Bar']) . "<br>";
|
||||
print "V-S::PRINTAR: " . $debug_support_class::printAr(['Foo', 'Bar']) . "<br>";
|
||||
// printBool
|
||||
print "S::PRINTBOOL(default): " . DebugSupport::printBool(true) . "<br>";
|
||||
print "S::PRINTBOOL(name): " . DebugSupport::printBool(true, 'Name') . "<br>";
|
||||
print "S::PRINTBOOL(name, ok): " . DebugSupport::printBool(true, 'Name', 'ok') . "<br>";
|
||||
print "S::PRINTBOOL(name, ok, not): " . DebugSupport::printBool(false, 'Name', 'ok', 'not') . "<br>";
|
||||
// debugString
|
||||
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
|
||||
print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
|
||||
print "S::DEBUSTRING(s>): " . DebugSupport::debugString('<SET>') . "<br>";
|
||||
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
|
||||
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
|
||||
// dumpVar
|
||||
print "S::DUMPVAR(s): " . DebugSupport::dumpVar('SET') . "<br>";
|
||||
print "S::DUMPVAR(s,true): " . DebugSupport::dumpVar('SET', true) . "<br>";
|
||||
print "S::DUMPVAR(s>): " . DebugSupport::dumpVar('<SET>') . "<br>";
|
||||
print "S::DUMPVAR(s>,true): " . DebugSupport::dumpVar('<SET>', true) . "<br>";
|
||||
print "S::DUMPVAR(''): " . DebugSupport::dumpVar('') . "<br>";
|
||||
print "S::DUMPVAR(,s): " . DebugSupport::dumpVar(null) . "<br>";
|
||||
print "S::DUMPVAR([a,b]): " . DebugSupport::dumpVar(['a', 'b']) . "<br>";
|
||||
print "S::DUMPVAR([a,b],true): " . DebugSupport::dumpVar(['a', 'b'], true) . "<br>";
|
||||
print "S::DUMPVAR([MIXED]): " . DebugSupport::dumpVar(<<<EOM
|
||||
Line is
|
||||
break
|
||||
with
|
||||
<html>block</html>
|
||||
and > and <
|
||||
EOM) . "<br>";
|
||||
// exportVar
|
||||
// print "S::EXPORTVAR(s): " . DebugSupport::exportVar('SET') . "<br>";
|
||||
// print "S::EXPORTVAR(s>): " . DebugSupport::exportVar('<SET>') . "<br>";
|
||||
// print "S::EXPORTVAR(''): " . DebugSupport::exportVar('') . "<br>";
|
||||
// print "S::EXPORTVAR(,s): " . DebugSupport::exportVar(null) . "<br>";
|
||||
// print "S::EXPORTVAR([a,b]): " . DebugSupport::exportVar(['a', 'b']) . "<br>";
|
||||
// print "S::EXPORTVAR([a,b],true): " . DebugSupport::exportVar(['a', 'b']) . "<br>";
|
||||
|
||||
// get test
|
||||
print "LOG FOLDER: " . $debug->getSetting('log_folder') . "<br>";
|
||||
@@ -87,7 +121,7 @@ print "C->PRINTERRORMSG: <br>" . $debug->printErrorMsg() . "<br>";
|
||||
echo "<b>OPTIONS DEBUG CALL</b><br>";
|
||||
|
||||
// new log type with options
|
||||
$new_log = new CoreLibs\Debug\Logging([
|
||||
$new_log = new CoreLibs\Debug\LoggingLegacy([
|
||||
'log_folder' => '../log/',
|
||||
'file_id' => 'DebugTestNewLogger',
|
||||
// add file date
|
||||
@@ -108,21 +142,36 @@ $new_log = new CoreLibs\Debug\Logging([
|
||||
$new_log->debug('OPTIONS TYPE', 'New Type error');
|
||||
print "OPTIONS LOGGER:<br>" . $new_log->printErrorMsg();
|
||||
$new_log->setLogLevel('debug', 'on', ['A', 'B', 'C' => false]);
|
||||
print "LOG LEVEL: " . DebugSupport::printAr($new_log->getLogLevel('debug', 'on')) . "<br>";
|
||||
print "LOG LEVEL: " . DebugSupport::printAr(\CoreLibs\Convert\SetVarType::setArray(
|
||||
$new_log->getLogLevel('debug', 'on')
|
||||
)) . "<br>";
|
||||
|
||||
echo "<b>CLASS DEBUG CALL</b><br>";
|
||||
|
||||
// @codingStandardsIgnoreLine
|
||||
class TestL
|
||||
{
|
||||
/** @var \CoreLibs\Debug\LoggingLegacy */
|
||||
public $log;
|
||||
public function __construct()
|
||||
{
|
||||
$this->log = new CoreLibs\Debug\Logging();
|
||||
$this->log = new CoreLibs\Debug\LoggingLegacy([
|
||||
'log_folder' => '../log/',
|
||||
'file_id' => 'DebugTestTestLLogger',
|
||||
]);
|
||||
}
|
||||
public function test(string $ts = null)
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string|null $ts
|
||||
* @return bool
|
||||
*/
|
||||
public function test(?string $ts = null): bool
|
||||
{
|
||||
print "* GETCALLERCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "<br>";
|
||||
print "* GETCALLERTOPCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "<br>";
|
||||
print "* GETCALLSTACK(INSIDE CLASS): <pre>"
|
||||
. DebugSupport::prAr(\CoreLibs\Debug\Support::getCallStack()) . "</pre><br>";
|
||||
$this->log->debug('TESTL', 'Logging in class testL' . ($ts !== null ? ': ' . $ts : ''));
|
||||
$this->log->debug('TESTL', 'Some other message');
|
||||
return true;
|
||||
@@ -131,14 +180,23 @@ class TestL
|
||||
// @codingStandardsIgnoreLine
|
||||
class TestR extends TestL
|
||||
{
|
||||
/** @var string */
|
||||
public $foo;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function subTest()
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function subTest(): bool
|
||||
{
|
||||
print "** GETCALLERCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "<br>";
|
||||
print "** GETCALLERTOPCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "<br>";
|
||||
print "** GETCALLSTACK(INSIDE EXTND CLASS): <pre>"
|
||||
. DebugSupport::prAr(\CoreLibs\Debug\Support::getCallStack()) . "</pre><br>";
|
||||
$this->log->debug('TESTR', 'Logging in class testR (extends testL)');
|
||||
$this->test('TESTR INSIDE');
|
||||
$this->log->debug('TESTR', 'Array: '
|
||||
@@ -160,12 +218,18 @@ print "CLASS EXTEND: PRINTERRORMSG: <br>" . $tr->log->printErrorMsg() . "<br>";
|
||||
// @codingStandardsIgnoreLine
|
||||
class AttachOutside
|
||||
{
|
||||
/** @var \CoreLibs\Debug\LoggingLegacy */
|
||||
public $log;
|
||||
public function __construct(object $logger_class)
|
||||
public function __construct(\CoreLibs\Debug\LoggingLegacy $logger_class)
|
||||
{
|
||||
$this->log = $logger_class;
|
||||
}
|
||||
public function test()
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function test(): string
|
||||
{
|
||||
$this->log->debug('ATTACHOUTSIDE', 'A test');
|
||||
return get_class($this);
|
||||
@@ -177,6 +241,7 @@ print "AO-CLASS: DEBUG: " . $ao->test() . "<br>";
|
||||
print "GETCALLERCLASS(NON CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "<br>";
|
||||
|
||||
// fdebug
|
||||
print "S::FSETFILENAME: " . FileWriter::fsetFolder(BASE . LOG) . "<br>";
|
||||
print "S::FSETFILENAME: " . FileWriter::fsetFilename('class_test_debug_file.log') . "<br>";
|
||||
print "S::FDEBUG: " . FileWriter::fdebug('CLASS TEST DEBUG FILE: ' . date('Y-m-d H:i:s')) . "<br>";
|
||||
|
||||
@@ -189,6 +254,12 @@ $debug->setLogPer('level', false);
|
||||
$ar = ['A', 1, ['B' => 'D']];
|
||||
$debug->debug('ARRAY', 'Array: ' . $debug->prAr($ar));
|
||||
$debug->debug('BOOL', 'True: ' . $debug->prBl(true) . ', False: ' . $debug->prBl(false));
|
||||
$debug->debug('MIXED', 'ANYTHING: ' . DebugSupport::dumpVar([
|
||||
'foo' => 1,
|
||||
'bar' => null,
|
||||
'self' => [1, 2, 3],
|
||||
'other' => false
|
||||
]));
|
||||
|
||||
// error message
|
||||
// future DEPRECATED
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,20 +21,15 @@ ob_end_flush();
|
||||
use CoreLibs\Check\Email;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -80,9 +68,6 @@ foreach ($email as $s_email) {
|
||||
print "S::CHECKEMAILFULL(true): " . $s_email . ": " . Dgs::printAr(Email::checkEmailFull($s_email, true)) . "<br>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,16 +21,12 @@ ob_end_flush();
|
||||
use CoreLibs\Convert\Encoding as ConEnc;
|
||||
use CoreLibs\Check\Encoding as ChkEnc;
|
||||
use CoreLibs\Convert\MimeEncode;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
// class type
|
||||
$_chk_enc = new CoreLibs\Check\Encoding();
|
||||
@@ -46,7 +35,7 @@ $chk_enc = 'CoreLibs\Check\Encoding';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ENCODING (CHECK/CONVERT/MIME)';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -102,10 +91,7 @@ foreach ($enc_strings as $_string) {
|
||||
// static use
|
||||
$_string = $enc_strings[1];
|
||||
$string = $chk_enc::checkConvertEncoding($_string, 'UTF-8', 'ISO-2022-JP-MS');
|
||||
print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : $string) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : Support::printAr($string)) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
110
www/admin/class_test.encryption.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-encryption';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Security\SymmetricEncryption;
|
||||
use CoreLibs\Security\CreateKey;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ENCRYPTION';
|
||||
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>';
|
||||
|
||||
$key = CreateKey::generateRandomKey();
|
||||
print "Secret Key: " . $key . "<br>";
|
||||
|
||||
$string = "I a some deep secret";
|
||||
//
|
||||
$crypt = new SymmetricEncryption($key);
|
||||
$encrypted = $crypt->encrypt($string);
|
||||
$decrypted = $crypt->decrypt($encrypted);
|
||||
print "[C] Encrypted: " . $encrypted . "<br>";
|
||||
print "[C] Decrytped: " . $decrypted . "<br>";
|
||||
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($string);
|
||||
$decrypted = SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||
print "[S] Original: " . $string . "<br>";
|
||||
print "[S] Encrypted: " . $encrypted . "<br>";
|
||||
print "[S] Decrytped: " . $decrypted . "<br>";
|
||||
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||
print "[SS] Encrypted: " . $encrypted . "<br>";
|
||||
print "[SS] Decrytped: " . $decrypted . "<br>";
|
||||
|
||||
print "<br>INIT KEY MISSING<br>";
|
||||
try {
|
||||
$crypt = new SymmetricEncryption();
|
||||
$encrypted = $crypt->decrypt($string);
|
||||
} catch (Exception $e) {
|
||||
print("Error: " . $e->getMessage() . "<br>");
|
||||
}
|
||||
|
||||
print "<br>WRONG CIPHERTEXT<br>";
|
||||
try {
|
||||
$decrypted = SymmetricEncryption::decryptKey('flupper', $key);
|
||||
} catch (Exception $e) {
|
||||
print "Error: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
print "<br>SHORT and WRONG KEY<br>";
|
||||
$key = 'wrong_key';
|
||||
try {
|
||||
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||
} catch (Exception $e) {
|
||||
print "Error: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
print "<br>INVALID HEX KEY<br>";
|
||||
$key = '1cabd5cba9e042f12522f4ff2de5c31d233b';
|
||||
try {
|
||||
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||
} catch (Exception $e) {
|
||||
print "Error: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
print "<br>WRONG KEY TO DECRYPT<br>";
|
||||
$key = CreateKey::generateRandomKey();
|
||||
$string = "I a some deep secret";
|
||||
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||
$key = 'wrong_key';
|
||||
try {
|
||||
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||
} catch (Exception $e) {
|
||||
print "Error: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
|
||||
// echo "<hr>";
|
||||
// $key = CreateKey::generateRandomKey();
|
||||
// $se = new SymmetricEncryption($key);
|
||||
// $string = "I a some deep secret";
|
||||
// $encrypted = $se->encrypt($string);
|
||||
// $decrypted = $se->decrypt($encrypted);
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
70
www/admin/class_test.error_msg.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-error_msg';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Logging\Logger\MessageLevel as ml;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: ERROR MSG';
|
||||
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>';
|
||||
|
||||
$em = new \CoreLibs\Logging\ErrorMessage($log);
|
||||
|
||||
print "Log ERROR: " . $log->prAr($em->getFlagLogError()) . "<br>";
|
||||
|
||||
print "FN: " . ml::fromName('Affe')->name . "<br>";
|
||||
print "NU: " . ml::fromValue(100)->name . "<br>";
|
||||
print "NU: " . ml::fromValue(1000)->name . "<br>";
|
||||
|
||||
$em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug');
|
||||
$em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug', 'target-id', 'other-style');
|
||||
$em->setErrorMsg('123', 'error', 'msg this is bad, logged always', log_error:true);
|
||||
$em->setErrorMsg('123', 'error', 'msg this is bad, never logged', log_error:false);
|
||||
$em->setErrorMsg('500', 'warning', 'This is perhaps not super good, logged_always', log_warning:true);
|
||||
$em->setErrorMsg('500', 'warning', 'This is perhaps not super good, logged_never', log_warning:false);
|
||||
$em->setErrorMsg('1000', 'info', 'This is good');
|
||||
$em->setErrorMsg('9999', 'abort', 'BAD: This is critical (abort)');
|
||||
$em->setErrorMsg('10-1000', 'wrong', 'Wrong level: This is emergency');
|
||||
// set some jump targets too
|
||||
$em->setErrorMsg('100-1', 'error', 'Input wring', jump_target:['target' => 'foo-123', 'info' => 'Jump Target 123']);
|
||||
$em->setErrorMsg('100-2', 'error', 'Input wring', jump_target:['target' => 'foo-123', 'info' => 'Jump Target 456']);
|
||||
$em->setMessage('error', 'I have no id set', jump_target:['target' => 'bar-123', 'info' => 'Jump Bar']);
|
||||
$em->setMessage('error', 'Jump empty', jump_target:['target' => 'bar-empty']);
|
||||
|
||||
print "ErrorsLast: <pre>" . $log->prAr($em->getLastErrorMsg()) . "</pre>";
|
||||
print "ErrorsIds: <pre>" . $log->prAr($em->getErrorIds()) . "</pre>";
|
||||
print "Errors: <pre>" . $log->prAr($em->getErrorMsg()) . "</pre>";
|
||||
print "JumpTargets: <pre>" . $log->prAr($em->getJumpTarget()) . "</pre>";
|
||||
|
||||
print "IS info > ok: " . ml::fromName('info')->isHigherThan(ml::ok) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
$log->debug('[END]', '==========================================>');
|
||||
|
||||
// __END__
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -22,25 +15,20 @@ define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-datetime';
|
||||
$LOG_FILE_ID = 'classTest-file';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Check\File;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: FILE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -49,9 +37,7 @@ $file = '/some/path/to/some/file.txt';
|
||||
print "GETFILENAMEENDING: $file: " . File::getFilenameEnding($file) . "<br>";
|
||||
$file = getcwd() . DIRECTORY_SEPARATOR . 'class_test.file.php';
|
||||
print "GETLINESFROMFILE: $file: " . File::getLinesFromFile($file) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
print "MIMEINFO: $file: " . File::getMimeType($file) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,15 +20,10 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Create\Hash;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$hash_class = 'CoreLibs\Create\Hash';
|
||||
|
||||
@@ -43,7 +31,7 @@ $hash_class = 'CoreLibs\Create\Hash';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HASH';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -55,12 +43,19 @@ print "S::__SHA1SHORT(off): $to_crc: " . $hash_class::__sha1short($to_crc) . "<b
|
||||
print "S::__SHA1SHORT(on): $to_crc: " . $hash_class::__sha1short($to_crc, true) . "<br>";
|
||||
print "S::__hash(d): " . $to_crc . "/"
|
||||
. Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
|
||||
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat'] as $__hash_c) {
|
||||
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'sha512'] as $__hash_c) {
|
||||
print "S::__hash($__hash_c): $to_crc: " . $hash_class::__hash($to_crc, $__hash_c) . "<br>";
|
||||
}
|
||||
// static use
|
||||
print "U-S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
|
||||
|
||||
echo "<hr>";
|
||||
$text = 'Some String Text';
|
||||
$type = 'crc32b';
|
||||
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
|
||||
print "Class: " . $type . ": " . Hash::__hash($text, $type) . "<br>";
|
||||
|
||||
echo "<hr>";
|
||||
print "<br>CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
|
||||
print "<br>CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
||||
print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>";
|
||||
@@ -69,9 +64,6 @@ print "HASH LONG: " . $to_crc . ": " . Hash::__hashLong($to_crc) . "<br>";
|
||||
// print "UNIQU ID SHORT : " . Hash::__uniqId() . "<br>";
|
||||
// print "UNIQU ID LONG : " . Hash::__uniqIdLong() . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,15 +21,10 @@ ob_end_flush();
|
||||
use CoreLibs\Convert\Html;
|
||||
use CoreLibs\Output\Form\Elements;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_html = new CoreLibs\Convert\Html();
|
||||
$_elements = new CoreLibs\Output\Form\Elements();
|
||||
@@ -47,19 +35,21 @@ $elements_class = 'CoreLibs\Output\Form\Elements';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>";
|
||||
$string = "Something < = > Other <br> Next line and Quotes '\"";
|
||||
echo "String: <pre>$string</pre><br>";
|
||||
$log->debug('HTMLENT', Html::htmlent($string));
|
||||
print "HTMLENT: " . Html::htmlent($string) . ": " . $_html->htmlent($string) . " (" . htmlentities($string) . ")<br>";
|
||||
print "REMOVELB: " . Html::htmlent($string) . ": " . $_html->removeLB($string) . "<br>";
|
||||
$date_str = [2021, 5, 1, 11, 10];
|
||||
print "PRINTDATETIME: "
|
||||
. $_elements->printDateTime($date_str[0], $date_str[1], $date_str[2], $date_str[3], $date_str[4]) . "<br>";
|
||||
// STATIC
|
||||
$string = "Something < = > Other <br> Next line";
|
||||
// $string = "Something < = > Other <br> Next line and Quotes '\"";
|
||||
print "S::HTMLENT: " . Html::htmlent($string) . ": " . $html_class::htmlent($string) . "<br>";
|
||||
print "S::REMOVELB: " . Html::htmlent($string) . ": " . $html_class::removeLB($string) . "<br>";
|
||||
$date_str = [2021, 5, 1, 11, 10];
|
||||
@@ -79,8 +69,10 @@ $checked_list = [
|
||||
['foo', ['bar']],
|
||||
];
|
||||
foreach ($checked_list as $check) {
|
||||
print "CHECKED(0): $check[0]: " . Html::checked($check[1], $check[0]) . "<br>";
|
||||
print "CHECKED(1): $check[0]: " . Html::checked($check[1], $check[0], Html::CHECKED) . "<br>";
|
||||
print "CHECKED(0): " . $check[0] . " -> " . print_r($check[1], true) . ": "
|
||||
. Html::checked($check[1], $check[0]) . "<br>";
|
||||
print "CHECKED(1): " . $check[0] . " -> " . print_r($check[1], true) . ": "
|
||||
. Html::checked($check[1], $check[0], Html::CHECKED) . "<br>";
|
||||
}
|
||||
|
||||
// magic link creation test
|
||||
@@ -105,9 +97,6 @@ is sucky';
|
||||
print "LB remove: " . \CoreLibs\Convert\Html::removeLB($text) . "<br>";
|
||||
print "LB remove: " . \CoreLibs\Convert\Html::removeLB($text, '##BR##') . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
83
www/admin/class_test.html_build.block.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build-block';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\Block;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: BLOCK';
|
||||
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>';
|
||||
|
||||
$el = Block::cel('div', 'el-1', 'Content', ['red'], ['onClick' => 'javascript:alert(\'JS alert\');']);
|
||||
|
||||
print "<pre>" . htmlentities(Block::buildHtml($el)) . "</pre>";
|
||||
|
||||
$el_a = Block::cel('div', 'u-id', '', ['base', 'cool']);
|
||||
$el_a_1 = Block::cel('span', 's-id-1', 'Span A', ['bold']);
|
||||
$el_a_2 = Block::cel('span', 's-id-2', 'Span B');
|
||||
$el_a_3 = Block::cel('a', 'link-a', 'Title', ['l-highlight'], ['OnClick' => 'Foo();']);
|
||||
$el_a_2 = Block::aelx($el_a_2, $el_a_3);
|
||||
// css changes before added to array
|
||||
$el_a_1 = Block::acssel($el_a_1, 'italic', 'green', 'italic', 'font-large');
|
||||
$el_a_1 = Block::rcssel($el_a_1, 'green');
|
||||
// switch
|
||||
$el_a_1 = Block::scssel($el_a_1, ['one', 'two', 'three'], ['three']);
|
||||
// this will add el_a_2 to the el_a block
|
||||
$el_a_1 = Block::aelx($el_a_1, $el_a_2);
|
||||
$el_a = Block::aelx($el_a, $el_a_1, $el_a_2);
|
||||
|
||||
// this will not update el_a
|
||||
// $el_a_1 = Block::aelx($el_a_1, $el_a_2);
|
||||
|
||||
$el_a_list = [];
|
||||
$el_a_list[] = Block::cel('foo', 'foo-A');
|
||||
$el_a_list[] = Block::cel('bar', 'foo-B');
|
||||
$el_a_list[] = Block::cel('baz', 'foo-C');
|
||||
$el_a_list[] = Block::cel('br');
|
||||
$el_a_list[] = Block::cel('input');
|
||||
|
||||
echo "<hr>";
|
||||
print "EL_A: <pre>" . print_r($el_a, true) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
print "phfo(\$el_o): <pre>" . htmlentities(Block::buildHtml($el_a, true)) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfa(\$el_list): <pre>" . htmlentities(Block::buildHtmlFromList($el_a_list, true)) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
// self loop test (will not trigger, are arrays)
|
||||
$el_s = Block::cel('div', 'id-s', 'Self', []);
|
||||
$el_s = Block::aelx($el_s, $el_s);
|
||||
|
||||
print "phfo(\$el_): <pre>" . htmlentities(Block::buildHtml($el_s, true)) . "</pre>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
142
www/admin/class_test.html_build.element.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\Element;
|
||||
use CoreLibs\Template\HtmlBuilder\General\Error;
|
||||
use CoreLibs\Template\HtmlBuilder\General\HtmlBuilderExcpetion;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD';
|
||||
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>';
|
||||
|
||||
$el = new Element('div', 'el-1', 'Content', ['red'], ['onClick' => 'javascript:alert(\'JS alert\');']);
|
||||
|
||||
print "<pre>" . htmlentities($el->buildHtml()) . "</pre>";
|
||||
|
||||
$el_o = new Element('div', 'u-id', '', ['base', 'cool']);
|
||||
$el_o_1 = new Element('span', 's-id-1', 'Span A', ['bold']);
|
||||
$el_o_2 = new Element('span', 's-id-2', 'Span B');
|
||||
$el_o_3 = new Element('a', 'link-a', 'Title', ['l-highlight'], ['OnClick' => 'Foo();']);
|
||||
$el_o_2->addSub($el_o_3);
|
||||
$el_o->addSub($el_o_1, $el_o_2);
|
||||
|
||||
$el_o_1->addCss('italic', 'green', 'italic', 'font-large')
|
||||
->removeCss('green');
|
||||
|
||||
$el_o_2->addCss('wrong-css')
|
||||
->removeCss('wrong-css', 'correct-css');
|
||||
$el_o_2->addCss('a', 'b')->removeCss('correct-css');
|
||||
|
||||
$el_o_1->addSub($el_o_2);
|
||||
|
||||
// var_dump($el2);
|
||||
|
||||
$el_o_list = [];
|
||||
$el_o_list[] = new Element('foo', 'foo-A');
|
||||
$el_o_list[] = new Element('bar', 'foo-B');
|
||||
$el_o_list[] = new Element('baz', 'foo-C');
|
||||
$el_o_list[] = new Element('br');
|
||||
$el_o_list[] = new Element('input', 'tag', '', [], ['name' => 'foo', 'value' => 'ABC']);
|
||||
|
||||
// $el2->resetSub();
|
||||
// var_dump($el2);
|
||||
echo "<hr>";
|
||||
print "EL_O: <pre>" . print_r($el_o, true) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
print "buildHtml(): <pre>" . htmlentities($el_o->buildHtml()) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfo(\$el_o): <pre>" . htmlentities($el_o::printHtmlFromObject($el_o, true)) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfa(\$el_list): <pre>" . htmlentities($el_o::buildHtmlFromList($el_o_list, true)) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
// self loop
|
||||
|
||||
$el_s = new Element('div', 'id-s', 'Self');
|
||||
try {
|
||||
$el_s->addSub($el_s, new Element('span', '', 'Span'));
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
}
|
||||
|
||||
// var_dump($el_s);
|
||||
print "el_s, buildHtml(): <pre>" . htmlentities($el_s->buildHtml()) . "</pre>";
|
||||
|
||||
$el_s_2 = new Element('div', 'id-s', 'Self', []);
|
||||
$el_s_2->addSub(
|
||||
new Element('span', 's-1', 's 1'),
|
||||
new Element('span', 's-2', 's 2'),
|
||||
);
|
||||
|
||||
$el_s_3 = new Element('div', 'id-3', 'ID 3');
|
||||
try {
|
||||
$el_s_3->addSub($el_s_2);
|
||||
$el_s_2->addSub($el_s_2);
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
}
|
||||
|
||||
// print "<pre>" . var_export($el_s_3, true) . "</pre>";
|
||||
|
||||
print "el_s_3, buildHtml(): <pre>" . htmlentities($el_s_3->buildHtml()) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
Error::resetMessages();
|
||||
try {
|
||||
$el_er = new Element('');
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
if ($e->getPrevious() !== null) {
|
||||
print "E: " . $e->getPrevious()->getMessage() . " | " . $e->getPrevious()->getTraceAsString() . "<br>";
|
||||
}
|
||||
}
|
||||
print "Errors: <pre>" . print_r(Error::getMessages(), true) . "</pre>";
|
||||
print "Warning: " . Support::printToString(Error::hasWarning()) . "<br>";
|
||||
print "Error: " . Support::printToString(Error::hasError()) . "<br>";
|
||||
Error::resetMessages();
|
||||
try {
|
||||
$el_er = new Element('123123');
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
if ($e->getPrevious() !== null) {
|
||||
print "E: " . $e->getPrevious()->getMessage() . " | " . $e->getPrevious()->getTraceAsString() . "<br>";
|
||||
}
|
||||
}
|
||||
print "Errors: <pre>" . print_r(Error::getMessages(), true) . "</pre>";
|
||||
print "Warning: " . Support::printToString(Error::hasWarning()) . "<br>";
|
||||
print "Error: " . Support::printToString(Error::hasError()) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
83
www/admin/class_test.html_build.replace.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build-string-replace';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\StringReplace;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: STRING REPLACE';
|
||||
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>';
|
||||
|
||||
$html_block = <<<HTML
|
||||
<div id="{ID}" class="{CSS}">
|
||||
{CONTENT}
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
print "<pre>" . htmlentities(StringReplace::replaceData(
|
||||
$html_block,
|
||||
[
|
||||
'ID' => 'block-id',
|
||||
'CSS' => join(',', ['blue', 'red']),
|
||||
'{CONTENT}' => 'Some content here<br>with bla bla inside'
|
||||
]
|
||||
)) . "</pre>";
|
||||
|
||||
StringReplace::loadElements(
|
||||
['foo', $html_block],
|
||||
['bar', <<<HTML
|
||||
<span id="{ID}">{CONTENT}</span>
|
||||
HTML]
|
||||
);
|
||||
|
||||
print "Get: <pre>" . htmlentities(StringReplace::getElement('bar') ?: '') . '</pre>';
|
||||
|
||||
print "Build element: <pre>" . htmlentities(StringReplace::buildElement(
|
||||
'bar',
|
||||
[
|
||||
'ID}' => 'new-id',
|
||||
'{CONTENT' => 'Test cow 日本語'
|
||||
]
|
||||
)) . '</pre>' ;
|
||||
|
||||
print "Build element as replace: <pre>" . htmlentities(StringReplace::buildElement(
|
||||
'bar',
|
||||
['
|
||||
ID}' => 'diff-id',
|
||||
'{CONTENT' => 'Test cow 日本語. More text plus'
|
||||
],
|
||||
'rpl-1'
|
||||
)) . '</pre>' ;
|
||||
|
||||
print "Get replacement: <pre>" . htmlentities(StringReplace::getReplaceBlock('rpl-1')) . "</pre>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,15 +20,10 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Output\Image;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_image = new CoreLibs\Output\Image();
|
||||
$image_class = 'CoreLibs\Output\Image';
|
||||
@@ -44,7 +32,7 @@ $image_class = 'CoreLibs\Output\Image';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: IMAGE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -53,21 +41,36 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
$thumb_width = 250;
|
||||
$thumb_height = 300;
|
||||
// class
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture_square.jpg';
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . 'no_picture_square.jpg';
|
||||
// folders
|
||||
$cache_folder = BASE . CONTENT_PATH . LAYOUT . CACHE . IMAGES;
|
||||
$web_folder = LAYOUT . CACHE . IMAGES;
|
||||
// rotate image first
|
||||
$_image->correctImageOrientation($image);
|
||||
try {
|
||||
$_image->correctImageOrientation($image);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
} catch (\RuntimeException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
// thumbnail tests
|
||||
echo "<div>CLASS->CREATETHUMBNAILSIMPLE: "
|
||||
. basename($image) . ": WIDTH: $thumb_width<br><img src="
|
||||
. $_image->createThumbnailSimple($image, $thumb_width) . "></div>";
|
||||
. $_image->createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . "></div>";
|
||||
// static
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture.jpg';
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . 'no_picture.jpg';
|
||||
// rotate image first
|
||||
$image_class::correctImageOrientation($image);
|
||||
try {
|
||||
$image_class::correctImageOrientation($image);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
} catch (\RuntimeException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
// thumbnail tests
|
||||
echo "<div>S::CREATETHUMBNAILSIMPLE: "
|
||||
. basename($image) . ": WIDTH: $thumb_width<br><img src="
|
||||
. $image_class::createThumbnailSimple($image, $thumb_width) . "></div>";
|
||||
. $image_class::createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . "></div>";
|
||||
|
||||
echo "U-STATIC VARIOUS:<br>";
|
||||
// image thumbnail
|
||||
@@ -91,27 +94,45 @@ $images = array(
|
||||
// return mime type ala mimetype
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
foreach ($images as $image) {
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image;
|
||||
list ($height, $width, $img_type) = getimagesize($image);
|
||||
$image = BASE . CONTENT_PATH . LAYOUT . IMAGES . $image;
|
||||
list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image));
|
||||
echo "<div><b>IMAGE INFO</b>: " . $height . "x" . $width . ", TYPE: "
|
||||
. $img_type . " [" . $finfo->file($image) . "]</div>";
|
||||
. \CoreLibs\Debug\Support::dumpVar($img_type) . " [" . $finfo->file($image) . "]</div>";
|
||||
// rotate image first
|
||||
Image::correctImageOrientation($image);
|
||||
try {
|
||||
Image::correctImageOrientation($image);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
} catch (\RuntimeException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
// thumbnail tests
|
||||
echo "<div>" . basename($image) . ": WIDTH: $thumb_width<br><img src="
|
||||
. Image::createThumbnailSimple($image, $thumb_width) . "></div>";
|
||||
. Image::createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . "></div>";
|
||||
echo "<div>" . basename($image) . ": HEIGHT: $thumb_height<br><img src="
|
||||
. Image::createThumbnailSimple($image, 0, $thumb_height) . "></div>";
|
||||
. Image::createThumbnailSimple($image, 0, $thumb_height, $cache_folder, $web_folder) . "></div>";
|
||||
echo "<div>" . basename($image) . ": WIDTH/HEIGHT: $thumb_width x $thumb_height<br><img src="
|
||||
. Image::createThumbnailSimple($image, $thumb_width, $thumb_height) . "></div>";
|
||||
. Image::createThumbnailSimple($image, $thumb_width, $thumb_height, $cache_folder, $web_folder) . "></div>";
|
||||
// test with dummy
|
||||
echo "<div>" . basename($image) . ": WIDTH/HEIGHT: $thumb_width x $thumb_height (+DUMMY)<br><img src="
|
||||
. Image::createThumbnailSimple($image, $thumb_width, $thumb_height, null, true, false) . "></div>";
|
||||
. Image::createThumbnailSimple(
|
||||
$image,
|
||||
$thumb_width,
|
||||
$thumb_height,
|
||||
$cache_folder,
|
||||
$web_folder,
|
||||
true,
|
||||
false
|
||||
) . "></div>";
|
||||
echo "<hr>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
// errros
|
||||
try {
|
||||
Image::createThumbnailSimple('', $thumb_width, 0, $cache_folder, $web_folder);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
print "Message:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,15 +21,10 @@ ob_end_flush();
|
||||
use CoreLibs\Convert\Json;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$json_class = 'CoreLibs\Convert\Json';
|
||||
|
||||
@@ -44,7 +32,7 @@ $json_class = 'CoreLibs\Convert\Json';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: JSON';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -75,8 +63,10 @@ print "J/S::E-JSON ERROR: " . $json_class::jsonGetLastError() . ": " . $json_cla
|
||||
// print "S::JSON: $json: " . DgS::printAr($output) . "<br>";
|
||||
// print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
// convert an array to json
|
||||
$array = ['foo' => 'bar'];
|
||||
$output = Json::jsonConvertArrayTo($array);
|
||||
print "S::JSON: " . DgS::printAr($array) . " => " . $output . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,37 +20,83 @@ ob_end_flush();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: LANG';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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\Language;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
echo "<br><b>LIST LOCALES</b><br>";
|
||||
|
||||
$locale = 'en_US.UTF-8';
|
||||
$locales = CoreLibs\Language\L10n::listLocales($locale);
|
||||
$locales = L10n::listLocales($locale);
|
||||
print "[" . $locale . "] LOCALES: " . Support::printAr($locales) . "<br>";
|
||||
$locale = 'en.UTF-8';
|
||||
$locales = CoreLibs\Language\L10n::listLocales($locale);
|
||||
$locales = L10n::listLocales($locale);
|
||||
print "[" . $locale . "] LOCALES: " . Support::printAr($locales) . "<br>";
|
||||
|
||||
echo "<br><b>LOCALE INFO</b><br>";
|
||||
echo "<br><b>PARSE LOCAL</b><br>";
|
||||
$locale = 'en_US.UTF-8';
|
||||
$locale_info = CoreLibs\Language\L10n::parseLocale($locale);
|
||||
$locale_info = L10n::parseLocale($locale);
|
||||
print "[" . $locale . "] INFO: " . Support::printAr($locale_info) . "<br>";
|
||||
$locale = 'en.UTF-8';
|
||||
$locale_info = CoreLibs\Language\L10n::parseLocale($locale);
|
||||
$locale_info = L10n::parseLocale($locale);
|
||||
print "[" . $locale . "] INFO: " . Support::printAr($locale_info) . "<br>";
|
||||
|
||||
echo "<br><b>AUTO DETECT</b><br>";
|
||||
|
||||
$get_locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
print "[AUTO]: " . Support::printAr($get_locale) . "<br>";
|
||||
$get_locale = \CoreLibs\Language\GetLocale::setLocale('en', 'foo', 'ISO-8895');
|
||||
// DEPRECATED
|
||||
// $get_locale = Language\GetLocale::setLocale();
|
||||
// print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "<br>";
|
||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||
SITE_LOCALE,
|
||||
str_replace('/', '', CONTENT_PATH),
|
||||
'',
|
||||
BASE . INCLUDES . LOCALE
|
||||
);
|
||||
print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "<br>";
|
||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||
'en',
|
||||
'foo',
|
||||
'ISO-8895',
|
||||
BASE . INCLUDES . LOCALE
|
||||
);
|
||||
print "[OVERRIDE]: " . Support::printAr($get_locale) . "<br>";
|
||||
// must set session vars for setLangFromSession
|
||||
// DEFAULT_LOCALE
|
||||
// DEFAULT_DOMAIN
|
||||
// DEFAULT_CHARSET (should be set from DEFAULT_LOCALE)
|
||||
// LOCALE_PATH
|
||||
$_SESSION['DEFAULT_LOCALE'] = 'ja_JP.UTF-8';
|
||||
$_SESSION['DEFAULT_CHARSET'] = 'UTF-8';
|
||||
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
||||
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||
SITE_LOCALE,
|
||||
SITE_DOMAIN,
|
||||
SITE_ENCODING,
|
||||
BASE . INCLUDES . LOCALE
|
||||
);
|
||||
print "[SESSION SET]: " . Support::printAr($get_locale) . "<br>";
|
||||
// must set session vars for setLangFromSession
|
||||
// DEFAULT_LOCALE
|
||||
// DEFAULT_DOMAIN
|
||||
// DEFAULT_CHARSET (should be set from DEFAULT_LOCALE)
|
||||
// LOCALE_PATH
|
||||
$_SESSION['DEFAULT_LOCALE'] = '00000#####';
|
||||
$_SESSION['DEFAULT_CHARSET'] = '';
|
||||
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
||||
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||
SITE_LOCALE,
|
||||
SITE_DOMAIN,
|
||||
SITE_ENCODING,
|
||||
BASE . INCLUDES . LOCALE
|
||||
);
|
||||
print "[SESSION SET INVALID]: " . Support::printAr($get_locale) . "<br>";
|
||||
|
||||
// try to load non existing
|
||||
echo "<br><b>NEW TYPE</b><br>";
|
||||
@@ -69,8 +108,8 @@ $domain = 'admin';
|
||||
$encoding = 'UTF-8';
|
||||
$path = BASE . INCLUDES . LOCALE;
|
||||
// load direct
|
||||
$l = new CoreLibs\Language\L10n($lang, $domain, $path);
|
||||
echo "*<br>";
|
||||
echo "* <b>NEW CLASS SET</b><br>";
|
||||
$l = new L10n($lang, $domain, $path, $encoding);
|
||||
echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "<br>";
|
||||
echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "<br>";
|
||||
echo "LANGUAGE FILE: " . $l->getMoFile() . "<br>";
|
||||
@@ -95,10 +134,11 @@ for ($n = 0; $n <= 3; $n++) {
|
||||
echo "CONTEXT MULTI TEST $n: " . $single_string . "/" . $multi_string . " => "
|
||||
. $l->__np($context, $single_string, $multi_string, $n) . "<br>";
|
||||
}
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
// change domain
|
||||
$domain = 'frontend';
|
||||
echo "* <b>CHANGE DOMAIN $domain</b><br>";
|
||||
$l->getTranslator('', $domain, $path);
|
||||
echo "*<br>";
|
||||
echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "<br>";
|
||||
echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "<br>";
|
||||
echo "LANGUAGE FILE: " . $l->getMoFile() . "<br>";
|
||||
@@ -108,11 +148,12 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "<br>";
|
||||
echo "LOAD ERROR: " . $l->getLoadError() . "<br>";
|
||||
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
|
||||
echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "<br>";
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
// change language short type
|
||||
$lang = 'en';
|
||||
$domain = 'admin';
|
||||
echo "* <b>CHANGE LANG $lang AND DOMAIN $domain</b><br>";
|
||||
$l->getTranslator($lang, $domain, $path);
|
||||
echo "*<br>";
|
||||
echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "<br>";
|
||||
echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "<br>";
|
||||
echo "LANGUAGE FILE: " . $l->getMoFile() . "<br>";
|
||||
@@ -122,10 +163,24 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "<br>";
|
||||
echo "LOAD ERROR: " . $l->getLoadError() . "<br>";
|
||||
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
|
||||
echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "<br>";
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
$encoding = 'SJIS';
|
||||
echo "* <b>SET DIFFERENT CHARSET $encoding</b><br>";
|
||||
$l->getTranslator($lang, $domain, $path, $encoding);
|
||||
echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "<br>";
|
||||
echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "<br>";
|
||||
echo "LANGUAGE FILE: " . $l->getMoFile() . "<br>";
|
||||
echo "CONTENT PATH: " . $l->getBaseContentPath() . "<br>";
|
||||
echo "DOMAIN PATH: " . $l->getTextDomain($domain) . "<br>";
|
||||
echo "BASE PATH: " . $l->getBaseLocalePath() . "<br>";
|
||||
echo "LOAD ERROR: " . $l->getLoadError() . "<br>";
|
||||
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
|
||||
echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "<br>";
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
// chang to wrong language
|
||||
$lang = 'tr';
|
||||
echo "* <b>CHANGE NOT FOUND LANG $lang</b><br>";
|
||||
$l->getTranslator($lang, $domain, $path);
|
||||
echo "*<br>";
|
||||
echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "<br>";
|
||||
echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "<br>";
|
||||
echo "LANGUAGE FILE: " . $l->getMoFile() . "<br>";
|
||||
@@ -135,6 +190,25 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "<br>";
|
||||
echo "LOAD ERROR: " . $l->getLoadError() . "<br>";
|
||||
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
|
||||
echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "<br>";
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
// set different encoding
|
||||
$lang = 'ja';
|
||||
$domain = 'admin';
|
||||
$encoding = 'SJIS';
|
||||
echo "* <b>CLASS NEW LAUNCH: $lang / $encoding</b><br>";
|
||||
$path = BASE . INCLUDES . LOCALE;
|
||||
// load direct
|
||||
$l = new L10n($lang, $domain, $path, $encoding);
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
// lang with full set
|
||||
$lang = 'ja_JP.UTF-8';
|
||||
$domain = 'admin';
|
||||
$encoding = 'SJIS';
|
||||
echo "* <b>CLASS NEW LAUNCH: $lang / $encoding</b><br>";
|
||||
$path = BASE . INCLUDES . LOCALE;
|
||||
// load direct
|
||||
$l = new L10n($lang, $domain, $path, $encoding);
|
||||
echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "<br>";
|
||||
|
||||
$lang = 'en';
|
||||
$domain = 'admin';
|
||||
@@ -146,8 +220,10 @@ L10n::getInstance()->setDomain($domain);
|
||||
echo "SET DOMAIN: " . L10n::getInstance()->getDomain() . "<br>";
|
||||
L10n::getInstance()->setTextDomain($domain, $path);
|
||||
echo "SET TEXT DOMAIN: " . L10n::getInstance()->getTextDomain($domain) . "<br>";
|
||||
// L10n::getInstance()->setOverrideEncoding('SJIS');
|
||||
// null call __bind_textdomain_codeset
|
||||
echo "INPUT TEST: " . $string . " => " . L10n::getInstance()->getTranslator()->gettext($string) . "<br>";
|
||||
echo "LOCALE: " . Support::printAr(L10n::getInstance()->getLocaleAsArray()) . "<br>";
|
||||
|
||||
echo "<br><b>FUNCTIONS</b><br>";
|
||||
// real statisc test
|
||||
|
||||
138
www/admin/class_test.logging.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// set session name
|
||||
$GLOBALS['SET_SESSION_NAME'] = EDIT_SESSION_NAME;
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-logging';
|
||||
ob_end_flush();
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
|
||||
// use CoreLibs\Debug\Support;
|
||||
|
||||
use CoreLibs\Debug\Support;
|
||||
use CoreLibs\Logging\Logger\Level;
|
||||
use CoreLibs\Logging\Logger\Flag;
|
||||
// use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_level' => Level::Debug,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: LOGGING';
|
||||
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>';
|
||||
|
||||
$log->logger2Debug();
|
||||
echo "<hr>";
|
||||
print "Level 250: " . Level::fromValue(250)->getName() . "<br>";
|
||||
print "Flag: per_class (16) (from int): " . Flag::fromValue(16)->getName() . "<br>";
|
||||
print "Flag: per_class getName(): " . Flag::per_class->getName() . "<br>";
|
||||
print "Flag: per_class ->name: " . Flag::per_class->name . "<br>";
|
||||
print "Flag: per_class ->value: " . Flag::per_class->value . "<br>";
|
||||
$log->setLogUniqueId();
|
||||
print "LogUniqId: " . $log->getLogUniqueId() . "<br>";
|
||||
|
||||
print "Is Debug (check): " . Support::printBool($log->getLoggingLevel()->includes(
|
||||
Level::Debug
|
||||
)) . "<br>";
|
||||
print "Is Debug (fk): " . Support::printBool($log->loggingLevelIsDebug()) . "<br>";
|
||||
$log->setLoggingLevel(Level::Notice);
|
||||
print "Is Debug (check): " . Support::printBool($log->getLoggingLevel()->includes(
|
||||
Level::Debug
|
||||
)) . "<br>";
|
||||
print "Is Debug (fk): " . Support::printBool($log->loggingLevelIsDebug()) . "<br>";
|
||||
$log->setLoggingLevel(Level::Debug);
|
||||
|
||||
print "DUMP: <pre>" . $log->dV(['something' => 'error']) . "</pre><br>";
|
||||
|
||||
$log->debug('LEGACY', 'Some legacy shit here');
|
||||
$log->debug('ARRAY', 'Dump some data: ' . $log->dV(['something' => 'error']));
|
||||
$log->debug('MIXED', 'Dump mixed: ' . $log->dV(<<<EOM
|
||||
Line is
|
||||
break
|
||||
with
|
||||
<html>block</html>
|
||||
and > and <
|
||||
EOM));
|
||||
$log->info('Info message', ['info' => 'log']);
|
||||
$log->notice('Notice message', ['notice' => 'log']);
|
||||
$log->warning('Warning message', ['warning' => 'log']);
|
||||
$log->error('Cannot process data', ['error' => 'log']);
|
||||
$log->critical('Critical message', ['critical' => 'log']);
|
||||
$log->alert('Alert message', ['Alert' => 'log']);
|
||||
$log->emergency('Emergency message', ['Emergency' => 'log']);
|
||||
print "Log File: " . $log->getLogFile() . "<br>";
|
||||
|
||||
$log->setLogFlag(Flag::per_run);
|
||||
$log->debug('PER RUN', 'per run logging');
|
||||
print "Log File: " . $log->getLogFile() . "<br>";
|
||||
$log->unsetLogFlag(Flag::per_run);
|
||||
|
||||
// init empty
|
||||
unset($LOG_FILE_ID);
|
||||
$ll = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
]);
|
||||
print "LFI: " . $ll->getLogFileId() . "<br>";
|
||||
try {
|
||||
$ll->setLoggingLevel('Invalid');
|
||||
} catch (\Psr\Log\InvalidArgumentException $e) {
|
||||
print "Invalid option: " . $e->getMessage() . "<br>";
|
||||
}
|
||||
/* $ll = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => 'a',
|
||||
'log_file_id' => 'a',
|
||||
]); */
|
||||
|
||||
// @codingStandardsIgnoreLine
|
||||
Class TestP
|
||||
{
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
public $log;
|
||||
public function __construct(
|
||||
\CoreLibs\Logging\Logging $log
|
||||
) {
|
||||
$this->log = $log;
|
||||
}
|
||||
|
||||
public function test(): void
|
||||
{
|
||||
$this->log->info('TestL::test call');
|
||||
}
|
||||
}
|
||||
|
||||
$tl = new TestP($log);
|
||||
$tl->test();
|
||||
|
||||
print '<hr>'
|
||||
. '<div style="width:100%; font-family: monospace;">'
|
||||
// . '<pre>'
|
||||
. nl2br(htmlentities(file_get_contents($log->getLogFolder() . $log->getLogFile()) ?: ''))
|
||||
// . '</pre>'
|
||||
. '</div>';
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -26,23 +19,32 @@ $LOG_FILE_ID = 'classTest-login';
|
||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
// init login & backend class
|
||||
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||
$login = new CoreLibs\ACL\Login(
|
||||
$db,
|
||||
$log,
|
||||
$session,
|
||||
[
|
||||
'auto_login' => false,
|
||||
'default_acl_level' => DEFAULT_ACL_LEVEL,
|
||||
'logout_target' => '',
|
||||
'site_locale' => SITE_LOCALE,
|
||||
'site_domain' => SITE_DOMAIN,
|
||||
'site_encoding' => SITE_ENCODING,
|
||||
'locale_path' => BASE . INCLUDES . LOCALE,
|
||||
]
|
||||
);
|
||||
ob_end_flush();
|
||||
$login->loginMainCall();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -53,9 +55,7 @@ echo "MIN ACCESS BASE: " . ($login->loginCheckAccessBase('admin') ? 'OK' : 'BAD'
|
||||
echo "MIN ACCESS PAGE: " . ($login->loginCheckAccessPage('admin') ? 'OK' : 'BAD') . "<br>";
|
||||
|
||||
echo "ACL: " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()) . "<br>";
|
||||
echo "ACL (MIN): " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()['min']) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
echo "ACL (MIN): " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()['min'] ?? []) . "<br>";
|
||||
echo "LOCALE: " . \CoreLibs\Debug\Support::printAr($login->loginGetLocale()) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,15 +18,10 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-math';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_math = new CoreLibs\Convert\Math();
|
||||
$math_class = 'CoreLibs\Convert\Math';
|
||||
@@ -42,7 +30,7 @@ $math_class = 'CoreLibs\Convert\Math';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: MATH';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -59,9 +47,6 @@ print "S-INITNUMERIC: " . $math_class::initNumeric(123.456) . "<br>";
|
||||
print "S-INITNUMERIC: " . $math_class::initNumeric('123') . "<br>";
|
||||
print "S-INITNUMERIC: " . $math_class::initNumeric('123.456') . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,20 +21,15 @@ ob_end_flush();
|
||||
use CoreLibs\Debug\MemoryUsage;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: MEMORY USAGE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -83,9 +71,6 @@ print "Memory usage 4 array: " . Support::printAr($data) . "<br>";
|
||||
print "Memory usage 4 string: " . MemoryUsage::printMemoryUsage($data) . "<br>";
|
||||
print "Memory usage 4 string raw: " . MemoryUsage::printMemoryUsage($data, true) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -4,16 +4,9 @@
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,21 +18,16 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-mime';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_mime = new CoreLibs\Convert\MimeAppName();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: MIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -62,8 +50,6 @@ print "S::App for mime $mime: " . \CoreLibs\Convert\MimeAppName::mimeGetAppName(
|
||||
$mime = 'application/vnd.ms-excel';
|
||||
print "S::App for mime $mime: " . \CoreLibs\Convert\MimeAppName::mimeGetAppName($mime) . "<br>";
|
||||
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -57,21 +50,31 @@ $table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
||||
]
|
||||
];
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log, table_arrays: $table_arrays);
|
||||
$l10n = new CoreLibs\Language\L10n(
|
||||
SITE_LOCALE,
|
||||
SITE_DOMAIN,
|
||||
BASE . INCLUDES . LOCALE,
|
||||
SITE_ENCODING
|
||||
);
|
||||
$form = new CoreLibs\Output\Form\Generate(
|
||||
DB_CONFIG,
|
||||
$log,
|
||||
$l10n,
|
||||
[
|
||||
'base' => 10,
|
||||
'admin' => 0
|
||||
],
|
||||
table_arrays: $table_arrays
|
||||
);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: FORM GENERATE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -80,9 +83,6 @@ print "MOBILE PHONE: " . $form->mobile_phone . "<br>";
|
||||
// sets table array to include
|
||||
print "MY PAGE NAME: " . $form->my_page_name . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -22,29 +15,24 @@ define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-pass';
|
||||
$LOG_FILE_ID = 'classTest-password';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Check\Password as PwdChk;
|
||||
use CoreLibs\Security\Password as PwdChk;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_password = new CoreLibs\Check\Password();
|
||||
$password_class = 'CoreLibs\Check\Password';
|
||||
$_password = new CoreLibs\Security\Password();
|
||||
$password_class = 'CoreLibs\Security\Password';
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: PASSWORD';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -63,9 +51,6 @@ print "PASSWORD REHASH: " . (string)$password_class::passwordRehashCheck($enc_pa
|
||||
// direct static
|
||||
print "S::PASSWORD VERFIY: " . (string)PwdChk::passwordVerify($password, $enc_password) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,80 +18,119 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest';
|
||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
|
||||
use CoreLibs\Logging;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
// init login & backend class
|
||||
$session = new CoreLibs\Create\Session($SET_SESSION_NAME);
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'file_id' => $LOG_FILE_ID,
|
||||
'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,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||
$login = new CoreLibs\ACL\Login($db, $log, $session);
|
||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
$login = new CoreLibs\ACL\Login(
|
||||
$db,
|
||||
$log,
|
||||
$session,
|
||||
[
|
||||
'auto_login' => true,
|
||||
'default_acl_level' => DEFAULT_ACL_LEVEL,
|
||||
'logout_target' => '',
|
||||
'site_locale' => SITE_LOCALE,
|
||||
'site_domain' => SITE_DOMAIN,
|
||||
'site_encoding' => SITE_ENCODING,
|
||||
'locale_path' => BASE . INCLUDES . LOCALE,
|
||||
]
|
||||
);
|
||||
$locale = $login->loginGetLocale();
|
||||
$l10n = new \CoreLibs\Language\L10n(
|
||||
$locale['locale'],
|
||||
$locale['domain'],
|
||||
$locale['path'],
|
||||
$locale['encoding'],
|
||||
);
|
||||
|
||||
$backend = new CoreLibs\Admin\Backend(
|
||||
$db,
|
||||
$log,
|
||||
$session,
|
||||
$l10n,
|
||||
DEFAULT_ACL_LEVEL
|
||||
);
|
||||
$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale);
|
||||
$backend->db->dbInfo(true);
|
||||
ob_end_flush();
|
||||
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS</title><head>";
|
||||
print "<html><head><title>TEST CLASS</title></head>";
|
||||
print "<body>";
|
||||
|
||||
print '<div><a href="class_test.db.php">Class Test: DB</a></div>';
|
||||
print '<div><a href="class_test.db.dbReturn.php">Class Test: DB dbReturn</a></div>';
|
||||
print '<div><a href="class_test.convert.colors.php">Class Test: CONVERT COLORS</a></div>';
|
||||
print '<div><a href="class_test.check.colors.php">Class Test: CHECK COLORS</a></div>';
|
||||
print '<div><a href="class_test.mime.php">Class Test: MIME</a></div>';
|
||||
print '<div><a href="class_test.json.php">Class Test: JSON</a></div>';
|
||||
print '<div><a href="class_test.token.php">Class Test: FORM TOKEN</a></div>';
|
||||
print '<div><a href="class_test.password.php">Class Test: PASSWORD</a></div>';
|
||||
print '<div><a href="class_test.math.php">Class Test: MATH</a></div>';
|
||||
print '<div><a href="class_test.html.php">Class Test: HTML/ELEMENTS</a></div>';
|
||||
print '<div><a href="class_test.email.php">Class Test: EMAIL</a></div>';
|
||||
print '<div><a href="class_test.create_email.php">Class Test: CREATE EMAIL</a></div>';
|
||||
print '<div><a href="class_test.uids.php">Class Test: UIDS</a></div>';
|
||||
print '<div><a href="class_test.phpv.php">Class Test: PHP VERSION</a></div>';
|
||||
print '<div><a href="class_test.hash.php">Class Test: HASH</a></div>';
|
||||
print '<div><a href="class_test.encoding.php">Class Test: ENCODING (CHECK/CONVERT/MIME)</a></div>';
|
||||
print '<div><a href="class_test.image.php">Class Test: IMAGE</a></div>';
|
||||
print '<div><a href="class_test.byte.php">Class Test: BYTE CONVERT</a></div>';
|
||||
print '<div><a href="class_test.strings.php">Class Test: STRING CONVERT</a></div>';
|
||||
print '<div><a href="class_test.datetime.php">Class Test: DATE/TIME</a></div>';
|
||||
print '<div><a href="class_test.array.php">Class Test: ARRAY HANDLER</a></div>';
|
||||
print '<div><a href="class_test.file.php">Class Test: FILE</a></div>';
|
||||
print '<div><a href="class_test.randomkey.php">Class Test: RANDOM KEY</a></div>';
|
||||
print '<div><a href="class_test.system.php">Class Test: SYSTEM</a></div>';
|
||||
print '<div><a href="class_test.readenvfile.php">Class Test: READ ENV FILE</a></div>';
|
||||
print '<div><a href="class_test.runningtime.php">Class Test: RUNNING TIME</a></div>';
|
||||
print '<div><a href="class_test.memoryusage.php">Class Test: MEMORY USAGE</a></div>';
|
||||
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.varistype.php">Class Test: SET VAR TYPE</a></div>';
|
||||
print '<div><a href="class_test.session.php">Class Test: SESSION</a></div>';
|
||||
print '<div><a href="class_test.session.read.php">Class Test: SESSION: READ</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>';
|
||||
print '<div><a href="class_test.config.link.php">Class Test: CONFIG LINK</a></div>';
|
||||
print '<div><a href="class_test.config.direct.php">Class Test: CONFIG DIRECT</a></div>';
|
||||
print '<div><a href="subfolder/class_test.config.direct.php">Class Test: CONFIG DIRECT SUB</a></div>';
|
||||
// key: file name, value; name
|
||||
$test_files = [
|
||||
'class_test.db.php' => 'Class Test: DB',
|
||||
'class_test.db.types.php' => 'Class Test: DB column type convert',
|
||||
'class_test.db.query-placeholder.php' => 'Class Test: DB query placeholder convert',
|
||||
'class_test.db.dbReturn.php' => 'Class Test: DB dbReturn',
|
||||
'class_test.db.single.php' => 'Class Test: DB single query tests',
|
||||
'class_test.convert.colors.php' => 'Class Test: CONVERT COLORS',
|
||||
'class_test.check.colors.php' => 'Class Test: CHECK COLORS',
|
||||
'class_test.mime.php' => 'Class Test: MIME',
|
||||
'class_test.json.php' => 'Class Test: JSON',
|
||||
'class_test.token.php' => 'Class Test: FORM TOKEN',
|
||||
'class_test.password.php' => 'Class Test: PASSWORD',
|
||||
'class_test.encryption.php' => 'Class Test: ENCRYPTION',
|
||||
'class_test.math.php' => 'Class Test: MATH',
|
||||
'class_test.html.php' => 'Class Test: HTML/ELEMENTS',
|
||||
'class_test.html_build.element.php' => 'Class Test: HTML BUILDER: ELEMENT',
|
||||
'class_test.html_build.block.php' => 'Class Test: HTML BUILDER: BLOCK',
|
||||
'class_test.html_build.replace.php' => 'Class Test: HTML BUILDER: STRING REPLACE',
|
||||
'class_test.email.php' => 'Class Test: EMAIL',
|
||||
'class_test.create_email.php' => 'Class Test: CREATE EMAIL',
|
||||
'class_test.uids.php' => 'Class Test: UIDS',
|
||||
'class_test.phpv.php' => 'Class Test: PHP VERSION',
|
||||
'class_test.hash.php' => 'Class Test: HASH',
|
||||
'class_test.encoding.php' => 'Class Test: ENCODING (CHECK/CONVERT/MIME)',
|
||||
'class_test.image.php' => 'Class Test: IMAGE',
|
||||
'class_test.byte.php' => 'Class Test: BYTE CONVERT',
|
||||
'class_test.strings.php' => 'Class Test: STRING CONVERT',
|
||||
'class_test.datetime.php' => 'Class Test: DATE/TIME',
|
||||
'class_test.array.php' => 'Class Test: ARRAY HANDLER',
|
||||
'class_test.file.php' => 'Class Test: FILE',
|
||||
'class_test.randomkey.php' => 'Class Test: RANDOM KEY',
|
||||
'class_test.system.php' => 'Class Test: SYSTEM',
|
||||
'class_test.readenvfile.php' => 'Class Test: READ ENV FILE',
|
||||
'class_test.runningtime.php' => 'Class Test: RUNNING TIME',
|
||||
'class_test.memoryusage.php' => 'Class Test: MEMORY USAGE',
|
||||
'class_test.debug.php' => 'Class Test: DEBUG',
|
||||
'class_test.logging.php' => 'Class Test: LOGGING',
|
||||
'class_test.output.form.php' => 'Class Test: OUTPUT FORM',
|
||||
'class_test.admin.backend.php' => 'Class Test: BACKEND ADMIN CLASS',
|
||||
'class_test.lang.php' => 'Class Test: LANG/L10n',
|
||||
'class_test.varistype.php' => 'Class Test: SET VAR TYPE',
|
||||
'class_test.session.php' => 'Class Test: SESSION',
|
||||
'class_test.session.read.php' => 'Class Test: SESSION: READ',
|
||||
'class_test.smarty.php' => 'Class Test: SMARTY',
|
||||
'class_test.login.php' => 'Class Test: LOGIN',
|
||||
'class_test.autoloader.php' => 'Class Test: AUTOLOADER',
|
||||
'class_test.config.link.php' => 'Class Test: CONFIG LINK',
|
||||
'class_test.config.direct.php' => 'Class Test: CONFIG DIRECT',
|
||||
'class_test.class-calls.php' => 'Class Test: CLASS CALLS',
|
||||
'class_test.error_msg.php' => 'Class Test: ERROR MSG',
|
||||
'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB',
|
||||
];
|
||||
|
||||
asort($test_files);
|
||||
|
||||
foreach ($test_files as $file => $name) {
|
||||
print '<div><a href="' . $file . '">' . $name . '</a></div>';
|
||||
}
|
||||
|
||||
print "<hr>";
|
||||
print "L: " . CoreLibs\Debug\Support::printAr($locale) . "<br>";
|
||||
print "L: " . Support::dumpVar($locale) . "<br>";
|
||||
// print all _ENV vars set
|
||||
print "<div>READ _ENV ARRAY:</div>";
|
||||
print CoreLibs\Debug\Support::printAr(array_map('htmlentities', $_ENV));
|
||||
print Support::dumpVar(array_map('htmlentities', $_ENV));
|
||||
// set + check edit access id
|
||||
$edit_access_id = 3;
|
||||
if (is_object($login) && isset($login->loginGetAcl()['unit'])) {
|
||||
@@ -113,7 +145,7 @@ if (is_object($login) && isset($login->loginGetAcl()['unit'])) {
|
||||
print "Something went wrong with the login<br>";
|
||||
}
|
||||
|
||||
// $backend->log->debug('SESSION', \CoreLibs\Debug\Support::printAr($_SESSION));
|
||||
// $backend->log->debug('SESSION', \CoreLibs\Debug\Support::dumpVar($_SESSION));
|
||||
|
||||
print '<form method="post" name="loginlogout">';
|
||||
print '<a href="javascript:document.loginlogout.login_logout.value=\'Logou\';'
|
||||
@@ -121,16 +153,23 @@ print '<a href="javascript:document.loginlogout.login_logout.value=\'Logou\';'
|
||||
print '<input type="hidden" name="login_logout" value="">';
|
||||
print '</form>';
|
||||
|
||||
// print the debug core vars
|
||||
foreach (['on', 'off'] as $flag) {
|
||||
foreach (['debug', 'echo', 'print'] as $type) {
|
||||
$prefix = $flag == 'off' ? 'NOT ' : '';
|
||||
print $prefix . strtoupper($type) . ' OUT: '
|
||||
. \CoreLibs\Debug\Support::printAr($backend->log->getLogLevel($type, $flag)) . '<br>';
|
||||
}
|
||||
}
|
||||
foreach (['debug', 'echo', 'print'] as $type) {
|
||||
print strtoupper($type) . ' OUT ALL: ' . $backend->log->getLogLevelAll($type) . '<br>';
|
||||
print "Log Level: " . $backend->log->getLoggingLevel()->getName() . "<br>";
|
||||
print "Log ID: " . $backend->log->getLogFileId() . "<br>";
|
||||
print "Log Date: " . $backend->log->getLogDate() . "<br>";
|
||||
print "Log Max File Size: " . $backend->log->getLogMaxFileSize() . " bytes<br>";
|
||||
print "Log Flags: " . $backend->log->getLogFlags() . "<br>";
|
||||
foreach (
|
||||
[
|
||||
Logging\Logger\Flag::per_run,
|
||||
Logging\Logger\Flag::per_date,
|
||||
Logging\Logger\Flag::per_group,
|
||||
Logging\Logger\Flag::per_page,
|
||||
Logging\Logger\Flag::per_class,
|
||||
Logging\Logger\Flag::per_level
|
||||
] as $flag
|
||||
) {
|
||||
print "Log Flag: " . $flag->name . ": "
|
||||
. CoreLibs\Debug\Support::printBool($backend->log->getLogFlag($flag)) . "<br>";
|
||||
}
|
||||
|
||||
$log->debug('SOME MARK', 'Some error output');
|
||||
@@ -139,7 +178,7 @@ $log->debug('SOME MARK', 'Some error output');
|
||||
print "EDIT ACCESS ID: " . $backend->edit_access_id . "<br>";
|
||||
if (is_object($login)) {
|
||||
// print "ACL: <br>".$backend->print_ar($login->loginGetAcl())."<br>";
|
||||
$log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()));
|
||||
// $log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl()));
|
||||
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
||||
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
||||
// $result = array_flip(
|
||||
@@ -161,15 +200,11 @@ print "THIS HOST: " . HOST_NAME . ", with PROTOCOL: " . HOST_PROTOCOL . " is run
|
||||
print "DIR: " . DIR . "<br>";
|
||||
print "BASE: " . BASE . "<br>";
|
||||
print "ROOT: " . ROOT . "<br>";
|
||||
print "HOST: " . HOST_NAME . " => DB HOST: " . DB_CONFIG_NAME . " => " . print_r(DB_CONFIG, true) . "<br>";
|
||||
print "HOST: " . HOST_NAME . " => DB HOST: " . DB_CONFIG_NAME . " => " . Support::dumpVar(DB_CONFIG) . "<br>";
|
||||
|
||||
print "DS is: " . DIRECTORY_SEPARATOR . "<br>";
|
||||
print "SERVER HOST: " . $_SERVER['HTTP_HOST'] . "<br>";
|
||||
|
||||
// print error messages
|
||||
// print $login->log->printErrorMsg();
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
# __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,15 +20,10 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Check\PhpVersion;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_phpv = new CoreLibs\Check\PhpVersion();
|
||||
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||
@@ -44,7 +32,7 @@ $phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: PHP VERSION';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -71,8 +59,7 @@ print "S::MAX $max_version_ss: " . (string)$phpv_class::checkPHPVersion(null, $m
|
||||
// use stats
|
||||
print "U-S::MIN: $min_version: " . (string)PhpVersion::checkPHPVersion($min_version) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
print "PHP_VERSION_ID: " . PHP_VERSION_ID . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,21 +20,16 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Create\RandomKey;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$array_class = 'CoreLibs\Create\RandomKey';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: RANDOM KEY';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -58,9 +46,6 @@ print "S::RANDOMKEYGEN($key_lenght_long): " . RandomKey::randomKeyGen($key_lengh
|
||||
$_array = new CoreLibs\Create\RandomKey();
|
||||
print "C->RANDOMKEYGEN(auto): " . $_array->randomKeyGen() . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -18,21 +18,16 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-readEnvFile';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$ref_class = 'CoreLibs\Get\ReadEnvFile';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: READ ENV FILE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -44,9 +39,7 @@ $status = \CoreLibs\Get\DotEnv::readEnvFile('.', 'test.env');
|
||||
print "test.env: STATUS: " . $status . "<br>";
|
||||
print "AFTER reading test.env file: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
// ;;
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,20 +20,15 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Debug\RunningTime;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: RUNNING TIME';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -64,9 +52,6 @@ RunningTime::hrRunningTime();
|
||||
echo "TIMED 2 [hr]: " . RunningTime::hrRunningTime() . "<br>";
|
||||
echo "TIMED 2 [hr-end]: " . RunningTime::hrRunningTimeFromStart() . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -2,14 +2,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
@@ -47,22 +40,17 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-session';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
use CoreLibs\Create\Session;
|
||||
$session = new Session();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SESSION';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -90,16 +78,18 @@ if (isset($_SESSION)) {
|
||||
#
|
||||
print "[UNSET] To set session name valid: "
|
||||
. ($session->checkValidSessionName($session_name) ? 'Valid' : 'Invalid') . "<br>";
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[SET] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[FAILED] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
// set again
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[2 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[2 SET] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[2 FAILED] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
print "[SET] Current session id: " . $session->getSessionId() . "<br>";
|
||||
print "[SET] Current session name: " . $session->getSessionName() . "<br>";
|
||||
@@ -128,19 +118,20 @@ $session->unsetS('setwrap');
|
||||
print "[READ WRAP] unset setwrap: " . $session->getS('setwrap') . "<br>";
|
||||
print "[READ WRAP] unset Isset: " . ($session->issetS('setwrap') ? 'Yes' : 'No') . "<br>";
|
||||
// test __get/__set
|
||||
$session->setwrap = 'YES, magic set _SESSION var';
|
||||
print "[READ MAGIC] A setwrap: " . $session->setwrap . "<br>";
|
||||
$session->setwrap = 'YES, magic set _SESSION var'; /** @phpstan-ignore-line GET/SETTER */
|
||||
print "[READ MAGIC] A setwrap: " . ($session->setwrap ?? '') . "<br>";
|
||||
print "[READ MAGIC] Isset: " . (isset($session->setwrap) ? 'Yes' : 'No') . "<br>";
|
||||
unset($session->setwrap);
|
||||
print "[READ MAGIC] unset setwrap: " . $session->setwrap . "<br>";
|
||||
print "[READ MAGIC] unset setwrap: " . ($session->setwrap ?? '') . "<br>";
|
||||
print "[READ MAGIC] unset Isset: " . (isset($session->setwrap) ? 'Yes' : 'No') . "<br>";
|
||||
|
||||
// differnt session name
|
||||
$session_name = 'class-test-session-ALT';
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[3 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[3 SET] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[3 FAILED] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
print "[SET AGAIN] Current session id: " . $session->getSessionId() . "<br>";
|
||||
|
||||
@@ -153,10 +144,11 @@ $_SESSION['will_never_be_written'] = 'empty';
|
||||
|
||||
// open again
|
||||
$session_name = 'class-test-session';
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[4 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[4 SET] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[4 FAILED] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
print "[START AGAIN] Current session id: " . $session->getSessionId() . "<br>";
|
||||
$_SESSION['will_be_written_again'] = 'Full';
|
||||
@@ -165,19 +157,17 @@ $_SESSION['will_be_written_again'] = 'Full';
|
||||
$session->writeClose();
|
||||
// invalid
|
||||
$session_name = '123';
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[5 FAILED] Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[5 SET] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[5 FAILED] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
print "[BAD NAME] Current session id: " . $session->getSessionId() . "<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 status: " . getSessionStatusString($session->getSessionStatus()) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -2,14 +2,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
@@ -47,22 +40,17 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-session.read';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
use CoreLibs\Create\Session;
|
||||
$session = new Session();
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -81,16 +69,18 @@ print "[UNSET] Current session status: " . getSessionStatusString($session->getS
|
||||
|
||||
print "[READ] " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||
// start
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "Session start failed: " . $session->getErrorStr() . "<br>";
|
||||
} else {
|
||||
print "Current session id: " . $session_id . "<br>";
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[1] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[1] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
// set again
|
||||
if (false === ($session_id = $session->startSession($session_name))) {
|
||||
print "[2] Session start failed<br>";
|
||||
} else {
|
||||
try {
|
||||
$session_id = $session->startSession($session_name);
|
||||
print "[2] Current session id: " . $session_id . "<br>";
|
||||
} catch (\Exception $e) {
|
||||
print "[2] Session start failed:<br>" . $e->getMessage() . "<br>" . $e . "<br>";
|
||||
}
|
||||
print "[SET] Current session id: " . $session->getSessionId() . "<br>";
|
||||
print "[SET] Current session name: " . $session->getSessionName() . "<br>";
|
||||
@@ -102,9 +92,6 @@ print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||
|
||||
print "[ALL SESSION]: " . \CoreLibs\Debug\Support::printAr($_SESSION) . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -27,39 +20,46 @@ $ECHO_ALL = true;
|
||||
$LOG_FILE_ID = 'classTest-smarty';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
$l10n = new \CoreLibs\Language\L10n(
|
||||
$locale['locale'],
|
||||
$locale['domain'],
|
||||
$locale['path'],
|
||||
SITE_LOCALE,
|
||||
SITE_DOMAIN,
|
||||
BASE . INCLUDES . LOCALE,
|
||||
SITE_ENCODING
|
||||
);
|
||||
$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||
$smarty = new CoreLibs\Template\SmartyExtend(
|
||||
$l10n,
|
||||
CACHE_ID,
|
||||
COMPILE_ID,
|
||||
);
|
||||
$adm = new CoreLibs\Admin\Backend(
|
||||
new CoreLibs\DB\IO(DB_CONFIG, $log),
|
||||
$log,
|
||||
new CoreLibs\Create\Session(EDIT_SESSION_NAME),
|
||||
$l10n,
|
||||
80
|
||||
);
|
||||
$adm->DATA['adm_set'] = 'SET from admin class';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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->DATA['JS_DEBUG'] = $log->loggingLevelIsDebug();
|
||||
$smarty->MASTER_TEMPLATE_NAME = 'main_body.tpl';
|
||||
$smarty->TEMPLATE_NAME = 'smarty_test.tpl';
|
||||
$smarty->CSS_SPECIAL_TEMPLATE_NAME = 'smart_test.css';
|
||||
$smarty->USE_PROTOTYPE = false;
|
||||
$smarty->USE_JQUERY = true;
|
||||
$smarty->JS_DATEPICKR = false;
|
||||
if ($smarty->USE_PROTOTYPE) {
|
||||
if ($smarty->USE_PROTOTYPE) { /** @phpstan-ignore-line for debug purpose */
|
||||
$smarty->ADMIN_JAVASCRIPT = 'edit.pt.js';
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js';
|
||||
} elseif ($smarty->USE_JQUERY) {
|
||||
@@ -67,7 +67,17 @@ if ($smarty->USE_PROTOTYPE) {
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js';
|
||||
}
|
||||
$smarty->PAGE_WIDTH = '100%';
|
||||
$smarty->setSmartyPaths();
|
||||
$smarty->setSmartyPaths(
|
||||
BASE . INCLUDES,
|
||||
BASE . INCLUDES . TEMPLATES . CONTENT_PATH,
|
||||
LAYOUT . JS,
|
||||
LAYOUT . CSS,
|
||||
LAYOUT . FONT,
|
||||
LAYOUT . IMAGES,
|
||||
LAYOUT . CACHE,
|
||||
ROOT . LAYOUT . CACHE,
|
||||
null // master template name optional
|
||||
);
|
||||
|
||||
// smarty test
|
||||
$smarty->DATA['SMARTY_TEST'] = 'Test Data';
|
||||
@@ -87,7 +97,7 @@ $smarty->DATA['drop_down_test'] = [
|
||||
'foobar' => 'Foo Bar',
|
||||
];
|
||||
$smarty->DATA['drop_down_test_selected'] = 'bar';
|
||||
$smarty->DATA['drop_down_test_nested'] = [
|
||||
$smarty->DATA['drop_down_test_nested'] = [
|
||||
'' => '選択してください',
|
||||
'4/25(木)' => [
|
||||
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
||||
@@ -122,10 +132,23 @@ $smarty->DATA['checkbox_test_selected'] = ['1', '-1'];
|
||||
$smarty->DATA['checkbox_test_pos_selected'] = ['0', '-1'];
|
||||
|
||||
|
||||
$smarty->setSmartyVarsAdmin();
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
$smarty->setSmartyVarsAdmin(
|
||||
[
|
||||
'compile_dir' => BASE . TEMPLATES_C,
|
||||
'cache_dir' => BASE . CACHE,
|
||||
'js' => JS,
|
||||
'css' => CSS,
|
||||
'font' => FONT,
|
||||
'g_title' => G_TITLE,
|
||||
'default_encoding' => DEFAULT_ENCODING,
|
||||
'admin_stylesheet' => ADMIN_STYLESHEET,
|
||||
'admin_javascript' => ADMIN_JAVASCRIPT,
|
||||
'page_width' => PAGE_WIDTH,
|
||||
'content_path' => CONTENT_PATH,
|
||||
'user_name' => $_SESSION['USER_NAME'] ?? ''
|
||||
],
|
||||
$adm
|
||||
);
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
|
||||
@@ -2,14 +2,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -21,21 +14,16 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-string';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$byte_class = 'CoreLibs\Convert\Strings';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: STRINGS CONVERT';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -78,9 +66,6 @@ foreach ($test_splits as $split) {
|
||||
print "$split with count: " . \CoreLibs\Convert\Strings::countSplitParts($split) . "<br>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -28,20 +21,15 @@ ob_end_flush();
|
||||
use CoreLibs\Get\System;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: SYSTEM';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -53,7 +41,7 @@ print "GETPAGENAME(0): " . System::getPageName() . "<br>";
|
||||
print "GETPAGENAME(1): " . System::getPageName(System::NO_EXTENSION) . "<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: " . DgS::printAr(System::getPageNameArray()) . "<br>";
|
||||
// seting errro codes file upload
|
||||
print "System::fileUploadErrorMessage():<br>";
|
||||
print "FILEUPLOADERRORMESSAGE(): " . System::fileUploadErrorMessage(-1) . "<br>";
|
||||
@@ -63,7 +51,6 @@ print "FILEUPLOADERRORMESSAGE(UPLOAD_ERR_CANT_WRITE): "
|
||||
print "System::checkCLI():<br>";
|
||||
print "Are we in an CLI: " . (System::checkCLI() ? 'Yes' : 'No') . "<br>";
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
print "Get Addresses: " . DgS::printAr(System::getIpAddresses()) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,22 +18,17 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-token';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_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>" . $PAGE_NAME . "</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>';
|
||||
@@ -61,9 +49,6 @@ $token_id = $basic->setFormToken($token);
|
||||
print "TOKEN: $token: (ID) ".$token_id." => (S) ".$_SESSION[$token]."<br>";
|
||||
print "VALIDATE: $token: ".(string)$basic->validateFormToken($token_id, $token)."<br>"; */
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -25,15 +18,10 @@ require 'config.php';
|
||||
$LOG_FILE_ID = 'classTest-uids';
|
||||
ob_end_flush();
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
$_uids = new CoreLibs\Create\Uids();
|
||||
use CoreLibs\Create\Uids;
|
||||
@@ -41,7 +29,7 @@ $uids_class = 'CoreLibs\Create\Uids';
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: UIDS';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -51,11 +39,16 @@ print "UUIDV4: " . $_uids->uuidv4() . "<br>";
|
||||
print "UNIQID (d): " . $_uids->uniqId() . "<br>";
|
||||
print "UNIQID (md5): " . $_uids->uniqId('md5') . "<br>";
|
||||
print "UNIQID (sha256): " . $_uids->uniqId('sha256') . "<br>";
|
||||
// statc
|
||||
// static
|
||||
print "S::UUIDV4: " . $uids_class::uuidv4() . "<br>";
|
||||
print "S::UNIQID (d): " . $uids_class::uniqId() . "<br>";
|
||||
print "S::UNIQID (md5): " . $uids_class::uniqId('md5') . "<br>";
|
||||
print "S::UNIQID (sha256): " . $uids_class::uniqId('sha256') . "<br>";
|
||||
// with direct length
|
||||
print "S:UNIQID (0->4): " . Uids::uniqId(0) . "<br>";
|
||||
print "S:UNIQID (9->8): " . Uids::uniqId(9) . "<br>";
|
||||
print "S:UNIQID (9,true): " . Uids::uniqId(9, true) . "<br>";
|
||||
print "S:UNIQID (512): " . Uids::uniqId(512) . "<br>";
|
||||
// uniq ids
|
||||
print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>";
|
||||
print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";
|
||||
@@ -64,9 +57,6 @@ print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";
|
||||
/* print "D/UUIDV4: ".$basic->uuidv4()."<br>";
|
||||
print "/DUNIQID (d): ".$basic->uniqId()."<br>"; */
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
|
||||
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);
|
||||
}
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -29,20 +22,15 @@ use CoreLibs\Convert\SetVarType;
|
||||
use CoreLibs\Convert\SetVarTypeNull;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Debug\Logging([
|
||||
$log = new CoreLibs\Logging\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,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: CONVERT\VARISTYPE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</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>';
|
||||
@@ -111,9 +99,6 @@ foreach ($checks as $string) {
|
||||
print "<hr>";
|
||||
}
|
||||
|
||||
// error message
|
||||
print $log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
5
www/admin/edit_base_page_test.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
// empty file for add and remove test
|
||||
|
||||
// __END__
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
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;
|
||||
$DEBUG_LEVEL = \CoreLibs\Logging\Logger\Level::Debug;
|
||||
|
||||
if ($DEBUG_ALL) {
|
||||
if ($DEBUG_LEVEL->name == 'Debug') {
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../layout/admin/
|
||||
@@ -377,7 +377,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
|
||||
border-top-color: rgba(3, 155, 229 ,1);
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
animation: rotate 600ms infinite linear;
|
||||
animation: progress-move 600ms infinite linear;
|
||||
/* align */
|
||||
left: 0;
|
||||
top: 0;
|
||||
@@ -385,7 +385,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
|
||||
z-index: 1000;
|
||||
}
|
||||
/* Animation for above progress */
|
||||
@keyframes rotate {
|
||||
@keyframes progress-move {
|
||||
to {
|
||||
transform: rotate(1turn)
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 489 KiB After Width: | Height: | Size: 489 KiB |
|
Before Width: | Height: | Size: 807 KiB After Width: | Height: | Size: 807 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 275 B |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 208 B |