From 3035287b5c4984975fb1b3f7eb8871739ffcfb7a Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 14 Jun 2021 15:00:02 +0900 Subject: [PATCH] Code clean up for Basic Class clean up Fix all other class code for calling former Basic class methods. Also try to replace all remaining array() calls to [] type Some docblock updates when missing or wrong set --- www/admin/class_test.array.php | 55 ++++++++++++++++------ www/admin/class_test.colors.php | 13 ++--- www/admin/class_test.datetime.php | 7 +-- www/admin/class_test.db.php | 8 ++-- www/admin/class_test.debug.php | 1 - www/admin/class_test.email.php | 3 +- www/admin/class_test.json.php | 11 +++-- www/admin/class_test.mime.php | 6 +++ www/admin/class_test.password.php | 4 +- www/admin/class_test.system.php | 3 +- www/admin/error_test.php | 2 + www/admin/namespace_test.php | 17 ++++--- www/admin/various_class_test.php | 12 ++--- www/includes/admin_header.php | 10 ++-- www/lib/CoreLibs/ACL/Login.php | 20 +------- www/lib/CoreLibs/Basic.php | 40 ++++++---------- www/lib/CoreLibs/Combined/ArrayHandler.php | 34 ++++++------- www/lib/CoreLibs/Combined/DateTime.php | 2 +- www/lib/CoreLibs/Convert/Colors.php | 10 ++-- www/lib/CoreLibs/Convert/MimeAppName.php | 23 +++------ www/lib/CoreLibs/DB/Extended/ArrayIO.php | 21 ++------- www/lib/CoreLibs/DB/IO.php | 16 +++---- www/lib/CoreLibs/DB/SQL/PgSQL.php | 4 +- www/lib/CoreLibs/Debug/Logging.php | 45 +++++++++++++++--- www/lib/CoreLibs/Output/Form/Generate.php | 41 ++++++++-------- www/lib/Error.Handling.php | 19 ++++++-- 26 files changed, 228 insertions(+), 199 deletions(-) diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php index 4cb8ed3c..3dcc7412 100644 --- a/www/admin/class_test.array.php +++ b/www/admin/class_test.array.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-array'; ob_end_flush(); use CoreLibs\Combined\ArrayHandler; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); // $_array= new CoreLibs\Combined\ArrayHandler(); @@ -37,24 +38,30 @@ print ""; print '
Class Test Master
'; // recursive array search -$test_array = array( +$test_array = [ 'foo' => 'bar', - 'input' => array( - 'element_a' => array( + 'input' => [ + 'element_a' => [ 'type' => 'text' - ), - 'element_b' => array( + ], + 'element_b' => [ 'type' => 'email' - ), - 'element_c' => array( + ], + 'element_c' => [ 'type' => 'email' - ) - ) -); + ], + ], +]; -echo "SOURCE ARRAY: ".$basic->printAr($test_array)."
"; -echo "FOUND ELEMENTS [base]: ".$basic->printAr(ArrayHandler::arraySearchRecursive('email', $test_array, 'type'))."
"; -echo "FOUND ELEMENTS [input]: ".$basic->printAr(ArrayHandler::arraySearchRecursive('email', $test_array['input'], 'type'))."
"; +echo "SOURCE ARRAY: ".DgS::printAr($test_array)."
"; +// frist return +echo "ARRAYSEARCHRECURSIVE(email, [array], type): ".DgS::printAr(ArrayHandler::arraySearchRecursive('email', $test_array, 'type'))."
"; +echo "ARRAYSEARCHRECURSIVE(email, [array]['input'], type): ".DgS::printAr(ArrayHandler::arraySearchRecursive('email', $test_array['input'], 'type'))."
"; +// all return +echo "ARRAYSEARCHRECURSIVEALL(email, [array], type): ".Dgs::printAr((array)ArrayHandler::arraySearchRecursiveAll('email', $test_array, 'type'))."
"; + +// simple search +echo "ARRAYSEARCHSIMPLE([array], type, email): ".(string)ArrayHandler::arraySearchSimple($test_array, 'type', 'email')."
"; $array_1 = [ 'foo' => 'bar' @@ -67,10 +74,28 @@ $array_3 = [ 'beta' => 4 ] ]; -print "ARRAYMERGERECURSIVE: ".$basic->printAr(ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3))."
"; +// recusrice merge +print "ARRAYMERGERECURSIVE: ".DgS::printAr(ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3))."
"; +// array difference +$array_left = [ + 'same' => 'data', + 'left' => 'Has L' +]; +$array_right = [ + 'same' => 'data', + 'right' => 'has R' +]; +print "ARRAYDIFF: ".DgS::printAr(ArrayHandler::arrayDiff($array_left, $array_right))."
"; +// in array check +print "INARRAYANY([1,3], [array]): ".DgS::printAr(ArrayHandler::inArrayAny([1, 3], $array_2))."
"; +// flatten array +print "FLATTENARRAY: ".DgS::printAr(ArrayHandler::flattenArray($test_array))."
"; +print "FLATTENARRAYKEY: ".DgS::printAr(ArrayHandler::flattenArrayKey($test_array))."
"; +// flatten for key set +print "ARRAYFLATFORKEY: ".DgS::printAr(ArrayHandler::arrayFlatForKey($test_array, 'type'))."
"; // DEPRECATED -// print "ARRAYMERGERECURSIVE: ".$basic->printAr($basic->arrayMergeRecursive($array_1, $array_2, $array_3))."
"; +// print "ARRAYMERGERECURSIVE: ".DgS::printAr($basic->arrayMergeRecursive($array_1, $array_2, $array_3))."
"; // error message print $basic->log->printErrorMsg(); diff --git a/www/admin/class_test.colors.php b/www/admin/class_test.colors.php index 25d7f363..d4d8b742 100644 --- a/www/admin/class_test.colors.php +++ b/www/admin/class_test.colors.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-colors'; ob_end_flush(); use CoreLibs\Convert\Colors; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); $color_class = 'CoreLibs\Convert\Colors'; @@ -46,14 +47,14 @@ $hex = '#0a141e'; $hsb = [210, 67, 12]; $hsl = [210, 50, 7.8]; print "S::COLOR rgb->hex: $rgb[0], $rgb[1], $rgb[2]: ".Colors::rgb2hex($rgb[0], $rgb[1], $rgb[2])."
"; -print "S::COLOR hex->rgb: $hex: ".$basic->printAr(Colors::hex2rgb($hex))."
"; -print "C::S/COLOR rgb->hext: $hex: ".$basic->printAr(CoreLibs\Convert\Colors::hex2rgb($hex))."
"; +print "S::COLOR hex->rgb: $hex: ".DgS::printAr(Colors::hex2rgb($hex))."
"; +print "C::S/COLOR rgb->hext: $hex: ".DgS::printAr(CoreLibs\Convert\Colors::hex2rgb($hex))."
"; // C(to hsb/hsl) -print "S::COLOR rgb->hsb: $rgb[0], $rgb[1], $rgb[2]: ".$basic->printAr(Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2]))."
"; -print "S::COLOR rgb->hsl: $rgb[0], $rgb[1], $rgb[2]: ".$basic->printAr(Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2]))."
"; +print "S::COLOR rgb->hsb: $rgb[0], $rgb[1], $rgb[2]: ".DgS::printAr(Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2]))."
"; +print "S::COLOR rgb->hsl: $rgb[0], $rgb[1], $rgb[2]: ".DgS::printAr(Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2]))."
"; // 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]: ".$basic->printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2]))."
"; -print "S::COLOR hsl->rgb: $hsl[0], $hsl[1], $hsl[2]: ".$basic->printAr(Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2]))."
"; +print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: ".DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2]))."
"; +print "S::COLOR hsl->rgb: $hsl[0], $hsl[1], $hsl[2]: ".DgS::printAr(Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2]))."
"; // TODO: run compare check input must match output diff --git a/www/admin/class_test.datetime.php b/www/admin/class_test.datetime.php index 3b1f4139..ce3e485d 100644 --- a/www/admin/class_test.datetime.php +++ b/www/admin/class_test.datetime.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-datetime'; ob_end_flush(); use CoreLibs\Combined\DateTime; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); $datetime_class = 'CoreLibs\Combination\DateTime'; @@ -118,8 +119,8 @@ $compare_dates = [ [ '2021-05-02', '2021-05-02', ], ]; foreach ($compare_dates as $compare_date) { - print "CALCDAYSINTERVAL: $compare_date[0] = $compare_date[1]: ".$basic->printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1]))."
"; - print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: ".$basic->printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], true))."
"; + print "CALCDAYSINTERVAL: $compare_date[0] = $compare_date[1]: ".DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1]))."
"; + print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: ".DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], true))."
"; } // DEPRECATED @@ -138,7 +139,7 @@ print "COMPAREDATE: $compare_date[0] = $compare_date[1]: ".(string)$basic->compa $compare_datetime = ['2021-05-01 10:00:00', '2021-05-01 11:00:00']; print "COMPAREDATE: $compare_datetime[0] = $compare_datetime[1]: ".(string)$basic->compareDateTime($compare_datetime[0], $compare_datetime[1])."
"; $compare_date = ['2021-05-01', '2021-05-10']; -print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: ".$basic->printAr($basic->calcDaysInterval($compare_date[0], $compare_date[1], true))."
"; */ +print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: ".DgS::printAr($basic->calcDaysInterval($compare_date[0], $compare_date[1], true))."
"; */ // error message print $basic->log->printErrorMsg(); diff --git a/www/admin/class_test.db.php b/www/admin/class_test.db.php index 95ee2419..c0850ce7 100644 --- a/www/admin/class_test.db.php +++ b/www/admin/class_test.db.php @@ -26,6 +26,8 @@ if (!defined('SET_SESSION_NAME')) { $LOG_FILE_ID = 'classTest-db'; ob_end_flush(); +use CoreLibs\Debug\Support as DgS; + $basic = new CoreLibs\Admin\Backend(DB_CONFIG); print "TEST CLASS: DB"; @@ -105,7 +107,7 @@ if ($basic->dbPrepare('sel_foo', "SELECT foo_id, test, some_bool, string_a, numb # db write class test $table = 'foo'; -print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."
"; +print "TABLE META DATA: ".DgS::printAr($basic->dbShowTableMetaData($table))."
"; $primary_key = ''; # unset $db_write_table = array('test', 'string_a', 'number_a', 'some_bool'); // $db_write_table = array('test'); @@ -186,7 +188,7 @@ $q = "SHOW search_path"; $cursor = $basic->dbExec($q); $data = $basic->dbFetchArray($cursor)['search_path']; print "RETURN DATA FOR search_path: ".$data."
"; -// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."
"; +// print "RETURN DATA FOR search_path: ".DgS::printAr($data)."
"; // 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."
"; @@ -195,7 +197,7 @@ print "NULL TEST DB READ
"; $q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'"; $res = $basic->dbReturnRow($q); var_dump($res); -print "RES: ".$basic->printAr($res)."
"; +print "RES: ".DgS::printAr($res)."
"; print "ISSET: ".isset($res['null_varchar'])."
"; print "EMPTY: ".empty($res['null_varchar'])."
"; diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index 174771ad..9cc712bc 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -30,7 +30,6 @@ ob_end_flush(); $ECHO_ALL = true; use CoreLibs\Debug\Support as DebugSupport; -use CoreLibs\Debug\Logging; use CoreLibs\Debug\FileWriter; $basic = new CoreLibs\Basic(); diff --git a/www/admin/class_test.email.php b/www/admin/class_test.email.php index ba0711bd..f40927aa 100644 --- a/www/admin/class_test.email.php +++ b/www/admin/class_test.email.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-email'; ob_end_flush(); use CoreLibs\Check\Email; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); @@ -39,7 +40,7 @@ print "S::GETEMAILREGEX(0): ".Email::getEmailRegex(0)."
"; print "S::GETEMAILREGEX(2): ".Email::getEmailRegex(2)."
"; print "S::GETEMAILREGEX(7): ".Email::getEmailRegex(7)."
"; print "S::GETEMAILREGEX(8 invalid): ".Email::getEmailRegex(8)."
"; -print "S::GETEMAILREGEXCHECK: ".$basic->printAr(Email::getEmailRegexCheck())."
"; +print "S::GETEMAILREGEXCHECK: ".DgS::printAr(Email::getEmailRegexCheck())."
"; $email = [ 'foo@bar.org', diff --git a/www/admin/class_test.json.php b/www/admin/class_test.json.php index a31474ca..b7aa5078 100644 --- a/www/admin/class_test.json.php +++ b/www/admin/class_test.json.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-json'; ob_end_flush(); use CoreLibs\Check\Jason; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); $json_class = 'CoreLibs\Check\Jason'; @@ -39,29 +40,29 @@ print '
Class Test Master
'; $json = '{"foo": "bar"}'; $output = Jason::jsonConvertToArray($json); -print "S::JSON: $json: ".$basic->printAr($output)."
"; +print "S::JSON: $json: ".DgS::printAr($output)."
"; print "S::JSON ERROR: ".Jason::jsonGetLastError().": ".Jason::jsonGetLastError(true)."
"; $json = '["f: {b"""ar}]'; $output = Jason::jsonConvertToArray($json); -print "S::E-JSON: $json: ".$basic->printAr($output)."
"; +print "S::E-JSON: $json: ".DgS::printAr($output)."
"; print "S::E-JSON ERROR: ".Jason::jsonGetLastError().": ".Jason::jsonGetLastError(true)."
"; // direct $json = '{"direct": "static function call"}'; $output = $json_class::jsonConvertToArray($json); -print "J/S::JSON: $json: ".$basic->printAr($output)."
"; +print "J/S::JSON: $json: ".DgS::printAr($output)."
"; print "J/S::JSON ERROR: ".$json_class::jsonGetLastError().": ".$json_class::jsonGetLastError(true)."
"; $json = '["f: {b"""ar}]'; $output = $json_class::jsonConvertToArray($json); -print "J/S::E-JSON: $json: ".$basic->printAr($output)."
"; +print "J/S::E-JSON: $json: ".DgS::printAr($output)."
"; print "J/S::E-JSON ERROR: ".$json_class::jsonGetLastError().": ".$json_class::jsonGetLastError(true)."
"; // DEPRECATE TEST /* $json = '["f: {b"""ar}]'; $output = $basic->jsonConvertToArray($json); -print "E-JSON: $json: ".$basic->printAr($output)."
"; +print "E-JSON: $json: ".DgS::printAr($output)."
"; print "E-JSON ERROR: ".$basic->jsonGetLastError().": ".$basic->jsonGetLastError(true)."
"; */ // error message diff --git a/www/admin/class_test.mime.php b/www/admin/class_test.mime.php index e4890f60..ebca3092 100644 --- a/www/admin/class_test.mime.php +++ b/www/admin/class_test.mime.php @@ -45,6 +45,12 @@ print "App for mime $mime: ".$_mime->mimeGetAppName($mime)."
"; $_mime->mimeSetAppName($mime, 'Microsoft (better) Excel'); print "App for mime changed $mime: ".$_mime->mimeGetAppName($mime)."
"; +// static call test +$mime = 'application/x-indesign'; +print "S::App for mime $mime: ".\CoreLibs\Convert\MimeAppName::mimeGetAppName($mime)."
"; +$mime = 'application/vnd.ms-excel'; +print "S::App for mime $mime: ".\CoreLibs\Convert\MimeAppName::mimeGetAppName($mime)."
"; + // DEPRECATED /* $mime = 'application/illustrator'; print "MIME $mime: ".$basic->mimeGetAppName($mime)."
"; diff --git a/www/admin/class_test.password.php b/www/admin/class_test.password.php index 5823ff06..5872bd67 100644 --- a/www/admin/class_test.password.php +++ b/www/admin/class_test.password.php @@ -49,6 +49,8 @@ $enc_password = $password_class::passwordSet($password); print "PASSWORD: $password: ".$enc_password."
"; print "S-PASSWORD VERIFY: ".(string)$password_class::passwordVerify($password, $enc_password)."
"; print "PASSWORD REHASH: ".(string)$password_class::passwordRehashCheck($enc_password)."
"; +// direct static +print "S::PASSWORD VERFIY: ".(string)PwdChk::passwordVerify($password, $enc_password)."
"; // DEPRECATED /* $password = 'deprecated4567'; @@ -58,7 +60,7 @@ print "PASSWORD VERIFY: ".(string)$basic->passwordVerify($password, $enc_passwor print "PASSWORD REHASH: ".(string)$basic->passwordRehashCheck($enc_password)."
"; */ // error message -print $basic->printErrorMsg(); +print $basic->log->printErrorMsg(); print ""; diff --git a/www/admin/class_test.system.php b/www/admin/class_test.system.php index f2e74fab..7d3ae39f 100644 --- a/www/admin/class_test.system.php +++ b/www/admin/class_test.system.php @@ -27,6 +27,7 @@ $LOG_FILE_ID = 'classTest-system'; ob_end_flush(); use CoreLibs\Get\System; +use CoreLibs\Debug\Support as DgS; $basic = new CoreLibs\Basic(); @@ -34,7 +35,7 @@ print "TEST CLASS: SYSTEM"; print ""; print '
Class Test Master
'; -print "GETHOSTNAME: ".$basic->printAr(System::getHostName())."
"; +print "GETHOSTNAME: ".DgS::printAr(System::getHostName())."
"; print "GETPAGENAME(0): ".System::getPageName()."
"; print "GETPAGENAME(1): ".System::getPageName(1)."
"; print "GETPAGENAME(2): ".System::getPageName(2)."
"; diff --git a/www/admin/error_test.php b/www/admin/error_test.php index 6b624871..8844ff45 100644 --- a/www/admin/error_test.php +++ b/www/admin/error_test.php @@ -17,3 +17,5 @@ require(BASE.LIB."Error.Handling.php"); if ($var) { echo "OUT
"; } +// this wll throw an error and also write +// asdfa(09); diff --git a/www/admin/namespace_test.php b/www/admin/namespace_test.php index efebe1e3..8975562c 100755 --- a/www/admin/namespace_test.php +++ b/www/admin/namespace_test.php @@ -20,23 +20,22 @@ if ($base->getConnectionStatus()) { die("Cannot connect to database"); } -print "Start time: ".$base->runningTime()."
"; -print "HumanReadableByteFormat: ".$base->HumanReadableByteFormat(1234567.12)."
"; -print "humanReadableByteFormat: ".$base->humanReadableByteFormat(1234567.12)."
"; -// print "get_page_name [DEPRECATED]: ".$base->get_page_name()."
"; -print "getPageName: ".$base->getPageName()."
"; +print "Start time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; +print "HumanReadableByteFormat: ".\CoreLibs\Convert\Byte::HumanReadableByteFormat(1234567.12)."
"; +print "humanReadableByteFormat: ".\CoreLibs\Convert\Byte::humanReadableByteFormat(1234567.12)."
"; +print "getPageName: ". \CoreLibs\Get\System::getPageName()."
"; print "DB Info: ".$base->dbInfo(true)."
"; -print "End Time: ".$base->runningTime()."
"; -print "Start Time: ".$base->runningTime()."
"; +print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; +print "Start Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; print "Lang: ".$base->l->__getLang().", MO File: ".$base->l->__getMoFile()."
"; print "Translate test: Year -> ".$base->l->__('Year')."
"; -print "End Time: ".$base->runningTime()."
"; +print "End Time: ".\CoreLibs\Debug\RunningTime::runningTime()."
"; // end error print -print $base->printErrorMsg(); +print $base->log->printErrorMsg(); # __END__ diff --git a/www/admin/various_class_test.php b/www/admin/various_class_test.php index 59e3be1e..e8de0c47 100755 --- a/www/admin/various_class_test.php +++ b/www/admin/various_class_test.php @@ -27,8 +27,8 @@ line breaks in there. Theis is sucky'; -print "LB remove: ".$base->removeLB($text)."
"; -print "LB remove: ".$base->removeLB($text, '##BR##')."
"; +print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text)."
"; +print "LB remove: ".\CoreLibs\Convert\Html::removeLB($text, '##BR##')."
"; // $test = array ( // 'A' => array ( @@ -47,7 +47,7 @@ print "LB remove: ".$base->removeLB($text, '##BR##')."
"; // ) // ); -// $base->debug('ARRAY', $base->printAr($test)); +// $base->log->debug('ARRAY', \CoreLibs\Debug\Support::printAr($test)); function rec($pre, $cur, $node = array ()) { @@ -103,9 +103,9 @@ $test = rec('C', 'U', $test); $test = rec('F', 'U', $test); $test = rec('', 'Al', $test); $test = rec('B', 'B1', $test); -$base->debug('REC', $base->printAr($test)); -print "FLATTEN: ".$base->printAr(flattenArrayKey($test))."
"; +$base->log->debug('REC', \CoreLibs\Debug\Support::printAr($test)); +print "FLATTEN: ".\CoreLibs\Debug\Support::printAr(flattenArrayKey($test))."
"; -print $base->printErrorMsg(); +print $base->log->printErrorMsg(); // __END__ diff --git a/www/includes/admin_header.php b/www/includes/admin_header.php index 5a1ef17d..26d3d4c2 100644 --- a/www/includes/admin_header.php +++ b/www/includes/admin_header.php @@ -80,12 +80,10 @@ if (!$login->login) { // automatic hide for DEBUG messages on live server // can be overridden when setting DEBUG_ALL_OVERRIDE on top of the script (for emergency debugging of one page only) if ((TARGET == 'live' || TARGET == 'remote') && !$DEBUG_ALL_OVERRIDE) { - $login->debug_output_all = false; - $login->echo_output_all = false; - $login->print_output_all = false; - $cms->debug_output_all = false; - $cms->echo_output_all = false; - $cms->print_output_all = false; + foreach (['debug', 'echo', 'print'] as $target) { + $login->log->setLogLevelAll($type, false); + $cms->log->setLogLevelAll($type, false); + } } $smarty->DATA['JS_DEBUG'] = DEBUG; diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php index efad71da..89374521 100644 --- a/www/lib/CoreLibs/ACL/Login.php +++ b/www/lib/CoreLibs/ACL/Login.php @@ -121,7 +121,7 @@ class Login extends \CoreLibs\DB\IO public function __construct(array $db_config) { // log login data for this class only - $this->log_per_class = 1; + $this->log->setLogPer('class', true); // create db connection and init base class parent::__construct($db_config); @@ -629,24 +629,6 @@ class Login extends \CoreLibs\DB\IO } } - // METHOD: loginSetAcl - // WAS : login_set_acl - // PARAMS: none - // RETURN: none - // DESC : sets all the basic ACLs - // init set the basic acl the user has, based on the following rules - // * init set from config DEFAULT ACL - // * if page ACL is set, it overrides the default ACL - // * if group ACL is set, it overrides the page ACL - // * if user ACL is set, it overrides the group ACL - // set the page ACL - // * default ACL set - // * set group ACL if not default overrides default ACL - // * set page ACL if not default overrides group ACL - // set edit access ACL and set default edit access group - // * if an account ACL is set, set this parallel, account ACL overrides user ACL if it applies - // * if edit access ACL level is set, use this, else use page - // set all base ACL levels as a list keyword -> ACL number /** * sets all the basic ACLs * init set the basic acl the user has, based on the following rules diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php index b4592c08..49772bb7 100644 --- a/www/lib/CoreLibs/Basic.php +++ b/www/lib/CoreLibs/Basic.php @@ -65,8 +65,6 @@ class Basic private $session_name = ''; private $session_id = ''; - // form token (used for form validation) - // private $form_token = ''; // ajax flag protected $ajax_page_flag = false; @@ -75,11 +73,6 @@ class Basic */ public function __construct() { - // set per run UID for logging - $this->running_uid = \CoreLibs\Create\Uids::uniqId(); - // running time start for script - $this->script_starttime = microtime(true); - // TODO make check dynamic for entries we MUST have depending on load type // before we start any work, we should check that all MUST constants are defined $abort = false; @@ -150,17 +143,13 @@ class Basic } } - // METHOD: __destruct - // PARAMS: none - // RETURN: if debug is on, return error data - // DESC : basic deconstructor (should be called from all deconstructors in higher classes) - // writes out $error_msg to global var + /** + * deconstructor + * basic deconstructor (should be called from all deconstructors in higher classes) + * writes out $error_msg to global var + */ public function __destruct() { - // this has to be changed, not returned here, this is the last class to close - // return $this->error_msg; - // close open file handles - // $this->fdebugFP('c'); } // ************************************************************* @@ -243,7 +232,7 @@ class Basic * writes a string to a file immediatly, for fast debug output * @param string $string string to write to the file * @param boolean $enter default true, if set adds a linebreak \n at the end - * @return void has no return + * @return bool True of False for success of writing * @deprecated Use \CoreLibs\Debug\FileWriter::fdebug() instead */ public function fdebug(string $string, bool $enter = true): bool @@ -267,6 +256,7 @@ class Basic public function debugFor(string $type, string $flag): void { trigger_error('Method '.__METHOD__.' is deprecated, use $basic->log->debugFor() or use \CoreLibs\Debug\Logging() class', E_USER_DEPRECATED); + /** @phan-suppress-next-line PhanTypeMismatchArgumentReal */ $this->log->debugFor(...[func_get_args()]); } @@ -456,8 +446,8 @@ class Basic * prints a html formatted (pre) array * @param array $array any array * @return string formatted array for output with
 tag added
-	 * DEPRCATE LATER
-	 * @_deprecated Use \CoreLibs\Debug\Support::printAr() instead
+	 * DEPRCATE HARD LATER
+	 * @deprecated Use \CoreLibs\Debug\Support::printAr() instead
 	 */
 	public static function printAr(array $array): string
 	{
@@ -1336,10 +1326,10 @@ class Basic
 	 * converts RGB to HSB/V values
 	 * returns:
 	 * array with hue (0-360), sat (0-100%), brightness/value (0-100%)
-	 * @param  int    $r red 0-255
-	 * @param  int    $g green 0-255
-	 * @param  int    $b blue 0-255
-	 * @return array  Hue, Sat, Brightness/Value
+	 * @param  int   $red   red 0-255
+	 * @param  int   $green green 0-255
+	 * @param  int   $blue  blue 0-255
+	 * @return array        Hue, Sat, Brightness/Value
 	 * @deprecated use \CoreLibs\Convert\Colors::rgb2hsb() instead
 	 */
 	public static function rgb2hsb(int $red, int $green, int $blue): array
@@ -1571,7 +1561,7 @@ class Basic
 	public function mimeSetAppName(string $mime, string $app): void
 	{
 		trigger_error('Method '.__METHOD__.' is deprecated, use \CoreLibs\Convert\MimeAppName()->mimeSetAppName()', E_USER_DEPRECATED);
-		$this->mime->mimeSetAppName($mime, $app);
+		\CoreLibs\Convert\MimeAppName::mimeSetAppName($mime, $app);
 	}
 
 	/**
@@ -1584,7 +1574,7 @@ class Basic
 	public function mimeGetAppName(string $mime): string
 	{
 		trigger_error('Method '.__METHOD__.' is deprecated, use \CoreLibs\Convert\MimeAppName()->mimeGetAppName()', E_USER_DEPRECATED);
-		return $this->mime->mimeGetAppName($mime);
+		return \CoreLibs\Convert\MimeAppName::mimeGetAppName($mime);
 	}
 
 	// *** MIME PARTS END ***
diff --git a/www/lib/CoreLibs/Combined/ArrayHandler.php b/www/lib/CoreLibs/Combined/ArrayHandler.php
index aad6c816..2f93b775 100644
--- a/www/lib/CoreLibs/Combined/ArrayHandler.php
+++ b/www/lib/CoreLibs/Combined/ArrayHandler.php
@@ -19,9 +19,9 @@ class ArrayHandler
 	 */
 	public static function arraySearchRecursive($needle, array $haystack, ?string $key_lookin = null): array
 	{
-		$path = array();
+		$path = [];
 		if (!is_array($haystack)) {
-			$haystack = array();
+			$haystack = [];
 		}
 		if ($key_lookin != null &&
 			!empty($key_lookin) &&
@@ -72,21 +72,21 @@ class ArrayHandler
 	{
 		// init if not set on null
 		if ($path === null) {
-			$path = array(
+			$path = [
 				'level' => 0,
-				'work' => array()
-			);
+				'work' => []
+			];
 		}
 		// init sub sets if not set
 		if (!isset($path['level'])) {
 			$path['level'] = 0;
 		}
 		if (!isset($path['work'])) {
-			$path['work'] = array();
+			$path['work'] = [];
 		}
 		// should not be needed because it would trigger a php mehtod error
 		if (!is_array($haystack)) {
-			$haystack = array();
+			$haystack = [];
 		}
 
 		// @phan HACK
@@ -112,7 +112,7 @@ class ArrayHandler
 		}
 		// @phan HACK
 		$path['level'] = $path['level'] ?? 0;
-		$path['work'] = $path['work'] ?? array();
+		$path['work'] = $path['work'] ?? [];
 		// cut all that is >= level
 		array_splice($path['work'], $path['level']);
 		// step back a level
@@ -130,7 +130,7 @@ class ArrayHandler
 	public static function arraySearchSimple(array $array, $key, $value): bool
 	{
 		if (!is_array($array)) {
-			$array = array();
+			$array = [];
 		}
 		foreach ($array as $_key => $_value) {
 			// if value is an array, we search
@@ -177,7 +177,7 @@ class ArrayHandler
 			trigger_error(__FUNCTION__.' needs two or more array arguments', E_USER_WARNING);
 			return false;
 		}
-		$merged = array();
+		$merged = [];
 		while ($arrays) {
 			$array = array_shift($arrays);
 			if (!is_array($array)) {
@@ -234,7 +234,7 @@ class ArrayHandler
 		if (!is_array($haystack)) {
 			return false;
 		}
-		$found = array();
+		$found = [];
 		foreach ($needle as $element) {
 			if (in_array($element, $haystack)) {
 				$found[] = $element;
@@ -257,7 +257,7 @@ class ArrayHandler
 	 */
 	public static function genAssocArray(array $db_array, $key, $value, bool $set_only = false): array
 	{
-		$ret_array = array();
+		$ret_array = [];
 		// do this to only run count once
 		for ($i = 0, $iMax = count($db_array); $i < $iMax; $i ++) {
 			// if no key then we make an order reference
@@ -283,7 +283,7 @@ class ArrayHandler
 	 */
 	public static function flattenArray(array $array): array
 	{
-		$return = array();
+		$return = [];
 		array_walk_recursive(
 			$array,
 			function ($value) use (&$return) {
@@ -298,13 +298,13 @@ class ArrayHandler
 	 * @param  array  $array  multidemnsional array to flatten
 	 * @return array          flattened keys array
 	 */
-	public static function flattenArrayKey(array $array/*, array $return = array()*/): array
+	public static function flattenArrayKey(array $array): array
 	{
-		$return = array();
+		$return = [];
 		array_walk_recursive(
 			$array,
 			function ($value, $key) use (&$return) {
-				$return [] = $key;
+				$return[] = $key;
 			}
 		);
 		return $return;
@@ -320,7 +320,7 @@ class ArrayHandler
 	public static function arrayFlatForKey(array $array, $search): array
 	{
 		if (!is_array($array)) {
-			$array = array();
+			$array = [];
 		}
 		foreach ($array as $key => $value) {
 			// if it is not an array do just nothing
diff --git a/www/lib/CoreLibs/Combined/DateTime.php b/www/lib/CoreLibs/Combined/DateTime.php
index a705dfd7..dcabdeaa 100644
--- a/www/lib/CoreLibs/Combined/DateTime.php
+++ b/www/lib/CoreLibs/Combined/DateTime.php
@@ -42,7 +42,7 @@ class DateTime
 			if ((int)$timestamp < 0) {
 				$negative = true;
 			}
-			$timestamp = abs($timestamp);
+			$timestamp = abs((float)$timestamp);
 			$timegroups = [86400, 3600, 60, 1];
 			$labels = ['d', 'h', 'm', 's'];
 			$time_string = '';
diff --git a/www/lib/CoreLibs/Convert/Colors.php b/www/lib/CoreLibs/Convert/Colors.php
index 9699ffe6..971d7ae7 100644
--- a/www/lib/CoreLibs/Convert/Colors.php
+++ b/www/lib/CoreLibs/Convert/Colors.php
@@ -227,7 +227,7 @@ class Colors
 		} else {
 			$sat = $chroma / (1 - abs(2 * $lum - 1));
 			if ($max == $red) {
-				$hue = fmod((($green - $blue) / $chrome), 6);
+				$hue = fmod((($green - $blue) / $chroma), 6);
 				if ($hue < 0) {
 					$hue = (6 - fmod(abs($hue), 6));
 				}
@@ -248,10 +248,10 @@ class Colors
 
 	/**
 	 * converts an HSL to RGB
-	 * @param  int   $h hue: 0-360 (degrees)
-	 * @param  float $s saturation: 0-100
-	 * @param  float $l luminance: 0-100
-	 * @return array     red/blue/green 0-255 each
+	 * @param  int   $hue hue: 0-360 (degrees)
+	 * @param  float $sat saturation: 0-100
+	 * @param  float $lum luminance: 0-100
+	 * @return array      red/blue/green 0-255 each
 	 */
 	public static function hsl2rgb(int $hue, float $sat, float $lum): array
 	{
diff --git a/www/lib/CoreLibs/Convert/MimeAppName.php b/www/lib/CoreLibs/Convert/MimeAppName.php
index d8264e87..e4d5db36 100644
--- a/www/lib/CoreLibs/Convert/MimeAppName.php
+++ b/www/lib/CoreLibs/Convert/MimeAppName.php
@@ -9,25 +9,14 @@ namespace CoreLibs\Convert;
 
 class MimeAppName
 {
-	private $mime_apps= [];
+	private static $mime_apps = [];
 
 	/**
 	 * constructor: init mime list
 	 */
 	public function __construct()
 	{
-		$this->mimeInitApps();
-	}
-
-	/**
-	 * init array for mime type to application name lookup
-	 * @return void
-	 */
-	private function mimeInitApps(): void
-	{
-		// match mime type to some application description
-		// this is NOT translated
-		$this->mime_apps = [
+		self::$mime_apps = [
 			// zip
 			'application/zip' => 'Zip File',
 			// Powerpoint
@@ -67,9 +56,9 @@ class MimeAppName
 	 * @param  string $app  Applicaiton name
 	 * @return void
 	 */
-	public function mimeSetAppName(string $mime, string $app): void
+	public static function mimeSetAppName(string $mime, string $app): void
 	{
-		$this->mime_apps[$mime] = $app;
+		self::$mime_apps[$mime] = $app;
 	}
 
 	/**
@@ -78,9 +67,9 @@ class MimeAppName
 	 * @param  string $mime MIME Name
 	 * @return string       Application name matching
 	 */
-	public function mimeGetAppName(string $mime): string
+	public static function mimeGetAppName(string $mime): string
 	{
-		return $this->mime_apps[$mime] ?? 'Other file';
+		return self::$mime_apps[$mime] ?? 'Other file';
 	}
 }
 
diff --git a/www/lib/CoreLibs/DB/Extended/ArrayIO.php b/www/lib/CoreLibs/DB/Extended/ArrayIO.php
index c198b429..ecd6284d 100644
--- a/www/lib/CoreLibs/DB/Extended/ArrayIO.php
+++ b/www/lib/CoreLibs/DB/Extended/ArrayIO.php
@@ -10,14 +10,6 @@
 *   table from the connected DB.
 *   you don't have to write any SQL queries, worry over update/insert
 *
-*   PUBLIC VARIABLES
-*
-*   PRIVATE VARIABLES
-*
-*   PUBLIC METHOD:S
-*
-*   PRIVATE METHOD:S
-*
 * HISTORY:
 * 2019/9/11 (cs) error string 21->91, 22->92 for not overlapping with IO
 * 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax
@@ -105,11 +97,6 @@ class ArrayIO extends \CoreLibs\DB\IO
 		return $text;
 	}
 
-	// METHOD: convertEntities
-	// WAS   : convert_entities
-	// PARAMS: string -> string to be changed
-	// RETURN: string -> altered string
-	// DESC  : changeds all HTML entities into non HTML ones
 	/**
 	 * changeds all HTML entities into non HTML ones
 	 * @param  string $text encoded html string
@@ -139,7 +126,7 @@ class ArrayIO extends \CoreLibs\DB\IO
 		}
 		// add output to internal error_msg
 		if ($write === true) {
-			$this->error_msg['db'] .= $string;
+			$this->__dbDebug('dbArray', $string);
 		}
 		return $string;
 	}
@@ -188,7 +175,7 @@ class ArrayIO extends \CoreLibs\DB\IO
 	 *                             set this as new table array too
 	 * @return array               returns the table array that was deleted
 	 */
-	public function dbDelete($table_array = array())
+	public function dbDelete($table_array = [])
 	{
 		// is array and has values, override set and set new
 		if (is_array($table_array) && count($table_array)) {
@@ -247,7 +234,7 @@ class ArrayIO extends \CoreLibs\DB\IO
 	 * @param  array   $table_array optional table array, overwrites internal set array
 	 * @return array                set table array with values
 	 */
-	public function dbRead($edit = false, $table_array = array())
+	public function dbRead($edit = false, $table_array = [])
 	{
 		// if array give, overrules internal array
 		if (is_array($table_array) && count($table_array)) {
@@ -320,7 +307,7 @@ class ArrayIO extends \CoreLibs\DB\IO
 	 * @param  array   $table_array optional table array, overwrites internal one
 	 * @return array                table array or null
 	 */
-	public function dbWrite($addslashes = false, $table_array = array())
+	public function dbWrite($addslashes = false, $table_array = [])
 	{
 		if (is_array($table_array) && count($table_array)) {
 			$this->table_array = $table_array;
diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php
index 5fd1280c..c684d834 100644
--- a/www/lib/CoreLibs/DB/IO.php
+++ b/www/lib/CoreLibs/DB/IO.php
@@ -278,7 +278,7 @@ class IO extends \CoreLibs\Basic
 	// other vars
 	private $nbsp = ''; // used by print_array recursion function
 	// error & warning id
-	// not error_id is defined in \CoreLibs\Basic
+	protected $error_id;
 	private $had_error;
 	private $warning_id;
 	private $had_warning;
@@ -535,7 +535,7 @@ class IO extends \CoreLibs\Basic
 	 * @param  string $type         query identifier (Q, I, etc)
 	 * @return void                 has no return
 	 */
-	private function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
+	protected function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
 	{
 		$prefix = '';
 		if ($id) {
@@ -562,7 +562,7 @@ class IO extends \CoreLibs\Basic
 	public function __dbError($cursor = false, string $msg = ''): void
 	{
 		$pg_error_string = '';
-		$where_called = (string)$this->getCallerMethod();
+		$where_called = (string)\CoreLibs\Debug\Support::getCallerMethod();
 		if ($cursor) {
 			$pg_error_string = $this->db_functions->__dbPrintError($cursor);
 		}
@@ -1115,7 +1115,7 @@ class IO extends \CoreLibs\Basic
 		$md5 = md5($query);
 		// pre declare array
 		if (!isset($this->cursor_ext[$md5])) {
-			$this->cursor_ext[$md5] = array(
+			$this->cursor_ext[$md5] = [
 				'query' => '',
 				'pos' => 0,
 				'cursor' => 0,
@@ -1123,7 +1123,7 @@ class IO extends \CoreLibs\Basic
 				'num_rows' => 0,
 				'num_fields' => 0,
 				'read_rows' => 0
-			);
+			];
 		}
 		// set the query
 		$this->cursor_ext[$md5]['query'] = $query;
@@ -1624,7 +1624,7 @@ class IO extends \CoreLibs\Basic
 		}
 		$result = $this->db_functions->__dbExecute($stm_name, $data);
 		if (!$result) {
-			$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.$this->printAr($data));
+			$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.\CoreLibs\Debug\Support::printAr($data));
 			$this->error_id = 22;
 			$this->__dbError($this->prepare_cursor[$stm_name]['result']);
 			$this->__dbDebug('db', 'DB-Error '.$stm_name.': Execution failed', 'DB_ERROR');
@@ -1868,10 +1868,10 @@ class IO extends \CoreLibs\Basic
 		array $data = []
 	) {
 		if (!is_array($primary_key)) {
-			$primary_key = array(
+			$primary_key = [
 				'row' => $table.'_id',
 				'value' => $primary_key
-			);
+			];
 		} else {
 			if (!isset($primary_key['row'])) {
 				$primary_key['row'] = '';
diff --git a/www/lib/CoreLibs/DB/SQL/PgSQL.php b/www/lib/CoreLibs/DB/SQL/PgSQL.php
index 1f7df192..f476ffa8 100644
--- a/www/lib/CoreLibs/DB/SQL/PgSQL.php
+++ b/www/lib/CoreLibs/DB/SQL/PgSQL.php
@@ -266,7 +266,7 @@ class PgSQL
 			if ($q = $this->__dbQuery($q)) {
 				list($id) = $this->__dbFetchArray($q);
 			} else {
-				$id = array(-1, $q);
+				$id = [-1, $q];
 			}
 			return $id;
 		}
@@ -444,7 +444,7 @@ class PgSQL
 	{
 		if (false === $limit) {
 			$limit = strlen($text) - 1;
-			$output = array();
+			$output = [];
 		}
 		if ('{}' != $text) {
 			do {
diff --git a/www/lib/CoreLibs/Debug/Logging.php b/www/lib/CoreLibs/Debug/Logging.php
index 14feaa3f..c47443f2 100644
--- a/www/lib/CoreLibs/Debug/Logging.php
+++ b/www/lib/CoreLibs/Debug/Logging.php
@@ -308,12 +308,14 @@ class Logging
 	 */
 	public function debugFor(string $type, string $flag): void
 	{
+		/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */
 		$this->setLogLevel(...[func_get_args()]);
 	}
 
 	/**
 	 * passes list of level names, to turn on debug
 	 * eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
+	 * TODO: currently we can only turn ON
 	 * @param  string $type  debug, echo, print
 	 * @param  string $flag  on/off
 	 *         array  $array of levels to turn on/off debug
@@ -342,13 +344,13 @@ class Logging
 
 	/**
 	 * return the log level for the array type normal and not (disable)
-	 * @param  string     $type  debug, echo, print
-	 * @param  string     $flag  on/off
-	 * @param  string     $level if not null then check if this array entry is set
-	 *                           else return false
-	 * @return bool|array        if $level is null, return array, else boolean true/false
+	 * @param  string      $type  debug, echo, print
+	 * @param  string      $flag  on/off
+	 * @param  string|null $level if not null then check if this array entry is set
+	 *                            else return false
+	 * @return bool|array         if $level is null, return array, else boolean true/false
 	 */
-	public function getLogLevel(string $type, string $flag, string $level = null)
+	public function getLogLevel(string $type, string $flag, ?string $level = null)
 	{
 		// abort if not valid type
 		if (!in_array($type, ['debug', 'echo', 'print'])) {
@@ -367,6 +369,37 @@ class Logging
 		return $this->{$switch};
 	}
 
+	/**
+	 * set flags for per log level type
+	 * - level: set per sub group level
+	 * - class: split by class
+	 * - page: split per page called
+	 * - run: for each run
+	 * @param  string $type Type to get: level, class, page, run
+	 * @param  bool   $set  True or False
+	 * @return void
+	 */
+	public function setLogPer(string $type, bool $set): void
+	{
+		if (!in_array($type, ['level', 'class', 'page', 'run'])) {
+			return;
+		}
+		$this->{'log_per'.$type} = $set;
+	}
+
+	/**
+	 * return current set log per flag in bool
+	 * @param  string $type Type to get: level, class, page, run
+	 * @return bool         True of false for turned on or off
+	 */
+	public function getLogPer(string $type): bool
+	{
+		if (!in_array($type, ['level', 'class', 'page', 'run'])) {
+			return false;
+		}
+		return $this->{'log_per'.$type};
+	}
+
 	/**
 	 * write debug data to error_msg array
 	 * @param  string $level  id for error message, groups messages together
diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php
index 49300506..1cd52fdf 100644
--- a/www/lib/CoreLibs/Output/Form/Generate.php
+++ b/www/lib/CoreLibs/Output/Form/Generate.php
@@ -1035,12 +1035,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
 							}
 							break;
 						case 'date': // YYYY-MM-DD
-							if (!$this->checkDate($this->table_array[$key]['value'])) {
+							if (!\CoreLibs\Combined\DateTime::checkDate($this->table_array[$key]['value'])) {
 								$this->msg .= sprintf($this->l->__('Please enter a vailid date (YYYY-MM-DD) for the %s Field!
'), $this->table_array[$key]['output_name']); } break; case 'time': // HH:MM[:SS] - if (!$this->checkDateTime($this->table_array[$key]['value'])) { + if (!\CoreLibs\Combined\DateTime::checkDateTime($this->table_array[$key]['value'])) { $this->msg .= sprintf($this->l->__('Please enter a vailid time (HH:MM[:SS]) for the %s Field!
'), $this->table_array[$key]['output_name']); } break; @@ -1198,7 +1198,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // $this->log->debug('edit_error_chk', 'KEY: $prfx$key | count: '.count($_POST[$prfx.$key]).' | M: $max'); // $this->log->debug('edit_error_chk', 'K: '.$_POST[$prfx.$key].' | '.$_POST[$prfx.$key][0]); } - $this->log->debug('POST ARRAY', $this->printAr($_POST)); + $this->log->debug('POST ARRAY', \CoreLibs\Debug\Support::printAr($_POST)); // init variables before inner loop run $mand_okay = 0; $mand_name = ''; @@ -1503,7 +1503,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO if (isset($this->table_array[$key]['type']) && $this->table_array[$key]['type'] == 'password') { if ($this->table_array[$key]['value']) { // use the better new passwordSet instead of crypt based - $this->table_array[$key]['value'] = $this->passwordSet($this->table_array[$key]['value']); + $this->table_array[$key]['value'] = \CoreLibs\Check\Password::passwordSet($this->table_array[$key]['value']); $this->table_array[$key]['HIDDEN_value'] = $this->table_array[$key]['value']; } else { // $this->table_array[$key]['HIDDEN_value'] = @@ -1715,11 +1715,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->msg = $this->l->__('Dataset has been saved!
'); } - // METHOD: formDeleteTableArray - // WAS : form_delete_table_array - // PARAMS: none - // RETURN: none - // DESC : delete a table and reference fields + /** + * delete a table and reference fields + * @return void + */ public function formDeleteTableArray() { // remove any reference arrays @@ -1759,12 +1758,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->msg = $this->l->__('Dataset has been deleted!'); } - // METHOD: formCreateHiddenFields - // WAS : form_create_hidden_fields - // PARAMS: $hidden_array - // RETURN: the input fields (html) - // DESC : creates HTML hidden input fields out of an hash array - public function formCreateHiddenFields($hidden_array = []) + /** + * creates HTML hidden input fields out of an hash array + * @param array $hidden_array The list of fields to be added as hidden + * @return array key -> value list of hidden fileds data + */ + public function formCreateHiddenFields(array $hidden_array = []): array { $hidden = []; if (!is_array($this->table_array)) { @@ -1791,12 +1790,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO return $hidden; } - // METHOD: formCreateElementReferenceTable - // WAS : form_create_element_reference_table - // PARAMS: show which reference table - // RETURN: array for output - // DESC : creates the multiple select part for a reference_table - public function formCreateElementReferenceTable($table_name) + /** + * creates the multiple select part for a reference_table + * @param string $table_name Table name for reference array lookup + * @return array Reference table output array + */ + public function formCreateElementReferenceTable(string $table_name): array { $data = []; $output_name = $this->reference_array[$table_name]['output_name']; diff --git a/www/lib/Error.Handling.php b/www/lib/Error.Handling.php index 9c0ef51b..b2ac7f28 100644 --- a/www/lib/Error.Handling.php +++ b/www/lib/Error.Handling.php @@ -25,11 +25,22 @@ if (defined('BASE')) { // RETURN: true, so cought errors do not get processed by the PHP error engine // DESC: will catch any error except E_ERROR and try to write them to the log file in log/php_error-.llog // if this fails, it will print the data to the window via echo -function MyErrorHandler($type, $message, $file, $line, $context) +/** + * will catch any error except E_ERROR and try to write them to the log file + * in log/php_error-.log + * if this fails, it will print the data to the window via echo + * @param int $type the error code from PHP + * @param string $message the error message from php + * @param string $file in which file the error happend. this is the source file (eg include) + * @param int $line in which line the error happened + * @param array $context array with all the variable + * @return bool true, so cought errors do not get processed by the PHP error engine + */ +function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool { if (!(error_reporting() & $type) && !SHOW_ALL_ERRORS) { // This error code is not included in error_reporting - return; + return false; } // ERROR LEVEL $error_level = array( @@ -52,7 +63,7 @@ function MyErrorHandler($type, $message, $file, $line, $context) ); // get the current page name (strip path) - $page_temp = explode("/", $_SERVER["PHP_SELF"]); + $page_temp = explode(DIRECTORY_SEPARATOR, $_SERVER["PHP_SELF"]); // the output string: // [] current timestamp // {} the current page name in which the error occured (running script) @@ -63,7 +74,7 @@ function MyErrorHandler($type, $message, $file, $line, $context) $output = '{'.array_pop($page_temp).'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message; # try to open file $ROOT = CURRENT_WORKING_DIR; - $LOG = 'log/'; + $LOG = 'log'.DIRECTORY_SEPARATOR; // if the log folder is not found, try to create it if (!is_dir($ROOT.$LOG) && !is_file($ROOT.LOG)) { $ok = mkdir($ROOT.$LOG);