diff --git a/www/composer.json b/www/composer.json index 4507707f..4a77136a 100644 --- a/www/composer.json +++ b/www/composer.json @@ -10,8 +10,8 @@ } ], "require": { - "egrajp/corelibs-composer-all": "^7.11", - "egrajp/smarty-extended": "^4.3" + "egrajp/smarty-extended": "^4.3", + "egrajp/corelibs-composer-all": "@dev" }, "autoload": { "classmap": [ @@ -19,6 +19,13 @@ ] }, "repositories": { + "CoreLibs-Composer-All": { + "type": "path", + "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", + "options": { + "symlink": false + } + }, "git.egplusww.jp.Composer": { "type": "composer", "url": "https://git.egplusww.jp/api/packages/Composer/composer" diff --git a/www/composer.lock b/www/composer.lock index 49c9db6e..96c9ee07 100644 --- a/www/composer.lock +++ b/www/composer.lock @@ -4,15 +4,15 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dc5d89075423c3c3df219079c491d91c", + "content-hash": "a80d1d945e4d8202a444c05b501eaf21", "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "7.12.1", + "version": "dev-development", "dist": { - "type": "zip", - "url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fcorelibs-composer-all/7.12.1/egrajp-corelibs-composer-all.7.12.1.zip", - "shasum": "457089ac43cb9fff5091e163877bb56ecb868151" + "type": "path", + "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", + "reference": "0a80abe8a4524188b42c5b4cffdd9a813ef407e6" }, "require": { "php": ">=8.1" @@ -39,7 +39,10 @@ } ], "description": "CoreLibs in a composer package", - "time": "2023-02-28T09:16:32+09:00" + "transport-options": { + "symlink": false, + "relative": false + } }, { "name": "egrajp/smarty-extended", @@ -75,7 +78,9 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "egrajp/corelibs-composer-all": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/www/vendor/composer/installed.json b/www/vendor/composer/installed.json index bfde1de0..07ae062b 100644 --- a/www/vendor/composer/installed.json +++ b/www/vendor/composer/installed.json @@ -2,12 +2,12 @@ "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "7.12.1", - "version_normalized": "7.12.1.0", + "version": "dev-development", + "version_normalized": "dev-development", "dist": { - "type": "zip", - "url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fcorelibs-composer-all/7.12.1/egrajp-corelibs-composer-all.7.12.1.zip", - "shasum": "457089ac43cb9fff5091e163877bb56ecb868151" + "type": "path", + "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", + "reference": "0a80abe8a4524188b42c5b4cffdd9a813ef407e6" }, "require": { "php": ">=8.1" @@ -18,7 +18,6 @@ "phpstan/phpstan": "1.10.x-dev", "phpunit/phpunit": "^9" }, - "time": "2023-02-28T09:16:32+09:00", "type": "library", "installation-source": "dist", "autoload": { @@ -36,6 +35,10 @@ } ], "description": "CoreLibs in a composer package", + "transport-options": { + "symlink": false, + "relative": false + }, "install-path": "../egrajp/corelibs-composer-all" }, { diff --git a/www/vendor/composer/installed.php b/www/vendor/composer/installed.php index 42bd23bf..9b0960d9 100644 --- a/www/vendor/composer/installed.php +++ b/www/vendor/composer/installed.php @@ -11,9 +11,9 @@ ), 'versions' => array( 'egrajp/corelibs-composer-all' => array( - 'pretty_version' => '7.12.1', - 'version' => '7.12.1.0', - 'reference' => NULL, + 'pretty_version' => 'dev-development', + 'version' => 'dev-development', + 'reference' => '0a80abe8a4524188b42c5b4cffdd9a813ef407e6', 'type' => 'library', 'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all', 'aliases' => array(), diff --git a/www/vendor/egrajp/corelibs-composer-all/phpstan.neon b/www/vendor/egrajp/corelibs-composer-all/phpstan.neon index 989e6ae1..7c0a0eb7 100644 --- a/www/vendor/egrajp/corelibs-composer-all/phpstan.neon +++ b/www/vendor/egrajp/corelibs-composer-all/phpstan.neon @@ -6,8 +6,6 @@ parameters: level: 8 # max is now 9 checkMissingCallableSignature: true treatPhpDocTypesAsCertain: false - strictRules: - allRules: false paths: - %currentWorkingDirectory%/src bootstrapFiles: @@ -27,9 +25,9 @@ parameters: #- # this error is ignore because of the PHP 8.0 to 8.1 change for pg_*, only for 8.0 or lower # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects resource(\\|null)?, object\\|resource(\\|bool)? given\\.$#" # path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php - - # this is for 8.1 or newer - message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects PgSql\\\\(Result|Connection(\\|string)?(\\|null)?), object\\|resource given\\.$#" - path: %currentWorkingDirectory%/src/DB/SQL/PgSQL.php + # - # this is for 8.1 or newer + # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects PgSql\\\\(Result|Connection(\\|string)?(\\|null)?), object\\|resource given\\.$#" + # path: %currentWorkingDirectory%/src/DB/SQL/PgSQL.php # this is ignored for now # - '#Expression in empty\(\) is always falsy.#' # - diff --git a/www/vendor/egrajp/corelibs-composer-all/publish/.gitignore b/www/vendor/egrajp/corelibs-composer-all/publish/.gitignore new file mode 100644 index 00000000..9094d2f1 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all/publish/.gitignore @@ -0,0 +1,2 @@ +*.zip +.env* diff --git a/www/vendor/egrajp/corelibs-composer-all/publish/last.published b/www/vendor/egrajp/corelibs-composer-all/publish/last.published new file mode 100644 index 00000000..ae9a76b9 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all/publish/last.published @@ -0,0 +1 @@ +8.0.0 diff --git a/www/vendor/egrajp/corelibs-composer-all/publish/publish.sh b/www/vendor/egrajp/corelibs-composer-all/publish/publish.sh new file mode 100755 index 00000000..e608d39c --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all/publish/publish.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +BASE_FOLDER=$(dirname $(readlink -f $0))"/"; +VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//"); +file_last_published="${BASE_FOLDER}last.published"; + +if [ -z "${VERSION}" ]; then + echo "Version must be set in the form x.y.z without any leading characters"; + exit; +fi; +# compare version, if different or newer, deploy +if [ -f "${file_last_published}" ]; then + LAST_PUBLISHED_VERSION=$(cat ${file_last_published}); + if $(dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"); then + echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}"; + exit; + fi; +fi; + +# read in the .env.deploy file and we must have +# GITLAB_USER +# GITLAB_TOKEN +# GITEA_DEPLOY_TOKEN +if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then + echo "Deploy enviroment file .env.deploy is missing"; + exit; +fi; +set -o allexport; +cd ${BASE_FOLDER}; +source .env.deploy; +cd -; +set +o allexport; + +# gitea +if [ ! -z "${GITEA_USER}" ] && [ ! -z "${GITEA_TOKEN}" ]; then + curl -LJO \ + --output-dir "${BASE_FOLDER}" \ + https://git.egplusww.jp/Composer/CoreLibs-Composer-All/archive/v${VERSION}.zip; + curl --user ${GITEA_USER}:${GITEA_TOKEN} \ + --upload-file "${BASE_FOLDER}/CoreLibs-Composer-All-v${VERSION}.zip" \ + https://git.egplusww.jp/api/packages/Composer/composer?version=${VERSION}; + echo "${VERSION}" > "${file_last_published}"; +else + echo "Missing either GITEA_USER or GITEA_TOKEN environment variable"; +fi; + +# gitlab +if [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then + curl --data tag=v${VERSION} \ + --header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \ + "https://gitlab-na.factory.tools/api/v4/projects/950/packages/composer"; + curl --data branch=master \ + --header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \ + "https://gitlab-na.factory.tools/api/v4/projects/950/packages/composer"; + echo "${VERSION}" > "${file_last_published}"; +else + echo "Missing GITLAB_DEPLOY_TOKEN environment variable"; +fi; + +# __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php b/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php index c8be7b2f..332692ea 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php @@ -157,7 +157,7 @@ class Login private $acl = []; /** @var array */ private $default_acl_list = []; - /** @var array Reverse list to lookup level from type */ + /** @var array Reverse list to lookup level from type */ private $default_acl_list_type = []; /** @var int default ACL level to be based on if nothing set */ private $default_acl_level = 0; @@ -332,7 +332,7 @@ class Login 'type' => $res['type'], 'name' => $res['name'] ]; - $this->default_acl_list_type[$res['type']] = $res['level']; + $this->default_acl_list_type[(string)$res['type']] = (int)$res['level']; } // write that into the session $_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list; @@ -986,7 +986,7 @@ class Login * @param string $password the new password * @return bool true or false if valid password or not */ - private function loginPasswordChangeValidPassword($password): bool + private function loginPasswordChangeValidPassword(string $password): bool { $is_valid_password = true; // check for valid in regex arrays in list @@ -1048,7 +1048,7 @@ class Login $res = $this->db->dbReturnRow($q); if ( !is_array($res) || - (is_array($res) && empty($res['edit_user_id'])) + empty($res['edit_user_id']) ) { // username wrong $this->login_error = 201; @@ -1068,9 +1068,11 @@ class Login } if ( !is_array($res) || - (is_array($res) && - (empty($res['edit_user_id']) || - !$this->loginPasswordCheck($res['old_password_hash'], $this->pw_old_password))) + empty($res['edit_user_id']) || + !$this->loginPasswordCheck( + $res['old_password_hash'], + $this->pw_old_password + ) ) { // old password wrong $this->login_error = 202; @@ -1124,7 +1126,7 @@ class Login * * @return string|null html data for login page, or null for nothing */ - private function loginCreateLoginHTML() + private function loginCreateLoginHTML(): ?string { $html_string = null; // if permission is ok, return null @@ -1421,8 +1423,12 @@ EOM; * @param string $username login user username * @return void has no return */ - private function writeLog(string $event, string $data, $error = '', string $username = ''): void - { + private function writeLog( + string $event, + string $data, + string|int $error = '', + string $username = '' + ): void { if ($this->login) { $this->action = 'Login'; } elseif ($this->logout) { @@ -1794,7 +1800,6 @@ EOM; // check that numeric, positive numeric, not longer than max input string lenght // and not short than min password length if ( - is_numeric($length) && $length >= $this->password_min_length_max && $length <= $this->password_max_length && $length <= 255 @@ -2069,9 +2074,12 @@ EOM; * @param string $type Type name to look in the acl list * @return int|bool Either int level or false for not found */ - public function loginGetAclListFromType(string $type) + public function loginGetAclListFromType(string $type): int|bool { - return $this->default_acl_list_type[$type] ?? false; + if (!isset($this->default_acl_list_type[$type])) { + return false; + } + return (int)$this->default_acl_list_type[$type]; } /** @@ -2081,7 +2089,7 @@ EOM; * @return bool true/false: if the edit access is not * in the valid list: false */ - public function loginCheckEditAccess($edit_access_id): bool + public function loginCheckEditAccess(?int $edit_access_id): bool { if ($edit_access_id === null) { return false; @@ -2122,8 +2130,10 @@ EOM; * @param string|int $data_key key value to search for * @return bool|string false for not found or string for found data */ - public function loginGetEditAccessData(int $edit_access_id, $data_key) - { + public function loginGetEditAccessData( + int $edit_access_id, + string|int $data_key + ): bool|string { if (!isset($_SESSION['UNIT'][$edit_access_id]['data'][$data_key])) { return false; } @@ -2137,9 +2147,12 @@ EOM; * @param string $uid Edit Access UID to look for * @return int|bool Either primary key in int or false in bool for not found */ - public function loginGetEditAccessIdFromUid(string $uid) + public function loginGetEditAccessIdFromUid(string $uid): int|bool { - return $_SESSION['UNIT_UID'][$uid] ?? false; + if (!isset($_SESSION['UNIT_UID'][$uid])) { + return false; + } + return (int)$_SESSION['UNIT_UID'][$uid]; } /** @@ -2204,8 +2217,10 @@ EOM; * @param string|int $data_key * @return bool|string */ - public function loginSetEditAccessData(int $edit_access_id, $data_key) - { + public function loginSetEditAccessData( + int $edit_access_id, + string|int $data_key + ): bool|string { return $this->loginGetEditAccessData($edit_access_id, $data_key); } } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php b/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php index b765cb5a..97d2da80 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php @@ -194,7 +194,7 @@ class Backend */ public function adbEditLog( string $event = '', - $data = '', + string|array $data = '', string $write_type = 'STRING' ): void { $data_binary = ''; @@ -262,7 +262,7 @@ class Backend * @param string|int $menu_show_flag * @return string|int */ - public function adbSetMenuShowFlag($menu_show_flag) + public function adbSetMenuShowFlag(string|int $menu_show_flag): string|int { // must be string or int $this->menu_show_flag = $menu_show_flag; @@ -274,7 +274,7 @@ class Backend * * @return string|int */ - public function adbGetMenuShowFlag() + public function adbGetMenuShowFlag(): string|int { return $this->menu_show_flag; } @@ -437,7 +437,7 @@ class Backend * @return array associative array * @deprecated \CoreLibs\Combined\ArrayHandler::genAssocArray() */ - public function adbAssocArray(array $db_array, $key, $value): array + public function adbAssocArray(array $db_array, string|int|bool $key, string|int|bool $value): array { trigger_error( 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Combined\ArrayHandler::genAssocArray', @@ -453,7 +453,7 @@ class Backend * @return string formatted string * @deprecated \CoreLibs\Convert\Byte::humanReadableByteFormat() */ - public function adbByteStringFormat($number): string + public function adbByteStringFormat(string|int|float $number): string { trigger_error( 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Convert\Byte::humanReadableByteFormat()', @@ -482,7 +482,7 @@ class Backend string $dummy = '', string $path = '', string $cache = '' - ) { + ): string|bool { trigger_error( 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Output\Image::createThumbnail()', E_USER_DEPRECATED @@ -569,28 +569,28 @@ class Backend * Basic class holds exact the same, except the Year/Month/Day/etc strings * are translated in this call * - * @param int $year year YYYY - * @param int $month month m - * @param int $day day d - * @param int $hour hour H - * @param int $min min i - * @param string $suffix additional info printed after the date time - * variable in the drop down - * also used for ID in the on change JS call - * @param int $min_steps default is 1 (minute), can set to anything, - * is used as sum up from 0 - * @param bool $name_pos_back default false, if set to true, - * the name will be printend - * after the drop down and not before the drop down - * @return string HTML formated strings for drop down lists - * of date and time + * @param int|string $year year YYYY + * @param int|string $month month m + * @param int|string $day day d + * @param int|string $hour hour H + * @param int|string $min min i + * @param string $suffix additional info printed after the date time + * variable in the drop down + * also used for ID in the on change JS call + * @param int $min_steps default is 1 (minute), can set to anything, + * is used as sum up from 0 + * @param bool $name_pos_back default false, if set to true, + * the name will be printend + * after the drop down and not before the drop down + * @return string HTML formated strings for drop down lists + * of date and time */ public function adbPrintDateTime( - $year, - $month, - $day, - $hour, - $min, + int|string $year, + int|string $month, + int|string $day, + int|string $hour, + int|string $min, string $suffix = '', int $min_steps = 1, bool $name_pos_back = false diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Admin/EditBase.php b/www/vendor/egrajp/corelibs-composer-all/src/Admin/EditBase.php index 46a37a47..74760448 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Admin/EditBase.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Admin/EditBase.php @@ -414,6 +414,8 @@ class EditBase $elements[] = $this->form->formCreateElement('additional_acl'); break; case 'edit_schemes': + // @deprecated Will be removed + case 'edit_schemas': $elements[] = $this->form->formCreateElement('enabled'); $elements[] = $this->form->formCreateElement('name'); $elements[] = $this->form->formCreateElement('header_color'); @@ -532,7 +534,7 @@ class EditBase * @throws Exception * @throws SmartyException */ - public function editBaseRun() + public function editBaseRun(): void { // set the template dir // WARNING: this has a special check for the mailing tool layout (old layout) diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Basic.php b/www/vendor/egrajp/corelibs-composer-all/src/Basic.php index c902bde5..27d0c3eb 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Basic.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Basic.php @@ -672,9 +672,6 @@ class Basic public static function arrayToString(array $array, string $connect_char): string { trigger_error('Method ' . __METHOD__ . ' is deprecated, use join()', E_USER_DEPRECATED); - if (!is_array($array)) { - $array = []; - } return join($connect_char, $array); } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Check/Colors.php b/www/vendor/egrajp/corelibs-composer-all/src/Check/Colors.php index 2d1d3ae3..466ff133 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Check/Colors.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Check/Colors.php @@ -42,8 +42,11 @@ class Colors * @param int|false $hsl_flag flag to check for hsl type * @return bool True if no error, False if error */ - private static function rgbHslContentCheck(string $color, $rgb_flag, $hsl_flag): bool - { + private static function rgbHslContentCheck( + string $color, + int|false $rgb_flag, + int|false $hsl_flag + ): bool { // extract string between () and split into elements preg_match("/\((.*)\)/", $color, $matches); if ( diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Check/Encoding.php b/www/vendor/egrajp/corelibs-composer-all/src/Check/Encoding.php index 09b23622..782b479e 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Check/Encoding.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Check/Encoding.php @@ -25,7 +25,7 @@ class Encoding * if null is set then "none" * @return void */ - public static function setErrorChar($string): void + public static function setErrorChar(string|int|null $string): void { if (empty($string)) { $string = 'none'; @@ -52,7 +52,7 @@ class Encoding * directly * @return string|int Set error character */ - public static function getErrorChar(bool $return_substitute_func = false) + public static function getErrorChar(bool $return_substitute_func = false): string|int { // return mb_substitute_character(); if ($return_substitute_func === true) { @@ -78,14 +78,14 @@ class Encoding * @param string $string string to test * @param string $from_encoding encoding of string to test * @param string $to_encoding target encoding - * @return bool|array false if no error or + * @return array|false false if no error or * array with failed characters */ public static function checkConvertEncoding( string $string, string $from_encoding, string $to_encoding - ) { + ): array|false { // convert to target encoding and convert back $temp = mb_convert_encoding($string, $to_encoding, $from_encoding); $compare = mb_convert_encoding($temp, $from_encoding, $to_encoding); diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Check/Jason.php b/www/vendor/egrajp/corelibs-composer-all/src/Check/Jason.php index 9a38d12c..7961c05f 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Check/Jason.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Check/Jason.php @@ -32,7 +32,7 @@ class Jason * or error string ('' for no error) * @deprecated Use Json::jsonGetLastError() */ - public static function jsonGetLastError(bool $return_string = false) + public static function jsonGetLastError(bool $return_string = false): int|string { return Json::jsonGetLastError($return_string); } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Combined/ArrayHandler.php b/www/vendor/egrajp/corelibs-composer-all/src/Combined/ArrayHandler.php index 925df15c..8029eb0d 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Combined/ArrayHandler.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Combined/ArrayHandler.php @@ -21,12 +21,12 @@ class ArrayHandler * the needle can be found in the * haystack array */ - public static function arraySearchRecursive($needle, array $haystack, ?string $key_search_for = null): array - { + public static function arraySearchRecursive( + string|int $needle, + array $haystack, + ?string $key_search_for = null + ): array { $path = []; - if (!is_array($haystack)) { - $haystack = []; - } if ( $key_search_for != null && array_key_exists($key_search_for, $haystack) && @@ -72,7 +72,7 @@ class ArrayHandler * * @param string|int $needle needle (search for) * @param array $haystack haystack (search in) - * @param string|int $key_search_for the key to look for in + * @param string|int|null $key_search_for the key to look for in * @param bool $old [true], if set to false will * return new flat layout * @param array|null $path recursive call for previous path @@ -80,9 +80,9 @@ class ArrayHandler * the element was found */ public static function arraySearchRecursiveAll( - $needle, + string|int $needle, array $haystack, - $key_search_for, + string|int|null $key_search_for, bool $old = true, ?array $path = null ): ?array { @@ -101,10 +101,6 @@ class ArrayHandler $path['work'] = []; } } - // should not be needed because it would trigger a php mehtod error - if (!is_array($haystack)) { - $haystack = []; - } // go through the array, foreach ($haystack as $_key => $_value) { @@ -152,17 +148,18 @@ class ArrayHandler * array search simple. looks for key, value combination, if found, returns true * on default does not strict check, so string '4' will match int 4 and vica versa * - * @param array $array search in as array - * @param string|int $key key (key to search in) - * @param string|int $value value (what to find) - * @param bool $strict [false], if set to true, will strict check key/value - * @return bool true on found, false on not found + * @param array $array search in as array + * @param string|int $key key (key to search in) + * @param string|int|bool $value value (what to find) + * @param bool $strict [false], if set to true, will strict check key/value + * @return bool true on found, false on not found */ - public static function arraySearchSimple(array $array, $key, $value, bool $strict = false): bool - { - if (!is_array($array)) { - $array = []; - } + public static function arraySearchSimple( + array $array, + string|int $key, + string|int|bool $value, + bool $strict = false + ): bool { foreach ($array as $_key => $_value) { // if value is an array, we search if (is_array($_value)) { @@ -189,9 +186,9 @@ class ArrayHandler * bool key flag: true: handle keys as string or int * default false: all keys are string * - * @return array|bool merged array + * @return array|false merged array */ - public static function arrayMergeRecursive() + public static function arrayMergeRecursive(): array|false { // croak on not enough arguemnts (we need at least two) if (func_num_args() < 2) { @@ -264,10 +261,10 @@ class ArrayHandler * @param array $needle elements to search for * @param array $haystack array where the $needle elements should * be searched int - * @return array|bool either the found elements or + * @return array|false either the found elements or * false for nothing found or error */ - public static function inArrayAny(array $needle, array $haystack) + public static function inArrayAny(array $needle, array $haystack): array|false { $found = []; foreach ($needle as $element) { @@ -291,8 +288,12 @@ class ArrayHandler * @param bool $set_only flag to return all (default), or set only * @return array associative array */ - public static function genAssocArray(array $db_array, $key, $value, bool $set_only = false): array - { + public static function genAssocArray( + array $db_array, + string|int|bool $key, + string|int|bool $value, + bool $set_only = false + ): array { $ret_array = []; // do this to only run count once for ($i = 0, $iMax = count($db_array); $i < $iMax; $i++) { @@ -385,11 +386,8 @@ class ArrayHandler * and will be pushed up * @return array modified, flattened array */ - public static function arrayFlatForKey(array $array, $search): array + public static function arrayFlatForKey(array $array, string|int $search): array { - if (!is_array($array)) { - $array = []; - } foreach ($array as $key => $value) { // if it is not an array do just nothing if (!is_array($value)) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Combined/DateTime.php b/www/vendor/egrajp/corelibs-composer-all/src/Combined/DateTime.php index 018cf2bb..c1f16147 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Combined/DateTime.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Combined/DateTime.php @@ -74,7 +74,7 @@ class DateTime * @return string formated date+time in Y-M-D h:m:s ms */ public static function dateStringFormat( - $timestamp, + int|float $timestamp, bool $show_micro = false, bool $micro_as_float = false ): string { @@ -100,8 +100,10 @@ class DateTime * @param bool $show_micro show micro seconds, default true * @return string interval formatted string or string as is */ - public static function timeStringFormat($timestamp, bool $show_micro = true): string - { + public static function timeStringFormat( + string|int|float $timestamp, + bool $show_micro = true + ): string { // check if the timestamp has any h/m/s/ms inside, if yes skip if (!preg_match("/(h|m|s|ms)/", (string)$timestamp)) { list($timestamp, $ms) = array_pad(explode('.', (string)round((float)$timestamp, 4)), 2, null); @@ -157,7 +159,7 @@ class DateTime * @param string|int|float $timestring formatted interval * @return string|int|float converted float interval, or string as is */ - public static function stringToTime($timestring) + public static function stringToTime(string|int|float $timestring): string|int|float { $timestamp = 0; if (preg_match("/(d|h|m|s|ms)/", (string)$timestring)) { @@ -247,9 +249,9 @@ class DateTime * @param string $date a date string in the format YYYY-MM-DD * @return bool true if valid date, false if date not valid */ - public static function checkDate($date): bool + public static function checkDate(string $date): bool { - if (!$date) { + if (empty($date)) { return false; } list ($year, $month, $day) = array_pad( @@ -324,7 +326,7 @@ class DateTime * @return int|bool false on error * or int -1 (se) as difference */ - public static function compareDate($start_date, $end_date) + public static function compareDate(string $start_date, string $end_date): int|bool { // pre check for empty or wrong if ($start_date == '--' || $end_date == '--' || !$start_date || !$end_date) { @@ -367,7 +369,7 @@ class DateTime * @return int|bool false for error * or -1 (se) as difference */ - public static function compareDateTime($start_datetime, $end_datetime) + public static function compareDateTime(string $start_datetime, string $end_datetime): int|bool { // pre check for empty or wrong if ($start_datetime == '--' || $end_datetime == '--' || !$start_datetime || !$end_datetime) { @@ -402,8 +404,11 @@ class DateTime * @param bool $return_named return array type, false (default), true for named * @return array 0/overall, 1/weekday, 2/weekend */ - public static function calcDaysInterval($start_date, $end_date, bool $return_named = false): array - { + public static function calcDaysInterval( + string $start_date, + string $end_date, + bool $return_named = false + ): array { // pos 0 all, pos 1 weekday, pos 2 weekend $days = []; // if anything invalid, return 0,0,0 diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Byte.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Byte.php index d7dc17ea..ebec727a 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Byte.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Byte.php @@ -39,7 +39,7 @@ class Byte * @return string converted byte number (float) with suffix * @throws \Exception 1: no valid flag set */ - public static function humanReadableByteFormat($bytes, int $flags = 0): string + public static function humanReadableByteFormat(string|int|float $bytes, int $flags = 0): string { // if not numeric, return as is if (is_numeric($bytes)) { @@ -121,7 +121,7 @@ class Byte * @return string|int|float converted value or original value * @throws \Exception 1: no valid flag set */ - public static function stringByteFormat($number, int $flags = 0) + public static function stringByteFormat(string|int|float $number, int $flags = 0): string|int|float { // use SI 1000 mod and not 1024 mod if ($flags & self::BYTE_FORMAT_SI) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php index 7f3c9f62..b88c6d3f 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php @@ -31,8 +31,12 @@ class Colors * @return string|bool rgb in hex values with leading # if set, * false for invalid color */ - public static function rgb2hex(int $red, int $green, int $blue, bool $hex_prefix = true) - { + public static function rgb2hex( + int $red, + int $green, + int $blue, + bool $hex_prefix = true + ): string|bool { $hex_color = ''; if ($hex_prefix === true) { $hex_color = '#'; @@ -61,7 +65,7 @@ class Colors string $hexStr, bool $return_as_string = false, string $seperator = ',' - ) { + ): string|array|bool { $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string if (!is_string($hexStr)) { return false; @@ -99,7 +103,7 @@ class Colors * @return array|bool Hue, Sat, Brightness/Value * false for input value error */ - public static function rgb2hsb(int $red, int $green, int $blue) + public static function rgb2hsb(int $red, int $green, int $blue): array|bool { // check that rgb is from 0 to 255 foreach (['red', 'green', 'blue'] as $c) { @@ -146,7 +150,7 @@ class Colors * @return array|bool 0 red/1 green/2 blue array as 0-255 * false for input value error */ - public static function hsb2rgb(float $H, float $S, float $V) + public static function hsb2rgb(float $H, float $S, float $V): array|bool { // check that H is 0 to 359, 360 = 0 // and S and V are 0 to 1 @@ -232,7 +236,7 @@ class Colors * @return array|bool hue/sat/luminance * false for input value error */ - public static function rgb2hsl(int $red, int $green, int $blue) + public static function rgb2hsl(int $red, int $green, int $blue): array|bool { // check that rgb is from 0 to 255 foreach (['red', 'green', 'blue'] as $c) { @@ -285,11 +289,8 @@ class Colors * @param float $lum luminance: 0-100 * @return array|bool red/blue/green 0-255 each */ - public static function hsl2rgb(float $hue, float $sat, float $lum) + public static function hsl2rgb(float $hue, float $sat, float $lum): array|bool { - if (!is_numeric($hue)) { - return false; - } if ($hue == 360) { $hue = 0; } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Html.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Html.php index 4c3f4354..147a6443 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Html.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Html.php @@ -19,7 +19,7 @@ class Html * @param mixed $string string to html encode * @return mixed if string, encoded, else as is (eg null) */ - public static function htmlent($string) + public static function htmlent(mixed $string): mixed { if (is_string($string)) { return htmlentities($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); @@ -52,7 +52,7 @@ class Html * @return ?string returns checked or selected, * else returns null */ - public static function checked($haystack, string $needle, int $type = 0): ?string + public static function checked(array|string $haystack, string $needle, int $type = 0): ?string { if (is_array($haystack)) { if (in_array($needle, $haystack)) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php index a051eb9f..96867157 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php @@ -51,13 +51,13 @@ class Json /** * returns human readable string for json errors thrown in jsonConvertToArray * - * @param bool|boolean $return_string [default=false] if set to true - * it will return the message string and not - * the error number - * @return int|string Either error number (0 for no error) - * or error string ('' for no error) + * @param bool $return_string [default=false] if set to true + * it will return the message string and not + * the error number + * @return int|string Either error number (0 for no error) + * or error string ('' for no error) */ - public static function jsonGetLastError(bool $return_string = false) + public static function jsonGetLastError(bool $return_string = false): int|string { $json_error_string = ''; // valid errors as of php 8.0 diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php index cddf4e2e..205abbf1 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php @@ -48,7 +48,7 @@ class Math * @param string|int|float $number string or number to check * @return float if not number, then returns 0, else original input */ - public static function initNumeric($number): float + public static function initNumeric(string|int|float $number): float { if (!is_numeric($number)) { return 0; diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Create/RandomKey.php b/www/vendor/egrajp/corelibs-composer-all/src/Create/RandomKey.php index 353aa568..3d340799 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Create/RandomKey.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Create/RandomKey.php @@ -32,7 +32,7 @@ class RandomKey * * @return void has no return */ - private static function initRandomKeyData() + private static function initRandomKeyData(): void { // random key generation base string self::$key_range = join('', array_merge( @@ -52,7 +52,6 @@ class RandomKey private static function validateRandomKeyLenght(int $key_length): bool { if ( - is_numeric($key_length) && $key_length > 0 && $key_length <= self::$max_key_length ) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Create/Session.php b/www/vendor/egrajp/corelibs-composer-all/src/Create/Session.php index f1d20f6e..46468cc8 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Create/Session.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Create/Session.php @@ -18,19 +18,6 @@ class Session /** @var string list for errors */ private $session_intern_error_str = ''; - /** - * Start session - * startSession should be called for complete check - * If this is called without any name set before the php.ini name is - * used. - * - * @return void - */ - protected function startSessionCall(): void - { - session_start(); - } - /** * init a session, if array is empty or array does not have session_name set * then no auto init is run @@ -44,6 +31,19 @@ class Session } } + /** + * Start session + * startSession should be called for complete check + * If this is called without any name set before the php.ini name is + * used. + * + * @return void + */ + protected function startSessionCall(): void + { + session_start(); + } + /** * check if we are in CLI, we set this, so we can mock this * Not this is just a wrapper for the static System::checkCLI call @@ -116,7 +116,7 @@ class Session * @param string|null $session_name * @return string|bool */ - public function startSession(?string $session_name = null) + public function startSession(?string $session_name = null): string|bool { // we can't start sessions on command line if ($this->checkCliStatus()) { @@ -163,7 +163,7 @@ class Session * * @return string|bool */ - public function getSessionId() + public function getSessionId(): string|bool { return session_id(); } @@ -173,7 +173,7 @@ class Session * * @return string|bool */ - public function getSessionName() + public function getSessionName(): string|bool { return session_name(); } @@ -275,7 +275,7 @@ class Session * @param mixed $value value to set (can be anything) * @return void */ - public function setS($name, $value): void + public function setS(string|int $name, mixed $value): void { $_SESSION[$name] = $value; } @@ -286,7 +286,7 @@ class Session * @param string|int $name value key to get from _SESSION * @return mixed value stored in _SESSION */ - public function getS($name) + public function getS(string|int $name): mixed { return $_SESSION[$name] ?? ''; } @@ -297,7 +297,7 @@ class Session * @param string|int $name Name to check for * @return bool True for set, False fornot set */ - public function issetS($name): bool + public function issetS(string|int $name): bool { return isset($_SESSION[$name]); } @@ -308,7 +308,7 @@ class Session * @param string|int $name _SESSION key name to remove * @return void */ - public function unsetS($name): void + public function unsetS(string|int $name): void { if (isset($_SESSION[$name])) { unset($_SESSION[$name]); @@ -325,7 +325,7 @@ class Session * @param mixed $value * @return void */ - public function __set($name, $value): void + public function __set(string|int $name, mixed $value): void { $_SESSION[$name] = $value; } @@ -334,13 +334,14 @@ class Session * Undocumented function * * @param string|int $name - * @return mixed + * @return mixed If name is not found, it will return null */ - public function __get($name) + public function __get(string|int $name): mixed { if (isset($_SESSION[$name])) { return $_SESSION[$name]; } + return null; } /** @@ -349,7 +350,7 @@ class Session * @param string|int $name * @return bool */ - public function __isset($name): bool + public function __isset(string|int $name): bool { return isset($_SESSION[$name]); } @@ -360,7 +361,7 @@ class Session * @param string|int $name * @return void */ - public function __unset($name): void + public function __unset(string|int $name): void { if (isset($_SESSION[$name])) { unset($_SESSION[$name]); diff --git a/www/vendor/egrajp/corelibs-composer-all/src/DB/Extended/ArrayIO.php b/www/vendor/egrajp/corelibs-composer-all/src/DB/Extended/ArrayIO.php index 3044d414..f972e047 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/DB/Extended/ArrayIO.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/DB/Extended/ArrayIO.php @@ -137,7 +137,7 @@ class ArrayIO extends \CoreLibs\DB\IO * @param string $text any html encoded string * @return string decoded html string */ - public function convertData($text): string + public function convertData(string $text): string { $text = str_replace('<b>', '', $text); $text = str_replace('</b>', '', $text); @@ -156,7 +156,7 @@ class ArrayIO extends \CoreLibs\DB\IO * @param string $text encoded html string * @return string decoded html string */ - public function convertEntities($text): string + public function convertEntities(string $text): string { $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); @@ -172,7 +172,7 @@ class ArrayIO extends \CoreLibs\DB\IO * @param bool $write write to error message, default false * @return string the array data as html string entry */ - public function dbDumpArray($write = false): string + public function dbDumpArray(bool $write = false): string { reset($this->table_array); $string = ''; @@ -192,7 +192,7 @@ class ArrayIO extends \CoreLibs\DB\IO * * @return bool true if pk value is set, else false */ - public function dbCheckPkSet() + public function dbCheckPkSet(): bool { // if pk_id is set, overrule ... if ($this->pk_id) { @@ -210,10 +210,10 @@ class ArrayIO extends \CoreLibs\DB\IO /** * resets the whole array values - * @param boolean $reset_pk true if we want to reset the pk too + * @param bool $reset_pk true if we want to reset the pk too * @return void has no return */ - public function dbResetArray($reset_pk = false): void + public function dbResetArray(bool $reset_pk = false): void { reset($this->table_array); foreach (array_keys($this->table_array) as $column) { @@ -230,10 +230,10 @@ class ArrayIO extends \CoreLibs\DB\IO * * @param array $table_array optional override for table array set * set this as new table array too - * @param boolean $acl_limit [false], if set to true, well do ACL limit check + * @param bool $acl_limit [false], if set to true, well do ACL limit check * @return array returns the table array that was deleted */ - public function dbDelete($table_array = [], $acl_limit = false) + public function dbDelete(array $table_array = [], bool $acl_limit = false): array { // is array and has values, override set and set new if (is_array($table_array) && count($table_array)) { @@ -294,12 +294,12 @@ class ArrayIO extends \CoreLibs\DB\IO /** * reads one row into the array * - * @param boolean $edit on true convert data, else as is + * @param bool $edit on true convert data, else as is * @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 = []) + public function dbRead(bool $edit = false, array $table_array = []): array { // if array give, overrules internal array if (is_array($table_array) && count($table_array)) { @@ -381,9 +381,9 @@ class ArrayIO extends \CoreLibs\DB\IO /** * writes one set into DB or updates one set (if PK exists) * - * @param boolean $addslashes old convert entities and set set escape + * @param bool $addslashes old convert entities and set set escape * @param array $table_array optional table array, overwrites internal one - * @param boolean $acl_limit [false], if set to true, well do ACL limit check + * @param bool $acl_limit [false], if set to true, well do ACL limit check * @return array table array or null */ public function dbWrite( @@ -391,7 +391,7 @@ class ArrayIO extends \CoreLibs\DB\IO array $table_array = [], bool $acl_limit = false ): array { - if (is_array($table_array) && count($table_array)) { + if (count($table_array)) { $this->table_array = $table_array; } // PK ID check @@ -475,13 +475,12 @@ class ArrayIO extends \CoreLibs\DB\IO $this->table_array[$column]['type'] != 'view' && strlen($column) > 0 && // no acl limiter - ($acl_limit === false || ( + $acl_limit === false || // acl limit is true, min edit must be at larger than set - $acl_limit === true && $this->base_acl_level >= ($this->table_array[$column]['min_edit_acl'] ?? 100) - )) + ) ) { // for password use hidden value if main is not set if ( @@ -528,7 +527,7 @@ class ArrayIO extends \CoreLibs\DB\IO } $q_data .= $_value; } elseif (isset($this->table_array[$column]['bool'])) { - // boolean storeage (reverse check on ifset) + // bool storage (reverse check on ifset) $q_data .= "'" . $this->dbBoolean($this->table_array[$column]['value'], true) . "'"; } elseif ( isset($this->table_array[$column]['interval']) || diff --git a/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php b/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php index 4ecef2b5..6fc5b993 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php @@ -12,7 +12,7 @@ * 2013/10/10, prepare/excute were added, including auto RETURNING primary key if * possible for any INSERT query in exec or prepare/execute, better debugging and * data dumping. Proper string escape wrapper, special db exec writer for complex -* array inserts in auto calls. boolean converter from postresql to php +* array inserts in auto calls. bool converter from postresql to php * * 2003/12/08, one major change: renamed db_exec_ext to db_return, as it has not * much in common with the normal db_exec wrapper, as it was written only for @@ -168,7 +168,7 @@ * - all HTML from the query data (color codes, etc) via flag to debug call * * HISTORY: -* 2008/10/25 (cs) add db_boolean to fix the postgres to php boolean var problem +* 2008/10/25 (cs) add db_boolean to fix the postgres to php bool var problem * (TODO: implement this in any select return) * 2008/07/03 (cs) add db_write_data function, original written for inventory tool "invSQLWriteData" * 2008/04/16 (cs) add db_escape_string function for correct string escape @@ -288,7 +288,7 @@ class IO private $query; // the query string at the moment // only inside // basic vars - /** @var object|resource|bool|int|null */ // replace object with PgSql\Connection| + /** @var \PgSql\Connection|false|null */ // replace object with PgSql\Connection| private $dbh; // the dbh handler, if disconnected by command is null, bool:false/int:-1 on error, /** @var bool */ private $db_debug = false; // DB_DEBUG ... (if set prints out debug msgs) @@ -315,7 +315,7 @@ class IO /** @var array */ private $cursor_ext; // hash of hashes // per query vars - /** @var object|resource|bool */ // replace object with PgSql\Result + /** @var \PgSql\Result|false */ // replace object with PgSql\Result private $cursor; // actual cursor (DBH) /** @var int */ private $num_rows; // how many rows have been found @@ -495,15 +495,15 @@ class IO * OTOH this whole class is so PgSQL specific * that non PgSQL doesn't make much sense anymore * - * @return \CoreLibs\DB\SQL\PgSQL|null DB functions object or false on error + * @return SQL\PgSQL|null DB functions object or false on error */ - private function __loadDBFunctions() + private function __loadDBFunctions(): SQL\PgSQL|null { $db_functions = null; switch ($this->db_type) { // list of valid DB function objects case 'pgsql': - $db_functions = new \CoreLibs\DB\SQL\PgSQL(); + $db_functions = new SQL\PgSQL(); break; // if non set or none matching abort default: @@ -566,7 +566,7 @@ class IO */ private function __closeDB(): void { - if (!empty($this->dbh) && $this->dbh !== false) { + if (!empty($this->dbh)) { $this->db_functions->__dbClose(); $this->dbh = null; } @@ -632,9 +632,6 @@ class IO private function __printArray(array $array): string { $string = ''; - if (!is_array($array)) { - $array = []; - } foreach ($array as $key => $value) { $string .= $this->nbsp . '' . $key . ' => '; if (is_array($value)) { @@ -701,7 +698,7 @@ class IO /** * Check if there is a cursor and write this cursors error info - * @param object|resource|bool $cursor current cursor for pg_result_error, + * @param \PgSql\Result|false $cursor current cursor for pg_result_error, * pg_last_error too, but pg_result_error * is more accurate (PgSql\Result) * @return array Pos 0: if we could get the method where it was called @@ -709,7 +706,7 @@ class IO * Pos 1: if we have the pg_error_string from last error * if nothing then empty string */ - private function __dbErrorPreprocessor($cursor = false): array + private function __dbErrorPreprocessor(\PgSql\Result|false $cursor = false): array { $pg_error_string = ''; // 1 = self/__dbErrorPreprocessor, 2 = __dbError, __dbWarning, @@ -774,12 +771,15 @@ class IO /** * write an error * @param integer $error_id Any Error ID, used in debug message string - * @param object|resource|bool $cursor Optional cursor, passed on to preprocessor + * @param \PgSql\Result|false $cursor Optional cursor, passed on to preprocessor * @param string $msg optional message added to debug * @return void */ - protected function __dbError(int $error_id, $cursor = false, string $msg = ''): void - { + protected function __dbError( + int $error_id, + \PgSql\Result|false $cursor = false, + string $msg = '' + ): void { $error_id = (string)$error_id; [$where_called, $pg_error_string] = $this->__dbErrorPreprocessor($cursor); // write error msg ... @@ -798,12 +798,15 @@ class IO /** * write a warning * @param integer $warning_id Integer warning id added to debug - * @param object|resource|bool $cursor Optional cursor, passed on to preprocessor + * @param \PgSql\Result|false $cursor Optional cursor, passed on to preprocessor * @param string $msg optional message added to debug * @return void */ - protected function __dbWarning(int $warning_id, $cursor = false, string $msg = ''): void - { + protected function __dbWarning( + int $warning_id, + \PgSql\Result|false $cursor = false, + string $msg = '' + ): void { $warning_id = (string)$warning_id; [$where_called, $pg_error_string] = $this->__dbErrorPreprocessor($cursor); $this->__dbDebug( @@ -821,18 +824,18 @@ class IO /** * if there is the 'to_encoding' var set, * and the field is in the wrong encoding converts it to the target - * @param array|bool|null $row Array from fetch_row - * @return array|bool Convert fetch_row array, or false + * @param array|false $row Array from fetch_row + * @return array|false Convert fetch_row array, or false */ - private function __dbConvertEncoding($row) + private function __dbConvertEncoding(array|false $row): array|false { - if ($row === null) { + if (is_bool($row)) { return false; } // only do if array, else pass through row (can be false) if ( !is_array($row) || - empty($this->to_encoding)// || empty($this->db_encoding) + empty($this->to_encoding) ) { return $row; } @@ -914,7 +917,7 @@ class IO * check if there is another query running, or do we hang after a * PHP error * @param integer $timeout_seconds For complex timeout waits, default 3 seconds - * @return boolean True for connection OK, else false + * @return bool True for connection OK, else false */ private function __dbCheckConnectionOk(int $timeout_seconds = 3): bool { @@ -932,7 +935,7 @@ class IO * dbReturn * Read data from previous written data cache * @param string $query_hash The hash for the current query - * @param boolean $assoc_only Only return assoc value (key named) + * @param bool $assoc_only Only return assoc value (key named) * @return array Current position query data from cache */ private function __dbReturnCacheRead(string $query_hash, bool $assoc_only): array @@ -983,10 +986,11 @@ class IO * - sets internal hash for query * - checks multiple call count * @param string $query query string - * @param string $pk_name primary key [if set to NULL no returning will be added] - * @return string|bool queryt hash OR boolean false on error + * @param string $pk_name primary key + * [if set to NULL no returning will be added] + * @return string|false queryt hash OR bool false on error */ - private function __dbPrepareExec(string $query, string $pk_name) + private function __dbPrepareExec(string $query, string $pk_name): string|false { // reset current cursor before exec $this->cursor = false; @@ -1152,10 +1156,10 @@ class IO * insert_id_ext [DEPRECATED, all in insert_id_arr] * - holds all returning as array * TODO: Only use insert_id_arr and use functions to get ok array or single - * @param boolean $returning_id + * @param bool $returning_id * @param string $query * @param string|null $pk_name - * @param object|resource|bool $cursor (PgSql\Result) + * @param \PgSql\Result|false $cursor (PgSql\Result) * @param string|null $stm_name If not null, is dbExecutre run * @return void */ @@ -1163,7 +1167,7 @@ class IO bool $returning_id, string $query, ?string $pk_name, - $cursor, + \PgSql\Result|false $cursor, ?string $stm_name = null ): void { // $this->log->debug('DB SET INSERT ID', 'Ret: ' . ($returning_id ? 'Y' : 'N') @@ -1271,10 +1275,10 @@ class IO /** * get certain settings like username, db name - * @param string $name what setting to query - * @return mixed setting value, if not allowed name return false + * @param string $name what setting to query + * @return int|string|bool setting value, if not allowed name return false */ - public function dbGetSetting(string $name) + public function dbGetSetting(string $name): int|string|bool { $setting = ''; switch ($name) { @@ -1373,7 +1377,7 @@ class IO * extended version info, can access all additional information data * @param string $parameter Array parameter name, if not valid returns * empty string - * @param boolean $strip Strip extended server info string, default true + * @param bool $strip Strip extended server info string, default true * eg nn.n (other info) will only return nn.n * @return string Parameter value */ @@ -1392,14 +1396,15 @@ class IO } /** - * returns boolean true or false if the string matches the database version + * returns bool true or false if the string matches the database version * @param string $compare string to match in type =X.Y, >X.Y, =X.Y * @return bool true for ok, false on not ok */ public function dbCompareVersion(string $compare): bool { $matches = []; - // compare has =, >, < prefix, and gets stripped, if the rest is not X.Y format then error + // compare has =, >, < prefix, and gets stripped + // if the rest is not X.Y format then error preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches); $compare = $matches[1]; $to_master = $matches[2]; @@ -1464,7 +1469,7 @@ class IO * else current cursor * @return string Formated string with all the data in the array */ - public function dbDumpData($query = ''): string + public function dbDumpData(string $query = ''): string { // set start array if ($query) { @@ -1490,7 +1495,7 @@ class IO * @param string|int|float|bool $string string to escape * @return string escaped string */ - public function dbEscapeString($string): string + public function dbEscapeString(string|int|float|bool $string): string { return $this->db_functions->__dbEscapeString($string); } @@ -1501,7 +1506,7 @@ class IO * @param string|int|float|bool $string string to escape * @return string escaped string */ - public function dbEscapeLiteral($string): string + public function dbEscapeLiteral(string|int|float|bool $string): string { return $this->db_functions->__dbEscapeLiteral($string); } @@ -1538,11 +1543,11 @@ class IO /** * clear up any data for valid DB insert - * @param int|float|string|null $value to escape data - * @param string $kbn escape trigger type - * @return string escaped value + * @param int|float|string|bool|null $value to escape data + * @param string $kbn escape trigger type + * @return string escaped value */ - public function dbSqlEscape($value, string $kbn = '') + public function dbSqlEscape(int|float|string|bool|null $value, string $kbn = ''): string { switch ($kbn) { case 'i': @@ -1551,24 +1556,35 @@ class IO case 'f': $value = empty($value) ? 'NULL' : floatval($value); break; + // string (null is null, else is string) case 't': $value = $value === null ? 'NULL' : "'" . $this->dbEscapeString($value) . "'"; break; + // string litereal (null is null, else is stirng) case 'tl': $value = $value === null ? 'NULL' : $this->dbEscapeLiteral($value); break; - // what is d? + // escape string, set empty to null case 'd': - $value = empty($value) ? 'NULL' : "'" . $this->dbEscapeString($value) . "'"; + $value = empty($value) ? + 'NULL' : + "'" . $this->dbEscapeString($value) . "'"; + break; + // escape string literal, set empty to null + case 'dl': + $value = empty($value) ? + 'NULL' : + $this->dbEscapeLiteral($value); break; // bytea data case 'by': $value = empty($value) ? 'NULL' : $this->dbEscapeBytea((string)$value); break; + // bool case 'b': if (is_float($value)) { $value = (int)$value; @@ -1577,6 +1593,7 @@ class IO 'NULL' : "'" . $this->dbBoolean($value, true) . "'"; break; + // int, but with empty value is 0 case 'i2': $value = empty($value) ? 0 : intval($value); break; @@ -1590,14 +1607,14 @@ class IO /** * if the input is a single char 't' or 'f - * it will return the boolean value instead + * it will return the bool value instead * also converts smallint 1/0 to true false * @param string|bool|int $string 't' / 'f' or any string, or bool true/false - * @param boolean $rev do reverse (bool to string) - * @return bool|string correct php boolean true/false + * @param bool $rev do reverse (bool to string) + * @return bool|string correct php bool true/false * or postgresql 't'/'f' */ - public function dbBoolean($string, $rev = false) + public function dbBoolean(string|bool|int $string, bool $rev = false): bool|string { if (!$rev) { if ($string == 't' || $string == 'true') { @@ -1696,9 +1713,9 @@ class IO * returns an array of the table with columns and values. FALSE on no table found * @param string $table table name * @param string $schema optional schema name - * @return array|bool array of table data, false on error (table not found) + * @return array|false array of table data, false on error (table not found) */ - public function dbShowTableMetaData(string $table, string $schema = '') + public function dbShowTableMetaData(string $table, string $schema = ''): array|false { $this->__dbErrorReset(); $table = (!empty($schema) ? $schema . '.' : '') . $table; @@ -1736,14 +1753,14 @@ class IO * NO_CACHE/3: don't write cache * @param bool $assoc_only True to only returned the named and not * index position ones - * @return array|bool return array data or false on error/end + * @return array|false return array data or false on error/end * @#suppress PhanTypeMismatchDimFetch */ public function dbReturn( string $query, int $cache = self::USE_CACHE, bool $assoc_only = false - ) { + ): array|false { $this->__dbErrorReset(); if (!$query) { $this->__dbError(11); @@ -1754,7 +1771,7 @@ class IO // pre declare array if (!isset($this->cursor_ext[$query_hash])) { $this->cursor_ext[$query_hash] = [ - // cursor, null: unset, 1: finished read/cache, 2: object/resource reading + // cursor, null: unset, 1: finished read/cache, 2: object reading 'cursor' => null, // cached data 'data' => [], @@ -2000,9 +2017,9 @@ class IO * if pk name is table name and _id, pk_name * is not needed to be set * if NULL is given here, no RETURNING will be auto added - * @return object|resource|bool cursor for this query or false on error (PgSql\Result) + * @return \PgSql\Result|false cursor for this query or false on error */ - public function dbExec(string $query = '', string $pk_name = '') + public function dbExec(string $query = '', string $pk_name = ''): \PgSql\Result|false { $this->__dbErrorReset(); // prepare and check if we can actually run it @@ -2031,7 +2048,7 @@ class IO /** * executes a cursor and returns the data, if no more data 0 will be returned - * @param object|resource|bool $cursor the cursor from db_exec or + * @param \PgSql\Result|false $cursor the cursor from db_exec or * pg_query/pg_exec/mysql_query * if not set will use internal cursor, * if not found, stops with 0 (error) @@ -2039,9 +2056,9 @@ class IO * @param bool $assoc_only false is default, * if true only named rows, * not numbered index rows - * @return array|bool row array or false on error + * @return array|false row array or false on error */ - public function dbFetchArray($cursor = false, bool $assoc_only = false) + public function dbFetchArray(\PgSql\Result|false $cursor = false, bool $assoc_only = false): array|false { $this->__dbErrorReset(); // set last available cursor if none set or false @@ -2064,9 +2081,9 @@ class IO * returns the FIRST row of the given query * @param string $query the query to be executed * @param bool $assoc_only if true, only return assoc entry (default false) - * @return array|bool row array or false on error + * @return array|false row array or false on error */ - public function dbReturnRow(string $query, bool $assoc_only = false) + public function dbReturnRow(string $query, bool $assoc_only = false): array|false { $this->__dbErrorReset(); if (!$query) { @@ -2091,9 +2108,9 @@ class IO * createds an array of hashes of the query (all data) * @param string $query the query to be executed * @param bool $assoc_only if true, only name ref are returned (default true) - * @return array|bool array of hashes (row -> fields), false on error + * @return array|false array of hashes (row -> fields), false on error */ - public function dbReturnArray(string $query, bool $assoc_only = true) + public function dbReturnArray(string $query, bool $assoc_only = true): array|false { $this->__dbErrorReset(); if (!$query) { @@ -2151,41 +2168,44 @@ class IO * returns the full array for cursor ext * or cursor for one query * or detail data fonr one query cursor data - * @param string|null $query Query string, if not null convert to hash - * and return set cursor ext for only this - * if not found or null return null - * @return array|string|int|resource|object|null - * Cursor Extended array full if no parameter - * Key is hash string from query run - * Or cursor data entry if query field is set - * If nothing found return null + * @param string|null $query Query string, if not null convert to hash + * and return set cursor ext for only this + * if not found or null return null + * @param string $query_field [=''] optional query field to get + * @return array|string|int|\PgSql\Result|null + * Cursor Extended array full if no parameter + * Key is hash string from query run + * Or cursor data entry if query field is set + * If nothing found return null */ - public function dbGetCursorExt($query = null, string $query_field = '') - { - if ($query !== null) { - $query_hash = $this->dbGetQueryHash($query); - if ( - is_array($this->cursor_ext) && - isset($this->cursor_ext[$query_hash]) - ) { - if (empty($query_field)) { - return $this->cursor_ext[$query_hash]; - } else { - return $this->cursor_ext[$query_hash][$query_field] ?? null; - } - } else { - return null; - } + public function dbGetCursorExt( + $query = null, + string $query_field = '' + ): array|string|int|\PgSql\Result|null { + if ($query === null) { + return $this->cursor_ext; + } + $query_hash = $this->dbGetQueryHash($query); + if ( + is_array($this->cursor_ext) && + isset($this->cursor_ext[$query_hash]) + ) { + if (empty($query_field)) { + return $this->cursor_ext[$query_hash]; + } else { + return $this->cursor_ext[$query_hash][$query_field] ?? null; + } + } else { + return null; } - return $this->cursor_ext; } /** * returns the current position the read out * @param string $query query to find in cursor_ext - * @return int|bool query position (row pos), false on error + * @return int|false query position (row pos), false on error */ - public function dbGetCursorPos(string $query) + public function dbGetCursorPos(string $query): int|false { $this->__dbErrorReset(); if (!$query) { @@ -2199,9 +2219,9 @@ class IO /** * returns the number of rows for the current select query * @param string $query query to find in cursor_ext - * @return int|bool query position (row pos), false on error + * @return int|false query position (row pos), false on error */ - public function dbGetCursorNumRows(string $query) + public function dbGetCursorNumRows(string $query): int|false { $this->__dbErrorReset(); if (!$query) { @@ -2253,11 +2273,14 @@ class IO * @param string $stm_name statement name * @param string $query queryt string to run * @param string $pk_name optional primary key - * @return bool|object|resource false on error, true on warning or - * result on full ok (PgSql\Result) + * @return \PgSql\Result|bool false on error, true on warning or + * result on full ok */ - public function dbPrepare(string $stm_name, string $query, string $pk_name = '') - { + public function dbPrepare( + string $stm_name, + string $query, + string $pk_name = '' + ): \PgSql\Result|bool { $this->__dbErrorReset(); $matches = []; if (!$query) { @@ -2361,9 +2384,9 @@ class IO * runs a prepare query * @param string $stm_name statement name for the query to run * @param array $data data to run for this query, empty array for none - * @return mixed false on error, or result on OK + * @return \PgSql\Result|false false on error, or result on OK */ - public function dbExecute(string $stm_name, array $data = []) + public function dbExecute(string $stm_name, array $data = []): \PgSql\Result|false { $this->__dbErrorReset(); // if no DB Handler drop out @@ -2483,11 +2506,10 @@ class IO /** * checks a previous async query and returns data if finished * NEEDS : dbExecAsync - * @return bool|object|resource cursor resource if the query is still running, - * false if an error occured or cursor of that query - * (PgSql\Result) + * @return \PgSql\Result|bool cursor resource if the query is still running, + * false if an error occured or cursor of that query */ - public function dbCheckAsync() + public function dbCheckAsync(): \PgSql\Result|bool { $this->__dbErrorReset(); // if there is actually a async query there @@ -2547,7 +2569,7 @@ class IO * @param int $primary_key id key to decide if we write insert or update * @param string $table name for the target table * @param array $data data array to override _POST data - * @return int|bool primary key + * @return int|false primary key */ public function dbWriteData( array $write_array, @@ -2555,13 +2577,7 @@ class IO int $primary_key, string $table, array $data = [] - ) { - if (!is_array($write_array)) { - $write_array = []; - } - if (!is_array($not_write_array)) { - $not_write_array = []; - } + ): int|false { $not_write_update_array = []; return $this->dbWriteDataExt( $write_array, @@ -2586,16 +2602,16 @@ class IO * to write during update (optional) * @param array $data optional array with data * if not _POST vars are used - * @return int|bool primary key + * @return int|false primary key */ public function dbWriteDataExt( array $write_array, - $primary_key, + int|string|array $primary_key, string $table, array $not_write_array = [], array $not_write_update_array = [], array $data = [] - ) { + ): int|false { if (!is_array($primary_key)) { $primary_key = [ 'row' => $table . '_id', @@ -2711,7 +2727,10 @@ class IO $primary_key['value'] = $this->dbGetInsertPK(); } // if there is not priamry key value field return false - return $primary_key['value'] ?? false; + if (!is_numeric($primary_key['value'])) { + return false; + } + return (int)$primary_key['value']; } // *************************** @@ -2724,7 +2743,7 @@ class IO * @param bool|null $debug true/false or null for just getting current set * @return bool Current debug flag as set */ - public function dbSetDebug($debug = null): bool + public function dbSetDebug(?bool $debug = null): bool { if ($debug !== null) { $this->db_debug = $debug; @@ -2805,7 +2824,7 @@ class IO * @return bool False on failure to find schema value or set schema, * True on successful set */ - public function dbSetSchema(string $db_schema) + public function dbSetSchema(string $db_schema): bool { $this->__dbErrorReset(); if (empty($db_schema)) { @@ -2934,9 +2953,9 @@ class IO /** * Return current database handler - * @return object|resource|bool|int|null + * @return \PgSql\Connection|false|null */ - public function dbGetDbh() + public function dbGetDbh(): \PgSql\Connection|false|null { return $this->dbh; } @@ -2992,7 +3011,7 @@ class IO * * @return array|string|int|null Current insert query primary key */ - public function dbGetInsertPK() + public function dbGetInsertPK(): array|string|int|null { if (empty($this->insert_id_pk_name)) { return null; @@ -3016,7 +3035,7 @@ class IO * @param integer|null $pos * @return array|string|int|null */ - public function dbGetReturningExt(?string $key = null, ?int $pos = null) + public function dbGetReturningExt(?string $key = null, ?int $pos = null): array|string|int|null { // return as is if key is null if ($key === null) { @@ -3110,7 +3129,7 @@ class IO * Not ethat returnin_id also can return false * but will not set an error entry */ - public function dbGetPrepareCursorValue(string $stm_name, string $key) + public function dbGetPrepareCursorValue(string $stm_name, string $key): null|string|int|bool { // if no statement name if (empty($stm_name)) { @@ -3159,8 +3178,8 @@ class IO * Sets error number that was last * So we always have the last error number stored even if a new * one is created - * @param boolean $transform Set to true to transform into id + error message - * @return string Last error number as string or error message + * @param bool $transform Set to true to transform into id + error message + * @return string Last error number as string or error message */ public function dbGetLastError(bool $transform = false): string { @@ -3180,10 +3199,10 @@ class IO /** * Sets warning number that was last * So we always have the last warning number stored even if a new one is created - * @param boolean $transform Set to true to transform into id + warning message - * @return string Last Warning number as string or warning message + * @param bool $transform Set to true to transform into id + warning message + * @return string Last Warning number as string or warning message */ - public function dbGetLastWarning(bool $transform = false) + public function dbGetLastWarning(bool $transform = false): string { // if no warning, return empty if (empty($this->warning_id)) { @@ -3221,7 +3240,7 @@ class IO * Null for error * @deprecated Use ->dbGetInsertPK(); */ - public function dbGetReturning() + public function dbGetReturning(): array|string|int|bool|null { return $this->dbGetInsertPK(); } @@ -3271,7 +3290,7 @@ class IO * @return array|string|int|bool|null See above * @deprecated use getReturningExt($key = null) instead */ - public function getInsertReturn($key = null) + public function getInsertReturn(?string $key = null): array|string|int|bool|null { trigger_error('Method ' . __METHOD__ . ' is deprecated, use getReturningExt($key = null)', E_USER_DEPRECATED); return $this->dbGetReturningExt($key); @@ -3282,7 +3301,7 @@ class IO * @return array|string|int|bool|null [DEPRECATED] * @deprecated use dbGetReturning() instead */ - public function getReturning() + public function getReturning(): array|string|int|bool|null { trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetReturning()', E_USER_DEPRECATED); return $this->dbGetInsertPK(); @@ -3293,7 +3312,7 @@ class IO * @return array|string|int|bool|null [DEPRECATED] * @deprecated use dbGetInsertPK() instead */ - public function getInsertPK() + public function getInsertPK(): array|string|int|bool|null { trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetInsertPK()', E_USER_DEPRECATED); return $this->dbGetInsertPK(); @@ -3305,7 +3324,7 @@ class IO * @return array|string|bool|int|null [DEPRECATED] * @deprecated use dbGetReturningExt($key = null) instead */ - public function getReturningExt($key = null) + public function getReturningExt(?string $key = null): array|string|int|bool|null { trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetReturningExt($key = null)', E_USER_DEPRECATED); return $this->dbGetReturningExt($key); @@ -3314,10 +3333,10 @@ class IO /** * DEPRECATED: getCursorExt * @param string|null $q [DEPRECATED] - * @return array|string|int|resource|object|null [DEPRECATED] + * @return array|string|int|\PgSql\Result|null [DEPRECATED] * @deprecated use dbGetCursorExt($q = null) instead */ - public function getCursorExt($q = null) + public function getCursorExt(?string $q = null): array|string|int|\PgSql\Result|null { trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetCursorExt($q = null)', E_USER_DEPRECATED); return $this->dbGetCursorExt($q); @@ -3328,7 +3347,7 @@ class IO * @return int|null [DEPRECATED] * @deprecated use dbGetNumRows() instead */ - public function getNumRows() + public function getNumRows(): ?int { trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetNumRows()', E_USER_DEPRECATED); return $this->dbGetNumRows(); diff --git a/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/SqlInterface/SqlFunctions.php b/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/Interface/SqlFunctions.php similarity index 64% rename from www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/SqlInterface/SqlFunctions.php rename to www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/Interface/SqlFunctions.php index 9380519f..36ef0f51 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/SqlInterface/SqlFunctions.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/Interface/SqlFunctions.php @@ -6,7 +6,7 @@ declare(strict_types=1); -namespace CoreLibs\DB\SQL\SqlInterface; +namespace CoreLibs\DB\SQL\Interface; interface SqlFunctions { @@ -21,33 +21,33 @@ interface SqlFunctions * Undocumented function * * @param string $query - * @return object|resource|bool + * @return \PgSql\Result|false */ - public function __dbQuery(string $query); + public function __dbQuery(string $query): \PgSql\Result|false; /** * Undocumented function * * @param string $query * @param array $params - * @return object|resource|bool + * @return \PgSql\Result|false */ - public function __dbQueryParams(string $query, array $params); + public function __dbQueryParams(string $query, array $params): \PgSql\Result|false; /** * Undocumented function * * @param string $query - * @return boolean + * @return bool */ public function __dbSendQuery(string $query): bool; /** * Undocumented function * - * @return object|resource|bool + * @return \PgSql\Result|false */ - public function __dbGetResult(); + public function __dbGetResult(): \PgSql\Result|false; /** * Undocumented function @@ -61,85 +61,85 @@ interface SqlFunctions * * @param string $name * @param string $query - * @return object|resource|bool + * @return \PgSql\Result|false */ - public function __dbPrepare(string $name, string $query); + public function __dbPrepare(string $name, string $query): \PgSql\Result|false; /** * Undocumented function * * @param string $name * @param array $data - * @return object|resource|bool + * @return \PgSql\Result|false */ - public function __dbExecute(string $name, array $data); + public function __dbExecute(string $name, array $data): \PgSql\Result|false; /** * Undocumented function * - * @param object|resource|bool $cursor - * @return integer + * @param \PgSql\Result|false $cursor + * @return int */ - public function __dbNumRows($cursor): int; + public function __dbNumRows(\PgSql\Result|false $cursor): int; /** * Undocumented function * - * @param object|resource|bool $cursor - * @return integer + * @param \PgSql\Result|false $cursor + * @return int */ - public function __dbNumFields($cursor): int; + public function __dbNumFields(\PgSql\Result|false $cursor): int; /** * Undocumented function * - * @param object|resource|bool $cursor + * @param \PgSql\Result|false $cursor * @param int $i - * @return string|bool + * @return string|false */ - public function __dbFieldName($cursor, int $i); + public function __dbFieldName(\PgSql\Result|false $cursor, int $i): string|false; /** * Undocumented function * - * @param object|resource|bool $cursor + * @param \PgSql\Result|false $cursor * @param int $result_type * @return array|bool */ - public function __dbFetchArray($cursor, int $result_type = PGSQL_BOTH); + public function __dbFetchArray(\PgSql\Result|false $cursor, int $result_type = PGSQL_BOTH); /** * Undocumented function * - * @param boolean $assoc_type - * @return integer + * @param bool $assoc_type + * @return int */ public function __dbResultType(bool $assoc_type = true): int; /** * Undocumented function * - * @param object|resource|bool $cursor + * @param \PgSql\Result|false $cursor * @return array|bool */ - public function __dbFetchAll($cursor); + public function __dbFetchAll(\PgSql\Result|false $cursor): array|bool; /** * Undocumented function * - * @param object|resource|bool $cursor - * @return integer + * @param \PgSql\Result|false $cursor + * @return int */ - public function __dbAffectedRows($cursor): int; + public function __dbAffectedRows(\PgSql\Result|false $cursor): int; /** * Undocumented function * * @param string $query * @param string|null $pk_name - * @return string|integer|false + * @return string|int|false */ - public function __dbInsertId(string $query, ?string $pk_name); + public function __dbInsertId(string $query, ?string $pk_name): string|int|false; /** * Undocumented function @@ -148,7 +148,7 @@ interface SqlFunctions * @param string $schema * @return string|bool */ - public function __dbPrimaryKey(string $table, string $schema = ''); + public function __dbPrimaryKey(string $table, string $schema = ''): string|bool; /** * Undocumented function @@ -157,9 +157,9 @@ interface SqlFunctions * @param string $db_user * @param string $db_pass * @param string $db_name - * @param integer $db_port + * @param int $db_port * @param string $db_ssl - * @return object|resource|bool + * @return \PgSql\Connection|false */ public function __dbConnect( string $db_host, @@ -168,24 +168,24 @@ interface SqlFunctions string $db_name, int $db_port, string $db_ssl = 'allow' - ); + ): \PgSql\Connection|false; /** * Undocumented function * - * @param object|resource|bool $cursor + * @param \PgSql\Result|false $cursor * @return string */ - public function __dbPrintError($cursor = false): string; + public function __dbPrintError(\PgSql\Result|false $cursor = false): string; /** * Undocumented function * * @param string $table - * @param boolean $extended + * @param bool $extended * @return array|bool */ - public function __dbMetaData(string $table, $extended = true); + public function __dbMetaData(string $table, bool $extended = true): array|bool; /** * Undocumented function @@ -193,7 +193,7 @@ interface SqlFunctions * @param string|int|float|bool $string * @return string */ - public function __dbEscapeString($string): string; + public function __dbEscapeString(string|int|float|bool $string): string; /** * Undocumented function @@ -201,7 +201,7 @@ interface SqlFunctions * @param string|int|float|bool $string * @return string */ - public function __dbEscapeLiteral($string): string; + public function __dbEscapeLiteral(string|int|float|bool $string): string; /** * Undocumented function @@ -230,15 +230,15 @@ interface SqlFunctions /** * Undocumented function * - * @return boolean + * @return bool */ public function __dbConnectionBusy(): bool; /** * Undocumented function * - * @param integer $timeout_seconds - * @return boolean + * @param int $timeout_seconds + * @return bool */ public function __dbConnectionBusySocketWait(int $timeout_seconds = 3): bool; @@ -253,8 +253,8 @@ interface SqlFunctions * Undocumented function * * @param string $array_text - * @param integer $start - * @param integer|null $end + * @param int $start + * @param int|null $end * @return array|null */ public function __dbArrayParse( @@ -275,7 +275,7 @@ interface SqlFunctions * Undocumented function * * @param string $db_schema - * @return integer + * @return int */ public function __dbSetSchema(string $db_schema): int; @@ -290,7 +290,7 @@ interface SqlFunctions * Undocumented function * * @param string $db_encoding - * @return integer + * @return int */ public function __dbSetEncoding(string $db_encoding): int; diff --git a/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/PgSQL.php b/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/PgSQL.php index 251148b6..b9da6d3a 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/PgSQL.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/DB/SQL/PgSQL.php @@ -51,12 +51,11 @@ namespace CoreLibs\DB\SQL; // as main system. Currently all @var sets are written as object /** @#phan-file-suppress PhanUndeclaredTypeProperty,PhanUndeclaredTypeParameter,PhanUndeclaredTypeReturnType */ -class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions +class PgSQL implements Interface\SqlFunctions { /** @var string */ private $last_error_query; - // NOTE for PHP 8.1 this is no longer a resource - /** @var object|resource|bool */ // replace object with PgSql\Connection + /** @var \PgSql\Connection|false */ private $dbh; /** @@ -77,12 +76,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * wrapper for pg_query, catches error and stores it in class var * * @param string $query Query string - * @return object|resource|bool query result (PgSql\Result) + * @return \PgSql\Result|false query result */ - public function __dbQuery(string $query) + public function __dbQuery(string $query): \PgSql\Result|false { $this->last_error_query = ''; - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } // read out the query status and save the query if needed @@ -100,12 +99,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * * @param string $query Query string with placeholders $1, .. * @param array $params Matching parameters for each placerhold - * @return object|resource|bool Query result (PgSql\Result) + * @return \PgSql\Result|false Query result */ - public function __dbQueryParams(string $query, array $params) + public function __dbQueryParams(string $query, array $params): \PgSql\Result|false { $this->last_error_query = ''; - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } // parse query and get all $n entries @@ -126,7 +125,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbSendQuery(string $query): bool { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } $result = pg_send_query($this->dbh, $query); @@ -136,12 +135,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_get_result * - * @return object|resource|bool resource handler or false for error (PgSql\Result) + * @return \PgSql\Result|false resource handler or false for error */ - public function __dbGetResult() + public function __dbGetResult(): \PgSql\Result|false { $this->last_error_query = ''; - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } $result = pg_get_result($this->dbh); @@ -161,7 +160,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbClose(): void { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return; } if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) { @@ -175,12 +174,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * * @param string $name statement name * @param string $query query string - * @return object|resource|bool prepare statement handler or - * false for error (PgSql\Result) + * @return \PgSql\Result|false prepare statement handler or + * false for error */ - public function __dbPrepare(string $name, string $query) + public function __dbPrepare(string $name, string $query): \PgSql\Result|false { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } $result = pg_prepare($this->dbh, $name, $query); @@ -195,11 +194,11 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * * @param string $name statement name * @param array $data data array - * @return object|resource|bool returns status or false for error (PgSql\Result) + * @return \PgSql\Result|false returns status or false for error */ - public function __dbExecute(string $name, array $data) + public function __dbExecute(string $name, array $data): \PgSql\Result|false { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } $result = pg_execute($this->dbh, $name, $data); @@ -212,12 +211,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_num_rows * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @return int number of rows, -1 on error + * @param \PgSql\Result|false $cursor cursor + * @return int number of rows, -1 on error */ - public function __dbNumRows($cursor): int + public function __dbNumRows(\PgSql\Result|false $cursor): int { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return -1; } return pg_num_rows($cursor); @@ -226,12 +225,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_num_fields * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @return int number for fields in result, -1 on error + * @param \PgSql\Result|false $cursor cursor + * @return int number for fields in result, -1 on error */ - public function __dbNumFields($cursor): int + public function __dbNumFields(\PgSql\Result|false $cursor): int { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return -1; } return pg_num_fields($cursor); @@ -240,13 +239,13 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_field_name * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @param int $i field position - * @return string|bool name or false on error + * @param \PgSql\Result|false $cursor cursor + * @param int $i field position + * @return string|false name or false on error */ - public function __dbFieldName($cursor, int $i) + public function __dbFieldName(\PgSql\Result|false $cursor, int $i): string|false { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return false; } return pg_field_name($cursor, $i); @@ -256,13 +255,13 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * wrapper for pg_fetch_array * if through/true false, use __dbResultType(true) * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @param int $result_type result type as int number - * @return array|bool array result data or false on end/error + * @param \PgSql\Result|false $cursor cursor + * @param int $result_type result type as int number + * @return array|false array result data or false on end/error */ - public function __dbFetchArray($cursor, int $result_type = PGSQL_BOTH) + public function __dbFetchArray(\PgSql\Result|false $cursor, int $result_type = PGSQL_BOTH): array|false { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return false; } // result type is passed on as is [should be checked] @@ -287,12 +286,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_fetch_all * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @return array|bool data array or false for end/error + * @param \PgSql\Result|false $cursor cursor + * @return array|false data array or false for end/error */ - public function __dbFetchAll($cursor) + public function __dbFetchAll(\PgSql\Result|false $cursor): array|false { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return false; } return pg_fetch_all($cursor); @@ -301,12 +300,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_affected_rows * - * @param object|resource|bool $cursor cursor PgSql\Result (former resource) - * @return int affected rows, 0 for none, -1 for error + * @param \PgSql\Result|false $cursor cursor + * @return int affected rows, 0 for none, -1 for error */ - public function __dbAffectedRows($cursor): int + public function __dbAffectedRows(\PgSql\Result|false $cursor): int { - if ($cursor === false || is_bool($cursor)) { + if (is_bool($cursor)) { return -1; } return pg_affected_rows($cursor); @@ -323,7 +322,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string|null $pk_name primary key name, if '' then auto detect * @return string|int|false primary key value */ - public function __dbInsertId(string $query, ?string $pk_name) + public function __dbInsertId(string $query, ?string $pk_name): string|int|false { // only if an insert has been done if (preg_match("/^insert /i", $query)) { @@ -371,7 +370,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string $schema optional schema name, '' for default * @return string|bool primary key name or false if not found */ - public function __dbPrimaryKey(string $table, string $schema = '') + public function __dbPrimaryKey(string $table, string $schema = ''): string|bool { if ($table) { // check if schema set is different from schema given, @@ -426,7 +425,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string $db_name databse name * @param integer $db_port port (int, 5432 is default) * @param string $db_ssl SSL (allow is default) - * @return object|resource|bool db handler PgSql\Connection or false on error + * @return \PgSql\Connection|false db handler or false on error */ public function __dbConnect( string $db_host, @@ -435,7 +434,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions string $db_name, int $db_port, string $db_ssl = 'allow' - ) { + ): \PgSql\Connection|false { if (empty($db_name)) { return false; } @@ -470,22 +469,22 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * reads the last error for this cursor and returns * html formatted string with error name * - * @param bool|object|resource $cursor cursor PgSql\Result (former resource) + * @param \PgSql\Result|false $cursor cursor * or null * @return string error string */ - public function __dbPrintError($cursor = false): string + public function __dbPrintError(\PgSql\Result|false $cursor = false): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } // run the query again for the error result here - if (($cursor === false || is_bool($cursor)) && $this->last_error_query) { + if ((is_bool($cursor)) && $this->last_error_query) { pg_send_query($this->dbh, $this->last_error_query); $this->last_error_query = ''; $cursor = pg_get_result($this->dbh); } - if ($cursor && !is_bool($cursor) && $error_str = pg_result_error($cursor)) { + if ($cursor && $error_str = pg_result_error($cursor)) { return '-PostgreSQL-Error- ' . $error_str; } else { @@ -500,9 +499,9 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param bool $extended show extended info (default true) * @return array|bool array data for the table info or false on error */ - public function __dbMetaData(string $table, $extended = true) + public function __dbMetaData(string $table, bool $extended = true): array|bool { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } // needs to prefixed with @ or it throws a warning on not existing table @@ -515,9 +514,9 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string|int|float|bool $string any string/int/float/bool * @return string excaped string */ - public function __dbEscapeString($string): string + public function __dbEscapeString(string|int|float|bool $string): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } return pg_escape_string($this->dbh, (string)$string); @@ -531,9 +530,9 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string|int|float|bool $string any string/int/float/bool * @return string excaped string including quites */ - public function __dbEscapeLiteral($string): string + public function __dbEscapeLiteral(string|int|float|bool $string): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return (string)''; } // for phpstan, thinks this is string|false? @@ -549,7 +548,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbEscapeIdentifier(string $string): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } // for phpstan, thinks this is string|false? @@ -564,7 +563,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbEscapeBytea(string $data): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } return pg_escape_bytea($this->dbh, $data); @@ -584,11 +583,12 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * wrapper for pg_connection_busy * - * @return bool True if connection is busy, False if not or no db connection at all + * @return bool True if connection is busy + * False if not or no db connection at all */ public function __dbConnectionBusy(): bool { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } return pg_connection_busy($this->dbh); @@ -597,13 +597,13 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions /** * Experimental wrapper with scoket timetout * - * @param integer $timeout_seconds Wait how many seconds on timeout - * @return boolean True if connection is busy, or false on - * not busy or no db connection at all + * @param integer $timeout_seconds Wait how many seconds on timeout + * @return bool True if connection is busy, or false on + * not busy or no db connection at all */ public function __dbConnectionBusySocketWait(int $timeout_seconds = 3): bool { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } $busy = pg_connection_busy($this->dbh); @@ -626,14 +626,14 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * On default 'version' will be stripped of any space attached info * eg 13.5 (other info) will return only 13.5 * - * @param string $parameter Parameter string to extract from array - * @param boolean $strip If parameter is server strip out on default - * Set to false to get original string AS is - * @return string The parameter value + * @param string $parameter Parameter string to extract from array + * @param bool $strip If parameter is server strip out on default + * Set to false to get original string AS is + * @return string The parameter value */ public function __dbVersionInfo(string $parameter, bool $strip = true): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } // extract element @@ -655,7 +655,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbVersionInfoParameterList(): array { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return []; } return array_keys(pg_version($this->dbh)); @@ -670,7 +670,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions */ public function __dbVersion(): string { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return ''; } // array has client, protocol, server, we just return server stripped @@ -762,9 +762,9 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions * @param string $parameter Parameter to query * @return string|bool Settings value as string */ - public function __dbParameter(string $parameter) + public function __dbParameter(string $parameter): string|bool { - if ($this->dbh === false || is_bool($this->dbh)) { + if (is_bool($this->dbh)) { return false; } if (empty($parameter)) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Debug/Logging.php b/www/vendor/egrajp/corelibs-composer-all/src/Debug/Logging.php index b07ce0f7..d9ffb343 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Debug/Logging.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Debug/Logging.php @@ -413,7 +413,7 @@ class Logging * @param string $name what variable to return * @return mixed can be anything, bool, string, int, array */ - public function getSetting(string $name) //:mixed DOES not work with PHP 7.4 + public function getSetting(string $name): mixed { // for debug purpose only return $this->{$name}; @@ -550,9 +550,9 @@ class Logging * @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 + * @return array|bool 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): array|bool { // abort if not valid type if (!in_array($type, ['debug', 'echo', 'print'])) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Language/Core/GetTextReader.php b/www/vendor/egrajp/corelibs-composer-all/src/Language/Core/GetTextReader.php index cfa8e7c1..3fa7404d 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Language/Core/GetTextReader.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Language/Core/GetTextReader.php @@ -122,7 +122,7 @@ class GetTextReader * @param bool $enable_cache Enable or disable caching * of strings (default on) */ - public function __construct($Reader, bool $enable_cache = true) + public function __construct(FileReader|bool $Reader, bool $enable_cache = true) { // If there isn't a StreamReader, turn on short circuit mode. if ((!is_object($Reader) && !$Reader) || (is_object($Reader) && $Reader->error)) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Language/Encoding.php b/www/vendor/egrajp/corelibs-composer-all/src/Language/Encoding.php index ebdbc612..443b3258 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Language/Encoding.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Language/Encoding.php @@ -46,7 +46,7 @@ class Encoding * @return void * @deprecated Use \CoreLibs\Check\Encoding::setErrorChar(); */ - public static function setErrorChar($string): void + public static function setErrorChar(string|int|null $string): void { \CoreLibs\Check\Encoding::setErrorChar($string); } @@ -60,7 +60,7 @@ class Encoding * @return string|int Set error character * @deprecated Use \CoreLibs\Check\Encoding::getErrorChar(); */ - public static function getErrorChar(bool $return_substitute_func = false) + public static function getErrorChar(bool $return_substitute_func = false): string|int { return \CoreLibs\Check\Encoding::getErrorChar($return_substitute_func); } @@ -81,7 +81,7 @@ class Encoding * @param string $string string to test * @param string $from_encoding encoding of string to test * @param string $to_encoding target encoding - * @return bool|array false if no error or + * @return array|false false if no error or * array with failed characters * @deprecated Use \CoreLibs\Check\Encoding::checkConvertEncoding(); */ @@ -89,7 +89,7 @@ class Encoding string $string, string $from_encoding, string $to_encoding - ) { + ): array|false { return \CoreLibs\Check\Encoding::checkConvertEncoding($string, $from_encoding, $to_encoding); } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Elements.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Elements.php index badbeae0..b6ee9d8b 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Elements.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Elements.php @@ -13,27 +13,27 @@ class Elements /** * print the date/time drop downs, used in any queue/send/insert at date/time place * - * @param int $year year YYYY - * @param int $month month m - * @param int $day day d - * @param int $hour hour H - * @param int $min min i - * @param string $suffix additional info printed after the date time - * variable in the drop down - * also used for ID in the on change JS call - * @param int $min_steps default is 1 (minute), can set to anything, - * is used as sum up from 0 - * @param bool $name_pos_back default false, if set to true, - * the name will be printend after the drop down - * and not before the drop down - * @return string HTML formated strings for drop down lists of date and time + * @param int|string $year year YYYY + * @param int|string $month month m + * @param int|string $day day d + * @param int|string $hour hour H + * @param int|string $min min i + * @param string $suffix additional info printed after the date time + * variable in the drop down + * also used for ID in the on change JS call + * @param int $min_steps default is 1 (minute), can set to anything, + * is used as sum up from 0 + * @param bool $name_pos_back default false, if set to true, + * the name will be printend after the drop down + * and not before the drop down + * @return string HTML formated strings for drop down lists of date and time */ public static function printDateTime( - $year, - $month, - $day, - $hour, - $min, + int|string $year, + int|string $month, + int|string $day, + int|string $hour, + int|string $min, string $suffix = '', int $min_steps = 1, bool $name_pos_back = false diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Generate.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Generate.php index d560e6fb..cfbe8ee2 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Generate.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/Generate.php @@ -366,7 +366,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $config_array = $table_arrays[System::getPageName(1)]; } else { // primary try to load the class - /** @var \CoreLibs\Output\Form\TableArraysInterface|false $content_class */ + /** @var TableArrays\Interface\TableArraysInterface|false $content_class */ $content_class = $this->loadTableArray(); if (is_object($content_class)) { $config_array = $content_class->setTableArray(); @@ -468,9 +468,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO /** * load table array class based on my page name converted to camel case * class files are in \TableArrays folder in \Output\Form - * @return object|bool Return class object or false on failure + * @return TableArrays\Interface\TableArraysInterface|false Return class object or false on failure */ - private function loadTableArray() + private function loadTableArray(): TableArrays\Interface\TableArraysInterface|false { // note: it schould be Schemas but an original type made it to this // this file is kept for the old usage, new one should be EditSchemas @@ -489,7 +489,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $page_name_camel_case ); try { - /** @var \CoreLibs\Output\Form\TableArraysInterface|false $class */ + /** @var TableArrays\Interface\TableArraysInterface|false $class */ $class = new $class_string($this); } catch (\Throwable $t) { $this->log->debug('CLASS LOAD', 'Failed loading: ' . $class_string . ' => ' . $t->getMessage()); @@ -651,7 +651,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->base_acl_level >= $this->security_level['new'] ) { if ($this->really_new == 'yes') { - $this->formUnsetTablearray(); + $this->formUnsetTableArray(); } else { $this->msg .= $this->l->__('You have to select the Checkbox for New!
'); $this->error = 2; @@ -731,9 +731,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO empty($this->table_array['protected']['value']) && !$this->error ) { - if (!is_array($element_list)) { - $element_list = []; - } for ($i = 0, $i_max = count($element_list); $i < $i_max; $i++) { // $this->log->debug('form_error', 'Array: ' // . is_array($this->element_list[$element_list[$i]]['read_data']) . ' | ' @@ -2294,11 +2291,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO } } } - if (is_array($hidden_array)) { - reset($hidden_array); - foreach ($hidden_array as $key => $value) { - $hidden[] = ['key' => $key, 'value' => $value]; - } + reset($hidden_array); + foreach ($hidden_array as $key => $value) { + $hidden[] = ['key' => $key, 'value' => $value]; } return $hidden; } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditAccess.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditAccess.php index 170046f9..3701e54c 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditAccess.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditAccess.php @@ -87,7 +87,9 @@ class EditAccess implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_access', - "load_query" => "SELECT edit_access_id, name FROM edit_access ORDER BY name", + "load_query" => "SELECT edit_access_id, name " + . "FROM edit_access " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditGroups.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditGroups.php index e9008101..0ff66ebc 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditGroups.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditGroups.php @@ -55,14 +55,19 @@ class EditGroups implements Interface\TableArraysInterface 'mandatory' => 1, 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_scheme_id' => [ 'value' => $_POST['edit_scheme_id'] ?? '', 'output_name' => 'Group Scheme', 'int_null' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_scheme_id, name FROM edit_scheme WHERE enabled = 1 ORDER BY name" + 'query' => "SELECT edit_scheme_id, name " + . "FROM edit_scheme " + . "WHERE enabled = 1 " + . "ORDER BY name" ], 'additional_acl' => [ 'value' => $_POST['additional_acl'] ?? '', @@ -73,7 +78,9 @@ class EditGroups implements Interface\TableArraysInterface 'cols' => 60 ], ], - 'load_query' => "SELECT edit_group_id, name, enabled FROM edit_group ORDER BY name", + 'load_query' => "SELECT edit_group_id, name, enabled " + . "FROM edit_group " + . "ORDER BY name", 'table_name' => 'edit_group', 'show_fields' => [ [ @@ -115,7 +122,9 @@ class EditGroups implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'int' => 1, 'preset' => 1, // first of the select - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_page_id' => [ 'int' => 1, diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditMenuGroup.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditMenuGroup.php index 6c327de7..48826bb8 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditMenuGroup.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditMenuGroup.php @@ -55,7 +55,9 @@ class EditMenuGroup implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_menu_group', - 'load_query' => "SELECT edit_menu_group_id, name FROM edit_menu_group ORDER BY name", + 'load_query' => "SELECT edit_menu_group_id, name " + . "FROM edit_menu_group " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditPages.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditPages.php index a051a504..6ecd26e5 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditPages.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditPages.php @@ -140,7 +140,10 @@ class EditPages implements Interface\TableArraysInterface ], ], 'load_query' => "SELECT edit_page_id, " - . "CASE WHEN hostname IS NOT NULL THEN hostname ELSE ''::VARCHAR END || filename AS filename, " + . "CASE " + . "WHEN hostname IS NOT NULL THEN hostname " + . "ELSE ''::VARCHAR " + . "END || filename AS filename, " . "name, online, menu, popup " . "FROM edit_page " . "ORDER BY order_number", @@ -178,7 +181,8 @@ class EditPages implements Interface\TableArraysInterface 'select_size' => 10, 'selected' => $_POST['edit_visible_group_id'] ?? '', 'query' => "SELECT edit_visible_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " - . "FROM edit_visible_group ORDER BY name" + . "FROM edit_visible_group " + . "ORDER BY name" ], 'edit_menu_group' => [ 'table_name' => 'edit_page_menu_group', @@ -188,7 +192,8 @@ class EditPages implements Interface\TableArraysInterface 'select_size' => 10, 'selected' => $_POST['edit_menu_group_id'] ?? '', 'query' => "SELECT edit_menu_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " - . "FROM edit_menu_group ORDER BY order_number" + . "FROM edit_menu_group " + . "ORDER BY order_number" ], ], 'element_list' => [ @@ -259,7 +264,9 @@ class EditPages implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'int' => 1, 'preset' => 1, // first of the select - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_page_content_id' => [ 'type' => 'hidden', diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditSchemas.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditSchemas.php index d91e14a1..8417ac1f 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditSchemas.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditSchemas.php @@ -68,7 +68,9 @@ class EditSchemas implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_scheme', - 'load_query' => "SELECT edit_scheme_id, name, enabled FROM edit_scheme ORDER BY name", + 'load_query' => "SELECT edit_scheme_id, name, enabled " + . "FROM edit_scheme " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditUsers.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditUsers.php index c3e9da2f..a85cb0e9 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditUsers.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditUsers.php @@ -274,7 +274,7 @@ class EditUsers implements Interface\TableArraysInterface 'type' => 'drop_down_db', 'query' => "SELECT edit_language_id, long_name " . "FROM edit_language " - . "WHERE enabled = 1" + . "WHERE enabled = 1 " . "ORDER BY order_number", 'min_edit_acl' => '100', 'min_show_acl' => '100', @@ -284,7 +284,10 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Scheme', 'int_null' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_scheme_id, name FROM edit_scheme WHERE enabled = 1 ORDER BY name", + 'query' => "SELECT edit_scheme_id, name " + . "FROM edit_scheme " + . "WHERE enabled = 1 " + . "ORDER BY name", 'min_edit_acl' => '100', 'min_show_acl' => '100', ], @@ -293,7 +296,10 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Group', 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_group_id, name FROM edit_group WHERE enabled = 1 ORDER BY name", + 'query' => "SELECT edit_group_id, name " + . "FROM edit_group " + . "WHERE enabled = 1 " + . "ORDER BY name", 'mandatory' => 1, 'min_edit_acl' => '100', 'min_show_acl' => '100', @@ -304,7 +310,9 @@ class EditUsers implements Interface\TableArraysInterface 'mandatory' => 1, 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level", + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level", 'min_edit_acl' => '100', 'min_show_acl' => '100', ], @@ -434,7 +442,9 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'preset' => 1, // first of the select 'int' => 1, - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_default' => [ 'type' => 'radio_group', diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditVisibleGroup.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditVisibleGroup.php index a00c33d8..98a2f223 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditVisibleGroup.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Form/TableArrays/EditVisibleGroup.php @@ -48,7 +48,9 @@ class EditVisibleGroup implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_visible_group', - 'load_query' => "SELECT edit_visible_group_id, name FROM edit_visible_group ORDER BY name", + 'load_query' => "SELECT edit_visible_group_id, name " + . "FROM edit_visible_group " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Output/Image.php b/www/vendor/egrajp/corelibs-composer-all/src/Output/Image.php index a3a14fd5..20d2a56f 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Output/Image.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Output/Image.php @@ -22,7 +22,7 @@ class Image * if empty ROOT is choosen * @param string $cache_source cache path, if not given TMP is used * @param bool $clear_cache if set to true, will create thumb all the tame - * @return string|bool thumbnail name, or false for error + * @return string|false thumbnail name, or false for error */ public static function createThumbnail( string $pic, @@ -32,7 +32,7 @@ class Image string $path = '', string $cache_source = '', bool $clear_cache = false - ) { + ): string|false { // get image type flags $image_types = [ 1 => 'gif', @@ -73,7 +73,7 @@ class Image $create_file = false; $delete_filename = ''; // check if we can skip the PDF creation: if we have size, if do not have type, we assume type png - if (!$type && is_numeric($size_x) && is_numeric($size_y)) { + if (!$type) { $check_thumb = $tmp_src . 'thumb_' . $pic . '_' . $size_x . 'x' . $size_y . '.' . $image_types[3]; if (!is_file($check_thumb)) { $create_file = true; @@ -100,10 +100,10 @@ class Image [$width, $height, $type] = getimagesize($filename) ?: []; } // if no size given, set size to original - if (!$size_x || $size_x < 1 || !is_numeric($size_x)) { + if (!$size_x || $size_x < 1) { $size_x = $width; } - if (!$size_y || $size_y < 1 || !is_numeric($size_y)) { + if (!$size_y || $size_y < 1) { $size_y = $height; } $thumb = 'thumb_' . $pic . '_' . $size_x . 'x' . $size_y . '.' . $image_types[$type]; @@ -170,7 +170,7 @@ class Image * set to false to not use (default true) * to use quick but less nice version * @param int $jpeg_quality default 80, set image quality for jpeg only - * @return string|bool thumbnail with path + * @return string|false thumbnail with path */ public static function createThumbnailSimple( string $filename, @@ -181,7 +181,7 @@ class Image bool $use_cache = true, bool $high_quality = true, int $jpeg_quality = 80 - ) { + ): string|false { $thumbnail = false; // $this->debug('IMAGE PREPARE', "FILE: $filename (exists " // .(string)file_exists($filename)."), WIDTH: $thumb_width, HEIGHT: $thumb_height"); @@ -425,7 +425,7 @@ class Image * @param string $filename path + filename to rotate. This file must be writeable * @return void */ - public static function correctImageOrientation($filename): void + public static function correctImageOrientation(string $filename): void { // function exists & file is writeable, else do nothing if (!function_exists('exif_read_data') || !is_writeable($filename)) { diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsACLLoginTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsACLLoginTest.php index c57528a6..2d011949 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsACLLoginTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsACLLoginTest.php @@ -1729,7 +1729,7 @@ final class CoreLibsACLLoginTest extends TestCase ], 20 ], - 'invalud search' => [ + 'invalid search' => [ 12, 'foo', [], diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsCombinedArrayHandlerTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsCombinedArrayHandlerTest.php index 1fac71ae..689f5922 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsCombinedArrayHandlerTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsCombinedArrayHandlerTest.php @@ -107,6 +107,13 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase */ public function arraySearchRecursiveAllProvider(): array { + /* + 0: $needle, + 1: array $input, + 2: ?string $key_search_for, + 3: bool $flag, + 4: array $expected + */ return [ 'find value' => [ 0 => 'bar', @@ -172,6 +179,13 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase */ public function arraySearchSimpleProvider(): array { + /* + 0: array $input, + 1: $key, + 2: $value, + 3: bool $flag, + 4: bool $expected + */ return [ 'key/value exist' => [ 0 => self::$array, @@ -665,7 +679,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase * * @param array $input * @param string|int $key - * @param string|int $value + * @param string|int|bool $value * @param bool $expected * @return void */ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsDBIOTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsDBIOTest.php index 4c4dea3d..c1908825 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsDBIOTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/CoreLibsDBIOTest.php @@ -1253,10 +1253,14 @@ final class CoreLibsDBIOTest extends TestCase 'string value literal' => ['string literal', 'tl', '\'string literal\'',], 'empty string value literal' => ['', 'tl', '\'\'',], 'null string value literal' => [null, 'tl', 'NULL',], - // ?d (I have no idea what that does, is like string) + // escape string, but set all empty strings to null ('' is null) 'string value d' => ['string d', 'd', '\'string d\'',], 'empty string value d' => ['', 'd', 'NULL',], 'null string value d' => [null, 'd', 'NULL',], + // escape literal string, but set all empty strings to null ('' is null) + 'string value literal d' => ['string d', 'dl', '\'string d\'',], + 'empty string value literal d' => ['', 'dl', 'NULL',], + 'null string value literal d' => [null, 'dl', 'NULL',], // by bytea 'string value d' => ['string d', 'by', '\x737472696e672064',], 'empty string value d' => ['', 'by', 'NULL',], @@ -1281,7 +1285,7 @@ final class CoreLibsDBIOTest extends TestCase * @dataProvider sqlEscapeProvider * @testdox Input value $input as $flag to $expected [$_dataName] * - * @param int|float|string|null $input + * @param int|float|string|bool|null $input * @param string $flag * @param int|float|string $expected * @return void diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/.gitignore b/www/vendor/egrajp/corelibs-composer-all_compare/.gitignore new file mode 100644 index 00000000..7579f743 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/.gitignore @@ -0,0 +1,2 @@ +vendor +composer.lock diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/.phan/config.php b/www/vendor/egrajp/corelibs-composer-all_compare/.phan/config.php new file mode 100644 index 00000000..cc0ea261 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/.phan/config.php @@ -0,0 +1,120 @@ + "8.2", + // turn color on (-C) + "color_issue_messages_if_supported" => true, + // If true, missing properties will be created when + // they are first seen. If false, we'll report an + // error message. + "allow_missing_properties" => false, + + // Allow null to be cast as any type and for any + // type to be cast to null. + "null_casts_as_any_type" => false, + + // Backwards Compatibility Checking + 'backward_compatibility_checks' => false, + + // Run a quick version of checks that takes less + // time + "quick_mode" => false, + + // Only emit critical issues to start with + // (0 is low severity, 5 is normal severity, 10 is critical) + "minimum_severity" => 0, + + // enable for dead code check + // this will spill out errors for all methods never called + // use after all is OK to try to find unused code blocks + // ignore recommended: PhanUnreferencedPublicMethod + // "dead_code_detection" => true, + + // default false for include path check + "enable_include_path_checks" => true, + "include_paths" => [ + '.', + // '../test/configs/' + ], + 'ignore_undeclared_variables_in_global_scope' => true, + + "file_list" => [ + "./test/configs/config.php", + // "./test/configs/config.db.php", + // "./test/configs/config.host.php", + // "./test/configs/config.path.php", + "./test/configs/config.other.php", + "./test/configs/config.master.php", + ], + + // A list of directories that should be parsed for class and + // method information. After excluding the directories + // defined in exclude_analysis_directory_list, the remaining + // files will be statically analyzed for errors. + // + // Thus, both first-party and third-party code being used by + // your application should be included in this list. + 'directory_list' => [ + // Change this to include the folders you wish to analyze + // (and the folders of their dependencies) + 'src', + // To speed up analysis, we recommend going back later and + // limiting this to only the vendor/ subdirectories your + // project depends on. + // `phan --init` will generate a list of folders for you + 'vendor/egrajp/smarty-extended', + ], + + + // A list of directories holding code that we want + // to parse, but not analyze + "exclude_analysis_directory_list" => [ + 'vendor/egrajp/smarty-extended', + ], + 'exclude_file_list' => [ + ], + + // what not to show as problem + 'suppress_issue_types' => [ + // 'PhanUndeclaredMethod', + 'PhanEmptyFile', + // ignore unreferences public methods, etc here (for dead code check) + 'PhanUnreferencedPublicMethod', + 'PhanUnreferencedClass', + 'PhanWriteOnlyPublicProperty', + 'PhanUnreferencedConstant', + 'PhanWriteOnlyPublicProperty', + 'PhanReadOnlyPublicProperty' + ], + + // Override to hardcode existence and types of (non-builtin) globals in the global scope. + // Class names should be prefixed with `\`. + // + // (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`) + 'globals_type_map' => [], +]; diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/ReadMe.md b/www/vendor/egrajp/corelibs-composer-all_compare/ReadMe.md new file mode 100644 index 00000000..77fb6d34 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/ReadMe.md @@ -0,0 +1,25 @@ +# Composer package from CoreLibs + +This is just the lib/CoreLibs folder in a composer package. + +For local install only + +**Note**: for following classes the `egrajp/smarty-extended` has to be installed + +- Template\SmartyExtended +- Admin\EditBase + +## Setup from central composer + +Setup from gitea internal servers + +```sh +composer config repositories.git.egplusww.jp.Composer composer https://git.egplusww.jp/api/packages/Composer/composer +``` + +Alternative setup composer local zip file repot: +`composer config repositories.composer.egplusww.jp composer http://composer.egplusww.jp` + +## Install package + +`composer require egrajp/corelibs-composer-all:^7.11` diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/composer.json b/www/vendor/egrajp/corelibs-composer-all_compare/composer.json new file mode 100644 index 00000000..2f0480f3 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/composer.json @@ -0,0 +1,33 @@ +{ + "name": "egrajp/corelibs-composer-all", + "description": "CoreLibs in a composer package", + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "CoreLibs\\": "src/" + } + }, + "authors": [ + { + "name": "Clemens Schwaighofer", + "email": "clemens.schwaighofer@egplusww.com" + } + ], + "minimum-stability": "dev", + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpstan/phpstan": "1.10.x-dev", + "phan/phan": "v5.x-dev", + "phpunit/phpunit": "^9", + "egrajp/smarty-extended": "^4.3" + }, + "repositories": { + "git.egplusww.jp.Composer": { + "type": "composer", + "url": "https://git.egplusww.jp/api/packages/Composer/composer" + } + } +} diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-baseline.neon b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-baseline.neon new file mode 100644 index 00000000..5413dc2a --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-baseline.neon @@ -0,0 +1,47 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$connection of function pg_escape_bytea expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_escape_identifier expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_escape_literal expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_escape_string expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_execute expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_parameter_status expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_prepare expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_query expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + + - + message: "#^Parameter \\#1 \\$connection of function pg_query_params expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" + count: 1 + path: src/DB/SQL/PgSQL.php + diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-bootstrap.php b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-bootstrap.php new file mode 100755 index 00000000..3d165225 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan-bootstrap.php @@ -0,0 +1,12 @@ += 8_00_00) { + // Change of signature in PHP 8.1 + /* $config['parameters']['ignoreErrors'][] = [ + 'message' => '~Parameter #1 \$(result|connection) of function pg_\w+ ' + . 'expects resource(\|null)?, object\|resource given\.~', + 'path' => 'www/lib/CoreLibs/DB/SQL/PgSQL.php', + // 'count' => 1, + ]; */ +} + +return $config; + +// __END_ diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/phpstan.neon b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan.neon new file mode 100644 index 00000000..7c0a0eb7 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/phpstan.neon @@ -0,0 +1,42 @@ +# PHP Stan Config +includes: + - phpstan-conditional.php +parameters: + tmpDir: /tmp/phpstan-corelibs-composer + level: 8 # max is now 9 + checkMissingCallableSignature: true + treatPhpDocTypesAsCertain: false + paths: + - %currentWorkingDirectory%/src + bootstrapFiles: + - %currentWorkingDirectory%/phpstan-bootstrap.php + - %currentWorkingDirectory%/vendor/autoload.php + scanDirectories: + - vendor/egrajp/smarty-extended + scanFiles: + - test/configs/config.php + - test/configs/config.master.php + - test/configs/config.other.php + # excludePaths: + # ignore composer + # - vendor + # ignore errores with + ignoreErrors: + #- # this error is ignore because of the PHP 8.0 to 8.1 change for pg_*, only for 8.0 or lower + # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects resource(\\|null)?, object\\|resource(\\|bool)? given\\.$#" + # path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php + # - # this is for 8.1 or newer + # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects PgSql\\\\(Result|Connection(\\|string)?(\\|null)?), object\\|resource given\\.$#" + # path: %currentWorkingDirectory%/src/DB/SQL/PgSQL.php + # this is ignored for now + # - '#Expression in empty\(\) is always falsy.#' + # - + # message: '#Reflection error: [a-zA-Z0-9\\_]+ not found.#' + # path: www/includes/edit_base.php + #- 'error regex' + #- + # message: 'error regex' + # path: %currentWorkingDirectory%/www/some/* + # paths: + # - ... + # - ... diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/phpunit.xml b/www/vendor/egrajp/corelibs-composer-all_compare/phpunit.xml new file mode 100644 index 00000000..23d3de4c --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/phpunit.xml @@ -0,0 +1,6 @@ + + diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/publish/.gitignore b/www/vendor/egrajp/corelibs-composer-all_compare/publish/.gitignore new file mode 100644 index 00000000..9094d2f1 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/publish/.gitignore @@ -0,0 +1,2 @@ +*.zip +.env* diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/publish/last.published b/www/vendor/egrajp/corelibs-composer-all_compare/publish/last.published new file mode 100644 index 00000000..ae9a76b9 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/publish/last.published @@ -0,0 +1 @@ +8.0.0 diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/publish/publish.sh b/www/vendor/egrajp/corelibs-composer-all_compare/publish/publish.sh new file mode 100755 index 00000000..e608d39c --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/publish/publish.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +BASE_FOLDER=$(dirname $(readlink -f $0))"/"; +VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//"); +file_last_published="${BASE_FOLDER}last.published"; + +if [ -z "${VERSION}" ]; then + echo "Version must be set in the form x.y.z without any leading characters"; + exit; +fi; +# compare version, if different or newer, deploy +if [ -f "${file_last_published}" ]; then + LAST_PUBLISHED_VERSION=$(cat ${file_last_published}); + if $(dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"); then + echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}"; + exit; + fi; +fi; + +# read in the .env.deploy file and we must have +# GITLAB_USER +# GITLAB_TOKEN +# GITEA_DEPLOY_TOKEN +if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then + echo "Deploy enviroment file .env.deploy is missing"; + exit; +fi; +set -o allexport; +cd ${BASE_FOLDER}; +source .env.deploy; +cd -; +set +o allexport; + +# gitea +if [ ! -z "${GITEA_USER}" ] && [ ! -z "${GITEA_TOKEN}" ]; then + curl -LJO \ + --output-dir "${BASE_FOLDER}" \ + https://git.egplusww.jp/Composer/CoreLibs-Composer-All/archive/v${VERSION}.zip; + curl --user ${GITEA_USER}:${GITEA_TOKEN} \ + --upload-file "${BASE_FOLDER}/CoreLibs-Composer-All-v${VERSION}.zip" \ + https://git.egplusww.jp/api/packages/Composer/composer?version=${VERSION}; + echo "${VERSION}" > "${file_last_published}"; +else + echo "Missing either GITEA_USER or GITEA_TOKEN environment variable"; +fi; + +# gitlab +if [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then + curl --data tag=v${VERSION} \ + --header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \ + "https://gitlab-na.factory.tools/api/v4/projects/950/packages/composer"; + curl --data branch=master \ + --header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \ + "https://gitlab-na.factory.tools/api/v4/projects/950/packages/composer"; + echo "${VERSION}" > "${file_last_published}"; +else + echo "Missing GITLAB_DEPLOY_TOKEN environment variable"; +fi; + +# __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all_compare/src/ACL/Login.php b/www/vendor/egrajp/corelibs-composer-all_compare/src/ACL/Login.php new file mode 100644 index 00000000..332692ea --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all_compare/src/ACL/Login.php @@ -0,0 +1,2228 @@ + width +* popup_y - if popup -> height +* online - page is online (user can access) +* query_string - string to paste for popup (will change) +* +* HISTORY: +* 2010/12/21 (cs) merge back password change interface +* 2010/12/17 (cs) change that password can be blowfish encrypted, +* auto detects if other encryption is used (md5, std des) +* and tries to use them +* 2007/05/29 (cs) BUG with assign query and visible sub arrays to pages +* 2005/09/21 (cs) if error -> unset the session vars +* 2005/07/04 (cs) add a function to write into the edit log file +* 2005/07/01 (cs) start adepting login class to new edit interface layout +* 2005/03/31 (cs) fixed the class call with all debug vars +* 2004/11/17 (cs) unused var cleanup +* 2004/11/16 (cs) rewrite login so it uses a template and not just plain html. +* prepare it, so it will be able to use external stuff later +* (some interface has to be designed for that +* 2004/11/16 (cs) removed the mobile html part from login +* 2004/09/30 (cs) layout fix +* 2003-11-11: if user has debug 1 unset memlimit, because there can be serious +* problems with the query logging +* 2003-06-12: added flag to PAGES array +* changed the get vars from GLOBALS to _POST +* changed the session registration. no more GLOBAL vars are registered +* only _SESSION["..."] +* 2003-06-09: added mobile phone login possibility +* 2003-03-04: droped ADMIN and added GROUP_LEVEL +* 2003-03-03: started to change the include file function collection +* to become a class +* 2003-02-28: various advances and changes, but far from perfect +* decided to change it into a class for easier handling +* add also possibility to change what will stored in the +* login session ? +* 2000-06-01: created basic idea and functions +*********************************************************************/ + +declare(strict_types=1); + +namespace CoreLibs\ACL; + +use CoreLibs\Check\Password; + +class Login +{ + /** @var string the user id var*/ + private $euid; + /** @var string _GET/_POST loginUserId parameter for non password login */ + private $login_user_id = ''; + /** @var string source, either _GET or _POST or empty */ + private $login_user_id_source = ''; + /** @var bool set to true if illegal characters where found in the login user id string */ + private $login_user_id_unclear = false; + // is set to one if login okay, or EUID is set and user is okay to access this page + /** @var bool */ + private $permission_okay = false; + /** @var string pressed login */ + private $login = ''; + /** @var string master action command */ + private $action; + /** @var string login name */ + private $username; + /** @var string login password */ + private $password; + /** @var string logout button */ + private $logout; + /** @var bool if this is set to true, the user can change passwords */ + private $password_change = false; + /** @var bool password change was successful */ + private $password_change_ok = false; + // can we reset password and mail to user with new password set screen + /** @var bool */ + private $password_forgot = false; + /** @var bool password forgot mail send ok */ + // private $password_forgot_ok = false; + /** @var string */ + private $change_password; + /** @var string */ + private $pw_username; + /** @var string */ + private $pw_old_password; + /** @var string */ + private $pw_new_password; + /** @var string */ + private $pw_new_password_confirm; + /** @var array array of users for which the password change is forbidden */ + private $pw_change_deny_users = []; + /** @var string */ + private $logout_target = ''; + /** @var int */ + private $max_login_error_count = -1; + /** @var array */ + private $lock_deny_users = []; + /** @var string */ + private $page_name = ''; + + /** @var int if we have password change we need to define some rules */ + private $password_min_length = 9; + /** @var int an true maxium min, can never be set below this */ + private $password_min_length_max = 9; + // max length is fixed as 255 (for input type max), if set highter + // it will be set back to 255 + /** @var int */ + private $password_max_length = 255; + /** @var array can have several regexes, if nothing set, all is ok */ + private $password_valid_chars = [ + // '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$', + // '^(?.*(\pL)u)(?=.*(\pN)u)(?=.*([^\pL\pN])u).{8,}', + ]; + + // login error code, can be matched to the array login_error_msg, + // which holds the string + /** @var int */ + private $login_error = 0; + /** @var array all possible login error conditions */ + private $login_error_msg = []; + // this is an array holding all strings & templates passed + // rom the outside (translation) + /** @var array */ + private $login_template = [ + 'strings' => [], + 'password_change' => '', + 'template' => '' + ]; + + // acl vars + /** @var array */ + private $acl = []; + /** @var array */ + private $default_acl_list = []; + /** @var array Reverse list to lookup level from type */ + private $default_acl_list_type = []; + /** @var int default ACL level to be based on if nothing set */ + private $default_acl_level = 0; + // login html, if we are on an ajax page + /** @var string|null */ + private $login_html = ''; + /** @var bool */ + private $login_is_ajax_page = false; + + /** @var \CoreLibs\Debug\Logging logger */ + public $log; + /** @var \CoreLibs\DB\IO database */ + public $db; + /** @var \CoreLibs\Language\L10n language */ + public $l; + /** @var \CoreLibs\Create\Session session class */ + public $session; + + /** + * constructor, does ALL, opens db, works through connection checks, + * finishes itself + * + * @param \CoreLibs\DB\IO $db Database connection class + * @param \CoreLibs\Debug\Logging $log Logging class + * @param \CoreLibs\Create\Session $session Session interface class + * @param bool $auto_login [default true] Auto login flag, legacy + * If set to true will run login + * during construction + */ + public function __construct( + \CoreLibs\DB\IO $db, + \CoreLibs\Debug\Logging $log, + \CoreLibs\Create\Session $session, + bool $auto_login = true + ) { + // attach db class + $this->db = $db; + // log login data for this class only + $log->setLogPer('class', true); + // attach logger + $this->log = $log; + // attach session class + $this->session = $session; + + // string key, msg: string, flag: e (error), o (ok) + $this->login_error_msg = [ + '0' => [ + 'msg' => 'No error', + 'flag' => 'o' + ], + // actually obsolete + '100' => [ + 'msg' => '[EUID] came in as GET/POST!', + 'flag' => 'e', + ], + // query errors + '1009' => [ + 'msg' => 'Login query reading failed', + 'flag' => 'e', + ], + // user not found + '1010' => [ + 'msg' => 'Login Failed - Wrong Username or Password', + 'flag' => 'e' + ], + // blowfish password wrong + '1011' => [ + 'msg' => 'Login Failed - Wrong Username or Password', + 'flag' => 'e' + ], + // fallback md5 password wrong + '1012' => [ + 'msg' => 'Login Failed - Wrong Username or Password', + 'flag' => 'e' + ], + // new password_hash wrong + '1013' => [ + 'msg' => 'Login Failed - Wrong Username or Password', + 'flag' => 'e' + ], + '1101' => [ + 'msg' => 'Login Failed - Login User ID must be validated', + 'flag' => 'e' + ], + '1102' => [ + 'msg' => 'Login Failed - Login User ID is outside valid date range', + 'flag' => 'e' + ], + '102' => [ + 'msg' => 'Login Failed - Please enter username and password', + 'flag' => 'e' + ], + '103' => [ + 'msg' => 'You do not have the rights to access this Page', + 'flag' => 'e' + ], + '104' => [ + 'msg' => 'Login Failed - User not enabled', + 'flag' => 'e' + ], + '105' => [ + 'msg' => 'Login Failed - User is locked', + 'flag' => 'e' + ], + '106' => [ + 'msg' => 'Login Failed - User is deleted', + 'flag' => 'e' + ], + '107' => [ + 'msg' => 'Login Failed - User in locked via date period', + 'flag' => 'e' + ], + '108' => [ + 'msg' => 'Login Failed - User is locked via Login User ID', + 'flag' => 'e' + ], + '109' => [ + 'msg' => 'Check permission query reading failed', + 'flag' => 'e' + ], + // actually this is an illegal user, but I mask it + '220' => [ + 'msg' => 'Password change - The user could not be found', + 'flag' => 'e' + ], + '200' => [ + 'msg' => 'Password change - Please enter username and old password', + 'flag' => 'e' + ], + '201' => [ + 'msg' => 'Password change - The user could not be found', + 'flag' => 'e' + ], + '202' => [ + 'msg' => 'Password change - The old password is not correct', + 'flag' => 'e' + ], + '203' => [ + 'msg' => 'Password change - Please fill out both new password fields', + 'flag' => 'e' + ], + '204' => [ + 'msg' => 'Password change - The new passwords do not match', + 'flag' => 'e' + ], + // we should also not here WHAT is valid + '205' => [ + 'msg' => 'Password change - The new password is not in a valid format', + 'flag' => 'e' + ], + // for OK password change + '300' => [ + 'msg' => 'Password change successful', + 'flag' => 'o' + ], + // this is bad bad error + '9999' => [ + 'msg' => 'Necessary crypt engine could not be found. Login is impossible', + 'flag' => 'e' + ], + ]; + + // init default ACL list array + $_SESSION['DEFAULT_ACL_LIST'] = []; + $_SESSION['DEFAULT_ACL_LIST_TYPE'] = []; + // read the current edit_access_right list into an array + $q = "SELECT level, type, name FROM edit_access_right " + . "WHERE level >= 0 ORDER BY level"; + while (is_array($res = $this->db->dbReturn($q))) { + // level to description format (numeric) + $this->default_acl_list[$res['level']] = [ + 'type' => $res['type'], + 'name' => $res['name'] + ]; + $this->default_acl_list_type[(string)$res['type']] = (int)$res['level']; + } + // write that into the session + $_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list; + $_SESSION['DEFAULT_ACL_LIST_TYPE'] = $this->default_acl_list_type; + + // this will be deprecated + if ($auto_login === true) { + $this->loginMainCall(); + } + } + + // ************************************************************************* + // **** PROTECTED INTERNAL + // ************************************************************************* + + /** + * Wrapper for exit calls + * + * @param int $code + * @return void + */ + protected function loginTerminate($code = 0): void + { + exit($code); + } + + /** + * return current page name + * + * @return string Current page name + */ + protected function loginReadPageName(): string + { + // set internal page name as is + return \CoreLibs\Get\System::getPageName(); + } + + /** + * print out login HTML via echo + * + * @return void + */ + protected function loginPrintLogin(): void + { + echo $this->loginGetLoginHTML(); + } + + // ************************************************************************* + // **** PRIVATE INTERNAL + // ************************************************************************* + + /** + * Checks for all flags and sets error codes for each + * In order: + * delete > enable > lock > period lock > login user id lock + * + * @param int $deleted User deleted check + * @param int $enabled User not enabled check + * @param int $locked Locked because of too many invalid passwords + * @param int $locked_period Locked because of time period set + * @param int $login_user_id_locked Locked from using Login User Id + * @return bool + */ + private function loginValidationCheck( + int $deleted, + int $enabled, + int $locked, + int $locked_period, + int $login_user_id_locked + ): bool { + $validation = false; + if ($deleted) { + // user is deleted + $this->login_error = 106; + } elseif (!$enabled) { + // user is not enabled + $this->login_error = 104; + } elseif ($locked) { + // user is locked, either set or auto set + $this->login_error = 105; + } elseif ($locked_period) { + // locked date trigger + $this->login_error = 107; + } elseif ($login_user_id_locked) { + // user is locked, either set or auto set + $this->login_error = 108; + } else { + $validation = true; + } + return $validation; + } + + /** + * checks if password is valid, sets internal error login variable + * + * @param string $hash password hash + * @param string $password submitted password + * @return bool true or false on password ok or not + */ + private function loginPasswordCheck(string $hash, string $password = ''): bool + { + // check with what kind of prefix the password begins: + // $2a$ or $2y$: BLOWFISCH + // $1$: MD5 + // $ and one alphanumeric letter, 13 chars long, but nor $ at the end: STD_DESC + // if no $ => normal password + // NOW, if we have a password encoded, but not the correct encoder available, throw special error + $password_ok = false; + if (!$password) { + $password = $this->password; + } + // first, errors on missing encryption + if ( + // below is all deprecated. all the ones below will always be true + // all the crypt standards are always set + // FIXME: remove this error code + /** @phpstan-ignore-next-line Why? */ + (preg_match("/^\\$2(a|y)\\$/", $hash) && CRYPT_BLOWFISH != 1) || + /** @phpstan-ignore-next-line Why? */ + (preg_match("/^\\$1\\$/", $hash) && CRYPT_MD5 != 1) || + /** @phpstan-ignore-next-line Why? */ + (preg_match("/^\\$[0-9A-Za-z.]{12}$/", $hash) && CRYPT_STD_DES != 1) + ) { + // this means password cannot be decrypted because of missing crypt methods + $this->login_error = 9999; + } elseif ( + preg_match("/^\\$2y\\$/", $hash) && + !Password::passwordVerify($password, $hash) + ) { + // this is the new password hash method, is only $2y$ + // all others are not valid anymore + $this->login_error = 1013; + } elseif ( + !preg_match("/^\\$2(a|y)\\$/", $hash) && + !preg_match("/^\\$1\\$/", $hash) && + !preg_match("/^\\$[0-9A-Za-z.]{12}$/", $hash) && + $hash != $password + ) { + // check old plain password, case sensitive + $this->login_error = 1012; + } else { + // all ok + $password_ok = true; + } + return $password_ok; + } + + /** + * Check if Login User ID is allowed to login + * + * @param int $login_user_id_valid_date + * @param int $login_user_id_revalidate + * @return bool + */ + private function loginLoginUserIdCheck( + int $login_user_id_valid_date, + int $login_user_id_revalidate + ): bool { + $login_id_ok = false; + if ($login_user_id_revalidate) { + $this->login_error = 1101; + } elseif (!$login_user_id_valid_date) { + $this->login_error = 1102; + } else { + $login_id_ok = true; + } + return $login_id_ok; + } + + /** + * if user pressed login button this script is called, + * but only if there is no preview euid set + * + * @return void has not return + */ + private function loginLoginUser(): void + { + // if pressed login at least and is not yet loggined in + if ($this->euid || (!$this->login && !$this->login_user_id)) { + return; + } + // if not username AND password where given + // OR no login_user_id + if (!($this->username && $this->password) && !$this->login_user_id) { + $this->login_error = 102; + $this->permission_okay = false; + return; + } + // have to get the global stuff here for setting it later + // we have to get the themes in here too + $q = "SELECT eu.edit_user_id, eu.username, eu.password, " + . "eu.edit_group_id, " + . "eg.name AS edit_group_name, admin, " + // login error + locked + . "eu.login_error_count, eu.login_error_date_last, " + . "eu.login_error_date_first, eu.strict, eu.locked, " + // date based lock + . "CASE WHEN (" + . "(eu.lock_until IS NULL " + . "OR (eu.lock_until IS NOT NULL AND NOW() >= eu.lock_until)) " + . "AND (eu.lock_after IS NULL " + . "OR (eu.lock_after IS NOT NULL AND NOW() <= eu.lock_after))" + . ") THEN 0::INT ELSE 1::INT END locked_period, " + // debug (legacy) + . "eu.debug, eu.db_debug, " + // enabled + . "eu.enabled, eu.deleted, " + // for checks only + . "eu.login_user_id, " + // login id validation + . "CASE WHEN (" + . "(eu.login_user_id_valid_from IS NULL " + . "OR (eu.login_user_id_valid_from IS NOT NULL AND NOW() >= eu.login_user_id_valid_from)) " + . "AND (eu.login_user_id_valid_until IS NULL " + . "OR (eu.login_user_id_valid_until IS NOT NULL AND NOW() <= eu.login_user_id_valid_until))" + . ") THEN 1::INT ELSE 0::INT END AS login_user_id_valid_date, " + // check if user must login + . "CASE WHEN eu.login_user_id_revalidate_after IS NOT NULL " + . "AND eu.login_user_id_revalidate_after > '0 days'::INTERVAL " + . "AND (eu.login_user_id_last_revalidate + eu.login_user_id_revalidate_after)::DATE " + . "<= NOW()::DATE " + . "THEN 1::INT ELSE 0::INT END AS login_user_id_revalidate, " + . "eu.login_user_id_locked, " + // language + . "el.short_name AS locale, el.iso_name AS encoding, " + // levels + . "eareu.level AS user_level, eareu.type AS user_type, " + . "eareg.level AS group_level, eareg.type AS group_type, " + // colors + . "first.header_color AS first_header_color, " + . "second.header_color AS second_header_color, second.template " + . "FROM edit_user eu " + . "LEFT JOIN edit_scheme second ON " + . "(second.edit_scheme_id = eu.edit_scheme_id AND second.enabled = 1), " + . "edit_language el, edit_group eg, " + . "edit_access_right eareu, " + . "edit_access_right eareg, " + . "edit_scheme first " + . "WHERE first.edit_scheme_id = eg.edit_scheme_id " + . "AND eu.edit_group_id = eg.edit_group_id " + . "AND eu.edit_language_id = el.edit_language_id " + . "AND eu.edit_access_right_id = eareu.edit_access_right_id " + . "AND eg.edit_access_right_id = eareg.edit_access_right_id " + . "AND " + // either login_user_id OR password must be given + . (!empty($this->login_user_id && empty($this->username)) ? + // check with login id if set and NO username + "eu.login_user_id = " . $this->db->dbEscapeLiteral($this->login_user_id) . " " : + // password match is done in script, against old plain or new blowfish encypted + "LOWER(username) = " . $this->db->dbEscapeLiteral(strtolower($this->username)) . " " + ); + // reset any query data that might exist + $this->db->dbCacheReset($q); + // never cache return data + $res = $this->db->dbReturn($q, $this->db::NO_CACHE); + // query was not run successful + if (!empty($this->db->dbGetLastError())) { + $this->login_error = 1009; + $this->permission_okay = false; + return; + } elseif (!is_array($res)) { + // username is wrong, but we throw for wrong username + // and wrong password the same error + $this->login_error = 1010; + $this->permission_okay = false; + return; + } + // if login errors is half of max errors and the last login error + // was less than 10s ago, forbid any new login try + + // check flow + // - user is enabled + // - user is not locked + // - password is readable + // - encrypted password matches + // - plain password matches + if ( + !$this->loginValidationCheck( + (int)$res['deleted'], + (int)$res['enabled'], + (int)$res['locked'], + (int)$res['locked_period'], + (int)$res['login_user_id_locked'] + ) + ) { + // error set in method (104, 105, 106, 107, 108) + } elseif ( + empty($this->username) && + !empty($this->login_user_id) && + !$this->loginLoginUserIdCheck( + (int)$res['login_user_id_valid_date'], + (int)$res['login_user_id_revalidate'] + ) + ) { + // check done in loginLoginIdCheck method + // aborts on must revalidate and not valid (date range) + } elseif ( + !empty($this->username) && + !$this->loginPasswordCheck($res['password']) + ) { + // none to be set, set in login password check + // this is not valid password input error here + // all error codes are set in loginPasswordCheck method + // also valid if login_user_id is ok + } else { + // check if the current password is an invalid hash and do a rehash and set password + // $this->debug('LOGIN', 'Hash: '.$res['password'].' -> VERIFY: ' + // .($Password::passwordVerify($this->password, $res['password']) ? 'OK' : 'FAIL') + // .' => HASH: '.(Password::passwordRehashCheck($res['password']) ? 'NEW NEEDED' : 'OK')); + if (Password::passwordRehashCheck($res['password'])) { + // update password hash to new one now + $q = "UPDATE edit_user " + . "SET password = '" . $this->db->dbEscapeString(Password::passwordSet($this->password)) + . "' WHERE edit_user_id = " . $res['edit_user_id']; + $this->db->dbExec($q); + } + // normal user processing + // set class var and session var + $_SESSION['EUID'] = $this->euid = $res['edit_user_id']; + // check if user is okay + $this->loginCheckPermissions(); + if ($this->login_error == 0) { + if ( + !empty($res['login_user_id']) && + !empty($this->username) && !empty($this->password) + ) { + $q = "UPDATE edit_user SET " + . "login_user_id_last_revalidate = NOW() " + . "WHERE edit_user_id = " . $this->euid; + $this->db->dbExec($q); + } + // now set all session vars and read page permissions + $_SESSION['DEBUG_ALL'] = $this->db->dbBoolean($res['debug']); + $_SESSION['DB_DEBUG'] = $this->db->dbBoolean($res['db_debug']); + // general info for user logged in + $_SESSION['USER_NAME'] = $res['username']; + $_SESSION['ADMIN'] = $res['admin']; + $_SESSION['GROUP_NAME'] = $res['edit_group_name']; + $_SESSION['USER_ACL_LEVEL'] = $res['user_level']; + $_SESSION['USER_ACL_TYPE'] = $res['user_type']; + $_SESSION['GROUP_ACL_LEVEL'] = $res['group_level']; + $_SESSION['GROUP_ACL_TYPE'] = $res['group_type']; + // deprecated TEMPLATE setting + $_SESSION['TEMPLATE'] = $res['template'] ? $res['template'] : ''; + $_SESSION['HEADER_COLOR'] = !empty($res['second_header_color']) ? + $res['second_header_color'] : + $res['first_header_color']; + // missing # before, this is for legacy data, will be deprecated + if (preg_match("/^[\dA-Fa-f]{6,8}$/", $_SESSION['HEADER_COLOR'])) { + $_SESSION['HEADER_COLOR'] = '#' . $_SESSION['HEADER_COLOR']; + } + // TODO: make sure that header color is valid: + // # + 6 hex + // # + 8 hex (alpha) + // rgb(), rgba(), hsl(), hsla() + // rgb: nnn.n for each + // hsl: nnn.n for first, nnn.n% for 2nd, 3rd + // Check\Colors::validateColor() + $_SESSION['LANG'] = $res['locale'] ?? 'en'; + $_SESSION['DEFAULT_CHARSET'] = $res['encoding'] ?? 'UTF-8'; + $_SESSION['DEFAULT_LOCALE'] = $_SESSION['LANG'] + . '.' . strtoupper($_SESSION['DEFAULT_CHARSET']); + $_SESSION['DEFAULT_LANG'] = $_SESSION['LANG'] . '_' + . strtolower(str_replace('-', '', $_SESSION['DEFAULT_CHARSET'])); + // reset any login error count for this user + if ($res['login_error_count'] > 0) { + $q = "UPDATE edit_user " + . "SET login_error_count = 0, login_error_date_last = NULL, " + . "login_error_date_first = NULL " + . "WHERE edit_user_id = " . $res['edit_user_id']; + $this->db->dbExec($q); + } + $edit_page_ids = []; + $pages = []; + $pages_acl = []; + // set pages access + $q = "SELECT ep.edit_page_id, ep.cuid, epca.cuid AS content_alias_uid, " + . "ep.hostname, ep.filename, ep.name AS edit_page_name, " + . "ep.order_number AS edit_page_order, ep.menu, " + . "ep.popup, ep.popup_x, ep.popup_y, ep.online, ear.level, ear.type " + . "FROM edit_page ep " + . "LEFT JOIN edit_page epca ON (epca.edit_page_id = ep.content_alias_edit_page_id)" + . ", edit_page_access epa, edit_access_right ear " + . "WHERE ep.edit_page_id = epa.edit_page_id " + . "AND ear.edit_access_right_id = epa.edit_access_right_id " + . "AND epa.enabled = 1 AND epa.edit_group_id = " . $res["edit_group_id"] . " " + . "ORDER BY ep.order_number"; + while ($res = $this->db->dbReturn($q)) { + if (!is_array($res)) { + break; + } + // page id array for sub data readout + $edit_page_ids[$res['edit_page_id']] = $res['cuid']; + // create the array for pages + $pages[$res['cuid']] = [ + 'edit_page_id' => $res['edit_page_id'], + 'cuid' => $res['cuid'], + // for reference of content data on a differen page + 'content_alias_uid' => $res['content_alias_uid'], + 'hostname' => $res['hostname'], + 'filename' => $res['filename'], + 'page_name' => $res['edit_page_name'], + 'order' => $res['edit_page_order'], + 'menu' => $res['menu'], + 'popup' => $res['popup'], + 'popup_x' => $res['popup_x'], + 'popup_y' => $res['popup_y'], + 'online' => $res['online'], + 'acl_level' => $res['level'], + 'acl_type' => $res['type'], + 'query' => [], + 'visible' => [] + ]; + // make reference filename -> level + $pages_acl[$res['filename']] = $res['level']; + } // for each page + // get the visible groups for all pages and write them to the pages + $q = "SELECT epvg.edit_page_id, name, flag " + . "FROM edit_visible_group evp, edit_page_visible_group epvg " + . "WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id " + . "AND epvg.edit_page_id IN (" . join(', ', array_keys($edit_page_ids)) . ") " + . "ORDER BY epvg.edit_page_id"; + while (is_array($res = $this->db->dbReturn($q))) { + $pages[$edit_page_ids[$res['edit_page_id']]]['visible'][$res['name']] = $res['flag']; + } + // get the same for the query strings + $q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs " + . "WHERE enabled = 1 AND edit_page_id " + . "IN (" . join(', ', array_keys($edit_page_ids)) . ") " + . "ORDER BY eqs.edit_page_id"; + while (is_array($res = $this->db->dbReturn($q))) { + $pages[$edit_page_ids[$res['edit_page_id']]]['query'][] = [ + 'name' => $res['name'], + 'value' => $res['value'], + 'dynamic' => $res['dynamic'] + ]; + } + // get the page content and add them to the page + $q = "SELECT epc.edit_page_id, epc.name, epc.uid, epc.order_number, " + . "epc.online, ear.level, ear.type " + . "FROM edit_page_content epc, edit_access_right ear " + . "WHERE epc.edit_access_right_id = ear.edit_access_right_id AND " + . "epc.edit_page_id IN (" . join(', ', array_keys($edit_page_ids)) . ") " + . "ORDER BY epc.order_number"; + while (is_array($res = $this->db->dbReturn($q))) { + $pages[$edit_page_ids[$res['edit_page_id']]]['content'][$res['uid']] = [ + 'name' => $res['name'], + 'uid' => $res['uid'], + 'online' => $res['online'], + 'order' => $res['order_number'], + // access name and level + 'acl_type' => $res['type'], + 'acl_level' => $res['level'] + ]; + } + // write back the pages data to the output array + $_SESSION['PAGES'] = $pages; + $_SESSION['PAGES_ACL_LEVEL'] = $pages_acl; + // load the edit_access user rights + $q = "SELECT ea.edit_access_id, level, type, ea.name, ea.color, ea.uid, edit_default " + . "FROM edit_access_user eau, edit_access_right ear, edit_access ea " + . "WHERE eau.edit_access_id = ea.edit_access_id " + . "AND eau.edit_access_right_id = ear.edit_access_right_id " + . "AND eau.enabled = 1 AND edit_user_id = " . $this->euid . " " + . "ORDER BY ea.name"; + $unit_access = []; + $eauid = []; + $unit_acl = []; + while (is_array($res = $this->db->dbReturn($q))) { + // read edit access data fields and drop them into the unit access array + $q_sub = "SELECT name, value " + . "FROM edit_access_data " + . "WHERE enabled = 1 AND edit_access_id = " . $res['edit_access_id']; + $ea_data = []; + while (is_array($res_sub = $this->db->dbReturn($q_sub))) { + $ea_data[$res_sub['name']] = $res_sub['value']; + } + // build master unit array + $unit_access[$res['edit_access_id']] = [ + 'id' => $res['edit_access_id'], + 'acl_level' => $res['level'], + 'acl_type' => $res['type'], + 'name' => $res['name'], + 'uid' => $res['uid'], + 'color' => $res['color'], + 'default' => $res['edit_default'], + 'data' => $ea_data + ]; + // set the default unit + if ($res['edit_default']) { + $_SESSION['UNIT_DEFAULT'] = $res['edit_access_id']; + } + $_SESSION['UNIT_UID'][$res['uid']] = $res['edit_access_id']; + // sub arrays for simple access + array_push($eauid, $res['edit_access_id']); + $unit_acl[$res['edit_access_id']] = $res['level']; + } + $_SESSION['UNIT'] = $unit_access; + $_SESSION['UNIT_ACL_LEVEL'] = $unit_acl; + $_SESSION['EAID'] = $eauid; + } // user has permission to THIS page + } // user was not enabled or other login error + if ($this->login_error && is_array($res)) { + $login_error_date_first = ''; + if ($res['login_error_count'] == 0) { + $login_error_date_first = ", login_error_date_first = NOW()"; + } + // update login error count for this user + $q = "UPDATE edit_user " + . "SET login_error_count = login_error_count + 1, " + . "login_error_date_last = NOW() " . $login_error_date_first . " " + . "WHERE edit_user_id = " . $res['edit_user_id']; + $this->db->dbExec($q); + // totally lock the user if error max is reached + if ( + $this->max_login_error_count != -1 && + $res['login_error_count'] + 1 > $this->max_login_error_count + ) { + // do some alert reporting in case this error is too big + // if strict is set, lock this user + // this needs manual unlocking by an admin user + if ($res['strict'] && !in_array($this->username, $this->lock_deny_users)) { + $q = "UPDATE edit_user SET locked = 1 WHERE edit_user_id = " . $res['edit_user_id']; + } + } + } + // if there was an login error, show login screen + if ($this->login_error) { + // reset the perm var, to confirm logout + $this->permission_okay = false; + } + } + + /** + * 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 + * + * @return void has no return + */ + private function loginSetAcl(): void + { + // only set acl if we have permission okay + if (!$this->permission_okay) { + return; + } + // username (login), group name + $this->acl['user_name'] = $_SESSION['USER_NAME']; + $this->acl['group_name'] = $_SESSION['GROUP_NAME']; + // we start with the default acl + $this->acl['base'] = $this->default_acl_level; + + // set admin flag and base to 100 + if (!empty($_SESSION['ADMIN'])) { + $this->acl['admin'] = 1; + $this->acl['base'] = 100; + } else { + $this->acl['admin'] = 0; + // now go throw the flow and set the correct ACL + // user > page > group + // group ACL 0 + if ($_SESSION['GROUP_ACL_LEVEL'] != -1) { + $this->acl['base'] = $_SESSION['GROUP_ACL_LEVEL']; + } + // page ACL 1 + if ( + isset($_SESSION['PAGES_ACL_LEVEL'][$this->page_name]) && + $_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1 + ) { + $this->acl['base'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; + } + // user ACL 2 + if ($_SESSION['USER_ACL_LEVEL'] != -1) { + $this->acl['base'] = $_SESSION['USER_ACL_LEVEL']; + } + } + $_SESSION['BASE_ACL_LEVEL'] = $this->acl['base']; + + // set the current page acl + // start with base acl + // set group if not -1, overrides default + // set page if not -1, overrides group set + $this->acl['page'] = $this->acl['base']; + if ($_SESSION['GROUP_ACL_LEVEL'] != -1) { + $this->acl['page'] = $_SESSION['GROUP_ACL_LEVEL']; + } + if ( + isset($_SESSION['PAGES_ACL_LEVEL'][$this->page_name]) && + $_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1 + ) { + $this->acl['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; + } + + // PER ACCOUNT (UNIT/edit access)-> + foreach ($_SESSION['UNIT'] as $ea_id => $unit) { + // if admin flag is set, all units are set to 100 + if (!empty($this->acl['admin'])) { + $this->acl['unit'][$ea_id] = $this->acl['base']; + } else { + if ($unit['acl_level'] != -1) { + $this->acl['unit'][$ea_id] = $unit['acl_level']; + } else { + $this->acl['unit'][$ea_id] = $this->acl['base']; + } + } + // detail name/level set + $this->acl['unit_detail'][$ea_id] = [ + 'name' => $unit['name'], + 'uid' => $unit['uid'], + 'level' => $this->default_acl_list[$this->acl['unit'][$ea_id]]['name'] ?? -1, + 'default' => $unit['default'], + 'data' => $unit['data'] + ]; + // set default + if (!empty($unit['default'])) { + $this->acl['unit_id'] = $unit['id']; + $this->acl['unit_name'] = $unit['name']; + $this->acl['unit_uid'] = $unit['uid']; + } + } + // flag if to show extra edit access drop downs (because user has multiple groups assigned) + if (count($_SESSION['UNIT']) > 1) { + $this->acl['show_ea_extra'] = true; + } else { + $this->acl['show_ea_extra'] = false; + } + // set the default edit access + $this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT'] ?? null; + // integrate the type acl list, but only for the keyword -> level + $this->acl['min'] = $this->default_acl_list_type; + // set the full acl list too (lookup level number and get level data) + $this->acl['acl_list'] = $this->default_acl_list; + // debug + // $this->debug('ACL', $this->print_ar($this->acl)); + } + + /** + * checks if the password is in a valid format + * + * @param string $password the new password + * @return bool true or false if valid password or not + */ + private function loginPasswordChangeValidPassword(string $password): bool + { + $is_valid_password = true; + // check for valid in regex arrays in list + if (is_array($this->password_valid_chars)) { + foreach ($this->password_valid_chars as $password_valid_chars) { + if (!preg_match("/$password_valid_chars/", $password)) { + $is_valid_password = false; + } + } + } + // check for min length + if ( + strlen($password) < $this->password_min_length || + strlen($password) > $this->password_max_length + ) { + $is_valid_password = false; + } + return $is_valid_password; + } + + /** + * dummy declare for password forget + * + * @return void has no return + */ + private function loginPasswordForgot(): void + { + // will do some password recovert, eg send email + } + + /** + * changes a user password + * + * @return void has no return + */ + private function loginPasswordChange(): void + { + // only continue if password change button pressed + if (!$this->change_password) { + return; + } + $event = 'Password Change'; + $data = ''; + // check that given username is NOT in the deny list, else silent skip (with error log) + if (!in_array($this->pw_username, $this->pw_change_deny_users)) { + // init the edit user id variable + $edit_user_id = ''; + // cehck if either username or old password is not set + if (!$this->pw_username || !$this->pw_old_password) { + $this->login_error = 200; + $data = 'Missing username or old password.'; + } + // check user exist, if not -> error + if (!$this->login_error) { + $q = "SELECT edit_user_id " + . "FROM edit_user " + . "WHERE enabled = 1 " + . "AND username = '" . $this->db->dbEscapeString($this->pw_username) . "'"; + $res = $this->db->dbReturnRow($q); + if ( + !is_array($res) || + empty($res['edit_user_id']) + ) { + // username wrong + $this->login_error = 201; + $data = 'User could not be found'; + } + } + // check old passwords match -> error + if (!$this->login_error) { + $q = "SELECT edit_user_id, password " + . "FROM edit_user " + . "WHERE enabled = 1 " + . "AND username = '" . $this->db->dbEscapeString($this->pw_username) . "'"; + $edit_user_id = ''; + $res = $this->db->dbReturnRow($q); + if (is_array($res)) { + $edit_user_id = $res['edit_user_id']; + } + if ( + !is_array($res) || + empty($res['edit_user_id']) || + !$this->loginPasswordCheck( + $res['old_password_hash'], + $this->pw_old_password + ) + ) { + // old password wrong + $this->login_error = 202; + $data = 'The old password does not match'; + } + } + // check if new passwords were filled out -> error + if (!$this->login_error) { + if (!$this->pw_new_password || !$this->pw_new_password_confirm) { + $this->login_error = 203; + $data = 'Missing new password or new password confirm.'; + } + } + // check new passwords both match -> error + if (!$this->login_error) { + if ($this->pw_new_password != $this->pw_new_password_confirm) { + $this->login_error = 204; + $data = 'The new passwords do not match'; + } + } + // password shall match to something in minimum length or form + if (!$this->login_error) { + if (!$this->loginPasswordChangeValidPassword($this->pw_new_password)) { + $this->login_error = 205; + $data = 'The new password string is not valid'; + } + } + // no error change this users password + if (!$this->login_error && $edit_user_id) { + // update the user (edit_user_id) with the new password + $q = "UPDATE edit_user " + . "SET password = " + . "'" . $this->db->dbEscapeString(Password::passwordSet($this->pw_new_password)) . "' " + . "WHERE edit_user_id = " . $edit_user_id; + $this->db->dbExec($q); + $data = 'Password change for user "' . $this->pw_username . '"'; + $this->password_change_ok = true; + } + } else { + // illegal user error + $this->login_error = 220; + $data = 'Illegal user for password change: ' . $this->pw_username; + } + // log this password change attempt + $this->writeLog($event, $data, $this->login_error, $this->pw_username); + } + + /** + * creates the login html part if no permission (error) is set + * this does not print anything yet + * + * @return string|null html data for login page, or null for nothing + */ + private function loginCreateLoginHTML(): ?string + { + $html_string = null; + // if permission is ok, return null + if ($this->permission_okay) { + return $html_string; + } + // set the templates now + $this->loginSetTemplates(); + // if there is a global logout target ... + if (file_exists($this->logout_target)) { + $LOGOUT_TARGET = $this->logout_target; + } else { + $LOGOUT_TARGET = ''; + } + + $html_string = (string)$this->login_template['template']; + + $locales = $this->l->parseLocale($this->l->getLocale()); + $this->login_template['strings']['LANGUAGE'] = $locales['lang'] ?? 'en'; + + // if password change is okay + if ($this->password_change) { + $html_string_password_change = $this->login_template['password_change']; + + // pre change the data in the PASSWORD_CHANGE_DIV first + foreach ($this->login_template['strings'] as $string => $data) { + if ($data) { + $html_string_password_change = str_replace( + '{' . $string . '}', + $data, + $html_string_password_change + ); + } + } + // print error messagae + if ($this->login_error) { + $html_string_password_change = str_replace( + '{ERROR_MSG}', + $this->loginGetErrorMsg($this->login_error) . '
', + $html_string_password_change + ); + } else { + $html_string_password_change = str_replace( + '{ERROR_MSG}', + '
', + $html_string_password_change + ); + } + // if pw change action, show the float again + if ($this->change_password && !$this->password_change_ok) { + $html_string_password_change = str_replace( + '{PASSWORD_CHANGE_SHOW}', + '', + $html_string_password_change + ); + } else { + $html_string_password_change = str_replace( + '{PASSWORD_CHANGE_SHOW}', + '', + $html_string_password_change + ); + } + $this->login_template['strings']['PASSWORD_CHANGE_DIV'] = $html_string_password_change; + } + + // put in the logout redirect string + if ($this->logout && $LOGOUT_TARGET) { + $html_string = str_replace( + '{LOGOUT_TARGET}', + '', + $html_string + ); + } else { + $html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); + } + + // print error messagae + if ($this->login_error) { + $html_string = str_replace( + '{ERROR_MSG}', + $this->loginGetErrorMsg($this->login_error) . '
', + $html_string + ); + } elseif ($this->password_change_ok && $this->password_change) { + $html_string = str_replace( + '{ERROR_MSG}', + $this->loginGetErrorMsg(300) . '
', + $html_string + ); + } else { + $html_string = str_replace('{ERROR_MSG}', '
', $html_string); + } + + // create the replace array context + foreach ($this->login_template['strings'] as $string => $data) { + $html_string = str_replace('{' . $string . '}', $data, $html_string); + } + // return the created HTML here + return $html_string; + } + + /** + * last function called, writes log and prints out error msg and + * exists script if permission 0 + * + * @return bool true on permission ok, false on permission wrong + */ + private function loginCloseClass(): bool + { + // write to LOG table ... + if ($this->login_error || $this->login || $this->logout) { + $username = ''; + // $password = ''; + // set event + if ($this->login) { + $event = 'Login'; + } elseif ($this->logout) { + $event = 'Logout'; + } else { + $event = 'No Permission'; + } + // prepare for log + if ($this->euid) { + // get user from user table + $q = "SELECT username FROM edit_user WHERE edit_user_id = " . $this->euid; + $username = ''; + if (is_array($res = $this->db->dbReturnRow($q))) { + $username = $res['username']; + } + } // if euid is set, get username (or try) + $this->writeLog($event, '', $this->login_error, $username); + } // write log under certain settings + // now close DB connection + // $this->error_msg = $this->_login(); + if (!$this->permission_okay) { + return false; + } else { + return true; + } + } + + /** + * checks if there are external templates, if not uses internal fallback ones + * + * @return void has no return + */ + private function loginSetTemplates(): void + { + $strings = [ + 'HTML_TITLE' => $this->l->__('LOGIN'), + 'TITLE' => $this->l->__('LOGIN'), + 'USERNAME' => $this->l->__('Username'), + 'PASSWORD' => $this->l->__('Password'), + 'LOGIN' => $this->l->__('Login'), + 'ERROR_MSG' => '', + 'LOGOUT_TARGET' => '', + 'PASSWORD_CHANGE_BUTTON_VALUE' => $this->l->__('Change Password') + ]; + + // if password change is okay + if ($this->password_change) { + $strings = array_merge($strings, [ + 'TITLE_PASSWORD_CHANGE' => 'Change Password for User', + 'OLD_PASSWORD' => $this->l->__('Old Password'), + 'NEW_PASSWORD' => $this->l->__('New Password'), + 'NEW_PASSWORD_CONFIRM' => $this->l->__('New Password confirm'), + 'CLOSE' => $this->l->__('Close'), + 'JS_SHOW_HIDE' => "function ShowHideDiv(id) { " + . "element = document.getElementById(id); " + . "if (element.className == 'visible' || !element.className) element.className = 'hidden'; " + . "else element.className = 'visible'; }", + 'PASSWORD_CHANGE_BUTTON' => '' + ]); + // TODO: submit or JS to set target page as ajax call + // NOTE: for the HTML block I ignore line lengths + // phpcs:disable + $this->login_template['password_change'] = <<