Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93cb7e0cab | ||
|
|
7fbce6529b | ||
|
|
6e086fe7b3 | ||
|
|
0ec19d5b75 | ||
|
|
8134da349f | ||
|
|
8396f7856b | ||
|
|
b18866077e | ||
|
|
a66cc09095 | ||
|
|
1cfdc45107 | ||
|
|
07e46c91ab | ||
|
|
8aee448c59 | ||
|
|
37367db878 | ||
|
|
2d30d1d160 | ||
|
|
531229e8b7 | ||
|
|
d09c20ff9d | ||
|
|
f4ddc5a5fc | ||
|
|
1791ec3908 | ||
|
|
3d13f55c35 | ||
|
|
cf1989819a | ||
|
|
b302fb4053 | ||
|
|
32decdd037 | ||
|
|
46cda40d37 | ||
|
|
e71df90144 | ||
|
|
bbcc642fde | ||
|
|
558694aa6c | ||
|
|
f3bd09529a | ||
|
|
816bb7c9ee | ||
|
|
fc7b705355 | ||
|
|
7b96c1f9ca | ||
|
|
26c6ebcea7 | ||
|
|
32dee1692e | ||
|
|
6291ed88c0 | ||
|
|
5e21ead6fa | ||
|
|
07fbd13213 | ||
|
|
44b825310a | ||
|
|
2c234ccef6 | ||
|
|
b493b3c4fd | ||
|
|
e7dd96b5d9 | ||
|
|
bcde36ac17 | ||
|
|
8bde34ec7d | ||
|
|
a345d71306 | ||
|
|
0ff6294faa | ||
|
|
757d7ae01d | ||
|
|
4e78b21c67 | ||
|
|
d7e6434808 | ||
|
|
443cc2751d | ||
|
|
cf6500b55a | ||
|
|
09c2ec653f | ||
|
|
fc105f9295 | ||
|
|
053ab69330 | ||
|
|
fd079316f5 | ||
|
|
08664e9834 | ||
|
|
e063162161 | ||
|
|
7fbc449a5c | ||
|
|
72912c8c90 | ||
|
|
de2ed8be3d | ||
|
|
9d65f5d7c1 | ||
|
|
fbe827e989 | ||
|
|
c778a4eb81 | ||
|
|
ce1c72a0bc | ||
|
|
10319ef728 | ||
|
|
8d0036eaac | ||
|
|
d1e65c702e | ||
|
|
7248906da7 | ||
|
|
7f9a4dc04f | ||
|
|
10935214eb | ||
|
|
41e116f7d4 | ||
|
|
881c93c343 | ||
|
|
185d044a0b | ||
|
|
cc067cc202 | ||
|
|
37e2e54b2a | ||
|
|
711b3bfe97 | ||
|
|
3bd21c75d8 | ||
|
|
4971f62490 | ||
|
|
1cf4fdf31a | ||
|
|
d16b920966 | ||
|
|
545279b9fe |
43
.eslintrc.js
43
.eslintrc.js
@@ -1,43 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
'env': {
|
|
||||||
'browser': true,
|
|
||||||
'es6': true,
|
|
||||||
'commonjs': true,
|
|
||||||
'jquery': true
|
|
||||||
},
|
|
||||||
'extends': 'eslint:recommended',
|
|
||||||
'parserOptions': {
|
|
||||||
'ecmaVersion': 6
|
|
||||||
},
|
|
||||||
'rules': {
|
|
||||||
'indent': [
|
|
||||||
'error',
|
|
||||||
'tab',
|
|
||||||
{
|
|
||||||
'SwitchCase': 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'linebreak-style': [
|
|
||||||
'error',
|
|
||||||
'unix'
|
|
||||||
],
|
|
||||||
'quotes': [
|
|
||||||
'error',
|
|
||||||
'single'
|
|
||||||
],
|
|
||||||
'semi': [
|
|
||||||
'error',
|
|
||||||
'always'
|
|
||||||
],
|
|
||||||
'no-console': 'off',
|
|
||||||
'no-unused-vars': [
|
|
||||||
'error', {
|
|
||||||
'vars': 'all',
|
|
||||||
'args': 'after-used',
|
|
||||||
'ignoreRestSiblings': false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
// Requires eslint >= v8.14.0
|
|
||||||
'no-constant-binary-expression': 'error'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ vendor/
|
|||||||
tools/
|
tools/
|
||||||
www/composer.lock
|
www/composer.lock
|
||||||
www/vendor
|
www/vendor
|
||||||
|
**/.env
|
||||||
|
**/.target
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phive xmlns="https://phar.io/phive">
|
<phive xmlns="https://phar.io/phive">
|
||||||
<phar name="phpunit" version="^9.6" installed="9.6.21" location="./tools/phpunit" copy="false"/>
|
<phar name="phpunit" version="^10.3.5" installed="10.3.5" location="./tools/phpunit" copy="false"/>
|
||||||
<phar name="phpcbf" version="^3.7.2" installed="3.10.3" location="./tools/phpcbf" copy="false"/>
|
<phar name="phpcbf" version="^3.7.2" installed="3.10.3" location="./tools/phpcbf" copy="false"/>
|
||||||
<phar name="phpcs" version="^3.7.2" installed="3.10.3" location="./tools/phpcs" copy="false"/>
|
<phar name="phpcs" version="^3.10.3" installed="3.10.3" location="./tools/phpcs" copy="false"/>
|
||||||
<phar name="phpstan" version="^1.10.37" installed="1.12.4" location="./tools/phpstan" copy="false"/>
|
<phar name="phpstan" version="^2.0" installed="2.0.4" location="./tools/phpstan" copy="false"/>
|
||||||
<phar name="phan" version="^5.4.2" installed="5.4.3" location="./tools/phan" copy="false"/>
|
<phar name="phan" version="^5.4.3" installed="5.4.3" location="./tools/phan" copy="false"/>
|
||||||
<phar name="psalm" version="^5.15.0" installed="5.24.0" location="./tools/psalm" copy="false"/>
|
<phar name="psalm" version="^5.15.0" installed="5.24.0" location="./tools/psalm" copy="false"/>
|
||||||
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
||||||
<phar name="phpdocumentor" version="^3.4.2" installed="3.4.3" location="./tools/phpDocumentor" copy="false"/>
|
<phar name="phpdocumentor" version="^3.4.2" installed="3.4.3" location="./tools/phpDocumentor" copy="false"/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
# must be run in ${base}
|
# must be run in ${base}
|
||||||
cd $base;
|
cd $base || exit;
|
||||||
${base}tools/phan --progress-bar -C --analyze-twice;
|
${base}tools/phan --progress-bar -C --analyze-twice;
|
||||||
cd ~;
|
cd ~ || exit;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
# must be run in ${base}
|
# must be run in ${base}
|
||||||
cd $base;
|
cd $base || exit;
|
||||||
${base}tools/phpstan;
|
${base}tools/phpstan;
|
||||||
cd ~;
|
cd ~ || exit;
|
||||||
|
|||||||
@@ -1,49 +1,96 @@
|
|||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
function error() {
|
||||||
|
if [ -t 1 ]; then echo "[MAK] ERROR: $*" >&2; fi; exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-t] [-v] [-p VERSION]
|
||||||
|
|
||||||
|
Runs all the PHP unit tests.
|
||||||
|
|
||||||
|
If -p is not set, the default intalled PHP is used.
|
||||||
|
|
||||||
|
Available options:
|
||||||
|
|
||||||
|
-h, --help Print this help and exit
|
||||||
|
-t, --testdox Enable testdox output for phpunit
|
||||||
|
-v, --verbose Enable verbose output for PHPunit
|
||||||
|
-p, --php VERSION Chose PHP version in the form of "N.N", if not found will exit
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# set base variables
|
||||||
|
BASE_PATH="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
|
PHPUNIT_CONFIG="${BASE_PATH}phpunit.xml";
|
||||||
|
PHP_BIN_PATH=$(which php);
|
||||||
|
if [ -z "${PHP_BIN_PATH}" ]; then
|
||||||
|
echo "Cannot find php binary";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
|
DEFAULT_PHP_VERSION=$(${PHP_BIN_PATH} -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;");
|
||||||
|
if [ -z "${DEFAULT_PHP_VERSION}" ]; then
|
||||||
|
echo "Cannot set default PHP version";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
# -c phpunit.xml
|
# -c phpunit.xml
|
||||||
# --testdox
|
# --testdox
|
||||||
# call with "t" to give verbose testdox output
|
# call with "-tt" to give verbose testdox output
|
||||||
# SUPPORTED: https://www.php.net/supported-versions.php
|
# SUPPORTED: https://www.php.net/supported-versions.php
|
||||||
# call with php version number to force a certain php version
|
# call with -p <php version number> to force a certain php version
|
||||||
|
|
||||||
opt_testdox="";
|
opt_testdox="";
|
||||||
if [ "${1}" = "t" ] || [ "${2}" = "t" ]; then
|
opt_verbose="";
|
||||||
opt_testdox="--testdox";
|
php_version="";
|
||||||
fi;
|
no_php_version=0;
|
||||||
php_bin="";
|
while [ -n "${1-}" ]; do
|
||||||
if [ -n "${1}" ]; then
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
-t | --testdox)
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
opt_testdox="--testdox";
|
||||||
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
;;
|
||||||
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
-v | --verbose)
|
||||||
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
opt_verbose="--verbose";
|
||||||
"8.3") php_bin="/usr/bin/php8.4 "; ;;
|
;;
|
||||||
*) echo "Not support PHP: ${1}"; exit; ;;
|
-p | --php)
|
||||||
esac;
|
php_version="${2-}";
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
# invalid option
|
||||||
|
-?*)
|
||||||
|
error "[!] Unknown option: '$1'."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift;
|
||||||
|
done;
|
||||||
|
|
||||||
|
if [ -z "${php_version}" ]; then
|
||||||
|
php_version="${DEFAULT_PHP_VERSION}";
|
||||||
|
no_php_version=1;
|
||||||
fi;
|
fi;
|
||||||
if [ -n "${2}" ] && [ -z "${php_bin}" ]; then
|
php_bin="${PHP_BIN_PATH}${php_version}";
|
||||||
case "${2}" in
|
echo "Use PHP Version: ${php_version}";
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
if [ ! -f "${php_bin}" ]; then
|
||||||
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
echo "Set php ${php_bin} does not exist";
|
||||||
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
exit;
|
||||||
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
|
||||||
"8.3") php_bin="/usr/bin/php8.3 "; ;;
|
|
||||||
*) echo "Not support PHP: ${1}"; exit; ;;
|
|
||||||
esac;
|
|
||||||
fi;
|
fi;
|
||||||
|
php_bin="${php_bin} ";
|
||||||
|
|
||||||
# Note 4dev/tests/bootstrap.php has to be set as bootstrap file in phpunit.xml
|
# Note 4dev/tests/bootstrap.php has to be set as bootstrap file in phpunit.xml
|
||||||
phpunit_call="${php_bin}${base}vendor/bin/phpunit ${opt_testdox} -c ${base}phpunit.xml ${base}4dev/tests/";
|
phpunit_call="${php_bin}${BASE_PATH}vendor/bin/phpunit ${opt_testdox} ${opt_verbose} -c ${PHPUNIT_CONFIG} ${BASE_PATH}4dev/tests/";
|
||||||
|
|
||||||
${phpunit_call};
|
${phpunit_call};
|
||||||
|
|
||||||
if [ ! -z "${php_bin}" ]; then
|
echo -e "\nPHPUnit Config: ${PHPUNIT_CONFIG}";
|
||||||
echo "CALLED WITH PHP: ${php_bin}"$(${php_bin} --version);
|
if [ "${no_php_version}" -eq 0 ]; then
|
||||||
|
echo "CALLED WITH PHP: ${php_bin}$(${php_bin} --version)";
|
||||||
else
|
else
|
||||||
echo "Default PHP used: "$(php --version);
|
echo "Default PHP used: $(php --version)";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# __END__
|
# __END__
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ CREATE TABLE edit_log (
|
|||||||
edit_log_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
edit_log_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
euid INT, -- this is a foreign key, but I don't nedd to reference to it
|
euid INT, -- this is a foreign key, but I don't nedd to reference to it
|
||||||
FOREIGN KEY (euid) REFERENCES edit_user (edit_user_id) MATCH FULL ON UPDATE CASCADE ON DELETE SET NULL,
|
FOREIGN KEY (euid) REFERENCES edit_user (edit_user_id) MATCH FULL ON UPDATE CASCADE ON DELETE SET NULL,
|
||||||
ecuid VARCHAR,
|
eucuid VARCHAR,
|
||||||
ecuuid UUID, -- this is the one we want to use, full UUIDv4 from the edit user table
|
eucuuid UUID, -- this is the one we want to use, full UUIDv4 from the edit user table
|
||||||
-- date_created equal, but can be overridden
|
-- date_created equal, but can be overridden
|
||||||
event_date TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
event_date TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
-- session ID if set
|
-- session ID if set
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ header("Content-Type: application/json; charset=UTF-8");
|
|||||||
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
||||||
header("HTTP/1.1 401 Unauthorized");
|
header("HTTP/1.1 401 Unauthorized");
|
||||||
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if server request type is get set file_get to null -> no body
|
// if server request type is get set file_get to null -> no body
|
||||||
@@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|||||||
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
print buildContent($http_headers, $file_get);
|
print buildContent($http_headers, $file_get);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ Not yet covered tests:
|
|||||||
- loginGetLocale
|
- loginGetLocale
|
||||||
- loginGetHeaderColor
|
- loginGetHeaderColor
|
||||||
- loginGetPages
|
- loginGetPages
|
||||||
|
- loginGetPageLookupList
|
||||||
|
- loginPageAccessAllowed
|
||||||
- loginGetEuid
|
- loginGetEuid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -152,7 +154,6 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
// TARGET
|
// TARGET
|
||||||
define('TARGET', 'test');
|
define('TARGET', 'test');
|
||||||
// LOGIN DB SCHEMA
|
// LOGIN DB SCHEMA
|
||||||
// define('LOGIN_DB_SCHEMA', '');
|
|
||||||
|
|
||||||
// SHOULD SET
|
// SHOULD SET
|
||||||
// DEFAULT_ACL_LEVEL (d80)
|
// DEFAULT_ACL_LEVEL (d80)
|
||||||
@@ -1531,6 +1532,12 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
$login_mock->loginGetEditAccessCuidFromUid($mock_settings['edit_access_uid']),
|
$login_mock->loginGetEditAccessCuidFromUid($mock_settings['edit_access_uid']),
|
||||||
'Assert check access uid to cuid valid'
|
'Assert check access uid to cuid valid'
|
||||||
);
|
);
|
||||||
|
// - loginGetEditAccessCuidFromId
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected['check_access_cuid'],
|
||||||
|
$login_mock->loginGetEditAccessCuidFromUid($mock_settings['edit_access_id']),
|
||||||
|
'Assert check access id to cuid valid'
|
||||||
|
);
|
||||||
// Deprecated
|
// Deprecated
|
||||||
// - loginCheckEditAccess
|
// - loginCheckEditAccess
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
|||||||
@@ -652,8 +652,8 @@ CREATE TABLE edit_log (
|
|||||||
edit_log_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
edit_log_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
euid INT, -- this is a foreign key, but I don't nedd to reference to it
|
euid INT, -- this is a foreign key, but I don't nedd to reference to it
|
||||||
FOREIGN KEY (euid) REFERENCES edit_user (edit_user_id) MATCH FULL ON UPDATE CASCADE ON DELETE SET NULL,
|
FOREIGN KEY (euid) REFERENCES edit_user (edit_user_id) MATCH FULL ON UPDATE CASCADE ON DELETE SET NULL,
|
||||||
ecuid VARCHAR,
|
eucuid VARCHAR,
|
||||||
ecuuid UUID, -- this is the one we want to use, full UUIDv4 from the edit user table
|
eucuuid UUID, -- this is the one we want to use, full UUIDv4 from the edit user table
|
||||||
-- date_created equal, but can be overridden
|
-- date_created equal, but can be overridden
|
||||||
event_date TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
event_date TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
-- session ID if set
|
-- session ID if set
|
||||||
|
|||||||
@@ -1286,6 +1286,118 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* provider for arrayModifyKey
|
||||||
|
*
|
||||||
|
* @return array<string,array<mixed>>
|
||||||
|
*/
|
||||||
|
public function providerArrayModifyKey(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'prefix and suffix add' => [
|
||||||
|
'array' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
'c' => 'foobar',
|
||||||
|
],
|
||||||
|
'prefix' => 'Prefix: ',
|
||||||
|
'suffix' => '.suffix',
|
||||||
|
'expected' => [
|
||||||
|
'Prefix: a.suffix' => 'foo',
|
||||||
|
'Prefix: b.suffix' => 'bar',
|
||||||
|
'Prefix: c.suffix' => 'foobar',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'prefix add only' => [
|
||||||
|
'array' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
'c' => 'foobar',
|
||||||
|
],
|
||||||
|
'prefix' => 'Prefix: ',
|
||||||
|
'suffix' => '',
|
||||||
|
'expected' => [
|
||||||
|
'Prefix: a' => 'foo',
|
||||||
|
'Prefix: b' => 'bar',
|
||||||
|
'Prefix: c' => 'foobar',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'suffix add only' => [
|
||||||
|
'array' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
'c' => 'foobar',
|
||||||
|
],
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '.suffix',
|
||||||
|
'expected' => [
|
||||||
|
'a.suffix' => 'foo',
|
||||||
|
'b.suffix' => 'bar',
|
||||||
|
'c.suffix' => 'foobar',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'empty array' => [
|
||||||
|
'array' => [],
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '.suffix',
|
||||||
|
'expected' => [],
|
||||||
|
],
|
||||||
|
'no suffix or prefix' => [
|
||||||
|
'array' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
'c' => 'foobar',
|
||||||
|
],
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'expected' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
'c' => 'foobar',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'integer index mixed' => [
|
||||||
|
'array' => [
|
||||||
|
'a' => 'foo',
|
||||||
|
'b' => 'bar',
|
||||||
|
3 => 'foobar',
|
||||||
|
],
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '.suffix',
|
||||||
|
'expected' => [
|
||||||
|
'a.suffix' => 'foo',
|
||||||
|
'b.suffix' => 'bar',
|
||||||
|
'3.suffix' => 'foobar',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::arrayModifyKey
|
||||||
|
* @dataProvider providerArrayModifyKey
|
||||||
|
* @testdox arrayModifyKey check that key is correctly modified with $key_mod_prefix and $key_mod_suffix [$_dataName]
|
||||||
|
*
|
||||||
|
* @param array<mixed> $in_array
|
||||||
|
* @param string $key_mod_prefix
|
||||||
|
* @param string $key_mod_suffix
|
||||||
|
* @param array<mixed> $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testArrayModifyKey(
|
||||||
|
array $in_array,
|
||||||
|
string $key_mod_prefix,
|
||||||
|
string $key_mod_suffix,
|
||||||
|
array $expected
|
||||||
|
): void {
|
||||||
|
$this->assertEquals(
|
||||||
|
\CoreLibs\Combined\ArrayHandler::arrayModifyKey($in_array, $key_mod_prefix, $key_mod_suffix),
|
||||||
|
$expected
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -926,48 +926,114 @@ final class CoreLibsCombinedDateTimeTest extends TestCase
|
|||||||
public function daysIntervalProvider(): array
|
public function daysIntervalProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'valid interval /, not named array' => [
|
// normal and format tests
|
||||||
'2020/1/1',
|
'valid interval / not named array' => [
|
||||||
'2020/1/30',
|
'input_a' => '2020/1/1',
|
||||||
false,
|
'input_b' => '2020/1/30',
|
||||||
[29, 22, 8],
|
'return_named' => false, // return_named
|
||||||
|
'include_end_date' => true, // include_end_date
|
||||||
|
'exclude_start_date' => false, // exclude_start_date
|
||||||
|
'expected' => [30, 22, 8, false],
|
||||||
],
|
],
|
||||||
'valid interval /, named array' => [
|
'valid interval / named array' => [
|
||||||
'2020/1/1',
|
'input_a' => '2020/1/1',
|
||||||
'2020/1/30',
|
'input_b' => '2020/1/30',
|
||||||
true,
|
'return_named' => true,
|
||||||
['overall' => 29, 'weekday' => 22, 'weekend' => 8],
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => ['overall' => 30, 'weekday' => 22, 'weekend' => 8, 'reverse' => false],
|
||||||
],
|
],
|
||||||
'valid interval -' => [
|
'valid interval with "-"' => [
|
||||||
'2020-1-1',
|
'input_a' => '2020-1-1',
|
||||||
'2020-1-30',
|
'input_b' => '2020-1-30',
|
||||||
false,
|
'return_named' => false,
|
||||||
[29, 22, 8],
|
'include_end_date' => true,
|
||||||
],
|
'exclude_start_date' => false,
|
||||||
'valid interval switched' => [
|
'expected' => [30, 22, 8, false],
|
||||||
'2020/1/30',
|
|
||||||
'2020/1/1',
|
|
||||||
false,
|
|
||||||
[28, 0, 0],
|
|
||||||
],
|
],
|
||||||
'valid interval with time' => [
|
'valid interval with time' => [
|
||||||
'2020/1/1 12:12:12',
|
'input_a' => '2020/1/1 12:12:12',
|
||||||
'2020/1/30 13:13:13',
|
'input_b' => '2020/1/30 13:13:13',
|
||||||
false,
|
'return_named' => false,
|
||||||
[28, 21, 8],
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [30, 22, 8, false],
|
||||||
],
|
],
|
||||||
|
// invalid
|
||||||
'invalid dates' => [
|
'invalid dates' => [
|
||||||
'abc',
|
'input_a' => 'abc',
|
||||||
'xyz',
|
'input_b' => 'xyz',
|
||||||
false,
|
'return_named' => false,
|
||||||
[0, 0, 0]
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [0, 0, 0, false]
|
||||||
],
|
],
|
||||||
// this test will take a long imte
|
// this test will take a long time
|
||||||
'out of bound dates' => [
|
'out of bound dates' => [
|
||||||
'1900-1-1',
|
'input_a' => '1900-1-1',
|
||||||
'9999-12-31',
|
'input_b' => '9999-12-31',
|
||||||
false,
|
'return_named' => false,
|
||||||
[2958463,2113189,845274],
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [2958463, 2113189, 845274, false],
|
||||||
|
],
|
||||||
|
// tests for include/exclude
|
||||||
|
'exclude end date' => [
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => false,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [29, 21, 8, false],
|
||||||
|
],
|
||||||
|
'exclude start date' => [
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => true,
|
||||||
|
'expected' => [29, 21, 8, false],
|
||||||
|
],
|
||||||
|
'exclude start and end date' => [
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => false,
|
||||||
|
'exclude_start_date' => true,
|
||||||
|
'expected' => [28, 20, 8, false],
|
||||||
|
],
|
||||||
|
// reverse
|
||||||
|
'reverse: valid interval' => [
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [30, 22, 8, true],
|
||||||
|
],
|
||||||
|
'reverse: exclude end date' => [
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => false,
|
||||||
|
'exclude_start_date' => false,
|
||||||
|
'expected' => [29, 21, 8, true],
|
||||||
|
],
|
||||||
|
'reverse: exclude start date' => [
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => true,
|
||||||
|
'exclude_start_date' => true,
|
||||||
|
'expected' => [29, 21, 8, true],
|
||||||
|
],
|
||||||
|
'reverse: exclude start and end date' => [
|
||||||
|
'input_a' => '2020/1/30',
|
||||||
|
'input_b' => '2020/1/1',
|
||||||
|
'return_named' => false,
|
||||||
|
'include_end_date' => false,
|
||||||
|
'exclude_start_date' => true,
|
||||||
|
'expected' => [28, 20, 8, true],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -982,20 +1048,52 @@ final class CoreLibsCombinedDateTimeTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @param string $input_a
|
* @param string $input_a
|
||||||
* @param string $input_b
|
* @param string $input_b
|
||||||
* @param bool $flag
|
* @param bool $return_named
|
||||||
* @param array $expected
|
* @param array $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCalcDaysInterval(
|
public function testCalcDaysInterval(
|
||||||
string $input_a,
|
string $input_a,
|
||||||
string $input_b,
|
string $input_b,
|
||||||
bool $flag,
|
bool $return_named,
|
||||||
|
bool $include_end_date,
|
||||||
|
bool $exclude_start_date,
|
||||||
$expected
|
$expected
|
||||||
): void {
|
): void {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Combined\DateTime::calcDaysInterval($input_a, $input_b, $flag)
|
\CoreLibs\Combined\DateTime::calcDaysInterval(
|
||||||
|
$input_a,
|
||||||
|
$input_b,
|
||||||
|
return_named:$return_named,
|
||||||
|
include_end_date:$include_end_date,
|
||||||
|
exclude_start_date:$exclude_start_date
|
||||||
|
),
|
||||||
|
'call calcDaysInterval'
|
||||||
);
|
);
|
||||||
|
if ($return_named) {
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Combined\DateTime::calcDaysIntervalNamedIndex(
|
||||||
|
$input_a,
|
||||||
|
$input_b,
|
||||||
|
include_end_date:$include_end_date,
|
||||||
|
exclude_start_date:$exclude_start_date
|
||||||
|
),
|
||||||
|
'call calcDaysIntervalNamedIndex'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Combined\DateTime::calcDaysIntervalNumIndex(
|
||||||
|
$input_a,
|
||||||
|
$input_b,
|
||||||
|
include_end_date:$include_end_date,
|
||||||
|
exclude_start_date:$exclude_start_date
|
||||||
|
),
|
||||||
|
'call calcDaysIntervalNamedIndex'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1187,7 +1285,38 @@ final class CoreLibsCombinedDateTimeTest extends TestCase
|
|||||||
'2023-07-03',
|
'2023-07-03',
|
||||||
'2023-07-27',
|
'2023-07-27',
|
||||||
true
|
true
|
||||||
]
|
],
|
||||||
|
// reverse
|
||||||
|
'reverse: no weekend' => [
|
||||||
|
'2023-07-04',
|
||||||
|
'2023-07-03',
|
||||||
|
false
|
||||||
|
],
|
||||||
|
'reverse: start weekend sat' => [
|
||||||
|
'2023-07-04',
|
||||||
|
'2023-07-01',
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'reverse: start weekend sun' => [
|
||||||
|
'2023-07-04',
|
||||||
|
'2023-07-02',
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'reverse: end weekend sat' => [
|
||||||
|
'2023-07-08',
|
||||||
|
'2023-07-03',
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'reverse: end weekend sun' => [
|
||||||
|
'2023-07-09',
|
||||||
|
'2023-07-03',
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'reverse: long period > 6 days' => [
|
||||||
|
'2023-07-27',
|
||||||
|
'2023-07-03',
|
||||||
|
true
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ final class CoreLibsConvertByteTest extends TestCase
|
|||||||
4 => '1.00 KB',
|
4 => '1.00 KB',
|
||||||
5 => '1.02KiB',
|
5 => '1.02KiB',
|
||||||
],
|
],
|
||||||
'invalud string number' => [
|
'invalid string number' => [
|
||||||
0 => '1024 MB',
|
0 => '1024 MB',
|
||||||
1 => '1024 MB',
|
1 => '1024 MB',
|
||||||
2 => '1024 MB',
|
2 => '1024 MB',
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
public function hashData(): array
|
public function hashData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'any string' => [
|
'hash tests' => [
|
||||||
|
// this is the string
|
||||||
'text' => 'Some String Text',
|
'text' => 'Some String Text',
|
||||||
|
// hash list special
|
||||||
'crc32b_reverse' => 'c5c21d91', // crc32b (in revere)
|
'crc32b_reverse' => 'c5c21d91', // crc32b (in revere)
|
||||||
'sha1Short' => '4d2bc9ba0', // sha1Short
|
'sha1Short' => '4d2bc9ba0', // sha1Short
|
||||||
// via hash
|
// via hash
|
||||||
@@ -31,6 +33,8 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
'fnv132' => '9df444f9', // hash: fnv132
|
'fnv132' => '9df444f9', // hash: fnv132
|
||||||
'fnv1a32' => '2c5f91b9', // hash: fnv1a32
|
'fnv1a32' => '2c5f91b9', // hash: fnv1a32
|
||||||
'joaat' => '50dab846', // hash: joaat
|
'joaat' => '50dab846', // hash: joaat
|
||||||
|
'ripemd160' => 'aeae3f041b20136451519edd9361570909300342', // hash: ripemd160,
|
||||||
|
'sha256' => '9055080e022f224fa835929b80582b3c71c672206fa3a49a87412c25d9d42ceb', // hash: sha256
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -81,7 +85,7 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
foreach ($this->hashData() as $name => $values) {
|
foreach ($this->hashData() as $name => $values) {
|
||||||
foreach ([null, 'crc32b', 'adler32', 'fnv132', 'fnv1a32', 'joaat'] as $_hash_type) {
|
foreach ([null, 'crc32b', 'adler32', 'fnv132', 'fnv1a32', 'joaat', 'ripemd160', 'sha256'] as $_hash_type) {
|
||||||
// default value test
|
// default value test
|
||||||
if ($_hash_type === null) {
|
if ($_hash_type === null) {
|
||||||
$hash_type = \CoreLibs\Create\Hash::STANDARD_HASH_SHORT;
|
$hash_type = \CoreLibs\Create\Hash::STANDARD_HASH_SHORT;
|
||||||
@@ -114,6 +118,22 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function hashStandardProvider(): array
|
||||||
|
{
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
return [
|
||||||
|
'Long Hash check: ' . \CoreLibs\Create\Hash::STANDARD_HASH => [
|
||||||
|
$hash_source,
|
||||||
|
hash(\CoreLibs\Create\Hash::STANDARD_HASH, $hash_source)
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -136,9 +156,13 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
|
* phpcs:disable Generic.Files.LineLength
|
||||||
* @covers ::__sha1Short
|
* @covers ::__sha1Short
|
||||||
|
* @covers ::__crc32b
|
||||||
|
* @covers ::sha1Short
|
||||||
* @dataProvider sha1ShortProvider
|
* @dataProvider sha1ShortProvider
|
||||||
* @testdox __sha1Short $input will be $expected (crc32b) and $expected_sha1 (sha1 short) [$_dataName]
|
* @testdox __sha1Short/__crc32b/sha1short $input will be $expected (crc32b) and $expected_sha1 (sha1 short) [$_dataName]
|
||||||
|
* phpcs:enable Generic.Files.LineLength
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
@@ -149,16 +173,29 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
// uses crc32b
|
// uses crc32b
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input)
|
\CoreLibs\Create\Hash::__sha1Short($input),
|
||||||
|
'__sha1Short depreacted'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input, false)
|
\CoreLibs\Create\Hash::__sha1Short($input, false),
|
||||||
|
'__sha1Short (false) depreacted'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::__crc32b($input),
|
||||||
|
'__crc32b'
|
||||||
);
|
);
|
||||||
// sha1 type
|
// sha1 type
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected_sha1,
|
$expected_sha1,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input, true)
|
\CoreLibs\Create\Hash::__sha1Short($input, true),
|
||||||
|
'__sha1Short (true) depreacted'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected_sha1,
|
||||||
|
\CoreLibs\Create\Hash::sha1Short($input),
|
||||||
|
'sha1Short'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,8 +203,10 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::__hash
|
* @covers ::__hash
|
||||||
|
* @covers ::hashShort
|
||||||
|
* @covers ::hashShort
|
||||||
* @dataProvider hashProvider
|
* @dataProvider hashProvider
|
||||||
* @testdox __hash $input with $hash_type will be $expected [$_dataName]
|
* @testdox __hash/hashShort/hash $input with $hash_type will be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string|null $hash_type
|
* @param string|null $hash_type
|
||||||
@@ -179,12 +218,24 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
if ($hash_type === null) {
|
if ($hash_type === null) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hash($input)
|
\CoreLibs\Create\Hash::__hash($input),
|
||||||
|
'__hash'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashShort($input),
|
||||||
|
'hashShort'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hash($input, $hash_type)
|
\CoreLibs\Create\Hash::__hash($input, $hash_type),
|
||||||
|
'__hash with hash type'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($input, $hash_type),
|
||||||
|
'hash with hash type'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,8 +244,9 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::__hashLong
|
* @covers ::__hashLong
|
||||||
|
* @covers ::hashLong
|
||||||
* @dataProvider hashLongProvider
|
* @dataProvider hashLongProvider
|
||||||
* @testdox __hashLong $input will be $expected [$_dataName]
|
* @testdox __hashLong/hashLong $input will be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
@@ -206,6 +258,168 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hashLong($input)
|
\CoreLibs\Create\Hash::__hashLong($input)
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashLong($input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::hash
|
||||||
|
* @covers ::hashStd
|
||||||
|
* @dataProvider hashStandardProvider
|
||||||
|
* @testdox hash/hashStd $input will be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testHashStandard(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashStd($input)
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::hash
|
||||||
|
* @testdox hash with invalid type
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalidHashType(): void
|
||||||
|
{
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
$expected = hash(\CoreLibs\Create\Hash::STANDARD_HASH, $hash_source);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($hash_source, 'DOES_NOT_EXIST')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: this only tests default sha256
|
||||||
|
*
|
||||||
|
* @covers ::hashHmac
|
||||||
|
* @testdox hash hmac test
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testHashMac(): void
|
||||||
|
{
|
||||||
|
$hash_key = 'FIX KEY';
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
$expected = '16479b3ef6fa44e1cdd8b2dcfaadf314d1a7763635e8738f1e7996d714d9b6bf';
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashHmac($hash_source, $hash_key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::hashHmac
|
||||||
|
* @testdox hash hmac with invalid type
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalidHashMacType(): void
|
||||||
|
{
|
||||||
|
$hash_key = 'FIX KEY';
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
$expected = hash_hmac(\CoreLibs\Create\Hash::STANDARD_HASH, $hash_source, $hash_key);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashHmac($hash_source, $hash_key, 'DOES_NOT_EXIST')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public function providerHashTypes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Hash crc32b' => [
|
||||||
|
'crc32b',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
'Hash adler32' => [
|
||||||
|
'adler32',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
'HAsh fnv132' => [
|
||||||
|
'fnv132',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
'Hash fnv1a32' => [
|
||||||
|
'fnv1a32',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
'Hash: joaat' => [
|
||||||
|
'joaat',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
'Hash: ripemd160' => [
|
||||||
|
'ripemd160',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
'Hash: sha256' => [
|
||||||
|
'sha256',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
'Hash: invalid' => [
|
||||||
|
'invalid',
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::isValidHashType
|
||||||
|
* @covers ::isValidHashHmacType
|
||||||
|
* @dataProvider providerHashTypes
|
||||||
|
* @testdox check if $hash_type is valid for hash $hash_ok and hash hmac $hash_hmac_ok [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $hash_type
|
||||||
|
* @param bool $hash_ok
|
||||||
|
* @param bool $hash_hmac_ok
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testIsValidHashAndHashHmacTypes(string $hash_type, bool $hash_ok, bool $hash_hmac_ok): void
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
$hash_ok,
|
||||||
|
\CoreLibs\Create\Hash::isValidHashType($hash_type),
|
||||||
|
'hash valid'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$hash_hmac_ok,
|
||||||
|
\CoreLibs\Create\Hash::isValidHashHmacType($hash_type),
|
||||||
|
'hash hmac valid'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
// check if they already exist, drop them
|
// check if they already exist, drop them
|
||||||
if ($db->dbShowTableMetaData('table_with_primary_key') !== false) {
|
if ($db->dbShowTableMetaData('table_with_primary_key') !== false) {
|
||||||
|
$db->dbExec("CREATE EXTENSION IF NOT EXISTS pgcrypto");
|
||||||
$db->dbExec("DROP TABLE table_with_primary_key");
|
$db->dbExec("DROP TABLE table_with_primary_key");
|
||||||
$db->dbExec("DROP TABLE table_without_primary_key");
|
$db->dbExec("DROP TABLE table_without_primary_key");
|
||||||
$db->dbExec("DROP TABLE test_meta");
|
$db->dbExec("DROP TABLE test_meta");
|
||||||
@@ -3692,7 +3693,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preparedProviderValue(): array
|
public function providerDbGetPrepareCursorValue(): array
|
||||||
{
|
{
|
||||||
// 1: query (can be empty for do not set)
|
// 1: query (can be empty for do not set)
|
||||||
// 2: stm name
|
// 2: stm name
|
||||||
@@ -3736,7 +3737,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
* test return prepare cursor errors
|
* test return prepare cursor errors
|
||||||
*
|
*
|
||||||
* @covers ::dbGetPrepareCursorValue
|
* @covers ::dbGetPrepareCursorValue
|
||||||
* @dataProvider preparedProviderValue
|
* @dataProvider providerDbGetPrepareCursorValue
|
||||||
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
@@ -3769,6 +3770,94 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerDbPreparedCursorStatus(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'empty statement pararm' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_a',
|
||||||
|
'check_stm_name' => '',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => false
|
||||||
|
],
|
||||||
|
'different stm_name' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_b',
|
||||||
|
'check_stm_name' => 'other_name',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => 0
|
||||||
|
],
|
||||||
|
'same stm_name' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_c',
|
||||||
|
'check_stm_name' => 'test_stm_c',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => 1
|
||||||
|
],
|
||||||
|
'same stm_name and query' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_d',
|
||||||
|
'check_stm_name' => 'test_stm_d',
|
||||||
|
'check_query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'expected' => 2
|
||||||
|
],
|
||||||
|
'same stm_name and different query' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_e',
|
||||||
|
'check_stm_name' => 'test_stm_e',
|
||||||
|
'check_query' => 'SELECT row_int, uid, row_int FROM table_with_primary_key',
|
||||||
|
'expected' => 1
|
||||||
|
],
|
||||||
|
'insert query test' => [
|
||||||
|
'query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||||
|
'stm_name' => 'test_stm_f',
|
||||||
|
'check_stm_name' => 'test_stm_f',
|
||||||
|
'check_query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||||
|
'expected' => 2
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test cursor status for prepared statement
|
||||||
|
*
|
||||||
|
* @covers ::dbPreparedCursorStatus
|
||||||
|
* @dataProvider providerDbPreparedCursorStatus
|
||||||
|
* @testdox Check prepared $stm_name ($check_stm_name) status is $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $query
|
||||||
|
* @param string $stm_name
|
||||||
|
* @param string $check_stm_name
|
||||||
|
* @param string $check_query
|
||||||
|
* @param bool|int $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDbPreparedCursorStatus(
|
||||||
|
string $query,
|
||||||
|
string $stm_name,
|
||||||
|
string $check_stm_name,
|
||||||
|
string $check_query,
|
||||||
|
bool|int $expected
|
||||||
|
): void {
|
||||||
|
$db = new \CoreLibs\DB\IO(
|
||||||
|
self::$db_config['valid'],
|
||||||
|
self::$log
|
||||||
|
);
|
||||||
|
$db->dbPrepare($stm_name, $query);
|
||||||
|
// $db->dbExecute($stm_name);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$db->dbPreparedCursorStatus($check_stm_name, $check_query),
|
||||||
|
'check prepared stement cursor status'
|
||||||
|
);
|
||||||
|
unset($db);
|
||||||
|
}
|
||||||
|
|
||||||
// - schema set/get tests
|
// - schema set/get tests
|
||||||
// dbGetSchema, dbSetSchema
|
// dbGetSchema, dbSetSchema
|
||||||
|
|
||||||
@@ -4656,7 +4745,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$res = $db->dbReturnRowParams($query_select, ['CONVERT_TYPE_TEST']);
|
$res = $db->dbReturnRowParams($query_select, ['CONVERT_TYPE_TEST']);
|
||||||
// all hast to be string
|
// all hast to be string
|
||||||
foreach ($res as $key => $value) {
|
foreach ($res as $key => $value) {
|
||||||
$this->assertIsString($value, 'Aseert string for column: ' . $key);
|
$this->assertIsString($value, 'Assert string for column: ' . $key);
|
||||||
}
|
}
|
||||||
// convert base only
|
// convert base only
|
||||||
$db->dbSetConvertFlag(Convert::on);
|
$db->dbSetConvertFlag(Convert::on);
|
||||||
@@ -4669,10 +4758,10 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
switch ($type_layout[$name]) {
|
switch ($type_layout[$name]) {
|
||||||
case 'int':
|
case 'int':
|
||||||
$this->assertIsInt($value, 'Aseert int for column: ' . $key . '/' . $name);
|
$this->assertIsInt($value, 'Assert int for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->assertIsString($value, 'Aseert string for column: ' . $key . '/' . $name);
|
$this->assertIsString($value, 'Assert string for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4686,13 +4775,13 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
switch ($type_layout[$name]) {
|
switch ($type_layout[$name]) {
|
||||||
case 'int':
|
case 'int':
|
||||||
$this->assertIsInt($value, 'Aseert int for column: ' . $key . '/' . $name);
|
$this->assertIsInt($value, 'Assert int for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
$this->assertIsFloat($value, 'Aseert float for column: ' . $key . '/' . $name);
|
$this->assertIsFloat($value, 'Assert float for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->assertIsString($value, 'Aseert string for column: ' . $key . '/' . $name);
|
$this->assertIsString($value, 'Assert string for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4706,17 +4795,17 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
switch ($type_layout[$name]) {
|
switch ($type_layout[$name]) {
|
||||||
case 'int':
|
case 'int':
|
||||||
$this->assertIsInt($value, 'Aseert int for column: ' . $key . '/' . $name);
|
$this->assertIsInt($value, 'Assert int for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
$this->assertIsFloat($value, 'Aseert float for column: ' . $key . '/' . $name);
|
$this->assertIsFloat($value, 'Assert float for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
case 'jsonb':
|
case 'jsonb':
|
||||||
$this->assertIsArray($value, 'Aseert array for column: ' . $key . '/' . $name);
|
$this->assertIsArray($value, 'Assert array for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->assertIsString($value, 'Aseert string for column: ' . $key . '/' . $name);
|
$this->assertIsString($value, 'Assert string for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4730,25 +4819,25 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
}
|
}
|
||||||
switch ($type_layout[$name]) {
|
switch ($type_layout[$name]) {
|
||||||
case 'int':
|
case 'int':
|
||||||
$this->assertIsInt($value, 'Aseert int for column: ' . $key . '/' . $name);
|
$this->assertIsInt($value, 'Assert int for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
$this->assertIsFloat($value, 'Aseert float for column: ' . $key . '/' . $name);
|
$this->assertIsFloat($value, 'Assert float for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
case 'jsonb':
|
case 'jsonb':
|
||||||
$this->assertIsArray($value, 'Aseert array for column: ' . $key . '/' . $name);
|
$this->assertIsArray($value, 'Assert array for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
case 'bytea':
|
case 'bytea':
|
||||||
// for hex types it must not start with \x
|
// for hex types it must not start with \x
|
||||||
$this->assertStringStartsNotWith(
|
$this->assertStringStartsNotWith(
|
||||||
'\x',
|
'\x',
|
||||||
$value,
|
$value,
|
||||||
'Aseert bytes not starts with \x for column: ' . $key . '/' . $name
|
'Assert bytes not starts with \x for column: ' . $key . '/' . $name
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->assertIsString($value, 'Aseert string for column: ' . $key . '/' . $name);
|
$this->assertIsString($value, 'Assert string for column: ' . $key . '/' . $name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4920,8 +5009,8 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
($params === null ?
|
($params === null ?
|
||||||
$db->dbGetQueryHash($query) :
|
$db->dbBuildQueryHash($query) :
|
||||||
$db->dbGetQueryHash($query, $params)
|
$db->dbBuildQueryHash($query, $params)
|
||||||
),
|
),
|
||||||
'Failed assertdbGetQueryHash '
|
'Failed assertdbGetQueryHash '
|
||||||
);
|
);
|
||||||
@@ -5147,6 +5236,9 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$3
|
$3
|
||||||
-- comment 3
|
-- comment 3
|
||||||
, $4
|
, $4
|
||||||
|
-- ignore $5, $6
|
||||||
|
-- $7, $8
|
||||||
|
-- digest($9, 10)
|
||||||
)
|
)
|
||||||
SQL,
|
SQL,
|
||||||
'count' => 4,
|
'count' => 4,
|
||||||
@@ -5196,8 +5288,78 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
SQL,
|
SQL,
|
||||||
'count' => 1,
|
'count' => 1,
|
||||||
'convert' => false,
|
'convert' => false,
|
||||||
|
],
|
||||||
|
'update with case' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
UPDATE table_with_primary_key SET
|
||||||
|
row_int = $1::INT,
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $2 ELSE 'bar'::VARCHAR END
|
||||||
|
WHERE
|
||||||
|
row_varchar = $3
|
||||||
|
SQL,
|
||||||
|
'count' => 3,
|
||||||
|
'convert' => false,
|
||||||
|
],
|
||||||
|
'select with case' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
SELECT row_int
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $1 ELSE $2 END
|
||||||
|
SQL,
|
||||||
|
'count' => 2,
|
||||||
|
'convert' => false,
|
||||||
|
],
|
||||||
|
// special $$ string case
|
||||||
|
'text string, with $ placehoders that could be seen as $$ string' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
SELECT row_int
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE
|
||||||
|
row_bytea = digest($3::VARCHAR, $4) OR
|
||||||
|
row_varchar = encode(digest($3, $4), 'hex') OR
|
||||||
|
row_bytea = hmac($3, $5, $4) OR
|
||||||
|
row_varchar = encode(hmac($3, $5, $4), 'hex') OR
|
||||||
|
row_bytea = pgp_sym_encrypt($3, $6) OR
|
||||||
|
row_varchar = encode(pgp_sym_encrypt($1, $6), 'hex') OR
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $1 ELSE $2 END
|
||||||
|
SQL,
|
||||||
|
'count' => 6,
|
||||||
|
'convert' => false,
|
||||||
|
],
|
||||||
|
// NOTE, in SQL heredoc we cannot write $$ strings parts
|
||||||
|
'text string, with $ placehoders are in $$ strings' => [
|
||||||
|
'query' => '
|
||||||
|
SELECT row_int
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE
|
||||||
|
row_varchar = $$some string$$ OR
|
||||||
|
row_varchar = $tag$some string$tag$ OR
|
||||||
|
row_varchar = $btag$some $1 string$btag$ OR
|
||||||
|
row_varchar = $btag$some $1 $subtag$ something $subtag$string$btag$ OR
|
||||||
|
row_varchar = $1
|
||||||
|
',
|
||||||
|
'count' => 1,
|
||||||
|
'convert' => false,
|
||||||
|
],
|
||||||
|
// a text string with escaped quite
|
||||||
|
'text string, with escaped quote' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
SELECT row_int
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE
|
||||||
|
row_varchar = 'foo bar bar baz $5' OR
|
||||||
|
row_varchar = 'foo bar '' barbar $6' OR
|
||||||
|
row_varchar = E'foo bar \' barbar $7' OR
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $1 ELSE $2 END
|
||||||
|
SQL,
|
||||||
|
'count' => 2,
|
||||||
|
'convert' => false,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
$string = <<<SQL
|
||||||
|
'''
|
||||||
|
SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
|
|||||||
}
|
}
|
||||||
$per_run_id = $log->getLogUniqueId();
|
$per_run_id = $log->getLogUniqueId();
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
"/^\d{4}-\d{2}-\d{2}_\d{6}_U_[a-z0-9]{8}$/",
|
"/^\d{4}-\d{2}-\d{2}_\d{6}\.U_[a-z0-9]{8}$/",
|
||||||
$per_run_id,
|
$per_run_id,
|
||||||
'assert per log run id 1st'
|
'assert per log run id 1st'
|
||||||
);
|
);
|
||||||
@@ -403,7 +403,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
|
|||||||
$log->setLogUniqueId(true);
|
$log->setLogUniqueId(true);
|
||||||
$per_run_id_2nd = $log->getLogUniqueId();
|
$per_run_id_2nd = $log->getLogUniqueId();
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
"/^\d{4}-\d{2}-\d{2}_\d{6}_U_[a-z0-9]{8}$/",
|
"/^\d{4}-\d{2}-\d{2}_\d{6}\.U_[a-z0-9]{8}$/",
|
||||||
$per_run_id_2nd,
|
$per_run_id_2nd,
|
||||||
'assert per log run id 2nd'
|
'assert per log run id 2nd'
|
||||||
);
|
);
|
||||||
@@ -824,13 +824,13 @@ final class CoreLibsLoggingLoggingTest extends TestCase
|
|||||||
$this->assertTrue($log_ok, 'assert ::log (debug) OK');
|
$this->assertTrue($log_ok, 'assert ::log (debug) OK');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$log->getLogFile(),
|
$log->getLogFile(),
|
||||||
$log->getLogFileId() . '_DEBUG.log'
|
$log->getLogFileId() . '.DEBUG.log'
|
||||||
);
|
);
|
||||||
$log_ok = $log->log(Level::Info, 'INFO', group_id: 'GROUP_ID', prefix: 'PREFIX:');
|
$log_ok = $log->log(Level::Info, 'INFO', group_id: 'GROUP_ID', prefix: 'PREFIX:');
|
||||||
$this->assertTrue($log_ok, 'assert ::log (info) OK');
|
$this->assertTrue($log_ok, 'assert ::log (info) OK');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$log->getLogFile(),
|
$log->getLogFile(),
|
||||||
$log->getLogFileId() . '_INFO.log'
|
$log->getLogFileId() . '.INFO.log'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,838 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace tests;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use CoreLibs\Security\CreateKey;
|
||||||
|
use CoreLibs\Security\AsymmetricAnonymousEncryption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for Security\AsymmetricAnonymousEncryption and Security\CreateKey
|
||||||
|
* @coversDefaultClass \CoreLibs\Security\AsymmetricAnonymousEncryption
|
||||||
|
* @testdox \CoreLibs\Security\AsymmetricAnonymousEncryption method tests
|
||||||
|
*/
|
||||||
|
final class CoreLibsSecurityAsymmetricAnonymousEncryptionTest extends TestCase
|
||||||
|
{
|
||||||
|
// MARK: key set and compare
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::compareKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if init class set key pair matches to created key pair and public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeyPairInitGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'set key pair not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'automatic set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key_pair,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'set key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'automatic set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::compareKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if init class set key pair and public key matches to created key pair and public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeyPairPublicKeyInitGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair, $public_key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'set key pair not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key_pair,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'set key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if init class set public key matches to created public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testPublicKeyInitGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption(public_key:$public_key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
null,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'unset set key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::setKeyPair
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::compareKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if set key pair after class init matches to created key pair and public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeyPairSetGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption();
|
||||||
|
$crypt->setKeyPair($key_pair);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'post class init set key pair not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'post class init automatic set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key_pair,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'post class init set key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'post class init automatic set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::setKeyPair
|
||||||
|
* @covers ::setPublicKey
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::compareKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if set key pair after class init matches to created key pair and public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeyPairPublicKeySetGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption();
|
||||||
|
$crypt->setKeyPair($key_pair);
|
||||||
|
$crypt->setPublicKey($public_key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'post class init set key pair not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'post class init set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key_pair,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'post class init set key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'post class init set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::setPublicKey
|
||||||
|
* @covers ::getKeyPair
|
||||||
|
* @covers ::compareKeyPair
|
||||||
|
* @covers ::getPublicKey
|
||||||
|
* @covers ::comparePublicKey
|
||||||
|
* @testdox Check if set key pair after class init matches to created key pair and public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testPublicKeySetGetCompare(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption();
|
||||||
|
$crypt->setPublicKey($public_key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'post class init set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
null,
|
||||||
|
$crypt->getKeyPair(),
|
||||||
|
'post class init unset key pair returned not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$public_key,
|
||||||
|
$crypt->getPublicKey(),
|
||||||
|
'post class init set public key returned not equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @testdox Check different key pair and public key set
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDifferentSetKeyPairPublicKey()
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$key_pair_2 = CreateKey::createKeyPair();
|
||||||
|
$public_key_2 = CreateKey::getPublicKey($key_pair_2);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair, $public_key_2);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'key pair set matches key pair created'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key_2),
|
||||||
|
'alternate public key set matches alternate public key created'
|
||||||
|
);
|
||||||
|
$this->assertFalse(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'alternate public key set does not match key pair public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @testdox Check if new set privat key does not overwrite set public key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testUpdateKeyPairNotUpdatePublicKey(): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair),
|
||||||
|
'set key pair not equal to original key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$key_pair_2 = CreateKey::createKeyPair();
|
||||||
|
$public_key_2 = CreateKey::getPublicKey($key_pair_2);
|
||||||
|
$crypt->setKeyPair($key_pair_2);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKeyPair($key_pair_2),
|
||||||
|
'new set key pair not equal to original new key pair'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->comparePublicKey($public_key),
|
||||||
|
'original set public key not equal to original public key'
|
||||||
|
);
|
||||||
|
$this->assertFalse(
|
||||||
|
$crypt->comparePublicKey($public_key_2),
|
||||||
|
'new public key equal to original public key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: empty encrytped string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::decryptKey
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @testdox Test empty encrypted string to decrypt
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEmptyDecryptionString(): void
|
||||||
|
{
|
||||||
|
$this->expectExceptionMessage('Encrypted string cannot be empty');
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey('', CreateKey::generateRandomKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: encrypt/decrypt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerEncryptDecryptSuccess(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'valid string' => [
|
||||||
|
'input' => 'I am a secret',
|
||||||
|
'expected' => 'I am a secret',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test encrypt/decrypt produce correct output
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptDecryptSuccess
|
||||||
|
* @testdox encrypt/decrypt $input must be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptDecryptSuccess(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
// test class
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class call',
|
||||||
|
);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair, $public_key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class call botjh set',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test encrypt/decrypt produce correct output
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptDecryptSuccess
|
||||||
|
* @testdox encrypt/decrypt indirect $input must be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptDecryptSuccessIndirect(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
// test indirect
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::getInstance(public_key:$public_key)->encrypt($input);
|
||||||
|
$decrypted = AsymmetricAnonymousEncryption::getInstance($key_pair)->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class Instance call',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test encrypt/decrypt produce correct output
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptDecryptSuccess
|
||||||
|
* @testdox encrypt/decrypt indirect with public key $input must be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptDecryptSuccessIndirectPublicKey(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
// test indirect
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::getInstance(public_key:$public_key)->encrypt($input);
|
||||||
|
$decrypted = AsymmetricAnonymousEncryption::getInstance($key_pair)->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class Instance call public key',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test encrypt/decrypt produce correct output
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptDecryptSuccess
|
||||||
|
* @testdox encrypt/decrypt static $input must be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptDecryptSuccessStatic(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
// test static
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::encryptKey($input, $public_key);
|
||||||
|
$decrypted = AsymmetricAnonymousEncryption::decryptKey($encrypted, $key_pair);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Static call',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: invalid decrypt key
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerEncryptFailed(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'wrong decryption key' => [
|
||||||
|
'input' => 'I am a secret',
|
||||||
|
'excpetion_message' => 'Invalid key pair'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test decryption with wrong key
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptFailed
|
||||||
|
* @testdox decrypt with wrong key $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptFailed(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$wrong_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// wrong key in class call
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption(public_key:$public_key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->setKeyPair($wrong_key_pair);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test decryption with wrong key
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptFailed
|
||||||
|
* @testdox decrypt indirect with wrong key $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptFailedIndirect(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$wrong_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::getInstance(public_key:$public_key)->encrypt($input);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::getInstance($wrong_key_pair)->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test decryption with wrong key
|
||||||
|
*
|
||||||
|
* @covers ::generateRandomKey
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerEncryptFailed
|
||||||
|
* @testdox decrypt static with wrong key $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEncryptFailedStatic(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
$wrong_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::encryptKey($input, $public_key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey($encrypted, $wrong_key_pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: invalid key pair
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerWrongKeyPair(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'not hex key pair' => [
|
||||||
|
'key_pair' => 'not_a_hex_key_pair',
|
||||||
|
'exception_message' => 'Invalid hex key pair'
|
||||||
|
],
|
||||||
|
'too short hex key pair' => [
|
||||||
|
'key_pair' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
||||||
|
'excpetion_message' => 'Key pair is not the correct size (must be '
|
||||||
|
],
|
||||||
|
'empty key pair' => [
|
||||||
|
'key_pair' => '',
|
||||||
|
'excpetion_message' => 'Key pair cannot be empty'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongKeyPair
|
||||||
|
* @testdox wrong key pair $key_pair throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $key_pair
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongKeyPair(string $key_pair, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key_pair);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->encrypt('test');
|
||||||
|
$crypt->setKeyPair($enc_key_pair);
|
||||||
|
$encrypted = $crypt->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->setKeyPair($key_pair);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongKeyPair
|
||||||
|
* @testdox wrong key pair indirect $key_pair throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $key_pair
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongKeyPairIndirect(string $key_pair, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// set valid encryption
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::getInstance($enc_key_pair)->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::getInstance($key_pair)->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongKeyPair
|
||||||
|
* @testdox wrong key pair static $key_pair throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $key_pair
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongKeyPairStatic(string $key_pair, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key_pair = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// set valid encryption
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::encryptKey('test', CreateKey::getPublicKey($enc_key_pair));
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey($encrypted, $key_pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: invalid public key
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerWrongPublicKey(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'not hex public key' => [
|
||||||
|
'public_key' => 'not_a_hex_public_key',
|
||||||
|
'exception_message' => 'Invalid hex public key'
|
||||||
|
],
|
||||||
|
'too short hex public key' => [
|
||||||
|
'public_key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
||||||
|
'excpetion_message' => 'Public key is not the correct size (must be '
|
||||||
|
],
|
||||||
|
'empty public key' => [
|
||||||
|
'public_key' => '',
|
||||||
|
'excpetion_message' => 'Public key cannot be empty'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongPublicKey
|
||||||
|
* @testdox wrong public key $public_key throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $public_key
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongPublicKey(string $public_key, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key_pair = CreateKey::createKeyPair();
|
||||||
|
// $enc_public_key = CreateKey::getPublicKey($enc_key_pair);
|
||||||
|
|
||||||
|
// class
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption(public_key:$public_key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->decrypt('test');
|
||||||
|
$crypt->setKeyPair($enc_key_pair);
|
||||||
|
$encrypted = $crypt->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->setPublicKey($public_key);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongPublicKey
|
||||||
|
* @testdox wrong public key indirect $key throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongPublicKeyIndirect(string $key, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::getInstance(public_key:$key)->encrypt('test');
|
||||||
|
// we must encrypt valid thing first so we can fail with the wrong key
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::getInstance($enc_key)->encrypt('test');
|
||||||
|
// $this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test invalid key provided to decrypt or encrypt
|
||||||
|
*
|
||||||
|
* @covers ::encrypt
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongPublicKey
|
||||||
|
* @testdox wrong public key static $key throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongPublicKeyStatic(string $key, string $exception_message): void
|
||||||
|
{
|
||||||
|
$enc_key = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::encryptKey('test', $key);
|
||||||
|
// we must encrypt valid thing first so we can fail with the wrong key
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::encryptKey('test', $enc_key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey($encrypted, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: wrong cipher text
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerWrongCiphertext(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'invalid cipher text' => [
|
||||||
|
'input' => 'short',
|
||||||
|
'exception_message' => 'base642bin failed: '
|
||||||
|
],
|
||||||
|
'cannot decrypt' => [
|
||||||
|
// phpcs:disable Generic.Files.LineLength
|
||||||
|
'input' => 'Um8tBGiVfFAOg2YoUgA5fTqK1wXPB1S7uxhPNE1lqDxgntkEhYJDOmjXa0DMpBlYHjab6sC4mgzwZSzGCUnXDAgsHckwYwfAzs/r',
|
||||||
|
// phpcs:enable Generic.Files.LineLength
|
||||||
|
'exception_message' => 'Invalid key pair'
|
||||||
|
],
|
||||||
|
'invalid text' => [
|
||||||
|
'input' => 'U29tZSB0ZXh0IGhlcmU=',
|
||||||
|
'exception_message' => 'Invalid key pair'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @dataProvider providerWrongCiphertext
|
||||||
|
* @testdox too short ciphertext $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongCiphertext(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key = CreateKey::createKeyPair();
|
||||||
|
// class
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption($key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->decrypt($input);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::decryptKey
|
||||||
|
* @dataProvider providerWrongCiphertext
|
||||||
|
* @testdox too short ciphertext indirect $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongCiphertextIndirect(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key = CreateKey::createKeyPair();
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::getInstance($key)->decrypt($input);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey($input, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::decryptKey
|
||||||
|
* @dataProvider providerWrongCiphertext
|
||||||
|
* @testdox too short ciphertext static $input throws $exception_message [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $exception_message
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongCiphertextStatic(string $input, string $exception_message): void
|
||||||
|
{
|
||||||
|
$key = CreateKey::createKeyPair();
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
AsymmetricAnonymousEncryption::decryptKey($input, $key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -13,6 +13,11 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsSecurityPasswordTest extends TestCase
|
final class CoreLibsSecurityPasswordTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function passwordProvider(): array
|
public function passwordProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -21,6 +26,11 @@ final class CoreLibsSecurityPasswordTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: we need different hash types for PHP versions
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function passwordRehashProvider(): array
|
public function passwordRehashProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -63,6 +73,10 @@ final class CoreLibsSecurityPasswordTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testPasswordRehashCheck(string $input, bool $expected): void
|
public function testPasswordRehashCheck(string $input, bool $expected): void
|
||||||
{
|
{
|
||||||
|
// in PHP 8.4 the length is $12
|
||||||
|
if (PHP_VERSION_ID > 80400) {
|
||||||
|
$input = str_replace('$2y$10$', '$2y$12$', $input);
|
||||||
|
}
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Security\Password::passwordRehashCheck($input)
|
\CoreLibs\Security\Password::passwordRehashCheck($input)
|
||||||
|
|||||||
@@ -15,6 +15,77 @@ use CoreLibs\Security\SymmetricEncryption;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
// MARK: key set compare
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::compareKey
|
||||||
|
* @covers ::getKey
|
||||||
|
* @testdox Check if init class set key matches to created key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeyInitGetCompare(): void
|
||||||
|
{
|
||||||
|
$key = CreateKey::generateRandomKey();
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKey($key),
|
||||||
|
'set key not equal to original key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key,
|
||||||
|
$crypt->getKey(),
|
||||||
|
'set key returned not equal to original key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::setKey
|
||||||
|
* @covers ::compareKey
|
||||||
|
* @covers ::getKey
|
||||||
|
* @testdox Check if set key after class init matches to created key
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testKeySetGetCompare(): void
|
||||||
|
{
|
||||||
|
$key = CreateKey::generateRandomKey();
|
||||||
|
$crypt = new SymmetricEncryption();
|
||||||
|
$crypt->setKey($key);
|
||||||
|
$this->assertTrue(
|
||||||
|
$crypt->compareKey($key),
|
||||||
|
'set key not equal to original key'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$key,
|
||||||
|
$crypt->getKey(),
|
||||||
|
'set key returned not equal to original key'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: empty encrypted string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::decryptKey
|
||||||
|
* @covers ::decrypt
|
||||||
|
* @testdox Test empty encrypted string to decrypt
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testEmptyDecryptionString(): void
|
||||||
|
{
|
||||||
|
$this->expectExceptionMessage('Encrypted string cannot be empty');
|
||||||
|
SymmetricEncryption::decryptKey('', CreateKey::generateRandomKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: encrypt/decrypt compare
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -88,8 +159,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
* test encrypt/decrypt produce correct output
|
* test encrypt/decrypt produce correct output
|
||||||
*
|
*
|
||||||
* @covers ::generateRandomKey
|
* @covers ::generateRandomKey
|
||||||
* @covers ::encrypt
|
* @covers ::encryptKey
|
||||||
* @covers ::decrypt
|
* @covers ::decryptKey
|
||||||
* @dataProvider providerEncryptDecryptSuccess
|
* @dataProvider providerEncryptDecryptSuccess
|
||||||
* @testdox encrypt/decrypt static $input must be $expected [$_dataName]
|
* @testdox encrypt/decrypt static $input must be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
@@ -111,6 +182,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: invalid key
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -180,8 +253,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
* Test decryption with wrong key
|
* Test decryption with wrong key
|
||||||
*
|
*
|
||||||
* @covers ::generateRandomKey
|
* @covers ::generateRandomKey
|
||||||
* @covers ::encrypt
|
* @covers ::encryptKey
|
||||||
* @covers ::decrypt
|
* @covers ::decryptKey
|
||||||
* @dataProvider providerEncryptFailed
|
* @dataProvider providerEncryptFailed
|
||||||
* @testdox decrypt static with wrong key $input throws $exception_message [$_dataName]
|
* @testdox decrypt static with wrong key $input throws $exception_message [$_dataName]
|
||||||
*
|
*
|
||||||
@@ -200,6 +273,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
SymmetricEncryption::decryptKey($encrypted, $wrong_key);
|
SymmetricEncryption::decryptKey($encrypted, $wrong_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: wrong key
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -216,6 +291,10 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
||||||
'excpetion_message' => 'Key is not the correct size (must be '
|
'excpetion_message' => 'Key is not the correct size (must be '
|
||||||
],
|
],
|
||||||
|
'empty key' => [
|
||||||
|
'key' => '',
|
||||||
|
'excpetion_message' => 'Key cannot be empty'
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +315,7 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
$enc_key = CreateKey::generateRandomKey();
|
$enc_key = CreateKey::generateRandomKey();
|
||||||
|
|
||||||
// class
|
// class
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
$crypt = new SymmetricEncryption($key);
|
$crypt = new SymmetricEncryption($key);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
$crypt->encrypt('test');
|
$crypt->encrypt('test');
|
||||||
@@ -244,22 +324,6 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
$crypt->setKey($key);
|
$crypt->setKey($key);
|
||||||
$crypt->decrypt($encrypted);
|
$crypt->decrypt($encrypted);
|
||||||
|
|
||||||
// class instance
|
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::getInstance($key)->encrypt('test');
|
|
||||||
// we must encrypt valid thing first so we can fail with the wrong key
|
|
||||||
$encrypted = SymmetricEncryption::getInstance($enc_key)->encrypt('test');
|
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
|
||||||
|
|
||||||
// class static
|
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::encryptKey('test', $key);
|
|
||||||
// we must encrypt valid thing first so we can fail with the wrong key
|
|
||||||
$encrypted = SymmetricEncryption::encryptKey('test', $enc_key);
|
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::decryptKey($encrypted, $key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,8 +354,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* test invalid key provided to decrypt or encrypt
|
* test invalid key provided to decrypt or encrypt
|
||||||
*
|
*
|
||||||
* @covers ::encrypt
|
* @covers ::encryptKey
|
||||||
* @covers ::decrypt
|
* @covers ::decryptKey
|
||||||
* @dataProvider providerWrongKey
|
* @dataProvider providerWrongKey
|
||||||
* @testdox wrong key static $key throws $exception_message [$_dataName]
|
* @testdox wrong key static $key throws $exception_message [$_dataName]
|
||||||
*
|
*
|
||||||
@@ -312,6 +376,8 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
SymmetricEncryption::decryptKey($encrypted, $key);
|
SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: wrong input
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -358,7 +424,7 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::decrypt
|
* @covers ::decryptKey
|
||||||
* @dataProvider providerWrongCiphertext
|
* @dataProvider providerWrongCiphertext
|
||||||
* @testdox too short ciphertext indirect $input throws $exception_message [$_dataName]
|
* @testdox too short ciphertext indirect $input throws $exception_message [$_dataName]
|
||||||
*
|
*
|
||||||
@@ -382,7 +448,7 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::decrypt
|
* @covers ::decryptKey
|
||||||
* @dataProvider providerWrongCiphertext
|
* @dataProvider providerWrongCiphertext
|
||||||
* @testdox too short ciphertext static $input throws $exception_message [$_dataName]
|
* @testdox too short ciphertext static $input throws $exception_message [$_dataName]
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -969,44 +969,76 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
|
|||||||
"query" => ["foo-get" => "bar"]
|
"query" => ["foo-get" => "bar"]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: get response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: get response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_FIRST_CALL":"get","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1","HTTP_FIRST_CALL":"get",'
|
||||||
. '"REQUEST_TYPE":"GET",'
|
. '"HTTP_ACCEPT":"*\/*"},"REQUEST_TYPE":"GET","PARAMS":{"foo-get":"bar"},"BODY":null}',
|
||||||
. '"PARAMS":{"foo-get":"bar"},"BODY":null}',
|
$response['content'],
|
||||||
$response['content'],
|
'multi call: get content not matching'
|
||||||
'multi call: get content not matching'
|
);
|
||||||
);
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_FIRST_CALL":"get","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"GET",'
|
||||||
|
. '"PARAMS":{"foo-get":"bar"},"BODY":null}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: get content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
// post
|
// post
|
||||||
$response = $curl->post($this->url_basic, [
|
$response = $curl->post($this->url_basic, [
|
||||||
"headers" => ["second-call" => "post"],
|
"headers" => ["second-call" => "post"],
|
||||||
"body" => ["foo-post" => "baz"]
|
"body" => ["foo-post" => "baz"]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: post response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: post response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
. '"REQUEST_TYPE":"POST",'
|
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*"},'
|
||||||
. '"PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
. '"REQUEST_TYPE":"POST","PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
||||||
$response['content'],
|
$response['content'],
|
||||||
'multi call: post content not matching'
|
'multi call: post content not matching'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"POST",'
|
||||||
|
. '"PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: post content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
// delete
|
// delete
|
||||||
$response = $curl->delete($this->url_basic, [
|
$response = $curl->delete($this->url_basic, [
|
||||||
"headers" => ["third-call" => "delete"],
|
"headers" => ["third-call" => "delete"],
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: delete response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: delete response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
. '"REQUEST_TYPE":"DELETE",'
|
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*"},'
|
||||||
. '"PARAMS":[],"BODY":[]}',
|
. '"REQUEST_TYPE":"DELETE","PARAMS":[],"BODY":[]}',
|
||||||
$response['content'],
|
$response['content'],
|
||||||
'multi call: delete content not matching'
|
'multi call: delete content not matching'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"DELETE",'
|
||||||
|
. '"PARAMS":[],"BODY":[]}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: delete content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: auth header set via config
|
// MARK: auth header set via config
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- 20241203: update edit tables
|
-- 20241203: update edit tables
|
||||||
ALTER TABLE edit_generic ADD cuuid UUID DEFAULT gen_random_uuid();
|
ALTER TABLE edit_generic ADD cuuid UUID DEFAULT gen_random_uuid();
|
||||||
ALTER TABLE edit_log ADD ecuid VARCHAR;
|
ALTER TABLE edit_log ADD eucuid VARCHAR;
|
||||||
ALTER TABLE edit_log ADD ecuuid VARCHAR;
|
ALTER TABLE edit_log ADD eucuuid VARCHAR;
|
||||||
ALTER TABLE edit_log ADD action_sub_id VARCHAR;
|
ALTER TABLE edit_log ADD action_sub_id VARCHAR;
|
||||||
ALTER TABLE edit_log ADD http_data JSONB;
|
ALTER TABLE edit_log ADD http_data JSONB;
|
||||||
ALTER TABLE edit_log ADD ip_address JSONB;
|
ALTER TABLE edit_log ADD ip_address JSONB;
|
||||||
@@ -32,3 +32,5 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
LANGUAGE 'plpgsql';
|
LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
|
-- END --
|
||||||
|
|||||||
@@ -114,3 +114,11 @@ Add `.libs` to the master .gitingore
|
|||||||
### Update phpunit
|
### Update phpunit
|
||||||
|
|
||||||
On a version update the old phpunit folder in .libs has to be removed and the new version extracted again
|
On a version update the old phpunit folder in .libs has to be removed and the new version extracted again
|
||||||
|
|
||||||
|
## Javascript
|
||||||
|
|
||||||
|
The original edit.js javascript functions are now in utils.js or utils.min.js.
|
||||||
|
|
||||||
|
The development for thos files is located in a different repository
|
||||||
|
|
||||||
|
https://[service]/CodeBlocks/javascript-utils
|
||||||
|
|||||||
59
eslint.config.mjs
Normal file
59
eslint.config.mjs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import globals from 'globals';
|
||||||
|
import pluginJs from '@eslint/js';
|
||||||
|
|
||||||
|
/*
|
||||||
|
module.exports = {
|
||||||
|
// in globals block
|
||||||
|
'extends': 'eslint:recommended',
|
||||||
|
'parserOptions': {
|
||||||
|
'ecmaVersion': 6
|
||||||
|
},
|
||||||
|
// rules copied
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
{languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.jquery
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
{
|
||||||
|
'rules': {
|
||||||
|
'indent': [
|
||||||
|
'error',
|
||||||
|
'tab',
|
||||||
|
{
|
||||||
|
'SwitchCase': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'linebreak-style': [
|
||||||
|
'error',
|
||||||
|
'unix'
|
||||||
|
],
|
||||||
|
// 'quotes': [
|
||||||
|
// 'error',
|
||||||
|
// 'single'
|
||||||
|
// ],
|
||||||
|
'semi': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-unused-vars': [
|
||||||
|
'error', {
|
||||||
|
'vars': 'all',
|
||||||
|
'args': 'after-used',
|
||||||
|
'ignoreRestSiblings': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// Requires eslint >= v8.14.0
|
||||||
|
'no-constant-binary-expression': 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
// https://www.typescriptlang.org/tsconfig/#compilerOptions
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
|
"checkJs": true,
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"strictFunctionTypes": true
|
"strictFunctionTypes": true
|
||||||
|
|||||||
1567
package-lock.json
generated
Normal file
1567
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
package.json
Normal file
17
package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "core-libraries",
|
||||||
|
"version": "9.26.8",
|
||||||
|
"main": "",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Clemens Schwaighofer",
|
||||||
|
"license": "",
|
||||||
|
"description": "Core Libraries",
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.20.0",
|
||||||
|
"esbuild": "^0.25.0",
|
||||||
|
"eslint": "^9.20.1",
|
||||||
|
"globals": "^15.15.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,5 +10,6 @@ $_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp';
|
|||||||
define('BASE_NAME', '');
|
define('BASE_NAME', '');
|
||||||
define('SITE_DOMAIN', '');
|
define('SITE_DOMAIN', '');
|
||||||
define('HOST_NAME', 'soba.tokyo.tequila.jp');
|
define('HOST_NAME', 'soba.tokyo.tequila.jp');
|
||||||
|
define('DEFAULT_ENCODING', 'en_US.UTF-8');
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ parameters:
|
|||||||
#friendly:
|
#friendly:
|
||||||
# lineBefore: 3
|
# lineBefore: 3
|
||||||
# lineAfter: 3
|
# lineAfter: 3
|
||||||
level: 8 # max is now 9
|
level: 8 # max is now 10
|
||||||
# strictRules:
|
# strictRules:
|
||||||
# allRules: false
|
# allRules: false
|
||||||
checkMissingCallableSignature: true
|
checkMissingCallableSignature: true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<phpunit
|
<phpunit
|
||||||
cacheResultFile="/tmp/phpunit-corelibs.result.cache"
|
cacheResultFile="/tmp/phpunit-corelibs.result.cache"
|
||||||
colors="true"
|
colors="true"
|
||||||
verbose="true"
|
verbose="false"
|
||||||
convertDeprecationsToExceptions="true"
|
convertDeprecationsToExceptions="true"
|
||||||
bootstrap="4dev/tests/bootstrap.php"
|
bootstrap="4dev/tests/bootstrap.php"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ header("Content-Type: application/json; charset=UTF-8");
|
|||||||
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
||||||
header("HTTP/1.1 401 Unauthorized");
|
header("HTTP/1.1 401 Unauthorized");
|
||||||
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if server request type is get set file_get to null -> no body
|
// if server request type is get set file_get to null -> no body
|
||||||
@@ -61,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|||||||
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
// str_replace('\"', '"', trim($file_get, '"'));
|
// str_replace('\"', '"', trim($file_get, '"'));
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -263,6 +263,8 @@ $out = array_intersect_key(
|
|||||||
);
|
);
|
||||||
print "array intersect key: " . DgS::printAr($keys) . ": " . DgS::printAr($out) . "<br>";
|
print "array intersect key: " . DgS::printAr($keys) . ": " . DgS::printAr($out) . "<br>";
|
||||||
|
|
||||||
|
print "array + suffix: " . DgS::printAr(ArrayHandler::arrayModifyKey($array, key_mod_suffix:'_attached')) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
// basic class test file
|
// basic class test file
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -268,7 +268,9 @@ foreach ($compare_datetimes as $compare_datetime) {
|
|||||||
print "COMPAREDATE: $compare_datetime[0] = $compare_datetime[1]: "
|
print "COMPAREDATE: $compare_datetime[0] = $compare_datetime[1]: "
|
||||||
. (string)DateTime::compareDateTime($compare_datetime[0], $compare_datetime[1]) . "<br>";
|
. (string)DateTime::compareDateTime($compare_datetime[0], $compare_datetime[1]) . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
|
print "<h2>calcDaysInterval</h2>";
|
||||||
$compare_dates = [
|
$compare_dates = [
|
||||||
[ '2021-05-01', '2021-05-10', ],
|
[ '2021-05-01', '2021-05-10', ],
|
||||||
[ '2021-05-10', '2021-05-01', ],
|
[ '2021-05-10', '2021-05-01', ],
|
||||||
@@ -279,9 +281,21 @@ foreach ($compare_dates as $compare_date) {
|
|||||||
print "CALCDAYSINTERVAL: $compare_date[0] = $compare_date[1]: "
|
print "CALCDAYSINTERVAL: $compare_date[0] = $compare_date[1]: "
|
||||||
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1])) . "<br>";
|
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1])) . "<br>";
|
||||||
print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: "
|
print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: "
|
||||||
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], true)) . "<br>";
|
. DgS::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], return_named:true)) . "<br>";
|
||||||
|
print "CALCDAYSINTERVAL(EXCLUDE END): $compare_date[0] = $compare_date[1]: "
|
||||||
|
. Dgs::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], include_end_date:false));
|
||||||
|
print "CALCDAYSINTERVAL(EXCLUDE START): $compare_date[0] = $compare_date[1]: "
|
||||||
|
. Dgs::printAr(DateTime::calcDaysInterval($compare_date[0], $compare_date[1], exclude_start_date:true));
|
||||||
|
print "CALCDAYSINTERVAL(EXCLUDE END, EXCLUDE START): $compare_date[0] = $compare_date[1]: "
|
||||||
|
. Dgs::printAr(DateTime::calcDaysInterval(
|
||||||
|
$compare_date[0],
|
||||||
|
$compare_date[1],
|
||||||
|
include_end_date:false,
|
||||||
|
exclude_start_date:true
|
||||||
|
));
|
||||||
}
|
}
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
|
print "<h2>setWeekdayNameFromIsoDow</h2>";
|
||||||
// test date conversion
|
// test date conversion
|
||||||
$dow = 2;
|
$dow = 2;
|
||||||
print "DOW[$dow]: " . DateTime::setWeekdayNameFromIsoDow($dow) . "<br>";
|
print "DOW[$dow]: " . DateTime::setWeekdayNameFromIsoDow($dow) . "<br>";
|
||||||
@@ -297,26 +311,25 @@ $date = '2022-70-242';
|
|||||||
print "DATE-dow[$date];invalid: " . DateTime::setWeekdayNameFromDate($date) . "<br>";
|
print "DATE-dow[$date];invalid: " . DateTime::setWeekdayNameFromDate($date) . "<br>";
|
||||||
print "DATE-dow[$date],long;invalid: " . DateTime::setWeekdayNameFromDate($date, true) . "<br>";
|
print "DATE-dow[$date],long;invalid: " . DateTime::setWeekdayNameFromDate($date, true) . "<br>";
|
||||||
print "DOW-date[$date];invalid: " . DateTime::setWeekdayNumberFromDate($date) . "<br>";
|
print "DOW-date[$date];invalid: " . DateTime::setWeekdayNumberFromDate($date) . "<br>";
|
||||||
print "<hr>";
|
|
||||||
// check date range includes a weekend
|
|
||||||
// does not:
|
|
||||||
$start_date = '2023-07-03';
|
|
||||||
$end_date = '2023-07-05';
|
|
||||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
|
||||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
|
||||||
$start_date = '2023-07-03';
|
|
||||||
$end_date = '2023-07-10';
|
|
||||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
|
||||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
|
||||||
$start_date = '2023-07-03';
|
|
||||||
$end_date = '2023-07-31';
|
|
||||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
|
||||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
|
||||||
$start_date = '2023-07-01';
|
|
||||||
$end_date = '2023-07-03';
|
|
||||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
|
||||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
|
||||||
|
|
||||||
|
print "<hr>";
|
||||||
|
print "<h2>dateRangeHasWeekend</h2>";
|
||||||
|
// check date range includes a weekend
|
||||||
|
$has_weekend_list = [
|
||||||
|
['2023-07-03', '2023-07-05'],
|
||||||
|
['2023-07-03', '2023-07-10'],
|
||||||
|
['2023-07-03', '2023-07-31'],
|
||||||
|
['2023-07-01', '2023-07-03'],
|
||||||
|
['2023-07-01', '2023-07-01'],
|
||||||
|
['2023-07-01', '2023-07-02'],
|
||||||
|
['2023-06-30', '2023-07-01'],
|
||||||
|
['2023-06-30', '2023-06-30'],
|
||||||
|
['2023-07-01', '2023-06-30'],
|
||||||
|
];
|
||||||
|
foreach ($has_weekend_list as $days) {
|
||||||
|
print "Has Weekend: " . $days[0] . " ~ " . $days[1] . ": "
|
||||||
|
. Dgs::prBl(DateTime::dateRangeHasWeekend($days[0], $days[1])) . "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
@@ -460,7 +473,10 @@ function intervalStringFormatDeprecated(
|
|||||||
// print "-> V: $value | $part, $time_name | I: " . is_int($value) . " | F: " . is_float($value)
|
// print "-> V: $value | $part, $time_name | I: " . is_int($value) . " | F: " . is_float($value)
|
||||||
// . " | " . ($value != 0 ? 'Not zero' : 'ZERO') . "<br>";
|
// . " | " . ($value != 0 ? 'Not zero' : 'ZERO') . "<br>";
|
||||||
// var_dump($skip_last_zero);
|
// var_dump($skip_last_zero);
|
||||||
if ($value != 0 || $skip_zero === false || $skip_last_zero === false) {
|
if (
|
||||||
|
is_numeric($value) &&
|
||||||
|
($value != 0 || $skip_zero === false || $skip_last_zero === false)
|
||||||
|
) {
|
||||||
if ($part == 'f') {
|
if ($part == 'f') {
|
||||||
if ($truncate_nanoseconds === true) {
|
if ($truncate_nanoseconds === true) {
|
||||||
$value = round($value, 3);
|
$value = round($value, 3);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Debug\Support;
|
use CoreLibs\Debug\Support;
|
||||||
use CoreLibs\DB\Support\ConvertPlaceholder;
|
use CoreLibs\DB\Support\ConvertPlaceholder;
|
||||||
|
use CoreLibs\Convert\Html;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -38,10 +39,12 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
|||||||
print "LOGFILE NAME: " . $log->getLogFile() . "<br>";
|
print "LOGFILE NAME: " . $log->getLogFile() . "<br>";
|
||||||
print "LOGFILE ID: " . $log->getLogFileId() . "<br>";
|
print "LOGFILE ID: " . $log->getLogFileId() . "<br>";
|
||||||
|
|
||||||
print "Lookup Regex: <pre>" . ConvertPlaceholder::REGEX_LOOKUP_PLACEHOLDERS . "</pre>";
|
print "Lookup Regex: <pre>" . Html::htmlent(ConvertPlaceholder::REGEX_LOOKUP_PLACEHOLDERS) . "</pre>";
|
||||||
print "Replace Named Regex: <pre>" . ConvertPlaceholder::REGEX_REPLACE_NAMED . "</pre>";
|
print "Lookup Numbered Regex: <pre>" . Html::htmlent(ConvertPlaceholder::REGEX_LOOKUP_NUMBERED) . "</pre>";
|
||||||
print "Replace Named Regex: <pre>" . ConvertPlaceholder::REGEX_REPLACE_QUESTION_MARK . "</pre>";
|
print "Replace Named Regex: <pre>" . Html::htmlent(ConvertPlaceholder::REGEX_REPLACE_NAMED) . "</pre>";
|
||||||
print "Replace Named Regex: <pre>" . ConvertPlaceholder::REGEX_REPLACE_NUMBERED . "</pre>";
|
print "Replace Question Mark Regex: <pre>"
|
||||||
|
. Html::htmlent(ConvertPlaceholder::REGEX_REPLACE_QUESTION_MARK) . "</pre>";
|
||||||
|
print "Replace Numbered Regex: <pre>" . Html::htmlent(ConvertPlaceholder::REGEX_REPLACE_NUMBERED) . "</pre>";
|
||||||
|
|
||||||
$uniqid = \CoreLibs\Create\Uids::uniqIdShort();
|
$uniqid = \CoreLibs\Create\Uids::uniqIdShort();
|
||||||
// $binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
// $binary_data = $db->dbEscapeBytea(file_get_contents('class_test.db.php') ?: '');
|
||||||
@@ -91,40 +94,63 @@ RETURNING
|
|||||||
some_binary
|
some_binary
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
print "[ALL] Convert: "
|
print "<b>[ALL] Convert</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
$query = "SELECT foo FROM bar WHERE baz = :baz AND buz = :baz AND biz = :biz AND boz = :bez";
|
$query = "SELECT foo FROM bar WHERE baz = :baz AND buz = :baz AND biz = :biz AND boz = :bez";
|
||||||
$params = [':baz' => 'SETBAZ', ':bez' => 'SETBEZ', ':biz' => 'SETBIZ'];
|
$params = [':baz' => 'SETBAZ', ':bez' => 'SETBEZ', ':biz' => 'SETBIZ'];
|
||||||
print "[NO PARAMS] Convert: "
|
print "<b>[NO PARAMS] Convert</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
$query = "SELECT foo FROM bar WHERE baz = :baz AND buz = :baz AND biz = :biz AND boz = :bez";
|
$query = "SELECT foo FROM bar WHERE baz = :baz AND buz = :baz AND biz = :biz AND boz = :bez";
|
||||||
$params = null;
|
$params = null;
|
||||||
print "[NO PARAMS] Convert: "
|
print "<b>[NO PARAMS] Convert</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
$query = "SELECT row_varchar FROM table_with_primary_key WHERE row_varchar <> :row_varchar";
|
$query = "SELECT row_varchar FROM table_with_primary_key WHERE row_varchar <> :row_varchar";
|
||||||
$params = null;
|
$params = null;
|
||||||
print "[NO PARAMS] Convert: "
|
print "<b>[NO PARAMS] Convert</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
$query = "SELECT row_varchar, row_varchar_literal, row_int, row_date FROM table_with_primary_key";
|
$query = "SELECT row_varchar, row_varchar_literal, row_int, row_date FROM table_with_primary_key";
|
||||||
$params = null;
|
$params = null;
|
||||||
print "[NO PARAMS] TEST: "
|
print "<b>[NO PARAMS] TEST</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
print "[P-CONV]: "
|
$query = <<<SQL
|
||||||
|
UPDATE table_with_primary_key SET
|
||||||
|
row_int = $1::INT, row_numeric = $1::NUMERIC, row_varchar = $1
|
||||||
|
WHERE
|
||||||
|
row_varchar = $1
|
||||||
|
SQL;
|
||||||
|
$params = [1];
|
||||||
|
print "<b>[All the same params] TEST</b>: "
|
||||||
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
|
. "<br>";
|
||||||
|
echo "<hr>";
|
||||||
|
|
||||||
|
$query = <<<SQL
|
||||||
|
SELECT row_varchar, row_varchar_literal, row_int, row_date
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE row_varchar = :row_varchar
|
||||||
|
SQL;
|
||||||
|
$params = [':row_varchar' => 1];
|
||||||
|
print "<b>[: param] TEST</b>: "
|
||||||
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params))
|
||||||
|
. "<br>";
|
||||||
|
echo "<hr>";
|
||||||
|
|
||||||
|
print "<b>[P-CONV]</b>: "
|
||||||
. Support::printAr(
|
. Support::printAr(
|
||||||
ConvertPlaceholder::updateParamList([
|
ConvertPlaceholder::updateParamList([
|
||||||
'original' => [
|
'original' => [
|
||||||
@@ -186,6 +212,13 @@ SQL,
|
|||||||
'params' => [\CoreLibs\Create\Uids::uniqIdShort(), 'string A-1', 1234],
|
'params' => [\CoreLibs\Create\Uids::uniqIdShort(), 'string A-1', 1234],
|
||||||
'direction' => 'pg',
|
'direction' => 'pg',
|
||||||
],
|
],
|
||||||
|
'b?' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
SELECT test FROM test_foo = ?
|
||||||
|
SQL,
|
||||||
|
'params' => [1234],
|
||||||
|
'direction' => 'pg',
|
||||||
|
],
|
||||||
'b:' => [
|
'b:' => [
|
||||||
'query' => <<<SQL
|
'query' => <<<SQL
|
||||||
INSERT INTO test_foo (
|
INSERT INTO test_foo (
|
||||||
@@ -220,7 +253,7 @@ foreach ($test_queries as $info => $data) {
|
|||||||
$query = $data['query'];
|
$query = $data['query'];
|
||||||
$params = $data['params'];
|
$params = $data['params'];
|
||||||
$direction = $data['direction'];
|
$direction = $data['direction'];
|
||||||
print "[$info] Convert: "
|
print "<b>[$info] Convert</b>: "
|
||||||
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params, $direction))
|
. Support::printAr(ConvertPlaceholder::convertPlaceholderInQuery($query, $params, $direction))
|
||||||
. "<br>";
|
. "<br>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
166
www/admin/class_test.db.encryption.php
Normal file
166
www/admin/class_test.db.encryption.php
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<?php // phpcs:ignore warning
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
// turn on all error reporting
|
||||||
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// basic class test file
|
||||||
|
define('USE_DATABASE', true);
|
||||||
|
// sample config
|
||||||
|
require 'config.php';
|
||||||
|
// for testing encryption compare
|
||||||
|
use OpenPGP\OpenPGP;
|
||||||
|
// define log file id
|
||||||
|
$LOG_FILE_ID = 'classTest-db-query-encryption';
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
// use CoreLibs\Debug\Support;
|
||||||
|
use CoreLibs\Security\SymmetricEncryption;
|
||||||
|
use CoreLibs\Security\CreateKey;
|
||||||
|
use CoreLibs\Create\Hash;
|
||||||
|
use CoreLibs\Debug\Support;
|
||||||
|
|
||||||
|
$log = new CoreLibs\Logging\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'log_file_id' => $LOG_FILE_ID,
|
||||||
|
'log_per_date' => true,
|
||||||
|
]);
|
||||||
|
// db connection and attach logger
|
||||||
|
$db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
||||||
|
$db->log->debug('START', '=============================>');
|
||||||
|
|
||||||
|
$PAGE_NAME = 'TEST CLASS: DB QUERY ENCRYPTION';
|
||||||
|
print "<!DOCTYPE html>";
|
||||||
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
|
print "<body>";
|
||||||
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
// encryption key
|
||||||
|
$key_new = CreateKey::generateRandomKey();
|
||||||
|
print "Secret Key NEW: " . $key_new . "<br>";
|
||||||
|
// for reproducable test results
|
||||||
|
$key = 'e475c19b9a3c8363feb06b51f5b73f1dc9b6f20757d4ab89509bf5cc70ed30ec';
|
||||||
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
|
||||||
|
// test text
|
||||||
|
$text_string = "I a some deep secret";
|
||||||
|
$text_string = "I a some deep secret ABC";
|
||||||
|
//
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($text_string);
|
||||||
|
$string_hashed = Hash::hashStd($text_string);
|
||||||
|
$string_hmac = Hash::hashHmac($text_string, $key);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
|
||||||
|
print "String: " . $text_string . "<br>";
|
||||||
|
print "Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "Hashed: " . $string_hashed . "<br>";
|
||||||
|
print "Hmac: " . $string_hmac . "<br>";
|
||||||
|
|
||||||
|
$db->dbExecParams(
|
||||||
|
<<<SQL
|
||||||
|
INSERT INTO test_encryption (
|
||||||
|
-- for compare
|
||||||
|
plain_text,
|
||||||
|
-- via php encryption
|
||||||
|
hash_text, hmac_text, crypt_text,
|
||||||
|
-- -- in DB encryption
|
||||||
|
pg_digest_bytea, pg_digest_text,
|
||||||
|
pg_hmac_bytea, pg_hmac_text,
|
||||||
|
pg_crypt_bytea, pg_crypt_text
|
||||||
|
) VALUES (
|
||||||
|
$1,
|
||||||
|
$2, $3, $4,
|
||||||
|
digest($1::VARCHAR, $5),
|
||||||
|
encode(digest($1, $5), 'hex'),
|
||||||
|
hmac($1, $6, $5),
|
||||||
|
encode(hmac($1, $6, $5), 'hex'),
|
||||||
|
pgp_sym_encrypt($1, $7),
|
||||||
|
encode(pgp_sym_encrypt($1, $7), 'hex')
|
||||||
|
) RETURNING cuuid
|
||||||
|
SQL,
|
||||||
|
[
|
||||||
|
// 1: original string
|
||||||
|
$text_string,
|
||||||
|
// 2: hashed, 3: hmac, 4: encrypted
|
||||||
|
$string_hashed, $string_hmac, $encrypted,
|
||||||
|
// 5: hash type, 6: hmac secret, 7: pgp secret
|
||||||
|
'sha256', $key, $key
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$cuuid = $db->dbGetReturningExt('cuuid');
|
||||||
|
print "INSERTED: " . print_r($cuuid, true) . "<br>";
|
||||||
|
print "LAST ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
// read back
|
||||||
|
$res = $db->dbReturnRowParams(
|
||||||
|
<<<SQL
|
||||||
|
SELECT
|
||||||
|
-- for compare
|
||||||
|
plain_text,
|
||||||
|
-- via php encryption
|
||||||
|
hash_text, hmac_text, crypt_text,
|
||||||
|
-- in DB encryption
|
||||||
|
pg_digest_bytea, pg_digest_text,
|
||||||
|
pg_hmac_bytea, pg_hmac_text,
|
||||||
|
pg_crypt_bytea, pg_crypt_text,
|
||||||
|
encode(pg_crypt_bytea, 'hex') AS pg_crypt_bytea_hex,
|
||||||
|
pgp_sym_decrypt(pg_crypt_bytea, $2) AS from_pg_crypt_bytea,
|
||||||
|
pgp_sym_decrypt(decode(pg_crypt_text, 'hex'), $2) AS from_pg_crypt_text
|
||||||
|
FROM
|
||||||
|
test_encryption
|
||||||
|
WHERE
|
||||||
|
cuuid = $1
|
||||||
|
SQL,
|
||||||
|
[
|
||||||
|
$cuuid, $key
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
print "RES: <pre>" . Support::prAr($res) . "</pre><br>";
|
||||||
|
|
||||||
|
if ($res === false) {
|
||||||
|
echo "Failed to run query<br>";
|
||||||
|
} else {
|
||||||
|
if (hash_equals($string_hashed, $res['pg_digest_text'])) {
|
||||||
|
print "libsodium and pgcrypto hash match<br>";
|
||||||
|
}
|
||||||
|
if (hash_equals($string_hmac, $res['pg_hmac_text'])) {
|
||||||
|
print "libsodium and pgcrypto hash hmac match<br>";
|
||||||
|
}
|
||||||
|
// do compare for PHP and pgcrypto settings
|
||||||
|
$encryptedMessage_template = <<<TEXT
|
||||||
|
-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
|
{BASE64}
|
||||||
|
-----END PGP MESSAGE-----
|
||||||
|
TEXT;
|
||||||
|
$base64_string = base64_encode(hex2bin($res['pg_crypt_text']) ?: '');
|
||||||
|
$encryptedMessage = str_replace(
|
||||||
|
'{BASE64}',
|
||||||
|
$base64_string,
|
||||||
|
$encryptedMessage_template
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
$literalMessage = OpenPGP::decryptMessage($encryptedMessage, passwords: [$key]);
|
||||||
|
$decrypted = $literalMessage->getLiteralData()->getData();
|
||||||
|
print "Pg decrypted PHP: " . $decrypted . "<br>";
|
||||||
|
if ($decrypted == $text_string) {
|
||||||
|
print "Decryption worked<br>";
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
print "Error decrypting message: " . $e->getMessage() . "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</body></html>";
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -76,41 +76,41 @@ $db->dbResetEncoding();
|
|||||||
|
|
||||||
// empty calls, none of the below should fail
|
// empty calls, none of the below should fail
|
||||||
//
|
//
|
||||||
$db->dbGetCursor();
|
$foo = $db->dbGetCursor();
|
||||||
//
|
//
|
||||||
$db->dbGetCursorExt();
|
$foo = $db->dbGetCursorExt();
|
||||||
//
|
//
|
||||||
$db->dbGetCursorPos('SELECT foo', ['bar']);
|
$foo = $db->dbGetCursorPos('SELECT foo', ['bar']);
|
||||||
//
|
//
|
||||||
$db->dbGetCursorNumRows('SELECT foo', ['bar']);
|
$foo = $db->dbGetCursorNumRows('SELECT foo', ['bar']);
|
||||||
//
|
//
|
||||||
$db->dbGetInsertPKName();
|
$foo = $db->dbGetInsertPKName();
|
||||||
//
|
//
|
||||||
$db->dbGetInsertPK();
|
$foo = $db->dbGetInsertPK();
|
||||||
//
|
//
|
||||||
$db->dbGetReturningExt();
|
$foo = $db->dbGetReturningExt();
|
||||||
$db->dbGetReturningExt('foo');
|
$foo = $db->dbGetReturningExt('foo');
|
||||||
$db->dbGetReturningExt('foo', 0);
|
$foo = $db->dbGetReturningExt('foo', 0);
|
||||||
$db->dbGetReturningExt(pos:0);
|
$foo = $db->dbGetReturningExt(pos:0);
|
||||||
//
|
//
|
||||||
$db->dbGetReturningArray();
|
$foo = $db->dbGetReturningArray();
|
||||||
//
|
//
|
||||||
$db->dbGetNumRows();
|
$foo = $db->dbGetNumRows();
|
||||||
//
|
//
|
||||||
$db->dbGetNumFields();
|
$foo = $db->dbGetNumFields();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldNames();
|
$foo = $db->dbGetFieldNames();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldTypes();
|
$foo = $db->dbGetFieldTypes();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldNameTypes();
|
$foo = $db->dbGetFieldNameTypes();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldName(0);
|
$foo = $db->dbGetFieldName(0);
|
||||||
//
|
//
|
||||||
$db->dbGetFieldType(0);
|
$foo = $db->dbGetFieldType(0);
|
||||||
$db->dbGetFieldType('foo');
|
$foo = $db->dbGetFieldType('foo');
|
||||||
//
|
//
|
||||||
$db->dbGetPrepareCursorValue('foo', 'bar');
|
$foo = $db->dbGetPrepareCursorValue('foo', 'bar');
|
||||||
|
|
||||||
// TEST CACHE READS
|
// TEST CACHE READS
|
||||||
|
|
||||||
@@ -273,8 +273,8 @@ $query_insert = <<<SQL
|
|||||||
INSERT INTO
|
INSERT INTO
|
||||||
test_foo
|
test_foo
|
||||||
(
|
(
|
||||||
test, some_bool, string_a, number_a, number_a_numeric,
|
test, some_bool, string_a, number_a, numeric_a,
|
||||||
some_time, some_timestamp, json_string
|
some_internval, some_timestamp, json_string
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5,
|
$1, $2, $3, $4, $5,
|
||||||
$6, $7, $8
|
$6, $7, $8
|
||||||
@@ -283,8 +283,8 @@ RETURNING test
|
|||||||
SQL;
|
SQL;
|
||||||
$query_select = <<<SQL
|
$query_select = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test, some_bool, string_a, number_a, number_a_numeric,
|
test, some_bool, string_a, number_a, numeric_a,
|
||||||
some_time, some_time, some_timestamp, json_string
|
some_time, some_internval, some_timestamp, json_string
|
||||||
FROM
|
FROM
|
||||||
test_foo
|
test_foo
|
||||||
WHERE
|
WHERE
|
||||||
@@ -554,7 +554,7 @@ print "<b>PREPARE QUERIES</b><br>";
|
|||||||
// READ PREPARE
|
// READ PREPARE
|
||||||
$q_prep = <<<SQL
|
$q_prep = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $1
|
WHERE test = $1
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -582,7 +582,7 @@ if ($db->dbPrepare('sel_test_foo', $q_prep) === false) {
|
|||||||
|
|
||||||
// sel test with ANY () type
|
// sel test with ANY () type
|
||||||
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
||||||
. "number_a_numeric, some_time "
|
. "numeric_a, some_time "
|
||||||
. "FROM test_foo "
|
. "FROM test_foo "
|
||||||
. "WHERE test = ANY($1) "
|
. "WHERE test = ANY($1) "
|
||||||
. "ORDER BY test_foo_id DESC LIMIT 5";
|
. "ORDER BY test_foo_id DESC LIMIT 5";
|
||||||
@@ -618,7 +618,7 @@ $test_bar = $db->dbEscapeLiteral('SOMETHING DIFFERENT');
|
|||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
-- comment
|
-- comment
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $test_bar
|
WHERE test = $test_bar
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -631,7 +631,7 @@ print "DB RETURN PARAMS<br>";
|
|||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
-- comment
|
-- comment
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $1
|
WHERE test = $1
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -646,7 +646,7 @@ echo "<hr>";
|
|||||||
print "DB RETURN PARAMS LIKE<br>";
|
print "DB RETURN PARAMS LIKE<br>";
|
||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
test_foo_id, test, some_bool, string_a, number_a, numeric_a
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE string_a LIKE $1;
|
WHERE string_a LIKE $1;
|
||||||
SQL;
|
SQL;
|
||||||
@@ -660,7 +660,7 @@ echo "<hr>";
|
|||||||
print "DB RETURN PARAMS ANY<br>";
|
print "DB RETURN PARAMS ANY<br>";
|
||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
test_foo_id, test, some_bool, string_a, number_a, numeric_a
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE string_a = ANY($1);
|
WHERE string_a = ANY($1);
|
||||||
SQL;
|
SQL;
|
||||||
@@ -707,6 +707,17 @@ if (
|
|||||||
} else {
|
} else {
|
||||||
print "[PGB] [3] pgb_sel_test_foo prepare OK<br>";
|
print "[PGB] [3] pgb_sel_test_foo prepare OK<br>";
|
||||||
}
|
}
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('');
|
||||||
|
print "[PGB] Empty statement name: " . $log->prAr($stm_status) . "<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foobar');
|
||||||
|
print "[PGB] Prepared name not match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo');
|
||||||
|
print "[PGB] Prepared name match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo', $q_prep);
|
||||||
|
print "[PGB] prepared exists and query match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo', "SELECT * FROM test_foo");
|
||||||
|
print "[PGB] prepared exists and query not match status: $stm_status<br>";
|
||||||
|
|
||||||
$db_pgb->dbClose();
|
$db_pgb->dbClose();
|
||||||
|
|
||||||
# db write class test
|
# db write class test
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
|||||||
print "NO DB HANDLER<br>";
|
print "NO DB HANDLER<br>";
|
||||||
}
|
}
|
||||||
// REGEX for placeholder count
|
// REGEX for placeholder count
|
||||||
print "Placeholder regex: <pre>" . CoreLibs\DB\Support\ConvertPlaceholder::REGEX_LOOKUP_PLACEHOLDERS . "</pre>";
|
print "Placeholder lookup regex: <pre>" . CoreLibs\DB\Support\ConvertPlaceholder::REGEX_LOOKUP_NUMBERED . "</pre>";
|
||||||
|
|
||||||
// turn on debug replace for placeholders
|
// turn on debug replace for placeholders
|
||||||
$db->dbSetDebugReplacePlaceholder(true);
|
$db->dbSetDebugReplacePlaceholder(true);
|
||||||
@@ -148,6 +148,7 @@ RETURNING
|
|||||||
bigint_a, number_real, number_double, numeric_3,
|
bigint_a, number_real, number_double, numeric_3,
|
||||||
uuid_var
|
uuid_var
|
||||||
SQL;
|
SQL;
|
||||||
|
print "Placeholders: <pre>" . print_r($db->dbGetQueryParamPlaceholders($query_insert), true) . "<pre>";
|
||||||
$status = $db->dbExecParams($query_insert, $query_params);
|
$status = $db->dbExecParams($query_insert, $query_params);
|
||||||
echo "<b>*</b><br>";
|
echo "<b>*</b><br>";
|
||||||
echo "INSERT ALL COLUMN TYPES: "
|
echo "INSERT ALL COLUMN TYPES: "
|
||||||
@@ -174,6 +175,26 @@ while (is_array($res = $db->dbReturnParams($query, [$query_value]))) {
|
|||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
|
echo "<b>CASE part</b><br>";
|
||||||
|
$query = <<<SQL
|
||||||
|
UPDATE
|
||||||
|
test_foo
|
||||||
|
SET
|
||||||
|
some_timestamp = NOW(),
|
||||||
|
-- if not 1 set, else keep at one
|
||||||
|
smallint_a = (CASE
|
||||||
|
WHEN smallint_a <> 1 THEN $1
|
||||||
|
ELSE 1::INT
|
||||||
|
END)::INT
|
||||||
|
WHERE
|
||||||
|
string_a = $2
|
||||||
|
SQL;
|
||||||
|
echo "QUERY: <pre>" . $query . "</pre>";
|
||||||
|
$res = $db->dbExecParams($query, [1, 'foobar']);
|
||||||
|
print "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
|
||||||
// test connectors: = , <> () for query detection
|
// test connectors: = , <> () for query detection
|
||||||
|
|
||||||
// convert placeholder tests
|
// convert placeholder tests
|
||||||
@@ -237,7 +258,7 @@ SQL,
|
|||||||
SQL,
|
SQL,
|
||||||
'params' => [1, 2, 3, 4, 5, 6],
|
'params' => [1, 2, 3, 4, 5, 6],
|
||||||
'direction' => 'pg'
|
'direction' => 'pg'
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$db->dbSetConvertPlaceholder(true);
|
$db->dbSetConvertPlaceholder(true);
|
||||||
@@ -306,6 +327,7 @@ SQL,
|
|||||||
) {
|
) {
|
||||||
print "RES: " . Support::prAr($res) . "<br>";
|
print "RES: " . Support::prAr($res) . "<br>";
|
||||||
}
|
}
|
||||||
|
print "PL: " . Support::PrAr($db->dbGetPlaceholderConverted()) . "<br>";
|
||||||
print "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
print "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
// turn on all error reporting
|
// turn on all error reporting
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -57,6 +57,43 @@ if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
|||||||
print "<b>TRUNCATE test_foo</b><br>";
|
print "<b>TRUNCATE test_foo</b><br>";
|
||||||
$db->dbExec("TRUNCATE test_foo");
|
$db->dbExec("TRUNCATE test_foo");
|
||||||
|
|
||||||
|
/*
|
||||||
|
BELOW IS THE FULL TABLE WITH ALL PostgreSQL Types
|
||||||
|
=> \d test_foo
|
||||||
|
Table "public.test_foo"
|
||||||
|
Column | Type | Nullable | Default
|
||||||
|
------------------+-----------------------------+----------+-----------------------------------------------
|
||||||
|
test | character varying | |
|
||||||
|
some_bool | boolean | |
|
||||||
|
string_a | character varying | |
|
||||||
|
number_a | integer | |
|
||||||
|
numeric_a | numeric | |
|
||||||
|
some_internval | interval | |
|
||||||
|
test_foo_id | integer | not null | generated always as identity
|
||||||
|
json_string | jsonb | |
|
||||||
|
some_timestamp | timestamp without time zone | |
|
||||||
|
some_binary | bytea | |
|
||||||
|
null_var | character varying | |
|
||||||
|
smallint_a | smallint | |
|
||||||
|
number_real | real | |
|
||||||
|
number_double | double precision | |
|
||||||
|
number_serial | integer | not null | nextval('test_foo_number_serial_seq'::regclass)
|
||||||
|
array_char_1 | character varying[] | |
|
||||||
|
array_char_2 | character varying[] | |
|
||||||
|
array_int_1 | integer[] | |
|
||||||
|
array_int_2 | integer[] | |
|
||||||
|
composite_item | inventory_item | |
|
||||||
|
array_composite | inventory_item[] | |
|
||||||
|
numeric_3 | numeric(3,0) | |
|
||||||
|
identity_always | bigint | not null | generated always as identity
|
||||||
|
identitiy_default | bigint | not null | generated by default as identity
|
||||||
|
uuid_var | uuid | | gen_random_uuid()
|
||||||
|
some_date | date | |
|
||||||
|
some_time | time without time zone | |
|
||||||
|
bigint_a | bigint | |
|
||||||
|
default_uuid | uuid | | gen_random_uuid()
|
||||||
|
*/
|
||||||
|
|
||||||
/* $q = <<<SQL
|
/* $q = <<<SQL
|
||||||
INSERT INTO test_foo (test, array_composite) VALUES ('C', '{"(a,1,1.5)","(b,2,2.5)"}')
|
INSERT INTO test_foo (test, array_composite) VALUES ('C', '{"(a,1,1.5)","(b,2,2.5)"}')
|
||||||
SQL;
|
SQL;
|
||||||
@@ -90,7 +127,7 @@ $query_params = [
|
|||||||
|
|
||||||
$query_insert = <<<SQL
|
$query_insert = <<<SQL
|
||||||
INSERT INTO test_foo (
|
INSERT INTO test_foo (
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_int_1,
|
array_char_1, array_int_1,
|
||||||
array_composite,
|
array_composite,
|
||||||
@@ -106,7 +143,7 @@ INSERT INTO test_foo (
|
|||||||
)
|
)
|
||||||
RETURNING
|
RETURNING
|
||||||
test_foo_id,
|
test_foo_id,
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_int_1,
|
array_char_1, array_int_1,
|
||||||
array_composite,
|
array_composite,
|
||||||
@@ -127,8 +164,8 @@ echo "<hr>";
|
|||||||
$query_select = <<<SQL
|
$query_select = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id,
|
test_foo_id,
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
number_real, number_double, number_numeric_3, number_serial,
|
number_real, number_double, numeric_3, number_serial,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_char_2, array_int_1, array_int_2, array_composite,
|
array_char_1, array_char_2, array_int_1, array_int_2, array_composite,
|
||||||
composite_item, (composite_item).*,
|
composite_item, (composite_item).*,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ $PRINT_ALL = false;
|
|||||||
$ECHO_ALL = true;
|
$ECHO_ALL = true;
|
||||||
$DB_DEBUG = true;
|
$DB_DEBUG = true;
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
107
www/admin/class_test.deprecated.helper.php
Normal file
107
www/admin/class_test.deprecated.helper.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php // phpcs:ignore warning
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// basic class test file
|
||||||
|
define('USE_DATABASE', false);
|
||||||
|
// sample config
|
||||||
|
require 'config.php';
|
||||||
|
// define log file id
|
||||||
|
$LOG_FILE_ID = 'classTest-phpv';
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
$log = new CoreLibs\Logging\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'log_file_id' => $LOG_FILE_ID,
|
||||||
|
'log_per_date' => true,
|
||||||
|
]);
|
||||||
|
$_phpv = new CoreLibs\Check\PhpVersion();
|
||||||
|
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||||
|
|
||||||
|
$PAGE_NAME = 'TEST CLASS: PHP VERSION';
|
||||||
|
print "<!DOCTYPE html>";
|
||||||
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
|
print "<body>";
|
||||||
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
// fputcsv
|
||||||
|
print "<h3>\CoreLibs\DeprecatedHelper\Deprecated84::fputcsv()</h3>";
|
||||||
|
$test_csv = BASE . TMP . 'DeprecatedHelper.test.csv';
|
||||||
|
print "File: $test_csv<br>";
|
||||||
|
|
||||||
|
$fp = fopen($test_csv, "w");
|
||||||
|
if (!is_resource($fp)) {
|
||||||
|
die("Cannot open file: $test_csv");
|
||||||
|
}
|
||||||
|
\CoreLibs\DeprecatedHelper\Deprecated84::fputcsv($fp, ["A", "B", "C"]);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fp = fopen($test_csv, "r");
|
||||||
|
if (!is_resource($fp)) {
|
||||||
|
die("Cannot open file: $test_csv");
|
||||||
|
}
|
||||||
|
while ($entry = \CoreLibs\DeprecatedHelper\Deprecated84::fgetcsv($fp)) {
|
||||||
|
print "fgetcsv: <pre>" . print_r($entry, true) . "</pre>";
|
||||||
|
}
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$out = \CoreLibs\DeprecatedHelper\Deprecated84::str_getcsv("A,B,C");
|
||||||
|
print "str_getcsv: <pre>" . print_r($out, true) . "</pre>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* temporary different CSV function, because fgetcsv seems to be broken on some systems
|
||||||
|
* (does not read out japanese text)
|
||||||
|
*
|
||||||
|
* @param string $string full line for csv split
|
||||||
|
* @param string $encoding optional, if given, converts string to the internal encoding
|
||||||
|
* before we do anything
|
||||||
|
* @param string $delimiter sepperate character, default ','
|
||||||
|
* @param string $enclosure string line marker, default '"'
|
||||||
|
* @param string $flag INTERN | EXTERN. if INTERN uses the PHP function, else uses explode
|
||||||
|
* @return array<int,string|null> array with split data from input line
|
||||||
|
*/
|
||||||
|
function mtParseCSV(
|
||||||
|
string $string,
|
||||||
|
string $encoding = '',
|
||||||
|
string $delimiter = ',',
|
||||||
|
string $enclosure = '"',
|
||||||
|
string $flag = 'INTERN'
|
||||||
|
): array {
|
||||||
|
$lines = [];
|
||||||
|
if ($encoding) {
|
||||||
|
$string = \CoreLibs\Convert\Encoding::convertEncoding(
|
||||||
|
$string,
|
||||||
|
'UTF-8',
|
||||||
|
$encoding
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($flag == 'INTERN') {
|
||||||
|
// split with PHP function
|
||||||
|
$lines = str_getcsv($string, $delimiter, $enclosure);
|
||||||
|
} else {
|
||||||
|
// split up with delimiter
|
||||||
|
$lines = explode(',', $string) ?: [];
|
||||||
|
}
|
||||||
|
// strip " from beginning and end of line
|
||||||
|
for ($i = 0; $i < count($lines); $i++) {
|
||||||
|
// remove line breaks
|
||||||
|
$lines[$i] = preg_replace("/\r\n?/", '', (string)$lines[$i]) ?? '';
|
||||||
|
// lingering " at the beginning and end of the line
|
||||||
|
$lines[$i] = preg_replace("/^\"/", '', (string)$lines[$i]) ?? '';
|
||||||
|
$lines[$i] = preg_replace("/\"$/", '', (string)$lines[$i]) ?? '';
|
||||||
|
}
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</body></html>";
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ require 'config.php';
|
|||||||
$LOG_FILE_ID = 'classTest-encryption';
|
$LOG_FILE_ID = 'classTest-encryption';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
use CoreLibs\Security\AsymmetricAnonymousEncryption;
|
||||||
use CoreLibs\Security\SymmetricEncryption;
|
use CoreLibs\Security\SymmetricEncryption;
|
||||||
use CoreLibs\Security\CreateKey;
|
use CoreLibs\Security\CreateKey;
|
||||||
|
|
||||||
@@ -36,6 +37,8 @@ print "<body>";
|
|||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
print "<h2>Symmetric Encryption</h2>";
|
||||||
|
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
print "Secret Key: " . $key . "<br>";
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
|
||||||
@@ -105,6 +108,49 @@ try {
|
|||||||
// $encrypted = $se->encrypt($string);
|
// $encrypted = $se->encrypt($string);
|
||||||
// $decrypted = $se->decrypt($encrypted);
|
// $decrypted = $se->decrypt($encrypted);
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
print "<h2>Asymmetric Encryption</h2>";
|
||||||
|
|
||||||
|
$key_pair = CreateKey::createKeyPair();
|
||||||
|
$public_key = CreateKey::getPublicKey($key_pair);
|
||||||
|
|
||||||
|
$string = "I am some asymmetric secret";
|
||||||
|
print "Message: " . $string . "<br>";
|
||||||
|
$encrypted = sodium_crypto_box_seal($string, CreateKey::hex2bin($public_key));
|
||||||
|
$message = sodium_bin2base64($encrypted, SODIUM_BASE64_VARIANT_ORIGINAL);
|
||||||
|
print "Encrypted PL: " . $message . "<br>";
|
||||||
|
$result = sodium_base642bin($message, SODIUM_BASE64_VARIANT_ORIGINAL);
|
||||||
|
$decrypted = sodium_crypto_box_seal_open($result, CreateKey::hex2bin($key_pair));
|
||||||
|
print "Decrypted PL: " . $decrypted . "<br>";
|
||||||
|
|
||||||
|
$encrypted = AsymmetricAnonymousEncryption::encryptKey($string, $public_key);
|
||||||
|
print "Encrypted ST: " . $encrypted . "<br>";
|
||||||
|
$decrypted = AsymmetricAnonymousEncryption::decryptKey($encrypted, $key_pair);
|
||||||
|
print "Decrypted ST: " . $decrypted . "<br>";
|
||||||
|
|
||||||
|
$aa_crypt = new AsymmetricAnonymousEncryption($key_pair, $public_key);
|
||||||
|
$encrypted = $aa_crypt->encrypt($string);
|
||||||
|
print "Encrypted: " . $encrypted . "<br>";
|
||||||
|
$decrypted = $aa_crypt->decrypt($encrypted);
|
||||||
|
print "Decrypted: " . $decrypted . "<br>";
|
||||||
|
|
||||||
|
print "Base64 encode: " . base64_encode('Some text here') . "<Br>";
|
||||||
|
|
||||||
|
/// this has to fail
|
||||||
|
$crypt = new AsymmetricAnonymousEncryption();
|
||||||
|
$crypt->setPublicKey(CreateKey::getPublicKey(CreateKey::createKeyPair()));
|
||||||
|
print "Public Key: " . $crypt->getPublicKey() . "<br>";
|
||||||
|
try {
|
||||||
|
$crypt->setPublicKey(CreateKey::createKeyPair());
|
||||||
|
} catch (RangeException $e) {
|
||||||
|
print "Invalid range: <pre>$e</pre>";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$crypt->setKeyPair(CreateKey::getPublicKey(CreateKey::createKeyPair()));
|
||||||
|
} catch (RangeException $e) {
|
||||||
|
print "Invalid range: <pre>$e</pre>";
|
||||||
|
}
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ $LOG_FILE_ID = 'classTest-hash';
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Create\Hash;
|
use CoreLibs\Create\Hash;
|
||||||
|
use CoreLibs\Security\CreateKey;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -38,28 +39,66 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
|||||||
|
|
||||||
$to_crc = 'Some text block';
|
$to_crc = 'Some text block';
|
||||||
// static
|
// static
|
||||||
print "S::__CRC32B: $to_crc: " . $hash_class::__crc32b($to_crc) . "<br>";
|
print "S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
|
||||||
print "S::__SHA1SHORT(off): $to_crc: " . $hash_class::__sha1short($to_crc) . "<br>";
|
// print "S::__SHA1SHORT(off): $to_crc: " . Hash::__sha1short($to_crc) . "<br>";
|
||||||
print "S::__SHA1SHORT(on): $to_crc: " . $hash_class::__sha1short($to_crc, true) . "<br>";
|
print "S::hashShort(__sha1Short replace): $to_crc: " . Hash::hashShort($to_crc) . "<br>";
|
||||||
print "S::__hash(d): " . $to_crc . "/"
|
// print "S::__SHA1SHORT(on): $to_crc: " . Hash::__sha1short($to_crc, true) . "<br>";
|
||||||
. Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
|
print "S::sha1Short(__sha1Short replace): $to_crc: " . Hash::sha1Short($to_crc) . "<br>";
|
||||||
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'sha512'] as $__hash_c) {
|
// print "S::__hash(d): " . $to_crc . "/"
|
||||||
print "S::__hash($__hash_c): $to_crc: " . $hash_class::__hash($to_crc, $__hash_c) . "<br>";
|
// . Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
|
||||||
|
$to_crc_list = [
|
||||||
|
'Some text block',
|
||||||
|
'Some String Text',
|
||||||
|
'any string',
|
||||||
|
];
|
||||||
|
foreach ($to_crc_list as $__to_crc) {
|
||||||
|
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'ripemd160', 'sha256', 'sha512'] as $__hash_c) {
|
||||||
|
print "Hash::hash($__hash_c): $__to_crc: " . Hash::hash($to_crc, $__hash_c) . "<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// static use
|
// static use
|
||||||
print "U-S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
|
print "U-S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
|
||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
$text = 'Some String Text';
|
$text = 'Some String Text';
|
||||||
|
// $text = 'any string';
|
||||||
$type = 'crc32b';
|
$type = 'crc32b';
|
||||||
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
|
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
|
||||||
print "Class: " . $type . ": " . Hash::__hash($text, $type) . "<br>";
|
// print "Class (old): " . $type . ": " . Hash::__hash($text, $type) . "<br>";
|
||||||
|
print "Class (new): " . $type . ": " . Hash::hash($text, $type) . "<br>";
|
||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
print "<br>CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
|
print "CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
|
||||||
print "<br>CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
print "CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
||||||
print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>";
|
print "CURRENT STANDARD_HASH: " . Hash::STANDARD_HASH . "<br>";
|
||||||
print "HASH LONG: " . $to_crc . ": " . Hash::__hashLong($to_crc) . "<br>";
|
print "HASH SHORT: " . $to_crc . ": " . Hash::hashShort($to_crc) . "<br>";
|
||||||
|
print "HASH LONG: " . $to_crc . ": " . Hash::hashLong($to_crc) . "<br>";
|
||||||
|
print "HASH DEFAULT: " . $to_crc . ": " . Hash::hashStd($to_crc) . "<br>";
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
$key = CreateKey::generateRandomKey();
|
||||||
|
$key = "FIX KEY";
|
||||||
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
print "HASHMAC DEFAULT (fix): " . $to_crc . ": " . Hash::hashHmac($to_crc, $key) . "<br>";
|
||||||
|
$key = CreateKey::generateRandomKey();
|
||||||
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
print "HASHMAC DEFAULT (random): " . $to_crc . ": " . Hash::hashHmac($to_crc, $key) . "<br>";
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
$hash_types = ['crc32b', 'sha256', 'invalid'];
|
||||||
|
foreach ($hash_types as $hash_type) {
|
||||||
|
echo "<b>Checking $hash_type:</b><br>";
|
||||||
|
if (Hash::isValidHashType($hash_type)) {
|
||||||
|
echo "hash type: $hash_type is valid<br>";
|
||||||
|
} else {
|
||||||
|
echo "hash type: $hash_type is INVALID<br>";
|
||||||
|
}
|
||||||
|
if (Hash::isValidHashHmacType($hash_type)) {
|
||||||
|
echo "hash hmac type: $hash_type is valid<br>";
|
||||||
|
} else {
|
||||||
|
echo "hash hmac type: $hash_type is INVALID<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// print "UNIQU ID SHORT : " . Hash::__uniqId() . "<br>";
|
// print "UNIQU ID SHORT : " . Hash::__uniqId() . "<br>";
|
||||||
// print "UNIQU ID LONG : " . Hash::__uniqIdLong() . "<br>";
|
// print "UNIQU ID LONG : " . Hash::__uniqIdLong() . "<br>";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ if (isset($login->loginGetAcl()['unit'])) {
|
|||||||
if ($login->loginCheckEditAccessCuid($edit_access_cuid)) {
|
if ($login->loginCheckEditAccessCuid($edit_access_cuid)) {
|
||||||
print "Set new:" . $edit_access_cuid . "<br>";
|
print "Set new:" . $edit_access_cuid . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "Load default unit id: " . $login->loginGetAcl()['unit_id'] . "<br>";
|
print "Load default unit id: " . $login->loginGetAcl()['unit_cuid'] . "<br>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "Something went wrong with the login<br>";
|
print "Something went wrong with the login<br>";
|
||||||
@@ -127,6 +127,12 @@ if (isset($login->loginGetAcl()['unit'])) {
|
|||||||
// IP check: 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP' in _SERVER
|
// IP check: 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP' in _SERVER
|
||||||
// Agent check: 'HTTP_USER_AGENT'
|
// Agent check: 'HTTP_USER_AGENT'
|
||||||
|
|
||||||
|
print "<hr>";
|
||||||
|
print "PAGE lookup:<br>";
|
||||||
|
$file_name = 'test_edit_base.php';
|
||||||
|
print "Access to '$file_name': " . $log->prAr($login->loginPageAccessAllowed($file_name)) . "<br>";
|
||||||
|
$file_name = 'i_do_not_exists.php';
|
||||||
|
print "Access to '$file_name': " . $log->prAr($login->loginPageAccessAllowed($file_name)) . "<br>";
|
||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
print "SESSION: " . Support::printAr($_SESSION) . "<br>";
|
print "SESSION: " . Support::printAr($_SESSION) . "<br>";
|
||||||
@@ -140,4 +146,17 @@ $login->writeLog(
|
|||||||
write_type:'JSON'
|
write_type:'JSON'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
print "<h3>Legacy Lookups</h3>";
|
||||||
|
|
||||||
|
$edit_access_id = 1;
|
||||||
|
$edit_access_cuid = $login->loginGetEditAccessCuidFromId($edit_access_id);
|
||||||
|
$edit_access_id_rev = null;
|
||||||
|
if (is_string($edit_access_cuid)) {
|
||||||
|
$edit_access_id_rev = $login->loginGetEditAccessIdFromCuid($edit_access_cuid);
|
||||||
|
}
|
||||||
|
print "EA ID: " . $edit_access_id . "<br>";
|
||||||
|
print "EA CUID: " . $log->prAr($edit_access_cuid) . "<br>";
|
||||||
|
print "REV EA CUID: " . $log->prAr($edit_access_id_rev) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -29,15 +29,17 @@ $table_arrays = [];
|
|||||||
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
||||||
// form fields mtaching up with db fields
|
// form fields mtaching up with db fields
|
||||||
'table_array' => [
|
'table_array' => [
|
||||||
|
'foo',
|
||||||
|
'bar'
|
||||||
],
|
],
|
||||||
// laod query
|
// laod query
|
||||||
'load_query' => '',
|
'load_query' => 'SELECT uuid_nr, foo, bar FROM test',
|
||||||
// database table to load from
|
// database table to load from
|
||||||
'table_name' => '',
|
'table_name' => 'test',
|
||||||
// for load dro pdown, format output
|
// for load dro pdown, format output
|
||||||
'show_fields' => [
|
'show_fields' => [
|
||||||
[
|
[
|
||||||
'name' => 'name'
|
'name' => 'foo'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'enabled',
|
'name' => 'enabled',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -37,6 +37,8 @@ print "<body>";
|
|||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
print "PHP Version: " . PHP_VERSION . "<br>";
|
||||||
|
|
||||||
$password = 'something1234';
|
$password = 'something1234';
|
||||||
$enc_password = $_password->passwordSet($password);
|
$enc_password = $_password->passwordSet($password);
|
||||||
print "PASSWORD: $password: " . $enc_password . "<br>";
|
print "PASSWORD: $password: " . $enc_password . "<br>";
|
||||||
@@ -51,6 +53,20 @@ print "PASSWORD REHASH: " . (string)$password_class::passwordRehashCheck($enc_pa
|
|||||||
// direct static
|
// direct static
|
||||||
print "S::PASSWORD VERFIY: " . (string)PwdChk::passwordVerify($password, $enc_password) . "<br>";
|
print "S::PASSWORD VERFIY: " . (string)PwdChk::passwordVerify($password, $enc_password) . "<br>";
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 80400) {
|
||||||
|
$rehash_test = '$2y$10$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
$rehash_test_throw = '$2y$12$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
} else {
|
||||||
|
$rehash_test = '$2y$12$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
$rehash_test_throw = '$2y$10$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
}
|
||||||
|
if (PwdChk::passwordRehashCheck($rehash_test)) {
|
||||||
|
print "Bad password [BAD]<br>";
|
||||||
|
}
|
||||||
|
if (PwdChk::passwordRehashCheck($rehash_test_throw)) {
|
||||||
|
print "Bad password [OK]<br>";
|
||||||
|
}
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -95,6 +95,7 @@ $test_files = [
|
|||||||
'class_test.db.dbReturn.php' => 'Class Test: DB dbReturn',
|
'class_test.db.dbReturn.php' => 'Class Test: DB dbReturn',
|
||||||
'class_test.db.single.php' => 'Class Test: DB single query tests',
|
'class_test.db.single.php' => 'Class Test: DB single query tests',
|
||||||
'class_test.db.convert-placeholder.php' => 'Class Test: DB convert placeholder',
|
'class_test.db.convert-placeholder.php' => 'Class Test: DB convert placeholder',
|
||||||
|
'class_test.db.encryption.php' => 'Class Test: DB pgcrypto',
|
||||||
'class_test.convert.colors.php' => 'Class Test: CONVERT COLORS',
|
'class_test.convert.colors.php' => 'Class Test: CONVERT COLORS',
|
||||||
'class_test.check.colors.php' => 'Class Test: CHECK COLORS',
|
'class_test.check.colors.php' => 'Class Test: CHECK COLORS',
|
||||||
'class_test.mime.php' => 'Class Test: MIME',
|
'class_test.mime.php' => 'Class Test: MIME',
|
||||||
@@ -141,6 +142,7 @@ $test_files = [
|
|||||||
'class_test.error_msg.php' => 'Class Test: ERROR MSG',
|
'class_test.error_msg.php' => 'Class Test: ERROR MSG',
|
||||||
'class_test.url-requests.curl.php' => 'Class Test: URL REQUESTS: CURL',
|
'class_test.url-requests.curl.php' => 'Class Test: URL REQUESTS: CURL',
|
||||||
'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB',
|
'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB',
|
||||||
|
'class_test.deprecated.helper.php' => 'Class Test: DEPRECATED HELPERS',
|
||||||
];
|
];
|
||||||
|
|
||||||
asort($test_files);
|
asort($test_files);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -28,8 +28,6 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
$_phpv = new CoreLibs\Check\PhpVersion();
|
$_phpv = new CoreLibs\Check\PhpVersion();
|
||||||
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||||
|
|
||||||
// define a list of from to color sets for conversion test
|
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: PHP VERSION';
|
$PAGE_NAME = 'TEST CLASS: PHP VERSION';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
@@ -86,8 +86,10 @@ if (!isset($_SESSION['counter'])) {
|
|||||||
$_SESSION['counter']++;
|
$_SESSION['counter']++;
|
||||||
print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
$_SESSION[$var] = $value;
|
$_SESSION[$var] = $value;
|
||||||
|
/** @phpstan-ignore-next-line nullCoalesce.offset */
|
||||||
print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||||
|
/** @phpstan-ignore-next-line equal.alwaysTrue, nullCoalesce.offset */
|
||||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||||
|
|
||||||
// test set wrappers methods
|
// test set wrappers methods
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME: Smarty Class must be updated for PHP 8.4
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
);
|
);
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend(
|
$smarty = new CoreLibs\Template\SmartyExtend(
|
||||||
$l10n,
|
$l10n,
|
||||||
|
$log,
|
||||||
CACHE_ID,
|
CACHE_ID,
|
||||||
COMPILE_ID,
|
COMPILE_ID,
|
||||||
);
|
);
|
||||||
@@ -45,6 +48,7 @@ $adm = new CoreLibs\Admin\Backend(
|
|||||||
);
|
);
|
||||||
$adm->DATA['adm_set'] = 'SET from admin class';
|
$adm->DATA['adm_set'] = 'SET from admin class';
|
||||||
|
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
/* general edit javascript */
|
/*
|
||||||
/* jquery version */
|
general edit javascript
|
||||||
|
jquery version
|
||||||
|
*/
|
||||||
|
|
||||||
/* jshint esversion: 11 */
|
/** @deprecated Do not use this anymore, use utils.js or utils.min.js */
|
||||||
|
|
||||||
/* global i18n */
|
/* global i18n */
|
||||||
|
|
||||||
@@ -18,11 +20,28 @@ if (!DEBUG) {
|
|||||||
var GL_OB_S = 100;
|
var GL_OB_S = 100;
|
||||||
var GL_OB_BASE = 100;
|
var GL_OB_BASE = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets html element or throws an error
|
||||||
|
* @param {string} el_id Element ID to get
|
||||||
|
* @returns {HTMLElement}
|
||||||
|
* @throws Error
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function loadEl(el_id)
|
||||||
|
{
|
||||||
|
let el = document.getElementById(el_id);
|
||||||
|
if (el === null) {
|
||||||
|
throw new Error('Cannot find: ' + el_id);
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* opens a popup window with winName and given features (string)
|
* opens a popup window with winName and given features (string)
|
||||||
* @param {String} theURL the url
|
* @param {String} theURL the url
|
||||||
* @param {String} winName window name
|
* @param {String} winName window name
|
||||||
* @param {Object} features popup features
|
* @param {Object} features popup features
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -33,6 +52,7 @@ function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* automatically resize a text area based on the amount of lines in it
|
* automatically resize a text area based on the amount of lines in it
|
||||||
* @param {string} ta_id element id
|
* @param {string} ta_id element id
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -58,6 +78,7 @@ function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the real window size for the current browser window
|
* wrapper to get the real window size for the current browser window
|
||||||
* @return {Object} object with width/height
|
* @return {Object} object with width/height
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getWindowSize()
|
function getWindowSize()
|
||||||
{
|
{
|
||||||
@@ -73,6 +94,7 @@ function getWindowSize()
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the correct scroll offset
|
* wrapper to get the correct scroll offset
|
||||||
* @return {Object} object with x/y px
|
* @return {Object} object with x/y px
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getScrollOffset()
|
function getScrollOffset()
|
||||||
{
|
{
|
||||||
@@ -88,6 +110,7 @@ function getScrollOffset()
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the correct scroll offset for opener page (from popup)
|
* wrapper to get the correct scroll offset for opener page (from popup)
|
||||||
* @return {Object} object with x/y px
|
* @return {Object} object with x/y px
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -105,6 +128,7 @@ function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} id element to center
|
* @param {String} id element to center
|
||||||
* @param {Boolean} left if true centers to the middle from the left
|
* @param {Boolean} left if true centers to the middle from the left
|
||||||
* @param {Boolean} top if true centers to the middle from the top
|
* @param {Boolean} top if true centers to the middle from the top
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function setCenter(id, left, top)
|
function setCenter(id, left, top)
|
||||||
{
|
{
|
||||||
@@ -142,6 +166,7 @@ function setCenter(id, left, top)
|
|||||||
* @param {Number} [offset=0] offset from top, default is 0 (px)
|
* @param {Number} [offset=0] offset from top, default is 0 (px)
|
||||||
* @param {Number} [duration=500] animation time, default 500ms
|
* @param {Number} [duration=500] animation time, default 500ms
|
||||||
* @param {String} [base='body,html'] base element for offset scroll
|
* @param {String} [base='body,html'] base element for offset scroll
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function goToPos(element, offset = 0, duration = 500, base = 'body,html') // eslint-disable-line no-unused-vars
|
function goToPos(element, offset = 0, duration = 500, base = 'body,html') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -156,11 +181,25 @@ function goToPos(element, offset = 0, duration = 500, base = 'body,html') // esl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* go to element, scroll
|
||||||
|
* non jquery
|
||||||
|
* @param {string} target
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function goTo(target) // eslint-disable-line no-unused-vars
|
||||||
|
{
|
||||||
|
loadEl(target).scrollIntoView({
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uses the i18n object created in the translation template
|
* uses the i18n object created in the translation template
|
||||||
* that is filled from gettext in PHP
|
* that is filled from gettext in PHP
|
||||||
* @param {String} string text to translate
|
* @param {String} string text to translate
|
||||||
* @return {String} translated text (based on PHP selected language)
|
* @return {String} translated text (based on PHP selected language)
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function __(string)
|
function __(string)
|
||||||
{
|
{
|
||||||
@@ -177,37 +216,70 @@ function __(string)
|
|||||||
* First, checks if it isn't implemented yet.
|
* First, checks if it isn't implemented yet.
|
||||||
* @param {String} String.prototype.format string with elements to be replaced
|
* @param {String} String.prototype.format string with elements to be replaced
|
||||||
* @return {String} Formated string
|
* @return {String} Formated string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.format) {
|
if (!String.prototype.format) {
|
||||||
String.prototype.format = function()
|
String.prototype.format = function()
|
||||||
{
|
{
|
||||||
var args = arguments;
|
console.error('[DEPRECATED] use formatString');
|
||||||
return this.replace(/{(\d+)}/g, function(match, number)
|
return formatString(this, arguments);
|
||||||
{
|
};
|
||||||
return typeof args[number] != 'undefined' ?
|
}
|
||||||
args[number] :
|
|
||||||
match
|
/**
|
||||||
;
|
* simple sprintf formater for replace
|
||||||
});
|
* usage: "{0} is cool, {1} is not".format("Alpha", "Beta");
|
||||||
|
* First, checks if it isn't implemented yet.
|
||||||
|
* @param {String} string String with {..} entries
|
||||||
|
* @param {...any} args List of replacement
|
||||||
|
* @returns {String} Escaped string
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function formatString(string, ...args)
|
||||||
|
{
|
||||||
|
return string.replace(/{(\d+)}/g, function(match, number)
|
||||||
|
{
|
||||||
|
return typeof args[number] != 'undefined' ?
|
||||||
|
args[number] :
|
||||||
|
match
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* round to digits (float)
|
||||||
|
* @param {Number} Number.prototype.round Float type number to round
|
||||||
|
* @param {Number} prec Precision to round to
|
||||||
|
* @return {Float} Rounded number
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
if (Number.prototype.round) {
|
||||||
|
Number.prototype.round = function (prec) {
|
||||||
|
console.error('[DEPRECATED] use roundPrecision');
|
||||||
|
return roundPrecision(this, prec);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* round to digits (float)
|
* round to digits (float)
|
||||||
* @param {Float} Number.prototype.round Float type number to round
|
* @param {Number} number Float type number to round
|
||||||
* @param {Number} prec Precision to round to
|
* @param {Number} precision Precision to round to
|
||||||
* @return {Float} Rounded number
|
* @return {Number} Rounded number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (Number.prototype.round) {
|
function roundPrecision(number, precision)
|
||||||
Number.prototype.round = function (prec) {
|
{
|
||||||
return Math.round(this * Math.pow(10, prec)) / Math.pow(10, prec);
|
if (!isNaN(number) || !isNaN(precision)) {
|
||||||
};
|
return number;
|
||||||
|
}
|
||||||
|
return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formats flat number 123456 to 123,456
|
* formats flat number 123456 to 123,456
|
||||||
* @param {Number} x number to be formated
|
* @param {Number} x number to be formated
|
||||||
* @return {String} formatted with , in thousands
|
* @return {String} formatted with , in thousands
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -220,6 +292,7 @@ function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
|||||||
* converts line breaks to br
|
* converts line breaks to br
|
||||||
* @param {String} string any string
|
* @param {String} string any string
|
||||||
* @return {String} string with <br>
|
* @return {String} string with <br>
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -228,51 +301,78 @@ function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* escape HTML string
|
* escape HTML string
|
||||||
* @param {String} !String.prototype.escapeHTML HTML data string to be escaped
|
* @param {String} String.prototype.escapeHTML HTML data string to be escaped
|
||||||
* @return {String} escaped string
|
* @return {String} escaped string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.escapeHTML) {
|
if (!String.prototype.escapeHTML) {
|
||||||
String.prototype.escapeHTML = function() {
|
String.prototype.escapeHTML = function() {
|
||||||
return this.replace(/[&<>"'/]/g, function (s) {
|
console.error('[DEPRECATED] use escapeHtml');
|
||||||
var entityMap = {
|
return escapeHtml(this);
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
'\'': ''',
|
|
||||||
'/': '/'
|
|
||||||
};
|
|
||||||
|
|
||||||
return entityMap[s];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unescape a HTML encoded string
|
* unescape a HTML encoded string
|
||||||
* @param {String} !String.prototype.unescapeHTML data with escaped entries
|
* @param {String} String.prototype.unescapeHTML data with escaped entries
|
||||||
* @return {String} HTML formated string
|
* @return {String} HTML formated string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.unescapeHTML) {
|
if (!String.prototype.unescapeHTML) {
|
||||||
String.prototype.unescapeHTML = function() {
|
String.prototype.unescapeHTML = function() {
|
||||||
return this.replace(/&[#\w]+;/g, function (s) {
|
console.error('[DEPRECATED] use unescapeHtml');
|
||||||
var entityMap = {
|
return unescapeHtml(this);
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
''': '\'',
|
|
||||||
'/': '/'
|
|
||||||
};
|
|
||||||
|
|
||||||
return entityMap[s];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes HTML in string
|
||||||
|
* @param {String} string Text to escape HTML in
|
||||||
|
* @returns {String}
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function escapeHtml(string)
|
||||||
|
{
|
||||||
|
return string.replace(/[&<>"'/]/g, function (s) {
|
||||||
|
var entityMap = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
'\'': ''',
|
||||||
|
'/': '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unescape a HTML encoded string
|
||||||
|
* @param {String} string Text to unescape HTML in
|
||||||
|
* @returns {String}
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function unescapeHtml(string)
|
||||||
|
{
|
||||||
|
return string.replace(/&[#\w]+;/g, function (s) {
|
||||||
|
var entityMap = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
''': '\'',
|
||||||
|
'/': '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns current timestamp (unix timestamp)
|
* returns current timestamp (unix timestamp)
|
||||||
* @return {Number} timestamp (in milliseconds)
|
* @return {Number} timestamp (in milliseconds)
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getTimestamp() // eslint-disable-line no-unused-vars
|
function getTimestamp() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -285,6 +385,7 @@ function getTimestamp() // eslint-disable-line no-unused-vars
|
|||||||
* i.e. 0-255 -> '00'-'ff'
|
* i.e. 0-255 -> '00'-'ff'
|
||||||
* @param {Number} dec decimal string
|
* @param {Number} dec decimal string
|
||||||
* @return {String} hex encdoded number
|
* @return {String} hex encdoded number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function dec2hex(dec)
|
function dec2hex(dec)
|
||||||
{
|
{
|
||||||
@@ -296,6 +397,7 @@ function dec2hex(dec)
|
|||||||
* only works on mondern browsers
|
* only works on mondern browsers
|
||||||
* @param {Number} len length of unique id string
|
* @param {Number} len length of unique id string
|
||||||
* @return {String} random string in length of len
|
* @return {String} random string in length of len
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function generateId(len) // eslint-disable-line no-unused-vars
|
function generateId(len) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -309,6 +411,7 @@ function generateId(len) // eslint-disable-line no-unused-vars
|
|||||||
* works on all browsers
|
* works on all browsers
|
||||||
* after many runs it will create duplicates
|
* after many runs it will create duplicates
|
||||||
* @return {String} not true random string
|
* @return {String} not true random string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function randomIdF() // eslint-disable-line no-unused-vars
|
function randomIdF() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -322,6 +425,7 @@ function randomIdF() // eslint-disable-line no-unused-vars
|
|||||||
* @param {Number} min minimum int number inclusive
|
* @param {Number} min minimum int number inclusive
|
||||||
* @param {Number} max maximumg int number inclusive
|
* @param {Number} max maximumg int number inclusive
|
||||||
* @return {Number} Random number
|
* @return {Number} Random number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -335,6 +439,7 @@ function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
|||||||
* check if name is a function
|
* check if name is a function
|
||||||
* @param {string} name Name of function to check if exists
|
* @param {string} name Name of function to check if exists
|
||||||
* @return {Boolean} true/false
|
* @return {Boolean} true/false
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function isFunction(name) // eslint-disable-line no-unused-vars
|
function isFunction(name) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -354,6 +459,7 @@ function isFunction(name) // eslint-disable-line no-unused-vars
|
|||||||
* @param {mixed} context context (window or first namespace)
|
* @param {mixed} context context (window or first namespace)
|
||||||
* hidden next are all the arguments
|
* hidden next are all the arguments
|
||||||
* @return {mixed} Return values from functon
|
* @return {mixed} Return values from functon
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function executeFunctionByName(functionName, context /*, args */) // eslint-disable-line no-unused-vars
|
function executeFunctionByName(functionName, context /*, args */) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -370,6 +476,7 @@ function executeFunctionByName(functionName, context /*, args */) // eslint-disa
|
|||||||
* checks if a variable is an object
|
* checks if a variable is an object
|
||||||
* @param {Mixed} val possible object
|
* @param {Mixed} val possible object
|
||||||
* @return {Boolean} true/false if it is an object or not
|
* @return {Boolean} true/false if it is an object or not
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function isObject(val)
|
function isObject(val)
|
||||||
{
|
{
|
||||||
@@ -383,6 +490,7 @@ function isObject(val)
|
|||||||
* get the length of an object (entries)
|
* get the length of an object (entries)
|
||||||
* @param {Object} object object to check
|
* @param {Object} object object to check
|
||||||
* @return {Number} number of entry
|
* @return {Number} number of entry
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getObjectCount(object)
|
function getObjectCount(object)
|
||||||
{
|
{
|
||||||
@@ -394,6 +502,7 @@ function getObjectCount(object)
|
|||||||
* @param {String} key key name
|
* @param {String} key key name
|
||||||
* @param {Object} object object to search key in
|
* @param {Object} object object to search key in
|
||||||
* @return {Boolean} true/false if key exists in object
|
* @return {Boolean} true/false if key exists in object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function keyInObject(key, object)
|
function keyInObject(key, object)
|
||||||
{
|
{
|
||||||
@@ -402,9 +511,10 @@ function keyInObject(key, object)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns matching key of value
|
* returns matching key of value
|
||||||
* @param {Object} obj object to search value in
|
* @param {Object} object object to search value in
|
||||||
* @param {Mixed} value any value (String, Number, etc)
|
* @param {Mixed} value any value (String, Number, etc)
|
||||||
* @return {String} the key found for the first matching value
|
* @return {String} the key found for the first matching value
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -416,9 +526,10 @@ function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if value is found in object with a key
|
* returns true if value is found in object with a key
|
||||||
* @param {Object} obj object to search value in
|
* @param {Object} object object to search value in
|
||||||
* @param {Mixed} value any value (String, Number, etc)
|
* @param {Mixed} value any value (String, Number, etc)
|
||||||
* @return {Boolean} true on value found, false on not found
|
* @return {Boolean} true on value found, false on not found
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -434,6 +545,7 @@ function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
|||||||
* or if JSON.parse(JSON.stringify(obj)) is failing
|
* or if JSON.parse(JSON.stringify(obj)) is failing
|
||||||
* @param {Object} inObject Object to copy
|
* @param {Object} inObject Object to copy
|
||||||
* @return {Object} Copied Object
|
* @return {Object} Copied Object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function deepCopyFunction(inObject)
|
function deepCopyFunction(inObject)
|
||||||
{
|
{
|
||||||
@@ -457,6 +569,7 @@ function deepCopyFunction(inObject)
|
|||||||
* checks if a DOM element actually exists
|
* checks if a DOM element actually exists
|
||||||
* @param {String} id Element id to check for
|
* @param {String} id Element id to check for
|
||||||
* @return {Boolean} true if element exists, false on failure
|
* @return {Boolean} true if element exists, false on failure
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function exists(id)
|
function exists(id)
|
||||||
{
|
{
|
||||||
@@ -468,6 +581,7 @@ function exists(id)
|
|||||||
* currently precision is fixed, if dynamic needs check for max/min precision
|
* currently precision is fixed, if dynamic needs check for max/min precision
|
||||||
* @param {Number} bytes bytes in int
|
* @param {Number} bytes bytes in int
|
||||||
* @return {String} string in GB/MB/KB
|
* @return {String} string in GB/MB/KB
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -484,6 +598,7 @@ function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
|||||||
* like formatBytes, but returns bytes for <1KB and not 0.n KB
|
* like formatBytes, but returns bytes for <1KB and not 0.n KB
|
||||||
* @param {Number} bytes bytes in int
|
* @param {Number} bytes bytes in int
|
||||||
* @return {String} string in GB/MB/KB
|
* @return {String} string in GB/MB/KB
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -496,6 +611,7 @@ function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
|||||||
* Convert a string with B/K/M/etc into a byte number
|
* Convert a string with B/K/M/etc into a byte number
|
||||||
* @param {String|Number} bytes Any string with B/K/M/etc
|
* @param {String|Number} bytes Any string with B/K/M/etc
|
||||||
* @return {String|Number} A byte number, or original string as is
|
* @return {String|Number} A byte number, or original string as is
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -526,6 +642,7 @@ function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* prints out error messages based on data available from the browser
|
* prints out error messages based on data available from the browser
|
||||||
* @param {Object} err error from try/catch block
|
* @param {Object} err error from try/catch block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function errorCatch(err)
|
function errorCatch(err)
|
||||||
{
|
{
|
||||||
@@ -533,22 +650,20 @@ function errorCatch(err)
|
|||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
// only FF
|
// only FF
|
||||||
if (err.lineNumber) {
|
if (err.lineNumber) {
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.lineNumber, err.message);
|
console.error('ERROR[%s:%s] ', err.name, err.lineNumber, err);
|
||||||
} else if (err.line) {
|
} else if (err.line) {
|
||||||
// only Safari
|
// only Safari
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.line, err.message);
|
console.error('ERROR[%s:%s] ', err.name, err.line, err);
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[%s] %s', err.name, err.message);
|
console.error('ERROR[%s] ', err.name, err);
|
||||||
}
|
}
|
||||||
// stack trace
|
|
||||||
console.log('ERROR[stack] %s', err.stack);
|
|
||||||
} else if (err.number) {
|
} else if (err.number) {
|
||||||
// IE
|
// IE
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.number, err.message);
|
console.error('ERROR[%s:%s] %s', err.name, err.number, err.message);
|
||||||
console.log('ERROR[description] %s', err.description);
|
console.error('ERROR[description] %s', err.description);
|
||||||
} else {
|
} else {
|
||||||
// the rest
|
// the rest
|
||||||
console.log('ERROR[%s] %s', err.name, err.message);
|
console.error('ERROR[%s] %s', err.name, err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,6 +686,7 @@ function errorCatch(err)
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-vars
|
function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -587,6 +703,7 @@ function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-v
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicatorShow(loc, overlay = true)
|
function actionIndicatorShow(loc, overlay = true)
|
||||||
{
|
{
|
||||||
@@ -609,6 +726,7 @@ function actionIndicatorShow(loc, overlay = true)
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicatorHide(loc, overlay = true)
|
function actionIndicatorHide(loc, overlay = true)
|
||||||
{
|
{
|
||||||
@@ -621,6 +739,7 @@ function actionIndicatorHide(loc, overlay = true)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* shows the overlay box or if already visible, bumps the zIndex to 100
|
* shows the overlay box or if already visible, bumps the zIndex to 100
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function overlayBoxShow()
|
function overlayBoxShow()
|
||||||
{
|
{
|
||||||
@@ -635,6 +754,7 @@ function overlayBoxShow()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function overlayBoxHide()
|
function overlayBoxHide()
|
||||||
{
|
{
|
||||||
@@ -648,6 +768,7 @@ function overlayBoxHide()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* position the overlay block box and shows it
|
* position the overlay block box and shows it
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function setOverlayBox() // eslint-disable-line no-unused-vars
|
function setOverlayBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -658,6 +779,7 @@ function setOverlayBox() // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* opposite of set, always hides overlay box
|
* opposite of set, always hides overlay box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideOverlayBox() // eslint-disable-line no-unused-vars
|
function hideOverlayBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -668,6 +790,7 @@ function hideOverlayBox() // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the abort call, clears the action box and hides it and the overlay box
|
* the abort call, clears the action box and hides it and the overlay box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function ClearCall() // eslint-disable-line no-unused-vars
|
function ClearCall() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -689,6 +812,7 @@ function ClearCall() // eslint-disable-line no-unused-vars
|
|||||||
* zIndex of 1000
|
* zIndex of 1000
|
||||||
* - indicator is page centered
|
* - indicator is page centered
|
||||||
* @param {String} loc ID string, only used for console log
|
* @param {String} loc ID string, only used for console log
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -727,6 +851,7 @@ function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
|||||||
* the overlayBox is not hidden but the zIndex
|
* the overlayBox is not hidden but the zIndex
|
||||||
* is set to this value
|
* is set to this value
|
||||||
* @param {String} loc ID string, only used for console log
|
* @param {String} loc ID string, only used for console log
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -750,6 +875,7 @@ function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* checks if overlayBox exists, if not it is
|
* checks if overlayBox exists, if not it is
|
||||||
* added as hidden item at the body end
|
* added as hidden item at the body end
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function checkOverlayExists()
|
function checkOverlayExists()
|
||||||
{
|
{
|
||||||
@@ -767,6 +893,7 @@ function checkOverlayExists()
|
|||||||
* if not visible show and set zIndex to 10 (GL_OB_BASE)
|
* if not visible show and set zIndex to 10 (GL_OB_BASE)
|
||||||
* if visible, add +1 to the GL_OB_S variable and
|
* if visible, add +1 to the GL_OB_S variable and
|
||||||
* up zIndex by this value
|
* up zIndex by this value
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -799,8 +926,9 @@ function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
|||||||
* and set zIndex and GL_OB_S to 0
|
* and set zIndex and GL_OB_S to 0
|
||||||
* else just set zIndex to the new GL_OB_S value
|
* else just set zIndex to the new GL_OB_S value
|
||||||
* @param {String} el_id Target to hide layer
|
* @param {String} el_id Target to hide layer
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideOverlayBoxLayers(el_id)
|
function hideOverlayBoxLayers(el_id='')
|
||||||
{
|
{
|
||||||
// console.log('HIDE overlaybox: %s', GL_OB_S);
|
// console.log('HIDE overlaybox: %s', GL_OB_S);
|
||||||
// remove on layer
|
// remove on layer
|
||||||
@@ -824,6 +952,7 @@ function hideOverlayBoxLayers(el_id)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* only for single action box
|
* only for single action box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function clearCallActionBox() // eslint-disable-line no-unused-vars
|
function clearCallActionBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -841,6 +970,7 @@ function clearCallActionBox() // eslint-disable-line no-unused-vars
|
|||||||
* @param {Array} [css=[]] array for css tags
|
* @param {Array} [css=[]] array for css tags
|
||||||
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
|
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
|
||||||
* @return {Object} created element as an object
|
* @return {Object} created element as an object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function cel(tag, id = '', content = '', css = [], options = {})
|
function cel(tag, id = '', content = '', css = [], options = {})
|
||||||
{
|
{
|
||||||
@@ -861,6 +991,7 @@ function cel(tag, id = '', content = '', css = [], options = {})
|
|||||||
* @param {Object} attach the object to be attached
|
* @param {Object} attach the object to be attached
|
||||||
* @param {String} [id=''] optional id, if given search in base for this id and attach there
|
* @param {String} [id=''] optional id, if given search in base for this id and attach there
|
||||||
* @return {Object} "none", technically there is no return needed as it is global attach
|
* @return {Object} "none", technically there is no return needed as it is global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function ael(base, attach, id = '')
|
function ael(base, attach, id = '')
|
||||||
{
|
{
|
||||||
@@ -891,6 +1022,7 @@ function ael(base, attach, id = '')
|
|||||||
* @param {Object} base object to where we attach the elements
|
* @param {Object} base object to where we attach the elements
|
||||||
* @param {...Object} attach attach 1..n: attach directly to the base element those attachments
|
* @param {...Object} attach attach 1..n: attach directly to the base element those attachments
|
||||||
* @return {Object} "none", technically there is no return needed, global attach
|
* @return {Object} "none", technically there is no return needed, global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function aelx(base, ...attach)
|
function aelx(base, ...attach)
|
||||||
{
|
{
|
||||||
@@ -907,6 +1039,7 @@ function aelx(base, ...attach)
|
|||||||
* @param {Object} base object to where we attach the elements
|
* @param {Object} base object to where we attach the elements
|
||||||
* @param {Array} attach array of objects to attach
|
* @param {Array} attach array of objects to attach
|
||||||
* @return {Object} "none", technically there is no return needed, global attach
|
* @return {Object} "none", technically there is no return needed, global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -921,6 +1054,7 @@ function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
|||||||
* resets the sub elements of the base element given
|
* resets the sub elements of the base element given
|
||||||
* @param {Object} base cel created element
|
* @param {Object} base cel created element
|
||||||
* @return {Object} returns reset base element
|
* @return {Object} returns reset base element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function rel(base) // eslint-disable-line no-unused-vars
|
function rel(base) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -933,6 +1067,7 @@ function rel(base) // eslint-disable-line no-unused-vars
|
|||||||
* @param {Object} _element element to work one
|
* @param {Object} _element element to work one
|
||||||
* @param {String} css style sheet to remove (name)
|
* @param {String} css style sheet to remove (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function rcssel(_element, css)
|
function rcssel(_element, css)
|
||||||
{
|
{
|
||||||
@@ -948,6 +1083,7 @@ function rcssel(_element, css)
|
|||||||
* @param {Object} _element element to work on
|
* @param {Object} _element element to work on
|
||||||
* @param {String} css style sheet to add (name)
|
* @param {String} css style sheet to add (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function acssel(_element, css)
|
function acssel(_element, css)
|
||||||
{
|
{
|
||||||
@@ -965,6 +1101,7 @@ function acssel(_element, css)
|
|||||||
* @param {String} rcss style to remove (name)
|
* @param {String} rcss style to remove (name)
|
||||||
* @param {String} acss style to add (name)
|
* @param {String} acss style to add (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -977,6 +1114,7 @@ function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
|||||||
* that can be inserted into the page
|
* that can be inserted into the page
|
||||||
* @param {Object} tree object tree with dom element declarations
|
* @param {Object} tree object tree with dom element declarations
|
||||||
* @return {String} HTML string that can be used as innerHTML
|
* @return {String} HTML string that can be used as innerHTML
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function phfo(tree)
|
function phfo(tree)
|
||||||
{
|
{
|
||||||
@@ -1083,6 +1221,7 @@ function phfo(tree)
|
|||||||
* Is like tree.sub call
|
* Is like tree.sub call
|
||||||
* @param {Array} list Array of cel created objects
|
* @param {Array} list Array of cel created objects
|
||||||
* @return {String} HTML String
|
* @return {String} HTML String
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function phfa(list) // eslint-disable-line no-unused-vars
|
function phfa(list) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1109,11 +1248,14 @@ function phfa(list) // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} [sort=''] if empty as is, else allowed 'keys',
|
* @param {String} [sort=''] if empty as is, else allowed 'keys',
|
||||||
* 'values' all others are ignored
|
* 'values' all others are ignored
|
||||||
* @return {String} html with build options block
|
* @return {String} html with build options block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '') // eslint-disable-line no-unused-vars
|
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
// wrapper to new call
|
// wrapper to new call
|
||||||
return html_options_block(name, data, selected, false, options_only, return_string, sort);
|
return html_options_block(
|
||||||
|
name, data, selected, 0, options_only, return_string, sort
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1134,9 +1276,11 @@ function html_options(name, data, selected = '', options_only = false, return_st
|
|||||||
* 'values' all others are ignored
|
* 'values' all others are ignored
|
||||||
* @param {String} [onchange=''] onchange trigger call, default unset
|
* @param {String} [onchange=''] onchange trigger call, default unset
|
||||||
* @return {String} html with build options block
|
* @return {String} html with build options block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function html_options_block(name, data, selected = '', multiple = 0, options_only = false, return_string = false, sort = '', onchange = '')
|
function html_options_block(
|
||||||
{
|
name, data, selected = '', multiple = 0, options_only = false, return_string = false, sort = '', onchange = ''
|
||||||
|
) {
|
||||||
var content = [];
|
var content = [];
|
||||||
var element_select;
|
var element_select;
|
||||||
var select_options = {};
|
var select_options = {};
|
||||||
@@ -1173,7 +1317,8 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl
|
|||||||
// basic options init
|
// basic options init
|
||||||
options = {
|
options = {
|
||||||
'label': value,
|
'label': value,
|
||||||
'value': key
|
'value': key,
|
||||||
|
'selected': ''
|
||||||
};
|
};
|
||||||
// add selected if matching
|
// add selected if matching
|
||||||
if (multiple == 0 && !Array.isArray(selected) && selected == key) {
|
if (multiple == 0 && !Array.isArray(selected) && selected == key) {
|
||||||
@@ -1184,7 +1329,7 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl
|
|||||||
options.selected = '';
|
options.selected = '';
|
||||||
}
|
}
|
||||||
// create the element option
|
// create the element option
|
||||||
element_option = cel('option', '', value, '', options);
|
element_option = cel('option', '', value, [], options);
|
||||||
// attach it to the select element
|
// attach it to the select element
|
||||||
ael(element_select, element_option);
|
ael(element_select, element_option);
|
||||||
}
|
}
|
||||||
@@ -1214,6 +1359,7 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl
|
|||||||
* @param {String} name name/id
|
* @param {String} name name/id
|
||||||
* @param {Object} data array of options
|
* @param {Object} data array of options
|
||||||
* @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
|
* @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
|
||||||
|
* @deprecated use utils.js
|
||||||
* all others are ignored
|
* all others are ignored
|
||||||
*/
|
*/
|
||||||
function html_options_refill(name, data, sort = '') // eslint-disable-line no-unused-vars
|
function html_options_refill(name, data, sort = '') // eslint-disable-line no-unused-vars
|
||||||
@@ -1236,7 +1382,7 @@ function html_options_refill(name, data, sort = '') // eslint-disable-line no-un
|
|||||||
[].forEach.call(document.querySelectorAll('#' + name + ' :checked'), function(elm) {
|
[].forEach.call(document.querySelectorAll('#' + name + ' :checked'), function(elm) {
|
||||||
option_selected = elm.value;
|
option_selected = elm.value;
|
||||||
});
|
});
|
||||||
document.getElementById(name).innerHTML = '';
|
loadEl(name).innerHTML = '';
|
||||||
for (const key of data_list) {
|
for (const key of data_list) {
|
||||||
value = data[key];
|
value = data[key];
|
||||||
// console.log('add [%s] options: key: %s, value: %s', name, key, value);
|
// console.log('add [%s] options: key: %s, value: %s', name, key, value);
|
||||||
@@ -1247,7 +1393,7 @@ function html_options_refill(name, data, sort = '') // eslint-disable-line no-un
|
|||||||
if (key == option_selected) {
|
if (key == option_selected) {
|
||||||
element_option.selected = true;
|
element_option.selected = true;
|
||||||
}
|
}
|
||||||
document.getElementById(name).appendChild(element_option);
|
loadEl(name).appendChild(element_option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1262,6 +1408,7 @@ function html_options_refill(name, data, sort = '') // eslint-disable-line no-un
|
|||||||
* @param {String} [return_key=''] if set only returns this key entry
|
* @param {String} [return_key=''] if set only returns this key entry
|
||||||
* or empty for none
|
* or empty for none
|
||||||
* @return {Object|String} parameter entry list
|
* @return {Object|String} parameter entry list
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
|
function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1311,11 +1458,12 @@ function parseQueryString(query = '', return_key = '') // eslint-disable-line no
|
|||||||
* all parameters are returned
|
* all parameters are returned
|
||||||
* @param {String} [query=''] different query string to parse, if not
|
* @param {String} [query=''] different query string to parse, if not
|
||||||
* set (default) the current window href is used
|
* set (default) the current window href is used
|
||||||
* @param {Bool} [single=false] if set to true then only the first found
|
* @param {Boolean} [single=false] if set to true then only the first found
|
||||||
* will be returned
|
* will be returned
|
||||||
* @return {Object|Array|String} if search is empty, object, if search is set
|
* @return {Object|Array|String} if search is empty, object, if search is set
|
||||||
* and only one entry, then string, else array
|
* and only one entry, then string, else array
|
||||||
* unless single is true
|
* unless single is true
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getQueryStringParam(search = '', query = '', single = false) // eslint-disable-line no-unused-vars
|
function getQueryStringParam(search = '', query = '', single = false) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1323,7 +1471,7 @@ function getQueryStringParam(search = '', query = '', single = false) // eslint-
|
|||||||
query = window.location.href;
|
query = window.location.href;
|
||||||
}
|
}
|
||||||
const url = new URL(query);
|
const url = new URL(query);
|
||||||
let param = '';
|
let param = null;
|
||||||
if (search) {
|
if (search) {
|
||||||
let _params = url.searchParams.getAll(search);
|
let _params = url.searchParams.getAll(search);
|
||||||
if (_params.length == 1 || single === true) {
|
if (_params.length == 1 || single === true) {
|
||||||
@@ -1353,6 +1501,7 @@ function getQueryStringParam(search = '', query = '', single = false) // eslint-
|
|||||||
// *** MASTER logout call
|
// *** MASTER logout call
|
||||||
/**
|
/**
|
||||||
* submits basic data for form logout
|
* submits basic data for form logout
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function loginLogout() // eslint-disable-line no-unused-vars
|
function loginLogout() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1373,6 +1522,7 @@ function loginLogout() // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} [header_id='mainHeader'] the target for the main element block
|
* @param {String} [header_id='mainHeader'] the target for the main element block
|
||||||
* if not set mainHeader is assumed
|
* if not set mainHeader is assumed
|
||||||
* this is the target div for the "loginRow"
|
* this is the target div for the "loginRow"
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1408,6 +1558,7 @@ function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disabl
|
|||||||
* @param {String} [header_id='mainHeader'] the target for the main element block
|
* @param {String} [header_id='mainHeader'] the target for the main element block
|
||||||
* if not set mainHeader is assumed
|
* if not set mainHeader is assumed
|
||||||
* this is the target div for the "menuRow"
|
* this is the target div for the "menuRow"
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
/* general edit javascript */
|
/*
|
||||||
/* prototype version */
|
general edit javascript
|
||||||
|
prototype version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @deprecated Do not use this anymore, use utils.js */
|
||||||
|
|
||||||
|
throw new Error("Prototype Support is deprected, please switch to jquery and utils.js/utils.min.js");
|
||||||
|
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
@@ -25,7 +31,7 @@ function pop(theURL, winName, features) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* automatically resize a text area based on the amount of lines in it
|
* automatically resize a text area based on the amount of lines in it
|
||||||
* @param {[string} ta_id element id
|
* @param {string} ta_id element id
|
||||||
*/
|
*/
|
||||||
function expandTA(ta_id) {
|
function expandTA(ta_id) {
|
||||||
var ta;
|
var ta;
|
||||||
|
|||||||
5
www/admin/layout/javascript/translateTest-ja_JP.UTF-8.js
Normal file
5
www/admin/layout/javascript/translateTest-ja_JP.UTF-8.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var i18n = {
|
||||||
|
"Original": "Translated"
|
||||||
|
};
|
||||||
|
|
||||||
|
// __END__
|
||||||
1567
www/admin/layout/javascript/utils.js
Normal file
1567
www/admin/layout/javascript/utils.js
Normal file
File diff suppressed because it is too large
Load Diff
3
www/admin/layout/javascript/utils.min.js
vendored
Normal file
3
www/admin/layout/javascript/utils.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
www/admin/layout/javascript/utils.min.js.map
Normal file
7
www/admin/layout/javascript/utils.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
37
www/admin/test.javascript.html
Normal file
37
www/admin/test.javascript.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<title>JavaScript Test</title>
|
||||||
|
<script type="text/javascript" src="layout/javascript/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript" src="layout/javascript/translateTest-ja_JP.UTF-8.js"></script>
|
||||||
|
<script type="text/javascript" src="layout/javascript/utils.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>JavaScript tests</h1>
|
||||||
|
<div id="test-div">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script languagae="JavaScript">
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
console.log('MAIN PAGE LOADED');
|
||||||
|
// console.log('Random: %o', mh.randomIdF());
|
||||||
|
console.log('Random: %o', randomIdF());
|
||||||
|
console.log("GW: %o", getWindowSize());
|
||||||
|
let bytes = 1021152;
|
||||||
|
console.log('FB: %o', formatBytes(bytes));
|
||||||
|
console.log('FBL: %o', formatBytesLong(bytes));
|
||||||
|
console.log('TR: %s', l10n.__('Original'));
|
||||||
|
console.log('TR: %s', l10n.__('Not exists'));
|
||||||
|
|
||||||
|
setCenter('test-div', true, true);
|
||||||
|
ClearCall();
|
||||||
|
overlayBoxShow();
|
||||||
|
actionIndicatorShow('testSmarty');
|
||||||
|
setTimeout(function() {
|
||||||
|
console.log('Waiting dummy ...');
|
||||||
|
actionIndicatorHide('testSmarty');
|
||||||
|
ClearCall();
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"egrajp/smarty-extended": "^4.3",
|
"egrajp/smarty-extended": "^5.4",
|
||||||
"php": ">=8.1",
|
"php": ">=8.1",
|
||||||
"gullevek/dotenv": "^2.0",
|
"gullevek/dotenv": "^2.0",
|
||||||
"psr/log": "^2.0 || ^3.0"
|
"psr/log": "^2.0 || ^3.0",
|
||||||
|
"php-privacy/openpgp": "^2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
www/configs/.target.example
Normal file
3
www/configs/.target.example
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# target can be live, stage, test, dev
|
||||||
|
# this overrides the SITE set "location" entry
|
||||||
|
TARGET=
|
||||||
@@ -78,42 +78,11 @@ define('TEMPLATES_C', 'templates_c' . DIRECTORY_SEPARATOR);
|
|||||||
// template base
|
// template base
|
||||||
define('TEMPLATES', 'templates' . DIRECTORY_SEPARATOR);
|
define('TEMPLATES', 'templates' . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
/************* HASH / ACL DEFAULT / ERROR SETTINGS / SMARTY *************/
|
/************* HASH / ACL DEFAULT *************/
|
||||||
// default hash type
|
// default hash type
|
||||||
define('DEFAULT_HASH', 'sha256');
|
define('DEFAULT_HASH', 'sha256');
|
||||||
// default acl level
|
// default acl level
|
||||||
define('DEFAULT_ACL_LEVEL', 80);
|
define('DEFAULT_ACL_LEVEL', $ENV['DEFAULT_ACL_LEVEL'] ?? 80);
|
||||||
// SSL host name
|
|
||||||
// define('SSL_HOST', $_ENV['SSL_HOST'] ?? '');
|
|
||||||
// error page strictness, Default is 3
|
|
||||||
// 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all
|
|
||||||
// 2: if template not found, do not search, show error template
|
|
||||||
// 3: if default template is not found, show error template, do not fall back to default tree
|
|
||||||
// 4: very strict, even on normal fixable errors through error
|
|
||||||
// define('ERROR_STRICT', 3);
|
|
||||||
// allow page caching in general, set to 'false' if you do debugging or development!
|
|
||||||
// define('ALLOW_SMARTY_CACHE', false);
|
|
||||||
// cache life time, in second', default here is 2 days (172800s)
|
|
||||||
// -1 is never expire cache
|
|
||||||
// define('SMARTY_CACHE_LIFETIME', -1);
|
|
||||||
|
|
||||||
/************* LOGOUT ********************/
|
|
||||||
// logout target
|
|
||||||
define('LOGOUT_TARGET', '');
|
|
||||||
|
|
||||||
/************* AJAX / ACCESS *************/
|
|
||||||
// ajax request type
|
|
||||||
define('AJAX_REQUEST_TYPE', 'POST');
|
|
||||||
// what AJAX type to use
|
|
||||||
define('USE_PROTOTYPE', false);
|
|
||||||
define('USE_SCRIPTACULOUS', false);
|
|
||||||
define('USE_JQUERY', true);
|
|
||||||
|
|
||||||
/************* LAYOUT WIDTHS *************/
|
|
||||||
define('PAGE_WIDTH', '100%');
|
|
||||||
define('CONTENT_WIDTH', '100%');
|
|
||||||
// the default template name
|
|
||||||
define('MASTER_TEMPLATE_NAME', 'main_body.tpl');
|
|
||||||
|
|
||||||
/************* OVERALL CONTROL NAMES *************/
|
/************* OVERALL CONTROL NAMES *************/
|
||||||
// BELOW has HAS to be changed
|
// BELOW has HAS to be changed
|
||||||
@@ -136,24 +105,15 @@ define('COMPILE_ID', 'COMPILE_' . BASE_NAME . '_' . SERVER_NAME_HASH);
|
|||||||
|
|
||||||
/************* LANGUAGE / ENCODING *******/
|
/************* LANGUAGE / ENCODING *******/
|
||||||
// default lang + encoding
|
// default lang + encoding
|
||||||
define('DEFAULT_LOCALE', 'en_US.UTF-8');
|
define('DEFAULT_LOCALE', $_ENV['LOCALE'] ?? 'en_US.UTF-8');
|
||||||
// default web page encoding setting
|
// default web page encoding setting
|
||||||
define('DEFAULT_ENCODING', 'UTF-8');
|
define('DEFAULT_ENCODING', (string)array_pad(explode('.', DEFAULT_LOCALE, 2), 2, 'UTF-8')[1]);
|
||||||
|
|
||||||
/************* QUEUE TABLE *************/
|
/************* HOST NAME *****************/
|
||||||
// if we have a dev/live system
|
// get the name without the port
|
||||||
// set_live is a per page/per item
|
list($HOST_NAME) = array_pad(explode(':', $_SERVER['HTTP_HOST'], 2), 2, null);
|
||||||
// live_queue is a global queue system
|
// set HOST name
|
||||||
// define('QUEUE', 'live_queue');
|
define('HOST_NAME', $HOST_NAME);
|
||||||
|
|
||||||
/************* DB PATHS (PostgreSQL) *****************/
|
|
||||||
// schema names, can also be defined per <DB INFO>
|
|
||||||
define('PUBLIC_SCHEMA', 'public');
|
|
||||||
define('DEV_SCHEMA', 'public');
|
|
||||||
define('TEST_SCHEMA', 'public');
|
|
||||||
define('LIVE_SCHEMA', 'public');
|
|
||||||
define('GLOBAL_DB_SCHEMA', '');
|
|
||||||
define('LOGIN_DB_SCHEMA', '');
|
|
||||||
|
|
||||||
/************* CORE HOST SETTINGS *****************/
|
/************* CORE HOST SETTINGS *****************/
|
||||||
if (file_exists(BASE . CONFIGS . 'config.host.php')) {
|
if (file_exists(BASE . CONFIGS . 'config.host.php')) {
|
||||||
@@ -162,6 +122,14 @@ if (file_exists(BASE . CONFIGS . 'config.host.php')) {
|
|||||||
if (!isset($SITE_CONFIG)) {
|
if (!isset($SITE_CONFIG)) {
|
||||||
$SITE_CONFIG = [];
|
$SITE_CONFIG = [];
|
||||||
}
|
}
|
||||||
|
// BAIL ON MISSING MASTER SITE CONFIG
|
||||||
|
if (!isset($SITE_CONFIG[HOST_NAME]['location'])) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'Missing SITE_CONFIG entry for: "' . HOST_NAME . '". Contact Administrator'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// set target first
|
||||||
|
define('TARGET', $_ENV['TARGET'] ?? $SITE_CONFIG[HOST_NAME]['location'] ?? 'test');
|
||||||
/************* DB ACCESS *****************/
|
/************* DB ACCESS *****************/
|
||||||
if (file_exists(BASE . CONFIGS . 'config.db.php')) {
|
if (file_exists(BASE . CONFIGS . 'config.db.php')) {
|
||||||
require BASE . CONFIGS . 'config.db.php';
|
require BASE . CONFIGS . 'config.db.php';
|
||||||
@@ -175,17 +143,6 @@ if (file_exists(BASE . CONFIGS . 'config.path.php')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/************* MASTER INIT *****************/
|
/************* MASTER INIT *****************/
|
||||||
// live frontend pages
|
|
||||||
// ** missing live domains **
|
|
||||||
// get the name without the port
|
|
||||||
[$HOST_NAME] = array_pad(explode(':', $_SERVER['HTTP_HOST'], 2), 2, null);
|
|
||||||
// set HOST name
|
|
||||||
define('HOST_NAME', $HOST_NAME);
|
|
||||||
// BAIL ON MISSING MASTER SITE CONFIG
|
|
||||||
if (!isset($SITE_CONFIG[HOST_NAME]['location'])) {
|
|
||||||
echo 'Missing SITE_CONFIG entry for: "' . HOST_NAME . '". Contact Administrator';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// BAIL ON MISSING DB CONFIG:
|
// BAIL ON MISSING DB CONFIG:
|
||||||
// we have either no db selction for this host but have db config entries
|
// we have either no db selction for this host but have db config entries
|
||||||
// or we have a db selection but no db config as array or empty
|
// or we have a db selection but no db config as array or empty
|
||||||
@@ -200,8 +157,9 @@ if (
|
|||||||
empty($DB_CONFIG[$SITE_CONFIG[HOST_NAME]['db_host']]))
|
empty($DB_CONFIG[$SITE_CONFIG[HOST_NAME]['db_host']]))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
echo 'No matching DB config found for: "' . HOST_NAME . '". Contact Administrator';
|
throw new \InvalidArgumentException(
|
||||||
exit;
|
'No matching DB config found for: "' . HOST_NAME . '". Contact Administrator'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// set SSL on
|
// set SSL on
|
||||||
$is_secure = false;
|
$is_secure = false;
|
||||||
@@ -235,35 +193,31 @@ define('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME] ?? [
|
|||||||
]);
|
]);
|
||||||
// because we can't change constant, but we want to for db debug flag
|
// because we can't change constant, but we want to for db debug flag
|
||||||
$GLOBALS['DB_CONFIG_SET'] = DB_CONFIG;
|
$GLOBALS['DB_CONFIG_SET'] = DB_CONFIG;
|
||||||
// define('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
|
|
||||||
// define('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
|
|
||||||
// override for login and global schemas
|
|
||||||
// where the edit* tables are
|
|
||||||
// define('LOGIN_DB_SCHEMA', PUBLIC_SCHEMA);
|
|
||||||
// where global tables are that are used by all schemas (eg queue tables for online, etc)
|
|
||||||
// define('GLOBAL_DB_SCHEMA', PUBLIC_SCHEMA);
|
|
||||||
// debug settings, site lang, etc
|
// debug settings, site lang, etc
|
||||||
define('TARGET', $SITE_CONFIG[HOST_NAME]['location'] ?? 'test');
|
|
||||||
define('DEBUG_LEVEL', $SITE_CONFIG[HOST_NAME]['debug_level'] ?? 'debug');
|
define('DEBUG_LEVEL', $SITE_CONFIG[HOST_NAME]['debug_level'] ?? 'debug');
|
||||||
define('SITE_LOCALE', $SITE_CONFIG[HOST_NAME]['site_locale'] ?? DEFAULT_LOCALE);
|
define('SITE_LOCALE', $SITE_CONFIG[HOST_NAME]['site_locale'] ?? DEFAULT_LOCALE);
|
||||||
define('SITE_DOMAIN', str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH));
|
define('SITE_DOMAIN', str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH));
|
||||||
define('SITE_ENCODING', $SITE_CONFIG[HOST_NAME]['site_encoding'] ?? DEFAULT_ENCODING);
|
define('SITE_ENCODING', $SITE_CONFIG[HOST_NAME]['site_encoding'] ?? DEFAULT_ENCODING);
|
||||||
define('LOGIN_ENABLED', $SITE_CONFIG[HOST_NAME]['login_enabled'] ?? false);
|
define('LOGIN_ENABLED', $SITE_CONFIG[HOST_NAME]['login_enabled'] ?? false);
|
||||||
define('AUTH', $SITE_CONFIG[HOST_NAME]['auth'] ?? false);
|
define('AUTH', $SITE_CONFIG[HOST_NAME]['auth'] ?? false);
|
||||||
// paths
|
|
||||||
// define('CSV_PATH', $PATHS[TARGET]['csv_path'] ?? '');
|
|
||||||
// define('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin'] ?? '');
|
|
||||||
// define('REDIRECT_URL', $PATHS[TARGET]['redirect_url'] ?? '');
|
|
||||||
|
|
||||||
|
// NOTE: everything below is smarty related and should be removed from here
|
||||||
/************* GENERAL PAGE TITLE ********/
|
/************* GENERAL PAGE TITLE ********/
|
||||||
define('G_TITLE', $_ENV['G_TITLE'] ?? '');
|
define('G_TITLE', $_ENV['G_TITLE'] ?? '');
|
||||||
|
/************* LAYOUT WIDTHS *************/
|
||||||
|
define('PAGE_WIDTH', $_ENV['SMARTY.PAGE_WIDTH'] ?? '100%');
|
||||||
|
define('CONTENT_WIDTH', $_ENV['SMARTY.CONTENT_WIDTH'] ?? '100%');
|
||||||
|
// the default template name
|
||||||
|
define('MASTER_TEMPLATE_NAME', $_ENV['MASTER_TEMPLATE_NAME'] ?? 'main_body.tpl');
|
||||||
|
/************* JS LIBRARIES *************/
|
||||||
|
define('USE_PROTOTYPE', false);
|
||||||
|
define('USE_SCRIPTACULOUS', false);
|
||||||
|
define('USE_JQUERY', true);
|
||||||
/************ STYLE SHEETS / JS **********/
|
/************ STYLE SHEETS / JS **********/
|
||||||
define('ADMIN_STYLESHEET', 'edit.css');
|
define('ADMIN_STYLESHEET', $_ENV['ADMIN.STYLESHEET'] ?? 'edit.css');
|
||||||
define('ADMIN_JAVASCRIPT', 'edit.js');
|
define('ADMIN_JAVASCRIPT', $_ENV['ADMIN.JAVASCRIPT'] ?? 'edit.js');
|
||||||
define('STYLESHEET', $_ENV['STYLESHEET'] ?? 'frontend.css');
|
define('STYLESHEET', $_ENV['STYLESHEET'] ?? 'frontend.css');
|
||||||
define('JAVASCRIPT', $_ENV['JAVASCRIPT'] ?? 'frontend.js');
|
define('JAVASCRIPT', $_ENV['JAVASCRIPT'] ?? 'frontend.js');
|
||||||
|
|
||||||
// anything optional
|
// anything optional
|
||||||
/************* INTERNAL ******************/
|
/************* INTERNAL ******************/
|
||||||
// any other global definitons in the config.other.php
|
// any other global definitons in the config.other.php
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ define('EDIT_BASE_STYLESHEET', 'edit.css');
|
|||||||
|
|
||||||
// define('SOME_ID', <SOME VALUE>);
|
// define('SOME_ID', <SOME VALUE>);
|
||||||
|
|
||||||
|
/************* QUEUE TABLE *************/
|
||||||
|
// if we have a dev/live system
|
||||||
|
// set_live is a per page/per item
|
||||||
|
// live_queue is a global queue system
|
||||||
|
// define('QUEUE', 'live_queue');
|
||||||
|
|
||||||
/************* CONVERT *******************/
|
/************* CONVERT *******************/
|
||||||
// this only needed if the external thumbnail create is used
|
// this only needed if the external thumbnail create is used
|
||||||
$paths = [
|
$paths = [
|
||||||
|
|||||||
@@ -35,4 +35,9 @@ define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR);
|
|||||||
],
|
],
|
||||||
];*/
|
];*/
|
||||||
|
|
||||||
|
// paths
|
||||||
|
// define('CSV_PATH', $PATHS[TARGET]['csv_path'] ?? '');
|
||||||
|
// define('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin'] ?? '');
|
||||||
|
// define('REDIRECT_URL', $PATHS[TARGET]['redirect_url'] ?? '');
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ for (
|
|||||||
\gullevek\dotEnv\DotEnv::readEnvFile(
|
\gullevek\dotEnv\DotEnv::readEnvFile(
|
||||||
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH
|
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH
|
||||||
);
|
);
|
||||||
|
// load target file if it exists
|
||||||
|
\gullevek\dotEnv\DotEnv::readEnvFile(
|
||||||
|
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH,
|
||||||
|
'.target'
|
||||||
|
);
|
||||||
// load master config file that loads all other config files
|
// load master config file that loads all other config files
|
||||||
require $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
|
require $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// create smarty object
|
// create smarty object
|
||||||
$smarty = new \CoreLibs\Template\SmartyExtend($l10n, CACHE_ID, COMPILE_ID);
|
$smarty = new \CoreLibs\Template\SmartyExtend($l10n, $log, CACHE_ID, COMPILE_ID);
|
||||||
// create new Backend class with db and loger attached
|
// create new Backend class with db and loger attached
|
||||||
$cms = new \CoreLibs\Admin\Backend($db, $log, $session, $l10n, DEFAULT_ACL_LEVEL);
|
$cms = new \CoreLibs\Admin\Backend($db, $log, $session, $l10n, DEFAULT_ACL_LEVEL);
|
||||||
// the menu show flag (what menu to show)
|
// the menu show flag (what menu to show)
|
||||||
@@ -116,7 +116,7 @@ $data = [
|
|||||||
// log action
|
// log action
|
||||||
// no log if login
|
// no log if login
|
||||||
if (!$login->loginActionRun()) {
|
if (!$login->loginActionRun()) {
|
||||||
$login->writeLog('Submit', $data, $cms->adbGetActionSet(), 'BINARY');
|
$login->writeLog('Submit', $data, action_set:$cms->adbGetActionSet(), write_type:'BINARY');
|
||||||
}
|
}
|
||||||
//------------------------------ logging end
|
//------------------------------ logging end
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user