Update and add class test pages, minor updates for CoreLibs
Some code clean up in smarty class (check if $cms object is actually set) Logger/Support Debug clean up for some minor logic with debug prefixes DB IO update debug prefix for log line so we can have a HTML formatted prefix for echo output
This commit is contained in:
@@ -27,3 +27,9 @@ msgstr "Month"
|
||||
|
||||
msgid "INPUT TEST"
|
||||
msgstr "OUTPUT TEST EN"
|
||||
|
||||
msgid "I should be translated"
|
||||
msgstr "I should be translated: I WAS TRANSLATED"
|
||||
|
||||
msgid "Are we translated?"
|
||||
msgstr "Are we translated? Yes, we are!"
|
||||
|
||||
52
www/admin/class_test.admin.backend.php
Normal file
52
www/admin/class_test.admin.backend.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
}
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-admin';
|
||||
ob_end_flush();
|
||||
|
||||
$basic = new CoreLibs\Basic();
|
||||
$backend = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||
|
||||
print "<html><head><title>TEST CLASS: ADMIN BACKEND</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
|
||||
// set acl, from eg login acl
|
||||
print "SETACL[]: ".$backend->setACL([])."<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($this->messages)."<br>";
|
||||
print "ADBPRINTDATETIME:<br>".$backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test')."<br>";
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
@@ -97,6 +98,96 @@ print "ARRAYFLATFORKEY: ".DgS::printAr(ArrayHandler::arrayFlatForKey($test_array
|
||||
// DEPRECATED
|
||||
// print "ARRAYMERGERECURSIVE: ".DgS::printAr($basic->arrayMergeRecursive($array_1, $array_2, $array_3))."<br>";
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function rec(string $pre, string $cur, array $node = [])
|
||||
{
|
||||
if (!is_array($node)) {
|
||||
$node = [];
|
||||
}
|
||||
print "<div style='color: green;'>#### PRE: ".$pre.", CUR: ".$cur.", N-c: ".count($node)." [".join('|', array_keys($node))."]</div>";
|
||||
if (!$pre) {
|
||||
print "** <span style='color: red;'>NEW</span><br>";
|
||||
$node[$cur] = [];
|
||||
} else {
|
||||
if (array_key_exists($pre, $node)) {
|
||||
print "+ <span style='color: orange;'>KEY FOUND:</span> ".$pre.", add: ".$cur."<br>";
|
||||
$node[$pre][$cur] = [];
|
||||
} else {
|
||||
print "- NOT FOUND: loop<br>";
|
||||
foreach ($node as $_pre => $_cur) {
|
||||
print "> TRY: ".$_pre." => ".count($_cur)." [".join('|', array_keys($_cur))."]<br>";
|
||||
if (count($_cur) > 0) {
|
||||
$node[$_pre] = rec($pre, $cur, $_cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* flatten array down to own level
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $return
|
||||
* @return array
|
||||
*/
|
||||
function flattenArrayKey(array $array, array $return = [])
|
||||
{
|
||||
foreach ($array as $key => $sub) {
|
||||
$return[] = $key;
|
||||
if (count($sub) > 0) {
|
||||
$return = flattenArrayKey($sub, $return);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
// $test = [
|
||||
// 'A' => [
|
||||
// 'B' => [],
|
||||
// 'C' => [
|
||||
// 'D' => [],
|
||||
// 'E' => [
|
||||
// 'F' => []
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// '1' => [],
|
||||
// '2' => [],
|
||||
// '3' => [
|
||||
// 'G' => []
|
||||
// ]
|
||||
// ];
|
||||
|
||||
// build a tested array for flatten
|
||||
$test = [];
|
||||
// core
|
||||
$test = rec('', 'A', $test);
|
||||
$test = rec('', '1', $test);
|
||||
$test = rec('', '2', $test);
|
||||
$test = rec('', '3', $test);
|
||||
$test = rec('3', 'G', $test);
|
||||
$test = rec('A', 'B', $test);
|
||||
$test = rec('A', 'C', $test);
|
||||
$test = rec('C', 'D', $test);
|
||||
$test = rec('C', 'E', $test);
|
||||
$test = rec('E', 'F', $test);
|
||||
// new
|
||||
$test = rec('C', 'U', $test);
|
||||
$test = rec('F', 'U', $test);
|
||||
$test = rec('', 'Al', $test);
|
||||
$test = rec('B', 'B1', $test);
|
||||
print "ORIGINAL: ".\CoreLibs\Debug\Support::printAr($test)."<br>";
|
||||
print "FLATTEN: ".\CoreLibs\Debug\Support::printAr(flattenArrayKey($test))."<br>";
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
@@ -18,6 +19,8 @@ ob_start();
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
@@ -28,77 +31,84 @@ ob_end_flush();
|
||||
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$basic = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||
$db = $basic = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||
|
||||
// NEXT STEP
|
||||
// $basic = new CoreLibs\Basic();
|
||||
// change __construct
|
||||
// add object $logger
|
||||
// add $this->log = $logger;
|
||||
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
|
||||
|
||||
print "<html><head><title>TEST CLASS: DB</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
|
||||
print "DBINFO: ".$basic->dbInfo()."<br>";
|
||||
print "DBINFO: ".$db->dbInfo()."<br>";
|
||||
echo "DB_CONFIG_SET constant: <pre>".print_r(DB_CONFIG, true)."</pre><br>";
|
||||
|
||||
// DB client encoding
|
||||
print "DB Client encoding: ".$basic->dbGetEncoding()."<br>";
|
||||
print "DB Client encoding: ".$db->dbGetEncoding()."<br>";
|
||||
|
||||
while ($res = $basic->dbReturn("SELECT * FROM max_test", 0, true)) {
|
||||
while ($res = $db->dbReturn("SELECT * FROM max_test", 0, true)) {
|
||||
print "TIME: ".$res['time']."<br>";
|
||||
}
|
||||
print "CACHED DATA: <pre>".print_r($basic->cursor_ext, true)."</pre><br>";
|
||||
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
|
||||
print "CACHED DATA: <pre>".print_r($db->cursor_ext, true)."</pre><br>";
|
||||
while ($res = $db->dbReturn("SELECT * FROM max_test")) {
|
||||
print "[CACHED] TIME: ".$res['time']."<br>";
|
||||
}
|
||||
|
||||
print "<pre>";
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
|
||||
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
|
||||
print "DIRECT INSERT STATUS: $status | "
|
||||
."PRIMARY KEY: ".$basic->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."<br>";
|
||||
."PRIMARY KEY: ".$db->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."<br>";
|
||||
|
||||
// should throw deprecated error
|
||||
// $basic->getReturningExt();
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->dbGetInsertPK()), true)."<br>";
|
||||
$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
|
||||
$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time()));
|
||||
// $db->getReturningExt();
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->dbGetInsertPK()), true)."<br>";
|
||||
$db->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
|
||||
$status = $db->dbExecute("ins_foo", array('BAR TEST '.time()));
|
||||
print "PREPARE INSERT STATUS: $status | "
|
||||
."PRIMARY KEY: ".$basic->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
|
||||
."RETURNING RETURN: ".print_r($basic->dbGetReturningArray(), true)."<br>";
|
||||
."PRIMARY KEY: ".$db->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | "
|
||||
."RETURNING RETURN: ".print_r($db->dbGetReturningArray(), true)."<br>";
|
||||
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->dbGetInsertPK()), true)."<br>";
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->dbGetInsertPK()), true)."<br>";
|
||||
// returning test with multiple entries
|
||||
// $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id");
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
|
||||
// $status = $db->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id");
|
||||
$status = $db->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
|
||||
print "DIRECT MULTIPLE INSERT STATUS: $status | "
|
||||
."PRIMARY KEYS: ".print_r($basic->dbGetInsertPK(), true)." | "
|
||||
."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."<br>";
|
||||
."PRIMARY KEYS: ".print_r($db->dbGetInsertPK(), true)." | "
|
||||
."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."<br>";
|
||||
|
||||
// no returning, but not needed ;
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
|
||||
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
|
||||
print "DIRECT INSERT STATUS: $status | "
|
||||
."PRIMARY KEY: ".$basic->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."<br>";
|
||||
."PRIMARY KEY: ".$db->dbGetInsertPK()." | "
|
||||
."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."<br>";
|
||||
|
||||
// UPDATE WITH RETURNING
|
||||
$status = $basic->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test");
|
||||
$status = $db->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test");
|
||||
print "UPDATE STATUS: $status | "
|
||||
."RETURNING EXT: ".print_r($basic->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($basic->dbGetReturningArray(), true)."<br>";
|
||||
."RETURNING EXT: ".print_r($db->dbGetReturningExt(), true)." | "
|
||||
."RETURNING ARRAY: ".print_r($db->dbGetReturningArray(), true)."<br>";
|
||||
print "</pre>";
|
||||
|
||||
// REEAD PREPARE
|
||||
if ($basic->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time FROM foo ORDER BY foo_id DESC LIMIT 5") === false) {
|
||||
if ($db->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time FROM foo ORDER BY foo_id DESC LIMIT 5") === false) {
|
||||
print "Error in sel_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 = $basic->dbExecute('sel_foo', []);
|
||||
$cursor = $db->dbExecute('sel_foo', []);
|
||||
$i = 1;
|
||||
while (($res = $basic->dbFetchArray($cursor, true)) !== false) {
|
||||
while (($res = $db->dbFetchArray($cursor, true)) !== false) {
|
||||
print "DB PREP EXEC FETCH ARR: ".$i.": <pre>".print_r($res, true)."</pre><br>";
|
||||
$i ++;
|
||||
}
|
||||
@@ -107,35 +117,35 @@ if ($basic->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, numb
|
||||
|
||||
# db write class test
|
||||
$table = 'foo';
|
||||
print "TABLE META DATA: ".DgS::printAr($basic->dbShowTableMetaData($table))."<br>";
|
||||
print "TABLE META DATA: ".DgS::printAr($db->dbShowTableMetaData($table))."<br>";
|
||||
$primary_key = ''; # unset
|
||||
$db_write_table = array('test', 'string_a', 'number_a', 'some_bool');
|
||||
// $db_write_table = array('test');
|
||||
$object_fields_not_touch = array();
|
||||
$object_fields_not_update = array();
|
||||
$data = array('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST UNSET '.time());
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $db->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
|
||||
// return Array Test
|
||||
$query = "SELECT type, sdate, integer FROM foobar";
|
||||
$data = $basic->dbReturnArray($query, true);
|
||||
$data = $db->dbReturnArray($query, true);
|
||||
print "Full foobar list: <br><pre>".print_r($data, true)."</pre><br>";
|
||||
|
||||
# async test queries
|
||||
/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||
/* $db->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||
echo "WAITING FOR ASYNC: ";
|
||||
$chars = array('|', '/', '-', '\\');
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
{
|
||||
if ((list($_, $char) = each($chars)) === FALSE)
|
||||
{
|
||||
@@ -147,37 +157,37 @@ while (($ret = $basic->dbCheckAsync()) === true)
|
||||
flush();
|
||||
}
|
||||
print "<br>END STATUS: ".$ret."<br>";
|
||||
// while ($res = $basic->dbFetchArray($ret))
|
||||
while ($res = $basic->dbFetchArray())
|
||||
// while ($res = $db->dbFetchArray($ret))
|
||||
while ($res = $db->dbFetchArray())
|
||||
{
|
||||
echo "RES: ".$res['test']."<br>";
|
||||
}
|
||||
# test async insert
|
||||
$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
|
||||
$db->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
|
||||
echo "WAITING FOR ASYNC INSERT: ";
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
{
|
||||
print ".";
|
||||
sleep(1);
|
||||
flush();
|
||||
}
|
||||
print "<br>END STATUS: ".$ret." | PK: ".$basic->insert_id."<br>";
|
||||
print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), true)."<br>"; */
|
||||
print "<br>END STATUS: ".$ret." | PK: ".$db->insert_id."<br>";
|
||||
print "ASYNC PREVIOUS INSERTED: ".print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$db->insert_id), true)."<br>"; */
|
||||
|
||||
$to_db_version = '9.1.9';
|
||||
print "VERSION DB: ".$basic->dbVersion()."<br>";
|
||||
print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."<br>";
|
||||
print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."<br>";
|
||||
print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."<br>";
|
||||
print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."<br>";
|
||||
print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."<br>";
|
||||
print "VERSION DB: ".$db->dbVersion()."<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>";
|
||||
print "DB Version bigger than $to_db_version: ".$db->dbCompareVersion('>='.$to_db_version)."<br>";
|
||||
print "DB Version bigger $to_db_version: ".$db->dbCompareVersion('>'.$to_db_version)."<br>";
|
||||
|
||||
/* $q = "SELECT FOO FRO BAR";
|
||||
// $q = "Select * from foo";
|
||||
$foo = $basic->dbExecAsync($q);
|
||||
$foo = $db->dbExecAsync($q);
|
||||
print "[ERR] Query: ".$q."<br>";
|
||||
print "[ERR] RESOURCE: $foo<br>";
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
{
|
||||
print "[ERR]: $ret<br>";
|
||||
sleep(5);
|
||||
@@ -185,17 +195,17 @@ while (($ret = $basic->dbCheckAsync()) === true)
|
||||
|
||||
// search path check
|
||||
$q = "SHOW search_path";
|
||||
$cursor = $basic->dbExec($q);
|
||||
$data = $basic->dbFetchArray($cursor)['search_path'];
|
||||
$cursor = $db->dbExec($q);
|
||||
$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 = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
|
||||
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."<br>";
|
||||
$status = $db->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
|
||||
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$db->pk_name.", PRIMARY KEY: ".$db->insert_id."<br>";
|
||||
|
||||
print "<b>NULL TEST DB READ</b><br>";
|
||||
$q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'";
|
||||
$res = $basic->dbReturnRow($q);
|
||||
$res = $db->dbReturnRow($q);
|
||||
var_dump($res);
|
||||
print "RES: ".DgS::printAr($res)."<br>";
|
||||
print "ISSET: ".isset($res['null_varchar'])."<br>";
|
||||
|
||||
@@ -121,6 +121,26 @@ class AttachOutside
|
||||
$ao = new AttachOutside($basic->log);
|
||||
print "AO-CLASS: DEBUG: ".$ao->test()."<br>";
|
||||
|
||||
// @codingStandardsIgnoreLine
|
||||
class AttachFull
|
||||
{
|
||||
public $main;
|
||||
public function __construct(object $class)
|
||||
{
|
||||
$this->main = $class;
|
||||
}
|
||||
public function test()
|
||||
{
|
||||
// should trigger deprecated
|
||||
return $this->main->rgb2hex(2, 3, 4);
|
||||
}
|
||||
}
|
||||
|
||||
$af = new AttachFull($basic);
|
||||
// should trigger deprecated
|
||||
print "DEPREACTEDTEST: ".$af->test()."<br>";
|
||||
|
||||
|
||||
print "GETCALLERCLASS(NON CLASS): ".\CoreLibs\Debug\Support::getCallerClass()."<br>";
|
||||
|
||||
// fdebug
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
@@ -93,6 +94,14 @@ $magic_link = 'http://www.somelink.com/?with=1234|Some Title|';
|
||||
print "D/MAGICLINK: ".Html::htmlent($basic->magicLinks($magic_link))."<Br>";
|
||||
*/
|
||||
|
||||
$text = 'I am some text
|
||||
with some
|
||||
line breaks
|
||||
in there. Theis
|
||||
is sucky';
|
||||
|
||||
print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text)."<br>";
|
||||
print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text, '##BR##')."<br>";
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
58
www/admin/class_test.lang.php
Normal file
58
www/admin/class_test.lang.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// init language
|
||||
$lang = 'en_utf8';
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
}
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-lang';
|
||||
|
||||
$l = new CoreLibs\Language\L10n($lang);
|
||||
ob_end_flush();
|
||||
|
||||
print "<html><head><title>TEST CLASS: LANG</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
|
||||
$string = 'INPUT TEST';
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
|
||||
// switch to other language
|
||||
$lang = 'ja_utf8';
|
||||
$l->l10nReloadMOfile($lang);
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
// TODO: run compare check input must match output
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
47
www/admin/class_test.output.form.php
Normal file
47
www/admin/class_test.output.form.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
}
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-form';
|
||||
ob_end_flush();
|
||||
|
||||
$basic = new CoreLibs\Basic();
|
||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG);
|
||||
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
|
||||
|
||||
print "<html><head><title>TEST CLASS: FORM GENERATE</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
|
||||
print "TODO<br>";
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
@@ -56,6 +57,10 @@ 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.runningtime.php">Class Test: RUNNING TIME</a></div>';
|
||||
print '<div><a href="class_test.debug.php">Class Test: DEBUG</a></div>';
|
||||
print '<div><a href="class_test.form.php">Class Test: FORM</a></div>';
|
||||
print '<div><a href="class_test.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.smarty.php">Class Test: SMARTY</a></div>';
|
||||
|
||||
// set + check edit access id
|
||||
$edit_access_id = 3;
|
||||
@@ -104,6 +109,17 @@ if (is_object($login)) {
|
||||
// $basic->adbSetACL($login->acl);
|
||||
}
|
||||
|
||||
print "THIS HOST: ".HOST_NAME.", with PROTOCOL: ".HOST_PROTOCOL." is running SSL: ".HOST_SSL."<br>";
|
||||
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>";
|
||||
|
||||
$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR;
|
||||
$du = DS ?? DIRECTORY_SEPARATOR;
|
||||
print "DS is: ".$ds."<br>";
|
||||
print "SERVER HOST: ".$_SERVER['HTTP_HOST']."<br>";
|
||||
|
||||
// print error messages
|
||||
// print $login->log->printErrorMsg();
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
94
www/admin/class_test.smarty.php
Normal file
94
www/admin/class_test.smarty.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php // phpcs:ignore warning
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', true);
|
||||
// set language
|
||||
$lang = 'en_utf8';
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// override ECHO ALL FALSE
|
||||
$ECHO_ALL = true;
|
||||
// set session name
|
||||
if (!defined('SET_SESSION_NAME')) {
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
}
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-smarty';
|
||||
ob_end_flush();
|
||||
|
||||
$basic = new CoreLibs\Basic();
|
||||
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||
// for testing with or without CMS
|
||||
// $cms = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||
$l = new CoreLibs\Language\L10n($lang);
|
||||
|
||||
print "<html><head><title>TEST CLASS: SMARTY</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
|
||||
$smarty->DATA['JS_DEBUG'] = DEBUG;
|
||||
$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) {
|
||||
$smarty->ADMIN_JAVASCRIPT = 'edit.pt.js';
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js';
|
||||
} elseif ($smarty->USE_JQUERY) {
|
||||
$smarty->ADMIN_JAVASCRIPT = 'edit.jq.js';
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js';
|
||||
}
|
||||
$smarty->PAGE_WIDTH = '100%';
|
||||
// require BASE.INCLUDES.'admin_set_paths.php';
|
||||
$smarty->setSmartyPaths();
|
||||
|
||||
// smarty test
|
||||
$smarty->DATA['SMARTY_TEST'] = 'Test Data';
|
||||
$smarty->DATA['TRANSLATE_TEST'] = $l->__('Are we translated?');
|
||||
$smarty->DATA['TRANSLATE_TEST_SMARTY'] = $smarty->l10n->__('Are we translated?');
|
||||
|
||||
// drop down test with optgroups
|
||||
$options = [
|
||||
'' => '選択してください',
|
||||
'4/25(木)' => [
|
||||
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
||||
'4/25(木) 12:20-13:00' => '4/25(木) 12:20-13:00'
|
||||
],
|
||||
'4/26(金)' => [
|
||||
'4/26(金) 11:00-11:50' => '4/26(金) 11:00-11:50',
|
||||
'4/26(金) 12:20-13:00' => '4/26(金) 12:20-13:00'
|
||||
],
|
||||
'4/27(土)' => [
|
||||
'4/27(土) 11:00-11:50' => '4/27(土) 11:00-11:50',
|
||||
'4/27(土) 12:20-13:00' => '4/27(土) 12:20-13:00'
|
||||
],
|
||||
];
|
||||
|
||||
$smarty->DATA['drop_down_test'] = $options;
|
||||
$smarty->DATA['loop_start'] = 2;
|
||||
// require BASE.INCLUDES.'admin_smarty.php';
|
||||
$smarty->setSmartyVarsAdmin();
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
// debug for L10n issues in php 7.3
|
||||
|
||||
// namespace test
|
||||
ob_start();
|
||||
|
||||
// init language
|
||||
$lang = 'en_utf8';
|
||||
// admin class tests
|
||||
require 'config.php';
|
||||
$l = new CoreLibs\Language\L10n($lang);
|
||||
ob_end_flush();
|
||||
|
||||
$string = 'INPUT TEST';
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
|
||||
// switch to other language
|
||||
$lang = 'ja_utf8';
|
||||
$l->l10nReloadMOfile($lang);
|
||||
|
||||
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||
|
||||
// __END__
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php 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;
|
||||
|
||||
// namespace test
|
||||
ob_start();
|
||||
|
||||
// admin class tests
|
||||
require 'config.php';
|
||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
|
||||
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
||||
|
||||
$base = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||
ob_end_flush();
|
||||
if ($base->getConnectionStatus()) {
|
||||
die("Cannot connect to database");
|
||||
}
|
||||
|
||||
print "Start time: ".\CoreLibs\Debug\RunningTime::runningTime()."<br>";
|
||||
print "HumanReadableByteFormat: ".\CoreLibs\Convert\Byte::HumanReadableByteFormat(1234567.12)."<br>";
|
||||
print "humanReadableByteFormat: ".\CoreLibs\Convert\Byte::humanReadableByteFormat(1234567.12)."<br>";
|
||||
print "getPageName: ". \CoreLibs\Get\System::getPageName()."<br>";
|
||||
|
||||
print "DB Info: ".$base->dbInfo(true)."<br>";
|
||||
|
||||
|
||||
print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."<br>";
|
||||
print "Start Time: ".\CoreLibs\Debug\RunningTime::runningTime()."<br>";
|
||||
|
||||
print "Lang: ".$base->l->__getLang().", MO File: ".$base->l->__getMoFile()."<br>";
|
||||
print "Translate test: Year -> ".$base->l->__('Year')."<br>";
|
||||
|
||||
print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."<br>";
|
||||
// end error print
|
||||
print $base->log->printErrorMsg();
|
||||
|
||||
# __END__
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Foo;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public $foo = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->foo = 'BAR';
|
||||
}
|
||||
|
||||
public function otherBarBar($wrong)
|
||||
{
|
||||
echo "B: $wrong<br>";
|
||||
}
|
||||
|
||||
public function barBar($wrong)
|
||||
{
|
||||
echo "B: $wrong<br>";
|
||||
}
|
||||
}
|
||||
|
||||
$foo = $bar ?? 'EMPTY';
|
||||
echo "BAR: ".$foo."<br>";
|
||||
// define('DS', DIRECTORY_SEPARATOR);
|
||||
$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR;
|
||||
$du = DS ?? DIRECTORY_SEPARATOR;
|
||||
echo "DS is: ".$ds."<br>";
|
||||
|
||||
echo "SERVER HOST: ".$_SERVER['HTTP_HOST']."<br>";
|
||||
|
||||
// __END__
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
$ENABLE_ERROR_HANDLING = 0;
|
||||
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = 1;
|
||||
$PRINT_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
$LOG_PER_RUN = 1;
|
||||
|
||||
define('USE_DATABASE', true);
|
||||
define('USE_HEADER', true);
|
||||
require 'config.php';
|
||||
require BASE.INCLUDES.'admin_header.php';
|
||||
if (is_object($smarty)) {
|
||||
$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) {
|
||||
$smarty->ADMIN_JAVASCRIPT = 'edit.pt.js';
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js';
|
||||
} elseif ($smarty->USE_JQUERY) {
|
||||
$smarty->ADMIN_JAVASCRIPT = 'edit.jq.js';
|
||||
$smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js';
|
||||
}
|
||||
$smarty->PAGE_WIDTH = '100%';
|
||||
// require BASE.INCLUDES.'admin_set_paths.php';
|
||||
$smarty->setSmartyPaths();
|
||||
|
||||
// smarty test
|
||||
$smarty->DATA['SMARTY_TEST'] = 'Test Data';
|
||||
$smarty->DATA['TRANSLATE_TEST'] = $cms->l->__('Are we translated?');
|
||||
}
|
||||
|
||||
// drop down test with optgroups
|
||||
$options = array (
|
||||
'' => '選択してください',
|
||||
'4/25(木)' => array (
|
||||
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
||||
'4/25(木) 12:20-13:00' => '4/25(木) 12:20-13:00'
|
||||
),
|
||||
'4/26(金)' => array (
|
||||
'4/26(金) 11:00-11:50' => '4/26(金) 11:00-11:50',
|
||||
'4/26(金) 12:20-13:00' => '4/26(金) 12:20-13:00'
|
||||
),
|
||||
'4/27(土)' => array (
|
||||
'4/27(土) 11:00-11:50' => '4/27(土) 11:00-11:50',
|
||||
'4/27(土) 12:20-13:00' => '4/27(土) 12:20-13:00'
|
||||
)
|
||||
);
|
||||
|
||||
if (is_object($smarty)) {
|
||||
$smarty->DATA['drop_down_test'] = $options;
|
||||
$smarty->DATA['loop_start'] = 2;
|
||||
// require BASE.INCLUDES.'admin_smarty.php';
|
||||
$smarty->setSmartyVarsAdmin();
|
||||
}
|
||||
require BASE.INCLUDES.'admin_footer.php';
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
namespace CoreLibs;
|
||||
|
||||
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
|
||||
$DEBUG_ALL = 1;
|
||||
$PRINT_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
|
||||
// admin class tests
|
||||
require 'config.php';
|
||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
$base = new Basic();
|
||||
|
||||
print "THIS HOST: ".HOST_NAME.", with PROTOCOL: ".HOST_PROTOCOL." is running SSL: ".HOST_SSL."<br>";
|
||||
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>";
|
||||
|
||||
$text = 'I am some text
|
||||
with some
|
||||
line breaks
|
||||
in there. Theis
|
||||
is sucky';
|
||||
|
||||
print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text)."<br>";
|
||||
print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text, '##BR##')."<br>";
|
||||
|
||||
// $test = array (
|
||||
// 'A' => array (
|
||||
// 'B' => array (),
|
||||
// 'C' => array (
|
||||
// 'D' => array (),
|
||||
// 'E' => array (
|
||||
// 'F' => array ()
|
||||
// )
|
||||
// )
|
||||
// ),
|
||||
// '1' => array (),
|
||||
// '2' => array (),
|
||||
// '3' => array (
|
||||
// 'G' => array ()
|
||||
// )
|
||||
// );
|
||||
|
||||
// $base->log->debug('ARRAY', \CoreLibs\Debug\Support::printAr($test));
|
||||
|
||||
function rec($pre, $cur, $node = array ())
|
||||
{
|
||||
if (!is_array($node)) {
|
||||
$node = array ();
|
||||
}
|
||||
print "<div style='color: green;'>#### PRE: ".$pre.", CUR: ".$cur.", N-c: ".count($node)." [".join('|', array_keys($node))."]</div>";
|
||||
if (!$pre) {
|
||||
print "** <span style='color: red;'>NEW</span><br>";
|
||||
$node[$cur] = array ();
|
||||
} else {
|
||||
if (array_key_exists($pre, $node)) {
|
||||
print "+ <span style='color: orange;'>KEY FOUND:</span> ".$pre.", add: ".$cur."<br>";
|
||||
$node[$pre][$cur] = array ();
|
||||
} else {
|
||||
print "- NOT FOUND: loop<br>";
|
||||
foreach ($node as $_pre => $_cur) {
|
||||
print "> TRY: ".$_pre." => ".count($_cur)." [".join('|', array_keys($_cur))."]<br>";
|
||||
if (count($_cur) > 0) {
|
||||
$node[$_pre] = rec($pre, $cur, $_cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
function flattenArrayKey(array $array, array $return = array ())
|
||||
{
|
||||
foreach ($array as $key => $sub) {
|
||||
$return[] = $key;
|
||||
if (count($sub) > 0) {
|
||||
$return = flattenArrayKey($sub, $return);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
$test = array ();
|
||||
// core
|
||||
$test = rec('', 'A', $test);
|
||||
$test = rec('', '1', $test);
|
||||
$test = rec('', '2', $test);
|
||||
$test = rec('', '3', $test);
|
||||
$test = rec('3', 'G', $test);
|
||||
$test = rec('A', 'B', $test);
|
||||
$test = rec('A', 'C', $test);
|
||||
$test = rec('C', 'D', $test);
|
||||
$test = rec('C', 'E', $test);
|
||||
$test = rec('E', 'F', $test);
|
||||
// new
|
||||
$test = rec('C', 'U', $test);
|
||||
$test = rec('F', 'U', $test);
|
||||
$test = rec('', 'Al', $test);
|
||||
$test = rec('B', 'B1', $test);
|
||||
$base->log->debug('REC', \CoreLibs\Debug\Support::printAr($test));
|
||||
print "FLATTEN: ".\CoreLibs\Debug\Support::printAr(flattenArrayKey($test))."<br>";
|
||||
|
||||
print $base->log->printErrorMsg();
|
||||
|
||||
// __END__
|
||||
@@ -10,9 +10,9 @@
|
||||
// please be VERY carefull only to change the right side
|
||||
$DB_CONFIG = [
|
||||
'test' => [
|
||||
'db_name' => 'gullevek',
|
||||
'db_user' => 'gullevek',
|
||||
'db_pass' => 'gullevek',
|
||||
'db_name' => 'clemens',
|
||||
'db_user' => 'clemens',
|
||||
'db_pass' => 'clemens',
|
||||
'db_host' => 'db.tokyo.tequila.jp',
|
||||
'db_port' => 5432,
|
||||
'db_schema' => 'public',
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
// print debug messages
|
||||
echo $login->log->printErrorMsg();
|
||||
echo $cms->log->printErrorMsg();
|
||||
$cms->log->debug('DEBUGEND', '==================================== [END]');
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
* 2003-06-10: creation of this page
|
||||
*********************************************************************/
|
||||
|
||||
$DEBUG_ALL = 1;
|
||||
$PRINT_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
$DEBUG_ALL = true;
|
||||
$PRINT_ALL = true;
|
||||
$DB_DEBUG = true;
|
||||
|
||||
// TODO: only extract _POST data that is needed
|
||||
extract($_POST, EXTR_SKIP);
|
||||
@@ -30,10 +30,10 @@ require 'config.php';
|
||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||
// overrride debug flags
|
||||
if (!DEBUG) {
|
||||
$DEBUG_ALL = 0;
|
||||
$PRINT_ALL = 0;
|
||||
$DB_DEBUG = 0;
|
||||
$ECHO_ALL = 0;
|
||||
$DEBUG_ALL = false;
|
||||
$PRINT_ALL = false;
|
||||
$DB_DEBUG = false;
|
||||
$ECHO_ALL = false;
|
||||
}
|
||||
|
||||
// should be utf8
|
||||
|
||||
Binary file not shown.
@@ -2,7 +2,10 @@
|
||||
{$SMARTY_TEST}
|
||||
</div>
|
||||
<div>
|
||||
TRANSLATION CLASS: {$TRANSLATE_TEST}
|
||||
TRANSLATION CLASS (OUT): {$TRANSLATE_TEST}
|
||||
</div>
|
||||
<div>
|
||||
TRANSLATION CLASS (SMARTY): {$TRANSLATE_TEST_SMARTY}
|
||||
</div>
|
||||
<div>
|
||||
<select id="drop_down_test" name="drop_down_test">
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
* - menu creation
|
||||
* - array vars for smarty
|
||||
*
|
||||
* CHANGE PLAN:
|
||||
* loads DB\IO + Logger and returns one group object
|
||||
* also checks all missing CONFIG vars from Basic class
|
||||
*
|
||||
* PUBLIC VARIABLES
|
||||
*
|
||||
* PRIVATE VARIABLES
|
||||
@@ -224,14 +228,14 @@ class Backend extends \CoreLibs\DB\IO
|
||||
$PAGES = [];
|
||||
}
|
||||
$pages = [];
|
||||
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
|
||||
foreach ($PAGES as $PAGE_DATA) {
|
||||
$pages[] = $PAGE_DATA;
|
||||
}
|
||||
// $this->debug('pages', $this->print_ar($pages));
|
||||
// if flag is 0, then we show all, else, we show only the matching flagges array points
|
||||
// array is already sorted after correct order
|
||||
reset($pages);
|
||||
foreach ($pages as $i => $data) {
|
||||
foreach ($pages as $data) {
|
||||
// for ($i = 0, $iMax = count($pages); $i < $iMax; $i ++) {
|
||||
$show = 0;
|
||||
// is it visible in the menu & is it online
|
||||
@@ -329,11 +333,12 @@ class Backend extends \CoreLibs\DB\IO
|
||||
}
|
||||
|
||||
/**
|
||||
* ONLY USED IN adbTopMenu
|
||||
* checks if this filename is in the current situation (user id, etc) available
|
||||
* @param string|null $filename filename
|
||||
* @return bool true for visible/accessable menu point, false for not
|
||||
*/
|
||||
public function adbShowMenuPoint(?string $filename): bool
|
||||
private function adbShowMenuPoint(?string $filename): bool
|
||||
{
|
||||
$enabled = false;
|
||||
if ($filename === null) {
|
||||
|
||||
@@ -30,7 +30,6 @@ class Email
|
||||
'.*@disney\.ne\.jp$' => 'keitai_softbank_disney', # (kids)
|
||||
'.*@willcom\.ne\.jp$' => 'keitai_willcom',
|
||||
'.*@willcom\.com$' => 'keitai_willcom', # new for pdx.ne.jp address
|
||||
'.*@willcom\.com$' => 'keitai_willcom', # new for pdx.ne.jp address
|
||||
'.*@wcm\.ne\.jp$' => 'keitai_willcom', # old willcom wcm.ne.jp
|
||||
'.*@pdx\.ne\.jp$' => 'keitai_willcom_pdx', # old pdx address for willcom
|
||||
'.*@bandai\.jp$' => 'keitai_willcom_bandai', # willcom paipo! (kids)
|
||||
|
||||
@@ -307,7 +307,7 @@ class IO extends \CoreLibs\Basic
|
||||
|
||||
/**
|
||||
* main DB concstructor with auto connection to DB and failure set on failed connection
|
||||
* @param array $db_config DB configuration array
|
||||
* @param array $db_config DB configuration array
|
||||
*/
|
||||
public function __construct(array $db_config)
|
||||
{
|
||||
@@ -317,6 +317,7 @@ class IO extends \CoreLibs\Basic
|
||||
if (!is_array($db_config)) {
|
||||
$db_config = [];
|
||||
}
|
||||
// TODO: check must set CONSTANTS
|
||||
// sets the names (for connect/reconnect)
|
||||
$this->db_name = $db_config['db_name'] ?? '';
|
||||
$this->db_user = $db_config['db_user'] ?? '';
|
||||
@@ -396,7 +397,7 @@ class IO extends \CoreLibs\Basic
|
||||
public function __destruct()
|
||||
{
|
||||
$this->__closeDB();
|
||||
parent::__destruct();
|
||||
// parent::__destruct();
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
@@ -547,7 +548,7 @@ class IO extends \CoreLibs\Basic
|
||||
if ($prefix) {
|
||||
$prefix .= '- ';
|
||||
}
|
||||
$this->log->debug($debug_id, $prefix.$error_string, true);
|
||||
$this->log->debug($debug_id, $error_string, true, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -869,6 +870,24 @@ class IO extends \CoreLibs\Basic
|
||||
return $this->db_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches db debug flag on or off
|
||||
* OR
|
||||
* with the optional parameter fix sets debug
|
||||
* returns current set stats
|
||||
* @param bool|null $debug Flag to turn debug on off
|
||||
* @return bool True for debug is on, False for off
|
||||
*/
|
||||
public function dbToggleDebug(?bool $debug = null)
|
||||
{
|
||||
if ($debug !== null) {
|
||||
$this->db_debug = $debug;
|
||||
} else {
|
||||
$this->db_debug = $this->db_debug ? false : true;
|
||||
}
|
||||
return $this->db_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* set max query calls, set to --1 to disable loop
|
||||
* protection. this will generate a warning
|
||||
@@ -1048,19 +1067,21 @@ class IO extends \CoreLibs\Basic
|
||||
public function dbInfo(bool $show = true): string
|
||||
{
|
||||
$string = '';
|
||||
$string .= '<b>-DB-info-></b> Connected to db <b>\''.$this->db_name.'\'</b> ';
|
||||
$string .= 'with schema <b>\''.$this->db_schema.'\'</b> ';
|
||||
$string .= 'as user <b>\''.$this->db_user.'\'</b> ';
|
||||
$string .= 'at host <b>\''.$this->db_host.'\'</b> ';
|
||||
$string .= 'on port <b>\''.$this->db_port.'\'</b> ';
|
||||
$string .= 'with ssl mode <b>\''.$this->db_ssl.'\'</b><br>';
|
||||
$string .= '<b>-DB-info-></b> DB IO Class debug output: <b>'.($this->db_debug ? 'Yes' : 'No').'</b>';
|
||||
$string .= '{b}-DB-info->{/b} Connected to db {b}\''.$this->db_name.'\'{/b} ';
|
||||
$string .= 'with schema {b}\''.$this->db_schema.'\'{/b} ';
|
||||
$string .= 'as user {b}\''.$this->db_user.'\'{/b} ';
|
||||
$string .= 'at host {b}\''.$this->db_host.'\'{/b} ';
|
||||
$string .= 'on port {b}\''.$this->db_port.'\'{/b} ';
|
||||
$string .= 'with ssl mode {b}\''.$this->db_ssl.'\'{/b}{br}';
|
||||
$string .= '{b}-DB-info->{/b} DB IO Class debug output: {b}'.($this->db_debug ? 'Yes' : 'No').'{/b}';
|
||||
if ($show === true) {
|
||||
$this->__dbDebug('db', $string, 'dbInfo');
|
||||
// if debug, remove / change b
|
||||
$this->__dbDebug('db', str_replace(['{b}', '{/b}', '{br}'], ['', '', ' **** '], $string), 'dbInfo');
|
||||
} else {
|
||||
$string = $string.'<br>';
|
||||
$string = $string.'{br}';
|
||||
}
|
||||
return $string;
|
||||
// for direct print, change to html
|
||||
return str_replace(['{b}', '{/b}', '{br}'], ['<b>', '</b>', '<br>'], $string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2125,24 +2146,6 @@ class IO extends \CoreLibs\Basic
|
||||
return $this->num_rows ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches db debug flag on or off
|
||||
* OR
|
||||
* with the optional parameter fix sets debug
|
||||
* returns current set stats
|
||||
* @param bool|null $debug Flag to turn debug on off
|
||||
* @return bool True for debug is on, False for off
|
||||
*/
|
||||
public function dbToggleDebug(?bool $debug = null)
|
||||
{
|
||||
if ($debug !== null) {
|
||||
$this->db_debug = $debug;
|
||||
} else {
|
||||
$this->db_debug = $this->db_debug ? false : true;
|
||||
}
|
||||
return $this->db_debug;
|
||||
}
|
||||
|
||||
// DEPEREACTED CALLS
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,7 @@ class Logging
|
||||
// debug flags/settings
|
||||
private $running_uid = ''; // unique ID set on class init and used in logging as prefix
|
||||
// log file name
|
||||
private $log_folder = '';
|
||||
private $log_file_name_ext = 'log'; // use this for date rotate
|
||||
private $log_max_filesize = 0; // set in kilobytes
|
||||
private $log_print_file = 'error_msg##LOGID####LEVEL####CLASS####PAGENAME####DATE##';
|
||||
@@ -60,6 +61,14 @@ class Logging
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// check must set constants
|
||||
if (defined('BASE') && defined('LOG')) {
|
||||
$this->log_folder = BASE.LOG;
|
||||
} else {
|
||||
// fallback + warning
|
||||
trigger_error('constant BASE or LOG are not defined, fallback to getcwd()', E_USER_WARNING);
|
||||
$this->log_folder = getcwd().DS;
|
||||
}
|
||||
// running time start for script
|
||||
$this->script_starttime = microtime(true);
|
||||
// set per run UID for logging
|
||||
@@ -205,7 +214,7 @@ class Logging
|
||||
// init output variable
|
||||
$output = $error_string; // output formated error string to output file
|
||||
// init base file path
|
||||
$fn = BASE.LOG.$this->log_print_file.'.'.$this->log_file_name_ext;
|
||||
$fn = $this->log_folder.$this->log_print_file.'.'.$this->log_file_name_ext;
|
||||
// log ID prefix settings, if not valid, replace with empty
|
||||
if (preg_match("/^[A-Za-z0-9]+$/", $this->log_file_id)) {
|
||||
$rpl_string = '_'.$this->log_file_id;
|
||||
@@ -434,9 +443,12 @@ class Logging
|
||||
* @param bool $strip default on false, if set to true,
|
||||
* all html tags will be stripped and <br> changed to \n
|
||||
* this is only used for debug output
|
||||
* @param string $prefix Attach some block before $string. Will not be stripped even
|
||||
* when strip is true
|
||||
* if strip is false, recommended to add that to $string
|
||||
* @return bool True if logged, false if not logged
|
||||
*/
|
||||
public function debug(string $level, string $string, bool $strip = false): bool
|
||||
public function debug(string $level, string $string, bool $strip = false, string $prefix = ''): bool
|
||||
{
|
||||
if (!$this->doDebugTrigger('debug', $level)) {
|
||||
return false;
|
||||
@@ -463,8 +475,8 @@ class Logging
|
||||
($strip ?
|
||||
// find any <br> and replace them with \n
|
||||
// strip rest of html elements (base only)
|
||||
preg_replace("/(<\/?)(\w+)([^>]*>)/", '', str_replace('<br>', "\n", $string)) :
|
||||
$string
|
||||
preg_replace("/(<\/?)(\w+)([^>]*>)/", '', str_replace('<br>', "\n", $prefix.$string)) :
|
||||
$prefix.$string
|
||||
)
|
||||
)
|
||||
."\n"
|
||||
@@ -483,6 +495,8 @@ class Logging
|
||||
.'[<span style="color: #08b369;">'.$this->page_name.'</span>] '
|
||||
.'[<span style="color: #0062A2;">'.$this->running_uid.'</span>] '
|
||||
.'{<span style="font-style: italic; color: #928100;">'.$class.'</span>} - '
|
||||
// as is prefix, allow HTML
|
||||
.$prefix
|
||||
// we replace special HTMLPRE with <pre> entries
|
||||
.preg_replace("/{##HTMLPRE##}((.|\n)*?){##\/HTMLPRE##}/m", "<pre>\\1</pre>", \CoreLibs\Convert\Html::htmlent($string))
|
||||
."</div><!--#BR#-->";
|
||||
|
||||
@@ -68,6 +68,12 @@ class Support
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) ?? [['class' => get_called_class()]];
|
||||
$class = null;
|
||||
while ($class === null) {
|
||||
// if current is
|
||||
// [function] => debug
|
||||
// [class] => CoreLibs\Debug\Logging
|
||||
// then return
|
||||
// (OUTSIDE) because it was not called from a class method
|
||||
// or return file name
|
||||
$class = array_pop($backtrace)['class'] ?? null;
|
||||
}
|
||||
return $class ?? '';
|
||||
|
||||
@@ -311,7 +311,9 @@ class SmartyExtend extends SmartyBC
|
||||
private function setSmartyVars($admin_call = false): void
|
||||
{
|
||||
global $cms;
|
||||
$this->mergeCmsSmartyVars($cms);
|
||||
if (is_object($cms)) {
|
||||
$this->mergeCmsSmartyVars($cms);
|
||||
}
|
||||
|
||||
// trigger flags
|
||||
$this->HEADER['USE_PROTOTYPE'] = $this->USE_PROTOTYPE;
|
||||
@@ -349,16 +351,24 @@ class SmartyExtend extends SmartyBC
|
||||
// special for admin
|
||||
if ($admin_call === true) {
|
||||
// set ACL extra show
|
||||
$this->DATA['show_ea_extra'] = $cms->acl['show_ea_extra'] ?? false;
|
||||
$this->DATA['ADMIN'] = !empty($cms->acl['admin']) ? $cms->acl['admin'] : 0;
|
||||
if (is_object($cms)) {
|
||||
$this->DATA['show_ea_extra'] = $cms->acl['show_ea_extra'] ?? false;
|
||||
$this->DATA['ADMIN'] = $cms->acl['admin'] ?? 0;
|
||||
// top menu
|
||||
$this->DATA['nav_menu'] = $cms->adbTopMenu() ?? [];
|
||||
$this->DATA['nav_menu_count'] = is_array($this->DATA['nav_menu']) ? count($this->DATA['nav_menu']) : 0;
|
||||
// messages = ['msg' =>, 'class' => 'error/warning/...']
|
||||
$this->DATA['messages'] = $cms->messages ?? [];
|
||||
} else {
|
||||
$this->DATA['show_ea_extra'] = false;
|
||||
$this->DATA['ADMIN'] = 0;
|
||||
$this->DATA['nav_menu'] = [];
|
||||
$this->DATA['nav_menu_count'] = 0;
|
||||
$this->DATA['messages'] = [];
|
||||
}
|
||||
// set style sheets
|
||||
$this->HEADER['STYLESHEET'] = $this->ADMIN_STYLESHEET ? $this->ADMIN_STYLESHEET : ADMIN_STYLESHEET;
|
||||
$this->HEADER['JAVASCRIPT'] = $this->ADMIN_JAVASCRIPT ? $this->ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT;
|
||||
// top menu
|
||||
$this->DATA['nav_menu'] = $cms->adbTopMenu();
|
||||
$this->DATA['nav_menu_count'] = is_array($this->DATA['nav_menu']) ? count($this->DATA['nav_menu']) : 0;
|
||||
// messages = ['msg' =>, 'class' => 'error/warning/...']
|
||||
$this->DATA['messages'] = $cms->messages ?? [];
|
||||
// the page name
|
||||
$this->DATA['page_name'] = $this->page_name;
|
||||
$this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH;
|
||||
|
||||
Reference in New Issue
Block a user