Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cced63c4b | ||
|
|
06c2ea5e0d | ||
|
|
2e9239ec23 | ||
|
|
0c89840dba | ||
|
|
db144493f3 | ||
|
|
5cec54d508 | ||
|
|
8e60c992f1 | ||
|
|
1b5437b675 | ||
|
|
ef80cba561 | ||
|
|
2d71e760e8 | ||
|
|
a8d07634ff | ||
|
|
aa2b60973e | ||
|
|
554dd5f73c | ||
|
|
e6f9559fbb | ||
|
|
770d6f30a4 | ||
|
|
f94f6cbe87 | ||
|
|
9b69390fa2 | ||
|
|
0524d8ac1b | ||
|
|
e933022671 | ||
|
|
c549d34e65 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.libs
|
.libs
|
||||||
|
node_modules/
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?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.19" location="./tools/phpunit" copy="false"/>
|
<phar name="phpunit" version="^9.6" installed="9.6.21" location="./tools/phpunit" copy="false"/>
|
||||||
<phar name="phpcbf" version="^3.7.2" installed="3.9.1" 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.9.1" location="./tools/phpcs" copy="false"/>
|
<phar name="phpcs" version="^3.7.2" installed="3.10.3" location="./tools/phpcs" copy="false"/>
|
||||||
<phar name="phpstan" version="^1.10.37" installed="1.10.67" location="./tools/phpstan" copy="false"/>
|
<phar name="phpstan" version="^1.10.37" installed="1.12.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.2" installed="5.4.3" location="./tools/phan" copy="false"/>
|
||||||
<phar name="psalm" version="^5.15.0" installed="5.23.1" 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"/>
|
||||||
<phar name="php-cs-fixer" version="^3.34.1" installed="3.53.0" location="./tools/php-cs-fixer" copy="false"/>
|
<phar name="php-cs-fixer" version="^3.34.1" installed="3.57.2" location="./tools/php-cs-fixer" copy="false"/>
|
||||||
</phive>
|
</phive>
|
||||||
|
|||||||
2
.shellcheckrc
Normal file
2
.shellcheckrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
shell=bash
|
||||||
|
external-sources=true
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
|
BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/";
|
||||||
# Assume script is in 4dev/bin
|
# Assume script is in 4dev/bin
|
||||||
base_folder="${BASE_FOLDER}../../www/";
|
base_folder="${BASE_FOLDER}../../www/";
|
||||||
|
|
||||||
# locale gettext po to mo translator master
|
# locale gettext po to mo translator master
|
||||||
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
for file in "${base_folder}"../4dev/locale/*.po; do
|
||||||
file=$(basename $file .po);
|
[[ -e "$file" ]] || break
|
||||||
|
file=$(basename "$file" .po);
|
||||||
locale=$(echo "${file}" | cut -d "-" -f 1);
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
domain=$(echo "${file}" | cut -d "-" -f 2);
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
echo "- Translate language file '${file}' for locale '${locale}' and domain '${domain}':";
|
echo "- Translate language file '${file}' for locale '${locale}' and domain '${domain}':";
|
||||||
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
||||||
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
||||||
fi;
|
fi;
|
||||||
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}../4dev/locale/${locale}-${domain}.po;
|
msgfmt -o "${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo" "${base_folder}../4dev/locale/${locale}-${domain}.po";
|
||||||
done;
|
done;
|
||||||
|
|
||||||
# __END__
|
# __END__
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
# read source mo files and writes target js files in object form
|
# read source mo files and writes target js files in object form
|
||||||
|
|
||||||
# check for ARG 1 is "mv"
|
# check for ARG 1 is "no-move"
|
||||||
# then move the files directly and don't do manual check (don't create temp files)
|
# then do not move the files directly for manual check
|
||||||
FILE_MOVE=0;
|
FILE_MOVE=1;
|
||||||
if [ "${1}" = "mv" ]; then
|
if [ "${1}" = "no-move" ]; then
|
||||||
|
echo "+++ CREATE TEMPORARY FILES +++";
|
||||||
|
FILE_MOVE=0;
|
||||||
|
else
|
||||||
echo "*** Direct write ***";
|
echo "*** Direct write ***";
|
||||||
FILE_MOVE=1;
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
target='';
|
target='';
|
||||||
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
|
BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/";
|
||||||
# Assume script is in 4dev/bin
|
# Assume script is in 4dev/bin
|
||||||
base_folder="${BASE_FOLDER}../../www/";
|
base_folder="${BASE_FOLDER}../../www/";
|
||||||
po_folder='../4dev/locale/'
|
po_folder='../4dev/locale/'
|
||||||
@@ -26,7 +28,7 @@ if [ "${target}" == '' ]; then
|
|||||||
echo "*** Non smarty ***";
|
echo "*** Non smarty ***";
|
||||||
TEXTDOMAINDIR=${base_folder}${mo_folder}.
|
TEXTDOMAINDIR=${base_folder}${mo_folder}.
|
||||||
# default is admin
|
# default is admin
|
||||||
TEXTDOMAIN=admin;
|
TEXTDOMAIN="admin";
|
||||||
fi;
|
fi;
|
||||||
js_folder="${TEXTDOMAIN}/layout/javascript/";
|
js_folder="${TEXTDOMAIN}/layout/javascript/";
|
||||||
|
|
||||||
@@ -44,15 +46,16 @@ if [ ${error} -eq 1 ]; then
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
# locale gettext po to mo translator master
|
# locale gettext po to mo translator master
|
||||||
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
for file in "${base_folder}"../4dev/locale/*.po; do
|
||||||
file=$(basename $file .po);
|
[[ -e "$file" ]] || break
|
||||||
echo "Translate language ${file}";
|
file=$(basename "$file" .po);
|
||||||
locale=$(echo "${file}" | cut -d "-" -f 1);
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
domain=$(echo "${file}" | cut -d "-" -f 2);
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
|
echo "- Translate language file '${file}' for locale '${locale}' and domain '${domain}':";
|
||||||
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
if [ ! -d "${base_folder}/includes/locale/${locale}/LC_MESSAGES/" ]; then
|
||||||
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
mkdir -p "${base_folder}/includes/locale/${locale}/LC_MESSAGES/";
|
||||||
fi;
|
fi;
|
||||||
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}${po_folder}${locale}-${domain}.po;
|
msgfmt -o "${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo" "${base_folder}${po_folder}${locale}-${domain}.po";
|
||||||
done;
|
done;
|
||||||
|
|
||||||
rx_msgid_empty="^msgid \"\"";
|
rx_msgid_empty="^msgid \"\"";
|
||||||
@@ -62,7 +65,7 @@ rx_msgstr="^msgstr \""
|
|||||||
# quick copy string at the end
|
# quick copy string at the end
|
||||||
quick_copy='';
|
quick_copy='';
|
||||||
|
|
||||||
for language in ${language_list[*]}; do
|
for language in "${language_list[@]}"; do
|
||||||
# I don't know which one must be set, but I think at least LANGUAGE
|
# I don't know which one must be set, but I think at least LANGUAGE
|
||||||
case ${language} in
|
case ${language} in
|
||||||
ja)
|
ja)
|
||||||
@@ -79,7 +82,8 @@ for language in ${language_list[*]}; do
|
|||||||
esac;
|
esac;
|
||||||
# write only one for language and then symlink files
|
# write only one for language and then symlink files
|
||||||
template_file=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##//" | sed -e "s/##LANGUAGE##/${LANG}/");
|
template_file=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##//" | sed -e "s/##LANGUAGE##/${LANG}/");
|
||||||
original_file=$(echo ${template_file} | sed -e 's/\.TMP//g');
|
# original_file=$(echo ${template_file} | sed -e 's/\.TMP//g');
|
||||||
|
original_file=${template_file//.TMP/};
|
||||||
if [ "${FILE_MOVE}" -eq 0 ]; then
|
if [ "${FILE_MOVE}" -eq 0 ]; then
|
||||||
file=${target_folder}${template_file};
|
file=${target_folder}${template_file};
|
||||||
else
|
else
|
||||||
@@ -88,16 +92,18 @@ for language in ${language_list[*]}; do
|
|||||||
echo "===> Write translation file ${file}";
|
echo "===> Write translation file ${file}";
|
||||||
echo ". = normal, : = escape, x = skip";
|
echo ". = normal, : = escape, x = skip";
|
||||||
# init line [aka don't touch this file]
|
# init line [aka don't touch this file]
|
||||||
echo "// AUTO FILL, changes will be overwritten" > $file;
|
echo "// AUTO FILL, changes will be overwritten" > "$file";
|
||||||
echo "// source: ${suffix}, language: ${language}" >> $file;
|
{
|
||||||
echo "// Translation strings in the format" >> $file;
|
echo "// source: ${suffix}, language: ${language}";
|
||||||
echo "// \"Original\":\"Translated\""$'\n' >> $file;
|
echo "// Translation strings in the format";
|
||||||
echo "var i18n = {" >> $file;
|
echo "// \"Original\":\"Translated\""$'\n'
|
||||||
|
echo "var i18n = {"
|
||||||
|
} >> "$file"
|
||||||
# translations stuff
|
# translations stuff
|
||||||
# read the po file
|
# read the po file
|
||||||
pos=0; # do we add a , for the next line
|
pos=0; # do we add a , for the next line
|
||||||
cat "${base_folder}${po_folder}${language}-${TEXTDOMAIN}.po" |
|
cat "${base_folder}${po_folder}${language}-${TEXTDOMAIN}.po" |
|
||||||
while read str; do
|
while read -r str; do
|
||||||
# echo "S: ${str}";
|
# echo "S: ${str}";
|
||||||
# skip empty
|
# skip empty
|
||||||
if [[ "${str}" =~ ${rx_msgid_empty} ]]; then
|
if [[ "${str}" =~ ${rx_msgid_empty} ]]; then
|
||||||
@@ -112,12 +118,13 @@ for language in ${language_list[*]}; do
|
|||||||
str_source=$(echo "${str}" | sed -e "s/^msgid \"//" | sed -e "s/\"$//");
|
str_source=$(echo "${str}" | sed -e "s/^msgid \"//" | sed -e "s/\"$//");
|
||||||
# close right side, if not last add ,
|
# close right side, if not last add ,
|
||||||
if [ "${pos}" -eq 1 ]; then
|
if [ "${pos}" -eq 1 ]; then
|
||||||
echo -n "," >> $file;
|
echo -n "," >> "$file";
|
||||||
fi;
|
fi;
|
||||||
# all " inside string need to be escaped
|
# all " inside string need to be escaped
|
||||||
str_source=$(echo "${str_source}" | sed -e 's/"/\\"/g');
|
# str_source=$(echo "${str_source}" | sed -e 's/"/\\"/g');
|
||||||
|
str_source=${str_source//\"/\\\"}
|
||||||
# fix with proper layout
|
# fix with proper layout
|
||||||
echo -n "\"$str_source\":\"$(TEXTDOMAINDIR=${TEXTDOMAINDIR} LANGUAGE=${language} LANG=${LANG} gettext ${TEXTDOMAIN} "${str_source}")\"" >> $file;
|
echo -n "\"$str_source\":\"$(TEXTDOMAINDIR=${TEXTDOMAINDIR} LANGUAGE=${language} LANG=${LANG} gettext "${TEXTDOMAIN}" "${str_source}")\"" >> "$file";
|
||||||
pos=1;
|
pos=1;
|
||||||
elif [[ "${str}" =~ ${rx_msgstr} ]]; then
|
elif [[ "${str}" =~ ${rx_msgstr} ]]; then
|
||||||
# open right side (ignore)
|
# open right side (ignore)
|
||||||
@@ -128,8 +135,8 @@ for language in ${language_list[*]}; do
|
|||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
echo "" >> $file;
|
echo "" >> "$file";
|
||||||
echo "};" >> $file;
|
echo "};" >> "$file";
|
||||||
echo " [DONE]";
|
echo " [DONE]";
|
||||||
|
|
||||||
# on no move
|
# on no move
|
||||||
@@ -140,19 +147,19 @@ for language in ${language_list[*]}; do
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
# symlink to master file
|
# symlink to master file
|
||||||
for suffix in ${source_list[*]}; do
|
for suffix in "${source_list[@]}"; do
|
||||||
# symlink with full lang name
|
# symlink with full lang name
|
||||||
symlink_file[0]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANG}/" | sed -e 's/\.TMP//g');
|
symlink_file[0]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANG}/" | sed -e 's/\.TMP//g');
|
||||||
# create second one with lang (no country) + encoding
|
# create second one with lang (no country) + encoding
|
||||||
symlink_file[1]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANGUAGE}\.${ENCODING}/" | sed -e 's/\.TMP//g');
|
symlink_file[1]=$(echo ${template_file_stump} | sed -e "s/##SUFFIX##/${suffix}_/" | sed -e "s/##LANGUAGE##/${LANGUAGE}\.${ENCODING}/" | sed -e 's/\.TMP//g');
|
||||||
for template_file in ${symlink_file[@]}; do
|
for template_file in "${symlink_file[@]}"; do
|
||||||
# if this is not symlink, create them
|
# if this is not symlink, create them
|
||||||
if [ ! -h "${template_file}" ]; then
|
if [ ! -h "${template_file}" ]; then
|
||||||
echo "Create symlink: ${template_file}";
|
echo "Create symlink: ${template_file}";
|
||||||
# symlik to original
|
# symlik to original
|
||||||
cd "${target_folder}";
|
cd "${target_folder}" || exit;
|
||||||
ln -sf "${original_file}" "${template_file}";
|
ln -sf "${original_file}" "${template_file}";
|
||||||
cd - >/dev/null;
|
cd - >/dev/null || exit;
|
||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
done;
|
done;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if [ "${1}" = "t" ] || [ "${2}" = "t" ]; then
|
|||||||
opt_testdox="--testdox";
|
opt_testdox="--testdox";
|
||||||
fi;
|
fi;
|
||||||
php_bin="";
|
php_bin="";
|
||||||
if [ ! -z "${1}" ]; then
|
if [ -n "${1}" ]; then
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
@@ -23,7 +23,7 @@ if [ ! -z "${1}" ]; then
|
|||||||
*) echo "Not support PHP: ${1}"; exit; ;;
|
*) echo "Not support PHP: ${1}"; exit; ;;
|
||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
if [ ! -z "${2}" ] && [ -z "${php_bin}" ]; then
|
if [ -n "${2}" ] && [ -z "${php_bin}" ]; then
|
||||||
case "${2}" in
|
case "${2}" in
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsConvertStringsTest extends TestCase
|
final class CoreLibsConvertStringsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private const DATA_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -330,6 +332,52 @@ final class CoreLibsConvertStringsTest extends TestCase
|
|||||||
\CoreLibs\Convert\Strings::stripMultiplePathSlashes($input)
|
\CoreLibs\Convert\Strings::stripMultiplePathSlashes($input)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerStripUTF8BomBytes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"utf8-bom" => [
|
||||||
|
"file" => "UTF8BOM.csv",
|
||||||
|
"expect" => "Asset Type,Epic,File Name\n",
|
||||||
|
],
|
||||||
|
"utf8" => [
|
||||||
|
"file" => "UTF8.csv",
|
||||||
|
"expect" => "Asset Type,Epic,File Name\n",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test utf8 bom remove
|
||||||
|
*
|
||||||
|
* @covers ::stripUTF8BomBytes
|
||||||
|
* @dataProvider providerStripUTF8BomBytes
|
||||||
|
* @testdox stripUTF8BomBytes $file will be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testStripUTF8BomBytes(string $file, string $expected): void
|
||||||
|
{
|
||||||
|
// load sample file
|
||||||
|
if (!is_file(self::DATA_FOLDER . $file)) {
|
||||||
|
$this->markTestSkipped('File: ' . $file . ' could not be opened');
|
||||||
|
}
|
||||||
|
$file = file_get_contents(self::DATA_FOLDER . $file);
|
||||||
|
if ($file === false) {
|
||||||
|
$this->markTestSkipped('File: ' . $file . ' could not be read');
|
||||||
|
}
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Convert\Strings::stripUTF8BomBytes($file)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
1
4dev/tests/Convert/data/UTF8.csv
Normal file
1
4dev/tests/Convert/data/UTF8.csv
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Asset Type,Epic,File Name
|
||||||
|
1
4dev/tests/Convert/data/UTF8BOM.csv
Normal file
1
4dev/tests/Convert/data/UTF8BOM.csv
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Asset Type,Epic,File Name
|
||||||
|
@@ -216,6 +216,29 @@ final class CoreLibsGetSystemTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::getIpAddresses
|
||||||
|
* @testdox getIpAddresses check
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testGetIpAddresses()
|
||||||
|
{
|
||||||
|
// response must have "REMOTE_ADDR" entry, others are optional
|
||||||
|
// NOTE: we have no IP addresses on command line
|
||||||
|
$this->assertTrue(
|
||||||
|
true,
|
||||||
|
"We do not have REMOTE_ADDR on command line"
|
||||||
|
);
|
||||||
|
// $this->assertContains(
|
||||||
|
// 'REMOTE_ADDR',
|
||||||
|
// array_keys(\CoreLibs\Get\System::getIpAddresses()),
|
||||||
|
// 'failed REMOTE_ADDR assert'
|
||||||
|
// );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'OK',
|
'str' => 'OK',
|
||||||
'expected' => 'ok',
|
'expected' => 'ok',
|
||||||
],
|
],
|
||||||
|
'success' => [
|
||||||
|
'level' => 'success',
|
||||||
|
'str' => 'SUCCESS',
|
||||||
|
'expected' => 'success',
|
||||||
|
],
|
||||||
'info' => [
|
'info' => [
|
||||||
'level' => 'info',
|
'level' => 'info',
|
||||||
'str' => 'INFO',
|
'str' => 'INFO',
|
||||||
@@ -225,6 +230,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'ERROR MESSAGE',
|
'str' => 'ERROR MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<ERROR> ERROR MESSAGE',
|
'expected' => '<ERROR> ERROR MESSAGE',
|
||||||
],
|
],
|
||||||
'error, logged' => [
|
'error, logged' => [
|
||||||
@@ -233,6 +239,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'ERROR MESSAGE',
|
'str' => 'ERROR MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => true,
|
'log_error' => true,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<ERROR> ERROR MESSAGE',
|
'expected' => '<ERROR> ERROR MESSAGE',
|
||||||
],
|
],
|
||||||
'error, logged, message' => [
|
'error, logged, message' => [
|
||||||
@@ -241,14 +248,43 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'ERROR MESSAGE',
|
'str' => 'ERROR MESSAGE',
|
||||||
'message' => 'OTHER ERROR MESSAGE',
|
'message' => 'OTHER ERROR MESSAGE',
|
||||||
'log_error' => true,
|
'log_error' => true,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<ERROR> OTHER ERROR MESSAGE',
|
'expected' => '<ERROR> OTHER ERROR MESSAGE',
|
||||||
],
|
],
|
||||||
|
'warn, not logged' => [
|
||||||
|
'id' => '300',
|
||||||
|
'level' => 'warn',
|
||||||
|
'str' => 'WARNING MESSAGE',
|
||||||
|
'message' => null,
|
||||||
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
|
'expected' => '<WARNING> WARNING MESSAGE',
|
||||||
|
],
|
||||||
|
'warn, logged' => [
|
||||||
|
'id' => '300',
|
||||||
|
'level' => 'warn',
|
||||||
|
'str' => 'WARNING MESSAGE',
|
||||||
|
'message' => null,
|
||||||
|
'log_error' => null,
|
||||||
|
'log_warning' => true,
|
||||||
|
'expected' => '<WARNING> WARNING MESSAGE',
|
||||||
|
],
|
||||||
|
'warn, logged, message' => [
|
||||||
|
'id' => '300',
|
||||||
|
'level' => 'warn',
|
||||||
|
'str' => 'WARNING MESSAGE',
|
||||||
|
'message' => 'OTHER WARNING MESSAGE',
|
||||||
|
'log_error' => null,
|
||||||
|
'log_warning' => true,
|
||||||
|
'expected' => '<WARNING> OTHER WARNING MESSAGE',
|
||||||
|
],
|
||||||
'notice' => [
|
'notice' => [
|
||||||
'id' => '100',
|
'id' => '100',
|
||||||
'level' => 'notice',
|
'level' => 'notice',
|
||||||
'str' => 'NOTICE MESSAGE',
|
'str' => 'NOTICE MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<NOTICE> NOTICE MESSAGE',
|
'expected' => '<NOTICE> NOTICE MESSAGE',
|
||||||
],
|
],
|
||||||
'notice, message' => [
|
'notice, message' => [
|
||||||
@@ -257,6 +293,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'NOTICE MESSAGE',
|
'str' => 'NOTICE MESSAGE',
|
||||||
'message' => 'OTHER NOTICE MESSAGE',
|
'message' => 'OTHER NOTICE MESSAGE',
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<NOTICE> OTHER NOTICE MESSAGE',
|
'expected' => '<NOTICE> OTHER NOTICE MESSAGE',
|
||||||
],
|
],
|
||||||
'crash' => [
|
'crash' => [
|
||||||
@@ -265,6 +302,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'CRASH MESSAGE',
|
'str' => 'CRASH MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<ALERT> CRASH MESSAGE',
|
'expected' => '<ALERT> CRASH MESSAGE',
|
||||||
],
|
],
|
||||||
'crash, message' => [
|
'crash, message' => [
|
||||||
@@ -273,6 +311,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'CRASH MESSAGE',
|
'str' => 'CRASH MESSAGE',
|
||||||
'message' => 'OTHER CRASH MESSAGE',
|
'message' => 'OTHER CRASH MESSAGE',
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<ALERT> OTHER CRASH MESSAGE',
|
'expected' => '<ALERT> OTHER CRASH MESSAGE',
|
||||||
],
|
],
|
||||||
'abort' => [
|
'abort' => [
|
||||||
@@ -281,6 +320,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'ABORT MESSAGE',
|
'str' => 'ABORT MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<CRITICAL> ABORT MESSAGE',
|
'expected' => '<CRITICAL> ABORT MESSAGE',
|
||||||
],
|
],
|
||||||
'abort, message' => [
|
'abort, message' => [
|
||||||
@@ -289,6 +329,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'ABORT MESSAGE',
|
'str' => 'ABORT MESSAGE',
|
||||||
'message' => 'OTHER ABORT MESSAGE',
|
'message' => 'OTHER ABORT MESSAGE',
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<CRITICAL> OTHER ABORT MESSAGE',
|
'expected' => '<CRITICAL> OTHER ABORT MESSAGE',
|
||||||
],
|
],
|
||||||
'unknown' => [
|
'unknown' => [
|
||||||
@@ -297,6 +338,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'WRONG LEVEL MESSAGE',
|
'str' => 'WRONG LEVEL MESSAGE',
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<EMERGENCY> WRONG LEVEL MESSAGE',
|
'expected' => '<EMERGENCY> WRONG LEVEL MESSAGE',
|
||||||
],
|
],
|
||||||
'unknown, message' => [
|
'unknown, message' => [
|
||||||
@@ -305,6 +347,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
'str' => 'WRONG LEVEL MESSAGE',
|
'str' => 'WRONG LEVEL MESSAGE',
|
||||||
'message' => 'OTHER WRONG LEVEL MESSAGE',
|
'message' => 'OTHER WRONG LEVEL MESSAGE',
|
||||||
'log_error' => null,
|
'log_error' => null,
|
||||||
|
'log_warning' => null,
|
||||||
'expected' => '<EMERGENCY> OTHER WRONG LEVEL MESSAGE',
|
'expected' => '<EMERGENCY> OTHER WRONG LEVEL MESSAGE',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -321,6 +364,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
* @param string $str
|
* @param string $str
|
||||||
* @param string|null $message
|
* @param string|null $message
|
||||||
* @param bool|null $log_error
|
* @param bool|null $log_error
|
||||||
|
* @param bool|null $log_warning
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -330,6 +374,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
string $str,
|
string $str,
|
||||||
?string $message,
|
?string $message,
|
||||||
?bool $log_error,
|
?bool $log_error,
|
||||||
|
?bool $log_warning,
|
||||||
string $expected
|
string $expected
|
||||||
): void {
|
): void {
|
||||||
$log = new \CoreLibs\Logging\Logging([
|
$log = new \CoreLibs\Logging\Logging([
|
||||||
@@ -344,7 +389,8 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
$level,
|
$level,
|
||||||
$str,
|
$str,
|
||||||
message: $message,
|
message: $message,
|
||||||
log_error: $log_error
|
log_error: $log_error,
|
||||||
|
log_warning: $log_warning
|
||||||
);
|
);
|
||||||
$file_content = '';
|
$file_content = '';
|
||||||
if (is_file($log->getLogFolder() . $log->getLogFile())) {
|
if (is_file($log->getLogFolder() . $log->getLogFile())) {
|
||||||
@@ -358,6 +404,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
$file_content
|
$file_content
|
||||||
);
|
);
|
||||||
|
} elseif ($level == 'warn' && ($log_warning === null || $log_warning === false)) {
|
||||||
|
$this->assertStringNotContainsString(
|
||||||
|
$expected,
|
||||||
|
$file_content
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
$expected,
|
$expected,
|
||||||
@@ -377,6 +428,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
* @param string $str
|
* @param string $str
|
||||||
* @param string|null $message
|
* @param string|null $message
|
||||||
* @param bool|null $log_error
|
* @param bool|null $log_error
|
||||||
|
* @param bool|null $log_warning
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -386,6 +438,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
string $str,
|
string $str,
|
||||||
?string $message,
|
?string $message,
|
||||||
?bool $log_error,
|
?bool $log_error,
|
||||||
|
?bool $log_warning,
|
||||||
string $expected
|
string $expected
|
||||||
): void {
|
): void {
|
||||||
$log = new \CoreLibs\Logging\Logging([
|
$log = new \CoreLibs\Logging\Logging([
|
||||||
@@ -400,7 +453,8 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
$level,
|
$level,
|
||||||
$str,
|
$str,
|
||||||
message: $message,
|
message: $message,
|
||||||
log_error: $log_error
|
log_error: $log_error,
|
||||||
|
log_warning: $log_warning
|
||||||
);
|
);
|
||||||
$file_content = '';
|
$file_content = '';
|
||||||
if (is_file($log->getLogFolder() . $log->getLogFile())) {
|
if (is_file($log->getLogFolder() . $log->getLogFile())) {
|
||||||
@@ -414,6 +468,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
$file_content
|
$file_content
|
||||||
);
|
);
|
||||||
|
} elseif ($level == 'warn' && $log_warning === false) {
|
||||||
|
$this->assertStringNotContainsString(
|
||||||
|
$expected,
|
||||||
|
$file_content
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
$expected,
|
$expected,
|
||||||
|
|||||||
@@ -46,12 +46,34 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testEncryptDecryptSuccess(string $input, string $expected): void
|
public function testEncryptDecryptSuccess(string $input, string $expected): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt($input, $key);
|
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
// test class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class call',
|
||||||
|
);
|
||||||
|
|
||||||
|
// test indirect
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($input);
|
||||||
|
$decrypted = SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class Instance call',
|
||||||
|
);
|
||||||
|
|
||||||
|
// test static
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($input, $key);
|
||||||
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$decrypted
|
$decrypted,
|
||||||
|
'Static call',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +108,24 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testEncryptFailed(string $input, string $exception_message): void
|
public function testEncryptFailed(string $input, string $exception_message): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt($input, $key);
|
|
||||||
$wrong_key = CreateKey::generateRandomKey();
|
$wrong_key = CreateKey::generateRandomKey();
|
||||||
|
|
||||||
|
// wrong key in class call
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($encrypted, $wrong_key);
|
$crypt->setKey($key);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($input);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($wrong_key)->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($input, $key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::decryptKey($encrypted, $wrong_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +143,6 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
'too short hex key' => [
|
'too short hex key' => [
|
||||||
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
||||||
'excpetion_message' => 'Key is not the correct size (must be '
|
'excpetion_message' => 'Key is not the correct size (must be '
|
||||||
. 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes long).'
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -126,13 +161,33 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWrongKey(string $key, string $exception_message): void
|
public function testWrongKey(string $key, string $exception_message): void
|
||||||
{
|
{
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::encrypt('test', $key);
|
|
||||||
// we must encrypt valid thing first so we can fail with the wrong kjey
|
|
||||||
$enc_key = CreateKey::generateRandomKey();
|
$enc_key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt('test', $enc_key);
|
|
||||||
|
// class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($encrypted, $key);
|
$crypt->encrypt('test');
|
||||||
|
$crypt->setKey($enc_key);
|
||||||
|
$encrypted = $crypt->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->setKey($key);
|
||||||
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +200,7 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
return [
|
return [
|
||||||
'too short ciphertext' => [
|
'too short ciphertext' => [
|
||||||
'input' => 'short',
|
'input' => 'short',
|
||||||
'exception_message' => 'Invalid ciphertext (too short)'
|
'exception_message' => 'Decipher message failed: '
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -164,8 +219,18 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testWrongCiphertext(string $input, string $exception_message): void
|
public function testWrongCiphertext(string $input, string $exception_message): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
|
// class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($input, $key);
|
$crypt->decrypt($input);
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($key)->decrypt($input);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::decryptKey($input, $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
includes:
|
includes:
|
||||||
- phpstan-conditional.php
|
- phpstan-conditional.php
|
||||||
parameters:
|
parameters:
|
||||||
tmpDir: /tmp/phpstan-corelibs
|
tmpDir: %currentWorkingDirectory%/tmp/phpstan-corelibs
|
||||||
level: 8 # max is now 9
|
level: 8 # max is now 9
|
||||||
checkMissingCallableSignature: true
|
checkMissingCallableSignature: true
|
||||||
treatPhpDocTypesAsCertain: false
|
treatPhpDocTypesAsCertain: false
|
||||||
|
|||||||
2
tmp/.gitignore
vendored
Normal file
2
tmp/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/php-cs-fixer-3.53.0.phar
|
/home/clemens/.phive/phars/php-cs-fixer-3.57.2.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpcbf-3.9.1.phar
|
/home/clemens/.phive/phars/phpcbf-3.10.3.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpcs-3.9.1.phar
|
/home/clemens/.phive/phars/phpcs-3.10.3.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpstan-1.10.67.phar
|
/home/clemens/.phive/phars/phpstan-1.12.4.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpunit-9.6.19.phar
|
/home/clemens/.phive/phars/phpunit-9.6.21.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/psalm-5.23.1.phar
|
/home/clemens/.phive/phars/psalm-5.24.0.phar
|
||||||
@@ -46,7 +46,7 @@ use CoreLibs\Debug\Support;
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
$PAGE_NAME = 'TEST CLASS: ADMIN BACKEND';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -55,7 +55,25 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
|||||||
print "SETACL[]: <br>";
|
print "SETACL[]: <br>";
|
||||||
$backend->setACL(['EMPTY' => 'EMPTY']);
|
$backend->setACL(['EMPTY' => 'EMPTY']);
|
||||||
print "ADBEDITLOG: <br>";
|
print "ADBEDITLOG: <br>";
|
||||||
$backend->adbEditLog('CLASSTEST-ADMIN', 'Some info string');
|
$backend->adbEditLog('CLASSTEST-ADMIN-BINARY', 'Some info string', 'BINARY');
|
||||||
|
$backend->adbEditLog('CLASSTEST-ADMIN-ZLIB', 'Some info string', 'ZLIB');
|
||||||
|
$backend->adbEditLog('CLASSTEST-ADMIN-SERIAL', 'Some info string', 'SERIAL');
|
||||||
|
$backend->adbEditLog('CLASSTEST-ADMIN-INVALID', 'Some info string', 'INVALID');
|
||||||
|
// test with various
|
||||||
|
$backend->action = 'TEST ACTION';
|
||||||
|
$backend->action_id = 'TEST ACTION ID';
|
||||||
|
$backend->action_yes = 'TEST ACTION YES';
|
||||||
|
$backend->action_flag = 'TEST ACTION FLAG';
|
||||||
|
$backend->action_menu = 'TEST ACTION MENU';
|
||||||
|
$backend->action_loaded = 'TEST ACTION LOADED';
|
||||||
|
$backend->action_value = 'TEST ACTION VALUE';
|
||||||
|
$backend->action_type = 'TEST ACTION TYPE';
|
||||||
|
$backend->action_error = 'TEST ACTION ERROR';
|
||||||
|
$backend->adbEditLog('CLASSTEST-ADMIN-JSON', [
|
||||||
|
"_GET" => $_GET,
|
||||||
|
"_POST" => $_POST,
|
||||||
|
], 'JSON');
|
||||||
|
|
||||||
print "ADBTOPMENU(0): " . Support::printAr($backend->adbTopMenu(CONTENT_PATH)) . "<br>";
|
print "ADBTOPMENU(0): " . Support::printAr($backend->adbTopMenu(CONTENT_PATH)) . "<br>";
|
||||||
print "ADBMSG: <br>";
|
print "ADBMSG: <br>";
|
||||||
$backend->adbMsg('info', 'Message: %1$d', [1]);
|
$backend->adbMsg('info', 'Message: %1$d', [1]);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ ob_end_flush();
|
|||||||
use CoreLibs\Combined\ArrayHandler;
|
use CoreLibs\Combined\ArrayHandler;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
use CoreLibs\Convert\SetVarType;
|
use CoreLibs\Convert\SetVarType;
|
||||||
use PHPUnit\Framework\Constraint\ArrayHasKey;
|
// use PHPUnit\Framework\Constraint\ArrayHasKey;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -33,7 +33,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ARRAY HANDLER';
|
$PAGE_NAME = 'TEST CLASS: ARRAY HANDLER';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use CoreLibs\Convert\Byte;
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: AUTOLOADER';
|
$PAGE_NAME = 'TEST CLASS: AUTOLOADER';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $byte_class = 'CoreLibs\Convert\Byte';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: BYTE CONVERT';
|
$PAGE_NAME = 'TEST CLASS: BYTE CONVERT';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CHECK COLORS';
|
$PAGE_NAME = 'TEST CLASS: CHECK COLORS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $db = new CoreLibs\DB\IO(DB_CONFIG, $log);
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CLASS CALLS';
|
$PAGE_NAME = 'TEST CLASS: CLASS CALLS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT';
|
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CONFIG LINK';
|
$PAGE_NAME = 'TEST CLASS: CONFIG LINK';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ $color_class = 'CoreLibs\Convert\Colors';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CONVERT COLORS';
|
$PAGE_NAME = 'TEST CLASS: CONVERT COLORS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CREATE EMAIL';
|
$PAGE_NAME = 'TEST CLASS: CREATE EMAIL';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $datetime_class = 'CoreLibs\Combined\DateTime';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DATE/TIME';
|
$PAGE_NAME = 'TEST CLASS: DATE/TIME';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -451,6 +451,7 @@ function intervalStringFormatDeprecated(
|
|||||||
$value = $interval->days;
|
$value = $interval->days;
|
||||||
$skip = true;
|
$skip = true;
|
||||||
} else {
|
} else {
|
||||||
|
/** @phan-suppress-next-line PhanUndeclaredProperty */
|
||||||
$value = $interval->$part;
|
$value = $interval->$part;
|
||||||
}
|
}
|
||||||
if ($value == 0 && $skip_last_zero === true) {
|
if ($value == 0 && $skip_last_zero === true) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ $db->log->debug('START', '=============================>');
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DB dbReturn';
|
$PAGE_NAME = 'TEST CLASS: DB dbReturn';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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><a href="class_test.db.php">Class Test DB</a></div>';
|
print '<div><a href="class_test.db.php">Class Test DB</a></div>';
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ $db->log->debug('START', '=============================>');
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DB';
|
$PAGE_NAME = 'TEST CLASS: DB';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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><a href="class_test.db.type.php">Class Test DB row type convert to PHP type</a></div>';
|
print '<div><a href="class_test.db.type.php">Class Test DB row type convert to PHP type</a></div>';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ $LOG_FILE_ID = 'classTest-db-query-placeholder';
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Debug\Support;
|
use CoreLibs\Debug\Support;
|
||||||
use CoreLibs\DB\Support\ConvertPlaceholder;
|
// use CoreLibs\DB\Support\ConvertPlaceholder;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -33,7 +33,7 @@ $db->log->debug('START', '=============================>');
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDER';
|
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDER';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ require 'config.php';
|
|||||||
$LOG_FILE_ID = 'classTest-db-query-placeholders';
|
$LOG_FILE_ID = 'classTest-db-query-placeholders';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Debug\Support;
|
// use CoreLibs\Debug\Support;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
@@ -32,7 +32,7 @@ $db->log->debug('START', '=============================>');
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDERS';
|
$PAGE_NAME = 'TEST CLASS: DB QUERY PLACEHOLDERS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ $db->log->debug('START', '=============================>');
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DB COLUMN TYPES';
|
$PAGE_NAME = 'TEST CLASS: DB COLUMN TYPES';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ $debug_logging_class = 'CoreLibs\Debug\LoggingLegacy';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: DEBUG';
|
$PAGE_NAME = 'TEST CLASS: DEBUG';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ $chk_enc = 'CoreLibs\Check\Encoding';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ENCODING (CHECK/CONVERT/MIME)';
|
$PAGE_NAME = 'TEST CLASS: ENCODING (CHECK/CONVERT/MIME)';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ENCRYPTION';
|
$PAGE_NAME = 'TEST CLASS: ENCRYPTION';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -40,16 +40,33 @@ $key = CreateKey::generateRandomKey();
|
|||||||
print "Secret Key: " . $key . "<br>";
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
|
||||||
$string = "I a some deep secret";
|
$string = "I a some deep secret";
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
//
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($string);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
print "[C] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[C] Decrytped: " . $decrypted . "<br>";
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($string);
|
||||||
|
$decrypted = SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
print "[S] Original: " . $string . "<br>";
|
||||||
|
print "[S] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[S] Decrytped: " . $decrypted . "<br>";
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
|
print "[SS] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[SS] Decrytped: " . $decrypted . "<br>";
|
||||||
|
|
||||||
print "Original: " . $string . "<br>";
|
print "<br>INIT KEY MISSING<br>";
|
||||||
print "Encrypted: " . $encrypted . "<br>";
|
try {
|
||||||
print "Decrytped: " . $decrypted . "<br>";
|
$crypt = new SymmetricEncryption();
|
||||||
|
$encrypted = $crypt->decrypt($string);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
print("Error: " . $e->getMessage() . "<br>");
|
||||||
|
}
|
||||||
|
|
||||||
print "<br>WRONG CIPHERTEXT<br>";
|
print "<br>WRONG CIPHERTEXT<br>";
|
||||||
try {
|
try {
|
||||||
$decrypted = SymmetricEncryption::decrypt('flupper', $key);
|
$decrypted = SymmetricEncryption::decryptKey('flupper', $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -57,7 +74,7 @@ try {
|
|||||||
print "<br>SHORT and WRONG KEY<br>";
|
print "<br>SHORT and WRONG KEY<br>";
|
||||||
$key = 'wrong_key';
|
$key = 'wrong_key';
|
||||||
try {
|
try {
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -65,7 +82,7 @@ try {
|
|||||||
print "<br>INVALID HEX KEY<br>";
|
print "<br>INVALID HEX KEY<br>";
|
||||||
$key = '1cabd5cba9e042f12522f4ff2de5c31d233b';
|
$key = '1cabd5cba9e042f12522f4ff2de5c31d233b';
|
||||||
try {
|
try {
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -73,21 +90,10 @@ try {
|
|||||||
print "<br>WRONG KEY TO DECRYPT<br>";
|
print "<br>WRONG KEY TO DECRYPT<br>";
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$string = "I a some deep secret";
|
$string = "I a some deep secret";
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
$key = CreateKey::generateRandomKey();
|
|
||||||
try {
|
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<br>WRONG KEY TO DECRYPT<br>";
|
|
||||||
$key = CreateKey::generateRandomKey();
|
|
||||||
$string = "I a some deep secret";
|
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
|
||||||
$key = 'wrong_key';
|
$key = 'wrong_key';
|
||||||
try {
|
try {
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: ERROR MSG';
|
$PAGE_NAME = 'TEST CLASS: ERROR MSG';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -45,6 +45,8 @@ $em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug');
|
|||||||
$em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug', 'target-id', 'other-style');
|
$em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug', 'target-id', 'other-style');
|
||||||
$em->setErrorMsg('123', 'error', 'msg this is bad, logged always', log_error:true);
|
$em->setErrorMsg('123', 'error', 'msg this is bad, logged always', log_error:true);
|
||||||
$em->setErrorMsg('123', 'error', 'msg this is bad, never logged', log_error:false);
|
$em->setErrorMsg('123', 'error', 'msg this is bad, never logged', log_error:false);
|
||||||
|
$em->setErrorMsg('500', 'warning', 'This is perhaps not super good, logged_always', log_warning:true);
|
||||||
|
$em->setErrorMsg('500', 'warning', 'This is perhaps not super good, logged_never', log_warning:false);
|
||||||
$em->setErrorMsg('1000', 'info', 'This is good');
|
$em->setErrorMsg('1000', 'info', 'This is good');
|
||||||
$em->setErrorMsg('9999', 'abort', 'BAD: This is critical (abort)');
|
$em->setErrorMsg('9999', 'abort', 'BAD: This is critical (abort)');
|
||||||
$em->setErrorMsg('10-1000', 'wrong', 'Wrong level: This is emergency');
|
$em->setErrorMsg('10-1000', 'wrong', 'Wrong level: This is emergency');
|
||||||
@@ -59,6 +61,8 @@ print "ErrorsIds: <pre>" . $log->prAr($em->getErrorIds()) . "</pre>";
|
|||||||
print "Errors: <pre>" . $log->prAr($em->getErrorMsg()) . "</pre>";
|
print "Errors: <pre>" . $log->prAr($em->getErrorMsg()) . "</pre>";
|
||||||
print "JumpTargets: <pre>" . $log->prAr($em->getJumpTarget()) . "</pre>";
|
print "JumpTargets: <pre>" . $log->prAr($em->getJumpTarget()) . "</pre>";
|
||||||
|
|
||||||
|
print "IS info > ok: " . ml::fromName('info')->isHigherThan(ml::ok) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
$log->debug('[END]', '==========================================>');
|
$log->debug('[END]', '==========================================>');
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: FILE';
|
$PAGE_NAME = 'TEST CLASS: FILE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ $hash_class = 'CoreLibs\Create\Hash';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HASH';
|
$PAGE_NAME = 'TEST CLASS: HASH';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -35,19 +35,21 @@ $elements_class = 'CoreLibs\Output\Form\Elements';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
$PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|
||||||
$string = "Something < = > Other <br> Next line";
|
$string = "Something < = > Other <br> Next line and Quotes '\"";
|
||||||
print "HTMLENT: " . Html::htmlent($string) . ": " . $_html->htmlent($string) . "<br>";
|
echo "String: <pre>$string</pre><br>";
|
||||||
|
$log->debug('HTMLENT', Html::htmlent($string));
|
||||||
|
print "HTMLENT: " . Html::htmlent($string) . ": " . $_html->htmlent($string) . " (" . htmlentities($string) . ")<br>";
|
||||||
print "REMOVELB: " . Html::htmlent($string) . ": " . $_html->removeLB($string) . "<br>";
|
print "REMOVELB: " . Html::htmlent($string) . ": " . $_html->removeLB($string) . "<br>";
|
||||||
$date_str = [2021, 5, 1, 11, 10];
|
$date_str = [2021, 5, 1, 11, 10];
|
||||||
print "PRINTDATETIME: "
|
print "PRINTDATETIME: "
|
||||||
. $_elements->printDateTime($date_str[0], $date_str[1], $date_str[2], $date_str[3], $date_str[4]) . "<br>";
|
. $_elements->printDateTime($date_str[0], $date_str[1], $date_str[2], $date_str[3], $date_str[4]) . "<br>";
|
||||||
// STATIC
|
// STATIC
|
||||||
$string = "Something < = > Other <br> Next line";
|
// $string = "Something < = > Other <br> Next line and Quotes '\"";
|
||||||
print "S::HTMLENT: " . Html::htmlent($string) . ": " . $html_class::htmlent($string) . "<br>";
|
print "S::HTMLENT: " . Html::htmlent($string) . ": " . $html_class::htmlent($string) . "<br>";
|
||||||
print "S::REMOVELB: " . Html::htmlent($string) . ": " . $html_class::removeLB($string) . "<br>";
|
print "S::REMOVELB: " . Html::htmlent($string) . ": " . $html_class::removeLB($string) . "<br>";
|
||||||
$date_str = [2021, 5, 1, 11, 10];
|
$date_str = [2021, 5, 1, 11, 10];
|
||||||
@@ -67,8 +69,10 @@ $checked_list = [
|
|||||||
['foo', ['bar']],
|
['foo', ['bar']],
|
||||||
];
|
];
|
||||||
foreach ($checked_list as $check) {
|
foreach ($checked_list as $check) {
|
||||||
print "CHECKED(0): $check[0]: " . Html::checked($check[1], $check[0]) . "<br>";
|
print "CHECKED(0): " . $check[0] . " -> " . print_r($check[1], true) . ": "
|
||||||
print "CHECKED(1): $check[0]: " . Html::checked($check[1], $check[0], Html::CHECKED) . "<br>";
|
. Html::checked($check[1], $check[0]) . "<br>";
|
||||||
|
print "CHECKED(1): " . $check[0] . " -> " . print_r($check[1], true) . ": "
|
||||||
|
. Html::checked($check[1], $check[0], Html::CHECKED) . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// magic link creation test
|
// magic link creation test
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: BLOCK';
|
$PAGE_NAME = 'TEST CLASS: HTML BUILD: BLOCK';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD';
|
$PAGE_NAME = 'TEST CLASS: HTML BUILD';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: STRING REPLACE';
|
$PAGE_NAME = 'TEST CLASS: HTML BUILD: STRING REPLACE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ $image_class = 'CoreLibs\Output\Image';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: IMAGE';
|
$PAGE_NAME = 'TEST CLASS: IMAGE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ $json_class = 'CoreLibs\Convert\Json';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: JSON';
|
$PAGE_NAME = 'TEST CLASS: JSON';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ ob_end_flush();
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: LANG';
|
$PAGE_NAME = 'TEST CLASS: LANG';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: LOGGING';
|
$PAGE_NAME = 'TEST CLASS: LOGGING';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ $login->loginMainCall();
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
$PAGE_NAME = 'TEST CLASS: LOGIN';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $math_class = 'CoreLibs\Convert\Math';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: MATH';
|
$PAGE_NAME = 'TEST CLASS: MATH';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: MEMORY USAGE';
|
$PAGE_NAME = 'TEST CLASS: MEMORY USAGE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ $_mime = new CoreLibs\Convert\MimeAppName();
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: MIME';
|
$PAGE_NAME = 'TEST CLASS: MIME';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ $form = new CoreLibs\Output\Form\Generate(
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: FORM GENERATE';
|
$PAGE_NAME = 'TEST CLASS: FORM GENERATE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ $password_class = 'CoreLibs\Security\Password';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: PASSWORD';
|
$PAGE_NAME = 'TEST CLASS: PASSWORD';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ $backend->db->dbInfo(true);
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>TEST CLASS</title><head>";
|
print "<html><head><title>TEST CLASS</title></head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
|
|
||||||
// key: file name, value; name
|
// key: file name, value; name
|
||||||
@@ -178,7 +178,7 @@ $log->debug('SOME MARK', 'Some error output');
|
|||||||
print "EDIT ACCESS ID: " . $backend->edit_access_id . "<br>";
|
print "EDIT ACCESS ID: " . $backend->edit_access_id . "<br>";
|
||||||
if (is_object($login)) {
|
if (is_object($login)) {
|
||||||
// print "ACL: <br>".$backend->print_ar($login->loginGetAcl())."<br>";
|
// print "ACL: <br>".$backend->print_ar($login->loginGetAcl())."<br>";
|
||||||
$log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl()));
|
// $log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl()));
|
||||||
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
||||||
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
// print "DEFAULT ACL: <br>".$backend->print_ar($login->default_acl_list)."<br>";
|
||||||
// $result = array_flip(
|
// $result = array_flip(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ $phpv_class = 'CoreLibs\Check\PhpVersion';
|
|||||||
|
|
||||||
$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>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $array_class = 'CoreLibs\Create\RandomKey';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: RANDOM KEY';
|
$PAGE_NAME = 'TEST CLASS: RANDOM KEY';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ $ref_class = 'CoreLibs\Get\ReadEnvFile';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: READ ENV FILE';
|
$PAGE_NAME = 'TEST CLASS: READ ENV FILE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: RUNNING TIME';
|
$PAGE_NAME = 'TEST CLASS: RUNNING TIME';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ $session = new Session();
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SESSION';
|
$PAGE_NAME = 'TEST CLASS: SESSION';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ $session = new Session();
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
$PAGE_NAME = 'TEST CLASS: SESSION (READ)';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ $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>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -97,7 +97,7 @@ $smarty->DATA['drop_down_test'] = [
|
|||||||
'foobar' => 'Foo Bar',
|
'foobar' => 'Foo Bar',
|
||||||
];
|
];
|
||||||
$smarty->DATA['drop_down_test_selected'] = 'bar';
|
$smarty->DATA['drop_down_test_selected'] = 'bar';
|
||||||
$smarty->DATA['drop_down_test_nested'] = [
|
$smarty->DATA['drop_down_test_nested'] = [
|
||||||
'' => '選択してください',
|
'' => '選択してください',
|
||||||
'4/25(木)' => [
|
'4/25(木)' => [
|
||||||
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ $byte_class = 'CoreLibs\Convert\Strings';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: STRINGS CONVERT';
|
$PAGE_NAME = 'TEST CLASS: STRINGS CONVERT';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SYSTEM';
|
$PAGE_NAME = 'TEST CLASS: SYSTEM';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
@@ -41,7 +41,7 @@ print "GETPAGENAME(0): " . System::getPageName() . "<br>";
|
|||||||
print "GETPAGENAME(1): " . System::getPageName(System::NO_EXTENSION) . "<br>";
|
print "GETPAGENAME(1): " . System::getPageName(System::NO_EXTENSION) . "<br>";
|
||||||
print "GETPAGENAME(2): " . System::getPageName(System::FULL_PATH) . "<br>";
|
print "GETPAGENAME(2): " . System::getPageName(System::FULL_PATH) . "<br>";
|
||||||
print "System::getPageNameArray():<br>";
|
print "System::getPageNameArray():<br>";
|
||||||
print "GETPAGENAMEARRAY: " . \CoreLibs\Debug\Support::printAr(System::getPageNameArray()) . "<br>";
|
print "GETPAGENAMEARRAY: " . DgS::printAr(System::getPageNameArray()) . "<br>";
|
||||||
// seting errro codes file upload
|
// seting errro codes file upload
|
||||||
print "System::fileUploadErrorMessage():<br>";
|
print "System::fileUploadErrorMessage():<br>";
|
||||||
print "FILEUPLOADERRORMESSAGE(): " . System::fileUploadErrorMessage(-1) . "<br>";
|
print "FILEUPLOADERRORMESSAGE(): " . System::fileUploadErrorMessage(-1) . "<br>";
|
||||||
@@ -51,4 +51,6 @@ print "FILEUPLOADERRORMESSAGE(UPLOAD_ERR_CANT_WRITE): "
|
|||||||
print "System::checkCLI():<br>";
|
print "System::checkCLI():<br>";
|
||||||
print "Are we in an CLI: " . (System::checkCLI() ? 'Yes' : 'No') . "<br>";
|
print "Are we in an CLI: " . (System::checkCLI() ? 'Yes' : 'No') . "<br>";
|
||||||
|
|
||||||
|
print "Get Addresses: " . DgS::printAr(System::getIpAddresses()) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $token_class = 'CoreLibs\Output\Form\Token';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: FORM TOKEN';
|
$PAGE_NAME = 'TEST CLASS: FORM TOKEN';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $uids_class = 'CoreLibs\Create\Uids';
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: UIDS';
|
$PAGE_NAME = 'TEST CLASS: UIDS';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CONVERT\VARISTYPE';
|
$PAGE_NAME = 'TEST CLASS: CONVERT\VARISTYPE';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* general edit javascript */
|
/* general edit javascript */
|
||||||
/* jquery version */
|
/* jquery version */
|
||||||
|
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 11 */
|
||||||
|
|
||||||
/* global i18n */
|
/* global i18n */
|
||||||
|
|
||||||
@@ -931,7 +931,7 @@ function rel(base) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* searches and removes style from css array
|
* searches and removes style from css array
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
function rcssel(_element, css)
|
function rcssel(_element, css)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT SUB';
|
$PAGE_NAME = 'TEST CLASS: CONFIG DIRECT SUB';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
print "<body>";
|
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>';
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
);
|
);
|
||||||
|
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>GROUP TESTER</title><head>";
|
print "<html><head><title>GROUP TESTER</title></head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
|
|
||||||
print '<form method="post" name="loginlogout">';
|
print '<form method="post" name="loginlogout">';
|
||||||
|
|||||||
12
www/composer.lock
generated
12
www/composer.lock
generated
@@ -38,16 +38,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gullevek/dotenv",
|
"name": "gullevek/dotenv",
|
||||||
"version": "v2.0.8",
|
"version": "v2.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/gullevek/dotEnv.git",
|
"url": "https://github.com/gullevek/dotEnv.git",
|
||||||
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e"
|
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
|
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/b9feacaded4e48effff9da7d1173752aef3dc27f",
|
||||||
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
|
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -86,9 +86,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/gullevek/dotEnv/issues",
|
"issues": "https://github.com/gullevek/dotEnv/issues",
|
||||||
"source": "https://github.com/gullevek/dotEnv/tree/v2.0.8"
|
"source": "https://github.com/gullevek/dotEnv/tree/v2.1.0"
|
||||||
},
|
},
|
||||||
"time": "2023-03-03T00:32:02+00:00"
|
"time": "2024-08-21T02:41:15+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/log",
|
"name": "psr/log",
|
||||||
|
|||||||
@@ -24,35 +24,29 @@ declare(strict_types=1);
|
|||||||
// ];
|
// ];
|
||||||
|
|
||||||
$__LOCAL_CONFIG = [
|
$__LOCAL_CONFIG = [
|
||||||
|
// db config selection
|
||||||
'db_host' => 'test',
|
'db_host' => 'test',
|
||||||
|
// other db connections
|
||||||
|
// 'db_host_target' => '',
|
||||||
|
// 'db_host_other' => '',
|
||||||
|
// location flagging (test/dev/live) for debug output
|
||||||
'location' => 'test',
|
'location' => 'test',
|
||||||
|
// show DEBUG override
|
||||||
'debug_level' => 'debug',
|
'debug_level' => 'debug',
|
||||||
|
// site locale
|
||||||
'site_locale' => 'en_US.UTF-8',
|
'site_locale' => 'en_US.UTF-8',
|
||||||
|
// site encoding
|
||||||
'site_encoding' => 'UTF-8',
|
'site_encoding' => 'UTF-8',
|
||||||
|
// enable/disable login override
|
||||||
'login_enabled' => true
|
'login_enabled' => true
|
||||||
];
|
];
|
||||||
|
|
||||||
// each host has a different db_host
|
// each host has a different db_host
|
||||||
$SITE_CONFIG = [
|
$SITE_CONFIG = [
|
||||||
// development host
|
// development host
|
||||||
'soba.tokyo.tequila.jp' => [
|
'soba.tokyo.tequila.jp' => $__LOCAL_CONFIG,
|
||||||
// db config selection
|
|
||||||
'db_host' => 'test',
|
|
||||||
// other db connections
|
|
||||||
// 'db_host_target' => '',
|
|
||||||
// 'db_host_other' => '',
|
|
||||||
// location flagging (test/dev/live) for debug output
|
|
||||||
'location' => 'test',
|
|
||||||
// show DEBUG override
|
|
||||||
'debug_level' => 'debug',
|
|
||||||
// site locale
|
|
||||||
'site_locale' => 'en_US.UTF-8',
|
|
||||||
// site encoding
|
|
||||||
'site_encoding' => 'UTF-8',
|
|
||||||
// enable/disable login override
|
|
||||||
'login_enabled' => true
|
|
||||||
],
|
|
||||||
// 'other.host.com' => $__LOCAL_CONFIG
|
// 'other.host.com' => $__LOCAL_CONFIG
|
||||||
|
'soba.egplusww.jp' => $__LOCAL_CONFIG,
|
||||||
'soba-dev.tequila.jp' => $__LOCAL_CONFIG,
|
'soba-dev.tequila.jp' => $__LOCAL_CONFIG,
|
||||||
'soba.tequila.jp' => $__LOCAL_CONFIG,
|
'soba.tequila.jp' => $__LOCAL_CONFIG,
|
||||||
'soba.teq.jp' => $__LOCAL_CONFIG,
|
'soba.teq.jp' => $__LOCAL_CONFIG,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* AUTHOR: Clemens Schwaighofer
|
* AUTHOR: Clemens Schwaighofer
|
||||||
@@ -11,6 +11,20 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
||||||
|
$folder = '';
|
||||||
|
foreach (['admin', 'frontend'] as $_folder) {
|
||||||
|
if (strstr(getcwd() ?: '', DIRECTORY_SEPARATOR . $_folder)) {
|
||||||
|
$folder = $_folder;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if content path is empty, fallback is default
|
||||||
|
if (empty($folder)) {
|
||||||
|
$folder = 'default';
|
||||||
|
}
|
||||||
|
define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// File and Folder paths
|
// File and Folder paths
|
||||||
// ID is TARGET (first array element)
|
// ID is TARGET (first array element)
|
||||||
/*$PATHS = [
|
/*$PATHS = [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php // phpcs:ignore warning
|
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* AUTHOR: Clemens Schwaighofer
|
* AUTHOR: Clemens Schwaighofer
|
||||||
@@ -53,19 +53,6 @@ for (
|
|||||||
\gullevek\dotEnv\DotEnv::readEnvFile(
|
\gullevek\dotEnv\DotEnv::readEnvFile(
|
||||||
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH
|
$__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH
|
||||||
);
|
);
|
||||||
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
|
||||||
$folder = '';
|
|
||||||
foreach (['admin', 'frontend'] as $_folder) {
|
|
||||||
if (strstr(getcwd() ?: '', DIRECTORY_SEPARATOR . $_folder)) {
|
|
||||||
$folder = $_folder;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if content path is empty, fallback is default
|
|
||||||
if (empty($folder)) {
|
|
||||||
$folder = 'default';
|
|
||||||
}
|
|
||||||
define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR);
|
|
||||||
// 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;
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\Admin;
|
namespace CoreLibs\Admin;
|
||||||
|
|
||||||
|
use CoreLibs\Convert\Json;
|
||||||
|
|
||||||
class Backend
|
class Backend
|
||||||
{
|
{
|
||||||
// page name
|
// page name
|
||||||
@@ -42,7 +44,7 @@ class Backend
|
|||||||
/** @var array<string> */
|
/** @var array<string> */
|
||||||
public array $action_list = [
|
public array $action_list = [
|
||||||
'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag',
|
'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag',
|
||||||
'action_menu', 'action_value', 'action_error', 'action_loaded'
|
'action_menu', 'action_value', 'action_type', 'action_error', 'action_loaded'
|
||||||
];
|
];
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public string $action;
|
public string $action;
|
||||||
@@ -61,20 +63,31 @@ class Backend
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
public string $action_value;
|
public string $action_value;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
public string $action_type;
|
||||||
|
/** @var string */
|
||||||
public string $action_error;
|
public string $action_error;
|
||||||
|
|
||||||
// ACL array variable if we want to set acl data from outisde
|
// ACL array variable if we want to set acl data from outisde
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public array $acl = [];
|
public array $acl = [];
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public int $default_acl;
|
public int $default_acl;
|
||||||
|
|
||||||
// queue key
|
// queue key
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public string $queue_key;
|
public string $queue_key;
|
||||||
|
|
||||||
|
/** @var array<string> list of allowed types for edit log write */
|
||||||
|
private const WRITE_TYPES = ['BINARY', 'BZIP2', 'LZIP', 'STRING', 'SERIAL', 'JSON'];
|
||||||
|
/** @var array<string> list of available write types for log */
|
||||||
|
private array $write_types_available = [];
|
||||||
|
|
||||||
// the current active edit access id
|
// the current active edit access id
|
||||||
/** @var int|null */
|
/** @var int|null */
|
||||||
public int|null $edit_access_id;
|
public int|null $edit_access_id;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public string $page_name;
|
public string $page_name;
|
||||||
|
|
||||||
// error/warning/info messages
|
// error/warning/info messages
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public array $messages = [];
|
public array $messages = [];
|
||||||
@@ -84,6 +97,7 @@ class Backend
|
|||||||
public bool $warning = false;
|
public bool $warning = false;
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public bool $info = false;
|
public bool $info = false;
|
||||||
|
|
||||||
// internal lang & encoding vars
|
// internal lang & encoding vars
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public string $lang_dir = '';
|
public string $lang_dir = '';
|
||||||
@@ -95,6 +109,7 @@ class Backend
|
|||||||
public string $domain;
|
public string $domain;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public string $encoding;
|
public string $encoding;
|
||||||
|
|
||||||
/** @var \CoreLibs\Logging\Logging logger */
|
/** @var \CoreLibs\Logging\Logging logger */
|
||||||
public \CoreLibs\Logging\Logging $log;
|
public \CoreLibs\Logging\Logging $log;
|
||||||
/** @var \CoreLibs\DB\IO database */
|
/** @var \CoreLibs\DB\IO database */
|
||||||
@@ -103,6 +118,7 @@ class Backend
|
|||||||
public \CoreLibs\Language\L10n $l;
|
public \CoreLibs\Language\L10n $l;
|
||||||
/** @var \CoreLibs\Create\Session session class */
|
/** @var \CoreLibs\Create\Session session class */
|
||||||
public \CoreLibs\Create\Session $session;
|
public \CoreLibs\Create\Session $session;
|
||||||
|
|
||||||
// smarty publics [end processing in smarty class]
|
// smarty publics [end processing in smarty class]
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public array $DATA = [];
|
public array $DATA = [];
|
||||||
@@ -117,18 +133,20 @@ class Backend
|
|||||||
/**
|
/**
|
||||||
* main class constructor
|
* main class constructor
|
||||||
*
|
*
|
||||||
* @param \CoreLibs\DB\IO $db Database connection class
|
* @param \CoreLibs\DB\IO $db Database connection class
|
||||||
* @param \CoreLibs\Logging\Logging $log Logging class
|
* @param \CoreLibs\Logging\Logging $log Logging class
|
||||||
* @param \CoreLibs\Create\Session $session Session interface class
|
* @param \CoreLibs\Create\Session $session Session interface class
|
||||||
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
||||||
* @param int|null $set_default_acl_level Default ACL level
|
* @param int|null $set_default_acl_level [default=null] Default ACL level
|
||||||
|
* @param bool $init_action_vars [default=true] If the action vars should be set
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\DB\IO $db,
|
\CoreLibs\DB\IO $db,
|
||||||
\CoreLibs\Logging\Logging $log,
|
\CoreLibs\Logging\Logging $log,
|
||||||
\CoreLibs\Create\Session $session,
|
\CoreLibs\Create\Session $session,
|
||||||
\CoreLibs\Language\L10n $l10n,
|
\CoreLibs\Language\L10n $l10n,
|
||||||
?int $set_default_acl_level = null
|
?int $set_default_acl_level = null,
|
||||||
|
bool $init_action_vars = true
|
||||||
) {
|
) {
|
||||||
// attach db class
|
// attach db class
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
@@ -151,9 +169,9 @@ class Backend
|
|||||||
// set the page name
|
// set the page name
|
||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
|
|
||||||
// set the action ids
|
// NOTE: if any of the "action" vars are used somewhere, it is recommended to NOT set them here
|
||||||
foreach ($this->action_list as $_action) {
|
if ($init_action_vars) {
|
||||||
$this->$_action = $_POST[$_action] ?? '';
|
$this->adbSetActionVars();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($set_default_acl_level === null) {
|
if ($set_default_acl_level === null) {
|
||||||
@@ -170,9 +188,12 @@ class Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
// queue key
|
// queue key
|
||||||
if (preg_match("/^(add|save|delete|remove|move|up|down|push_live)$/", $this->action)) {
|
if (preg_match("/^(add|save|delete|remove|move|up|down|push_live)$/", $this->action ?? '')) {
|
||||||
$this->queue_key = \CoreLibs\Create\RandomKey::randomKeyGen(3);
|
$this->queue_key = \CoreLibs\Create\RandomKey::randomKeyGen(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check what edit log data write types are allowed
|
||||||
|
$this->adbSetEditLogWriteTypeAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,7 +204,26 @@ class Backend
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
// PUBLIC METHODS |=================================================>
|
// MARK: PRIVATE METHODS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the write types that are allowed
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function adbSetEditLogWriteTypeAvailable()
|
||||||
|
{
|
||||||
|
// check what edit log data write types are allowed
|
||||||
|
$this->write_types_available = self::WRITE_TYPES;
|
||||||
|
if (!function_exists('bzcompress')) {
|
||||||
|
$this->write_types_available = array_diff($this->write_types_available, ['BINARY', 'BZIP']);
|
||||||
|
}
|
||||||
|
if (!function_exists('gzcompress')) {
|
||||||
|
$this->write_types_available = array_diff($this->write_types_available, ['LZIP']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: PUBLIC METHODS |=================================================>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set internal ACL from login ACL
|
* set internal ACL from login ACL
|
||||||
@@ -195,30 +235,83 @@ class Backend
|
|||||||
$this->acl = $acl;
|
$this->acl = $acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return current set ACL
|
||||||
|
*
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public function adbGetAcl(): array
|
||||||
|
{
|
||||||
|
return $this->acl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set _POST action vars if needed
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function adbSetActionVars()
|
||||||
|
{
|
||||||
|
// set the action ids
|
||||||
|
foreach ($this->action_list as $_action) {
|
||||||
|
$this->$_action = $_POST[$_action] ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* writes all action vars plus other info into edit_log table
|
* writes all action vars plus other info into edit_log table
|
||||||
*
|
*
|
||||||
* @param string $event any kind of event description,
|
* @param string $event [default=''] any kind of event description,
|
||||||
* @param string|array<mixed> $data any kind of data related to that event
|
* @param string|array<mixed> $data [default=''] any kind of data related to that event
|
||||||
* @param string $write_type write type can bei STRING or BINARY
|
* @param string $write_type [default=JSON] write type can be
|
||||||
* @param string|null $db_schema override target schema
|
* JSON, STRING/SERIEAL, BINARY/BZIP or ZLIB
|
||||||
|
* @param string|null $db_schema [default=null] override target schema
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function adbEditLog(
|
public function adbEditLog(
|
||||||
string $event = '',
|
string $event = '',
|
||||||
string|array $data = '',
|
string|array $data = '',
|
||||||
string $write_type = 'STRING',
|
string $write_type = 'JSON',
|
||||||
?string $db_schema = null
|
?string $db_schema = null
|
||||||
): void {
|
): void {
|
||||||
$data_binary = '';
|
$data_binary = '';
|
||||||
$data_write = '';
|
$data_write = '';
|
||||||
if ($write_type == 'BINARY') {
|
// check if write type is valid, if not fallback to JSON
|
||||||
$data_binary = $this->db->dbEscapeBytea((string)bzcompress(serialize($data)));
|
if (!in_array($write_type, $this->write_types_available)) {
|
||||||
$data_write = 'see bzip compressed data_binary field';
|
$this->log->warning('Write type not in allowed array, fallback to JSON', context:[
|
||||||
|
"write_type" => $write_type,
|
||||||
|
"write_list" => $this->write_types_available,
|
||||||
|
]);
|
||||||
|
$write_type = 'JSON';
|
||||||
}
|
}
|
||||||
if ($write_type == 'STRING') {
|
switch ($write_type) {
|
||||||
$data_binary = '';
|
case 'BINARY':
|
||||||
$data_write = $this->db->dbEscapeString(serialize($data));
|
case 'BZIP':
|
||||||
|
$data_binary = $this->db->dbEscapeBytea((string)bzcompress(serialize($data)));
|
||||||
|
$data_write = 'see bzip compressed data_binary field';
|
||||||
|
break;
|
||||||
|
case 'ZLIB':
|
||||||
|
$data_binary = $this->db->dbEscapeBytea((string)gzcompress(serialize($data)));
|
||||||
|
$data_write = 'see zlib compressed data_binary field';
|
||||||
|
break;
|
||||||
|
case 'STRING':
|
||||||
|
case 'SERIAL':
|
||||||
|
$data_binary = '';
|
||||||
|
$data_write = serialize($data);
|
||||||
|
break;
|
||||||
|
case 'JSON':
|
||||||
|
$data_binary = '';
|
||||||
|
// must be converted to array
|
||||||
|
if (!is_array($data)) {
|
||||||
|
$data = ["data" => $data];
|
||||||
|
}
|
||||||
|
$data_write = Json::jsonConvertArrayTo($data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->log->alert('Invalid type for data compression was set', context:[
|
||||||
|
"write_type" => $write_type
|
||||||
|
]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string $DB_SCHEMA check schema */
|
/** @var string $DB_SCHEMA check schema */
|
||||||
@@ -228,44 +321,62 @@ class Backend
|
|||||||
} elseif (!empty($this->db->dbGetSchema())) {
|
} elseif (!empty($this->db->dbGetSchema())) {
|
||||||
$DB_SCHEMA = $this->db->dbGetSchema();
|
$DB_SCHEMA = $this->db->dbGetSchema();
|
||||||
}
|
}
|
||||||
$q = "INSERT INTO " . $DB_SCHEMA . ".edit_log "
|
$q = <<<SQL
|
||||||
. "(euid, event_date, event, data, data_binary, page, "
|
INSERT INTO {DB_SCHEMA}.edit_log (
|
||||||
. "ip, user_agent, referer, script_name, query_string, server_name, http_host, "
|
euid, event_date, event, data, data_binary, page,
|
||||||
. "http_accept, http_accept_charset, http_accept_encoding, session_id, "
|
ip, user_agent, referer, script_name, query_string, server_name, http_host,
|
||||||
. "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "
|
http_accept, http_accept_charset, http_accept_encoding, session_id,
|
||||||
. "VALUES "
|
action, action_id, action_yes, action_flag, action_menu, action_loaded,
|
||||||
. "(" . $this->db->dbEscapeString(isset($_SESSION['EUID']) && is_numeric($_SESSION['EUID']) ?
|
action_value, action_type, action_error
|
||||||
$_SESSION['EUID'] :
|
) VALUES (
|
||||||
'NULL')
|
$1, NOW(), $2, $3, $4, $5,
|
||||||
. ", "
|
$6, $7, $8, $9, $10, $11, $12,
|
||||||
. "NOW(), "
|
$13, $14, $15, $16,
|
||||||
. "'" . $this->db->dbEscapeString((string)$event) . "', "
|
$17, $18, $19, $20, $21, $22,
|
||||||
. "'" . $data_write . "', "
|
$23, $24, $25
|
||||||
. "'" . $data_binary . "', "
|
)
|
||||||
. "'" . $this->db->dbEscapeString((string)$this->page_name) . "', "
|
SQL;
|
||||||
. "'" . ($_SERVER["REMOTE_ADDR"] ?? '') . "', "
|
$this->db->dbExecParams(
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_USER_AGENT'] ?? '') . "', "
|
str_replace(
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_REFERER'] ?? '') . "', "
|
['{DB_SCHEMA}'],
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['SCRIPT_FILENAME'] ?? '') . "', "
|
[$DB_SCHEMA],
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['QUERY_STRING'] ?? '') . "', "
|
$q
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['SERVER_NAME'] ?? '') . "', "
|
),
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_HOST'] ?? '') . "', "
|
[
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT'] ?? '') . "', "
|
// row 1
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_CHARSET'] ?? '') . "', "
|
isset($_SESSION['EUID']) && is_numeric($_SESSION['EUID']) ?
|
||||||
. "'" . $this->db->dbEscapeString($_SERVER['HTTP_ACCEPT_ENCODING'] ?? '') . "', "
|
$_SESSION['EUID'] : null,
|
||||||
. ($this->session->getSessionId() === false ?
|
(string)$event,
|
||||||
"NULL" :
|
$data_write,
|
||||||
"'" . $this->session->getSessionId() . "'")
|
$data_binary,
|
||||||
. ", "
|
(string)$this->page_name,
|
||||||
. "'" . $this->db->dbEscapeString($this->action) . "', "
|
// row 2
|
||||||
. "'" . $this->db->dbEscapeString($this->action_id) . "', "
|
$_SERVER["REMOTE_ADDR"] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_yes) . "', "
|
$_SERVER['HTTP_USER_AGENT'] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_flag) . "', "
|
$_SERVER['HTTP_REFERER'] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_menu) . "', "
|
$_SERVER['SCRIPT_FILENAME'] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_loaded) . "', "
|
$_SERVER['QUERY_STRING'] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_value) . "', "
|
$_SERVER['SERVER_NAME'] ?? '',
|
||||||
. "'" . $this->db->dbEscapeString($this->action_error) . "')";
|
$_SERVER['HTTP_HOST'] ?? '',
|
||||||
$this->db->dbExec($q, 'NULL');
|
// row 3
|
||||||
|
$_SERVER['HTTP_ACCEPT'] ?? '',
|
||||||
|
$_SERVER['HTTP_ACCEPT_CHARSET'] ?? '',
|
||||||
|
$_SERVER['HTTP_ACCEPT_ENCODING'] ?? '',
|
||||||
|
$this->session->getSessionId() !== false ?
|
||||||
|
$this->session->getSessionId() : null,
|
||||||
|
// row 4
|
||||||
|
$this->action ?? '',
|
||||||
|
$this->action_id ?? '',
|
||||||
|
$this->action_yes ?? '',
|
||||||
|
$this->action_flag ?? '',
|
||||||
|
$this->action_menu ?? '',
|
||||||
|
$this->action_loaded ?? '',
|
||||||
|
$this->action_value ?? '',
|
||||||
|
$this->action_type ?? '',
|
||||||
|
$this->action_error ?? '',
|
||||||
|
],
|
||||||
|
'NULL'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,9 +615,9 @@ class Backend
|
|||||||
string $data,
|
string $data,
|
||||||
string $key_name,
|
string $key_name,
|
||||||
string $key_value,
|
string $key_value,
|
||||||
string $associate = null,
|
?string $associate = null,
|
||||||
string $file = null,
|
?string $file = null,
|
||||||
string $db_schema = null,
|
?string $db_schema = null,
|
||||||
): void {
|
): void {
|
||||||
/** @var string $DB_SCHEMA check schema */
|
/** @var string $DB_SCHEMA check schema */
|
||||||
$DB_SCHEMA = 'public';
|
$DB_SCHEMA = 'public';
|
||||||
@@ -515,16 +626,30 @@ class Backend
|
|||||||
} elseif (!empty($this->db->dbGetSchema())) {
|
} elseif (!empty($this->db->dbGetSchema())) {
|
||||||
$DB_SCHEMA = $this->db->dbGetSchema();
|
$DB_SCHEMA = $this->db->dbGetSchema();
|
||||||
}
|
}
|
||||||
$q = "INSERT INTO " . $DB_SCHEMA . ".live_queue ("
|
$q = <<<SQL
|
||||||
. "queue_key, key_value, key_name, type, target, data, group_key, action, associate, file"
|
INSERT INTO {DB_SCHEMA}.live_queue (
|
||||||
. ") VALUES ("
|
queue_key, key_value, key_name, type,
|
||||||
. "'" . $this->db->dbEscapeString($queue_key) . "', '" . $this->db->dbEscapeString($key_value) . "', "
|
target, data, group_key, action, associate, file
|
||||||
. "'" . $this->db->dbEscapeString($key_name) . "', '" . $this->db->dbEscapeString($type) . "', "
|
) VALUES (
|
||||||
. "'" . $this->db->dbEscapeString($target) . "', '" . $this->db->dbEscapeString($data) . "', "
|
$1, $2, $3, $4,
|
||||||
. "'" . $this->queue_key . "', '" . $this->action . "', "
|
$5, $6, $7, $8, $9, $10
|
||||||
. "'" . $this->db->dbEscapeString((string)$associate) . "', "
|
)
|
||||||
. "'" . $this->db->dbEscapeString((string)$file) . "')";
|
SQL;
|
||||||
$this->db->dbExec($q);
|
// $this->db->dbExec($q);
|
||||||
|
$this->db->dbExecParams(
|
||||||
|
str_replace(
|
||||||
|
['{DB_SCHEMA}'],
|
||||||
|
[$DB_SCHEMA],
|
||||||
|
$q
|
||||||
|
),
|
||||||
|
[
|
||||||
|
$queue_key, $key_value,
|
||||||
|
$key_name, $type,
|
||||||
|
$target, $data,
|
||||||
|
$this->queue_key, $this->action,
|
||||||
|
(string)$associate, (string)$file
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class Basic
|
|||||||
* @deprecated DO NOT USE Class\Basic anymore. Use dedicated logger and sub classes
|
* @deprecated DO NOT USE Class\Basic anymore. Use dedicated logger and sub classes
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\Logging\Logging $log = null,
|
?\CoreLibs\Logging\Logging $log = null,
|
||||||
?string $session_name = null
|
?string $session_name = null
|
||||||
) {
|
) {
|
||||||
trigger_error('Class \CoreLibs\Basic is deprected', E_USER_DEPRECATED);
|
trigger_error('Class \CoreLibs\Basic is deprected', E_USER_DEPRECATED);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class SetVarTypeMain
|
|||||||
*/
|
*/
|
||||||
protected static function makeStrMain(
|
protected static function makeStrMain(
|
||||||
mixed $val,
|
mixed $val,
|
||||||
string $default = null,
|
?string $default = null,
|
||||||
bool $to_null = false
|
bool $to_null = false
|
||||||
): ?string {
|
): ?string {
|
||||||
// int/float/string/bool/null, everything else is ignored
|
// int/float/string/bool/null, everything else is ignored
|
||||||
@@ -113,7 +113,7 @@ class SetVarTypeMain
|
|||||||
*/
|
*/
|
||||||
protected static function makeIntMain(
|
protected static function makeIntMain(
|
||||||
mixed $val,
|
mixed $val,
|
||||||
int $default = null,
|
?int $default = null,
|
||||||
bool $to_null = false
|
bool $to_null = false
|
||||||
): ?int {
|
): ?int {
|
||||||
// if we can filter it to a valid int, we can convert it
|
// if we can filter it to a valid int, we can convert it
|
||||||
@@ -167,7 +167,7 @@ class SetVarTypeMain
|
|||||||
*/
|
*/
|
||||||
protected static function makeFloatMain(
|
protected static function makeFloatMain(
|
||||||
mixed $val,
|
mixed $val,
|
||||||
float $default = null,
|
?float $default = null,
|
||||||
bool $to_null = false
|
bool $to_null = false
|
||||||
): ?float {
|
): ?float {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -16,16 +16,22 @@ class Html
|
|||||||
/**
|
/**
|
||||||
* full wrapper for html entities
|
* full wrapper for html entities
|
||||||
*
|
*
|
||||||
|
* uses default params as: ENT_QUOTES | ENT_HTML5
|
||||||
|
* switches from ENT_HTML401 to ENT_HTML5 as we assume all our pages have <!DOCTYPE html>
|
||||||
|
* removed: ENT_SUBSTITUTE -> wrong characters will be replaced with space
|
||||||
|
* encodes in UTF-8
|
||||||
|
* does not double encode
|
||||||
|
*
|
||||||
* @param mixed $string string to html encode
|
* @param mixed $string string to html encode
|
||||||
|
* @param int $flags [default: ENT_QUOTES | ENT_HTML5]
|
||||||
* @return mixed if string, encoded, else as is (eg null)
|
* @return mixed if string, encoded, else as is (eg null)
|
||||||
*/
|
*/
|
||||||
public static function htmlent(mixed $string): mixed
|
public static function htmlent(mixed $string, int $flags = ENT_QUOTES | ENT_HTML5): mixed
|
||||||
{
|
{
|
||||||
if (is_string($string)) {
|
if (is_string($string)) {
|
||||||
return htmlentities($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
return htmlentities($string, $flags, 'UTF-8', false);
|
||||||
} else {
|
|
||||||
return $string;
|
|
||||||
}
|
}
|
||||||
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,14 +60,10 @@ class Html
|
|||||||
*/
|
*/
|
||||||
public static function checked(array|string $haystack, string $needle, int $type = 0): ?string
|
public static function checked(array|string $haystack, string $needle, int $type = 0): ?string
|
||||||
{
|
{
|
||||||
if (is_array($haystack)) {
|
if (is_array($haystack) && in_array($needle, $haystack)) {
|
||||||
if (in_array($needle, $haystack)) {
|
return $type ? 'checked' : 'selected';
|
||||||
return $type ? 'checked' : 'selected';
|
} elseif (!is_array($haystack) && $haystack == $needle) {
|
||||||
}
|
return $type ? 'checked' : 'selected';
|
||||||
} else {
|
|
||||||
if ($haystack == $needle) {
|
|
||||||
return $type ? 'checked' : 'selected';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
|||||||
* @param string|null $default Default override value
|
* @param string|null $default Default override value
|
||||||
* @return string|null Input value as string or default as string/null
|
* @return string|null Input value as string or default as string/null
|
||||||
*/
|
*/
|
||||||
public static function makeStr(mixed $val, string $default = null): ?string
|
public static function makeStr(mixed $val, ?string $default = null): ?string
|
||||||
{
|
{
|
||||||
return SetVarTypeMain::makeStrMain($val, $default, true);
|
return SetVarTypeMain::makeStrMain($val, $default, true);
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
|||||||
* @param int|null $default Default override value
|
* @param int|null $default Default override value
|
||||||
* @return int|null Input value as int or default as int/null
|
* @return int|null Input value as int or default as int/null
|
||||||
*/
|
*/
|
||||||
public static function makeInt(mixed $val, int $default = null): ?int
|
public static function makeInt(mixed $val, ?int $default = null): ?int
|
||||||
{
|
{
|
||||||
return SetVarTypeMain::makeIntMain($val, $default, true);
|
return SetVarTypeMain::makeIntMain($val, $default, true);
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ class SetVarTypeNull extends Extends\SetVarTypeMain
|
|||||||
* @param float|null $default Default override value
|
* @param float|null $default Default override value
|
||||||
* @return float|null Input value as float or default as float/null
|
* @return float|null Input value as float or default as float/null
|
||||||
*/
|
*/
|
||||||
public static function makeFloat(mixed $val, float $default = null): ?float
|
public static function makeFloat(mixed $val, ?float $default = null): ?float
|
||||||
{
|
{
|
||||||
return SetVarTypeMain::makeFloatMain($val, $default, true);
|
return SetVarTypeMain::makeFloatMain($val, $default, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,18 @@ class Strings
|
|||||||
$path
|
$path
|
||||||
) ?? $path;
|
) ?? $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove UTF8 BOM Byte string from line
|
||||||
|
* Note: this is often found in CSV files exported from Excel at the first row, first element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function stripUTF8BomBytes(string $text): string
|
||||||
|
{
|
||||||
|
return trim($text, pack('H*', 'EFBBBF'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -1324,8 +1324,12 @@ class IO
|
|||||||
// /s for matching new line in . list
|
// /s for matching new line in . list
|
||||||
// [disabled, we don't used ^ or $] /m for multi line match
|
// [disabled, we don't used ^ or $] /m for multi line match
|
||||||
// Matches in 1:, must be array_filtered to remove empty, count with array_unique
|
// Matches in 1:, must be array_filtered to remove empty, count with array_unique
|
||||||
|
$query_split = '[(=,?-]|->|->>|#>|#>>|@>|<@|\?\|\?\&|\|\||#-';
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/(?:\'.*?\')?\s*(?:\?\?|<>|[(=,])\s*(?:\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))/s',
|
'/'
|
||||||
|
. '(?:\'.*?\')?\s*(?:\?\?|<>|' . $query_split . ')\s*'
|
||||||
|
. '(?:\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))'
|
||||||
|
. '/s',
|
||||||
$query,
|
$query,
|
||||||
$match
|
$match
|
||||||
);
|
);
|
||||||
@@ -1892,7 +1896,12 @@ class IO
|
|||||||
$matches = [];
|
$matches = [];
|
||||||
// compare has =, >, < prefix, and gets stripped
|
// compare has =, >, < prefix, and gets stripped
|
||||||
// if the rest is not X.Y format then error
|
// if the rest is not X.Y format then error
|
||||||
preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches);
|
if (!preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches)) {
|
||||||
|
$this->log->error('Could not regex match compare version string', [
|
||||||
|
"compare" => $compare
|
||||||
|
]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$compare = $matches[1];
|
$compare = $matches[1];
|
||||||
$to_master = $matches[2];
|
$to_master = $matches[2];
|
||||||
$to_minor = $matches[3];
|
$to_minor = $matches[3];
|
||||||
@@ -1904,11 +1913,18 @@ class IO
|
|||||||
}
|
}
|
||||||
// db_version can return X.Y.Z
|
// db_version can return X.Y.Z
|
||||||
// we only compare the first two
|
// we only compare the first two
|
||||||
preg_match(
|
if (
|
||||||
"/^(\d{1,})\.(\d{1,})\.?(\d{1,})?/",
|
!preg_match(
|
||||||
$this->dbVersion(),
|
"/^(\d{1,})\.(\d{1,})\.?(\d{1,})?/",
|
||||||
$matches
|
$this->dbVersion(),
|
||||||
);
|
$matches
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$this->log->error('Could not regex match dbVersion string', [
|
||||||
|
"dbVersion" => $this->dbVersion()
|
||||||
|
]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$master = $matches[1];
|
$master = $matches[1];
|
||||||
$minor = $matches[2];
|
$minor = $matches[2];
|
||||||
$version = $master . ($minor < 10 ? '0' : '') . $minor;
|
$version = $master . ($minor < 10 ? '0' : '') . $minor;
|
||||||
@@ -2398,7 +2414,7 @@ class IO
|
|||||||
// flag if we have cache data stored at the moment
|
// flag if we have cache data stored at the moment
|
||||||
'cached' => false,
|
'cached' => false,
|
||||||
// when fetch array or cache read returns false
|
// when fetch array or cache read returns false
|
||||||
// in loop read that means dbReturn retuns false without erro
|
// in loop read that means dbReturn retuns false without error
|
||||||
'finished' => false,
|
'finished' => false,
|
||||||
// read from cache/db (pos == rows)
|
// read from cache/db (pos == rows)
|
||||||
'read_finished' => false,
|
'read_finished' => false,
|
||||||
|
|||||||
@@ -39,9 +39,11 @@ class ConvertPlaceholder
|
|||||||
): array {
|
): array {
|
||||||
$convert_to = strtolower($convert_to);
|
$convert_to = strtolower($convert_to);
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
$query_split = '[(=,?-]|->|->>|#>|#>>|@>|<@|\?\|\?\&|\|\||#-';
|
||||||
$pattern = '/'
|
$pattern = '/'
|
||||||
// prefix string part, must match towards
|
// prefix string part, must match towards
|
||||||
. '(?:\'.*?\')?\s*(?:\?\?|[(=,])\s*'
|
// seperator for ( = , ? - [and json/jsonb in pg doc section 9.15]
|
||||||
|
. '(?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*'
|
||||||
// match for replace part
|
// match for replace part
|
||||||
. '(?:'
|
. '(?:'
|
||||||
// digit -> ignore
|
// digit -> ignore
|
||||||
@@ -96,7 +98,10 @@ class ConvertPlaceholder
|
|||||||
$type = 'named';
|
$type = 'named';
|
||||||
$matches_return = $named_matches;
|
$matches_return = $named_matches;
|
||||||
// only check for :named
|
// only check for :named
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(:\w+))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(:\w+))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
@@ -134,7 +139,10 @@ class ConvertPlaceholder
|
|||||||
// order and data stays the same
|
// order and data stays the same
|
||||||
$params_new = $params;
|
$params_new = $params;
|
||||||
// only check for ?
|
// only check for ?
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(?:(?:\?\?)?\s*(\?{1})))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(?:(?:\?\?)?\s*(\?{1})))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
@@ -163,7 +171,10 @@ class ConvertPlaceholder
|
|||||||
$type = 'numbered';
|
$type = 'numbered';
|
||||||
$matches_return = $numbered_matches;
|
$matches_return = $numbered_matches;
|
||||||
// only check for $n
|
// only check for $n
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
|
|||||||
@@ -116,6 +116,29 @@ class System
|
|||||||
3
|
3
|
||||||
) === 'cli' ? true : false;
|
) === 'cli' ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect all IP addresses
|
||||||
|
* REMOTE_ADDR, HTTP_X_FORWARD_FOR, CLIENT_IP
|
||||||
|
* and retuns them in an array with index of io source
|
||||||
|
* if address source has addresses with "," will add "-array" with these as array block
|
||||||
|
*
|
||||||
|
* @return array<string,string|array<string>>
|
||||||
|
*/
|
||||||
|
public static function getIpAddresses(): array
|
||||||
|
{
|
||||||
|
$ip_addr = [];
|
||||||
|
foreach (['REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP'] as $_ip_source) {
|
||||||
|
if (!empty($_SERVER[$_ip_source])) {
|
||||||
|
$ip_addr[$_ip_source] = $_SERVER[$_ip_source];
|
||||||
|
// same level as ARRAY IF there is a , inside
|
||||||
|
if (strstr($_SERVER[$_ip_source], ',') !== false) {
|
||||||
|
$ip_addr[$_ip_source . '-array'] = explode(',', $_SERVER[$_ip_source]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ip_addr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class CachedFileReader extends \CoreLibs\Language\Core\StringReader
|
|||||||
if (!is_resource($fd)) {
|
if (!is_resource($fd)) {
|
||||||
$this->error = 3; // Cannot read file, probably permissions
|
$this->error = 3; // Cannot read file, probably permissions
|
||||||
} else {
|
} else {
|
||||||
$this->fd_str = fread($fd, filesize($filename) ?: 0) ?: '';
|
$this->fd_str = fread($fd, filesize($filename) ?: 1) ?: '';
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class GetLocale
|
|||||||
$matches
|
$matches
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$lang = ($matches['lang'] ?? 'en')
|
$lang = $matches['lang']
|
||||||
// add country only if set
|
// add country only if set
|
||||||
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
||||||
} else {
|
} else {
|
||||||
@@ -235,7 +235,7 @@ class GetLocale
|
|||||||
$matches
|
$matches
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$lang = ($matches['lang'] ?? 'en')
|
$lang = $matches['lang']
|
||||||
// add country only if set
|
// add country only if set
|
||||||
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
. (!empty($matches['country']) ? '_' . $matches['country'] : '');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,16 +24,20 @@ class ErrorMessage
|
|||||||
|
|
||||||
/** @var bool $log_error global flag to log error level message */
|
/** @var bool $log_error global flag to log error level message */
|
||||||
private bool $log_error = false;
|
private bool $log_error = false;
|
||||||
|
/** @var bool $log_warning global flat to log warning level messages */
|
||||||
|
private bool $log_warning = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init ErrorMessage
|
* init ErrorMessage
|
||||||
*
|
*
|
||||||
* @param \CoreLibs\Logging\Logging $log
|
* @param \CoreLibs\Logging\Logging $log
|
||||||
* @param null|bool $log_error [=null], defaults to false if log is not level debug
|
* @param null|bool $log_error [=null], defaults to false if log is not level debug
|
||||||
|
* @param null|bool $log_warning [=null], defaults to false if log is not level debug
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\Logging\Logging $log,
|
\CoreLibs\Logging\Logging $log,
|
||||||
?bool $log_error = null
|
?bool $log_error = null,
|
||||||
|
?bool $log_warning = null
|
||||||
) {
|
) {
|
||||||
$this->log = $log;
|
$this->log = $log;
|
||||||
// if log default logging is debug then log_error is default set to true
|
// if log default logging is debug then log_error is default set to true
|
||||||
@@ -43,6 +47,13 @@ class ErrorMessage
|
|||||||
$log_error = $log_error ?? false;
|
$log_error = $log_error ?? false;
|
||||||
}
|
}
|
||||||
$this->log_error = $log_error;
|
$this->log_error = $log_error;
|
||||||
|
// if log default logging is debug then log_warning is default set to true
|
||||||
|
if ($this->log->loggingLevelIsDebug() && $log_warning === null) {
|
||||||
|
$log_warning = true;
|
||||||
|
} else {
|
||||||
|
$log_warning = $log_warning ?? false;
|
||||||
|
}
|
||||||
|
$this->log_warning = $log_warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +92,8 @@ class ErrorMessage
|
|||||||
* @param array<mixed> $context Additionl info for abort/crash messages
|
* @param array<mixed> $context Additionl info for abort/crash messages
|
||||||
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
|
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
|
||||||
* else set for this call only
|
* else set for this call only
|
||||||
|
* @param bool|null $log_warning [=null] log level 'warning' to warning, if null use global,
|
||||||
|
* else set for this call only
|
||||||
*/
|
*/
|
||||||
public function setErrorMsg(
|
public function setErrorMsg(
|
||||||
string $error_id,
|
string $error_id,
|
||||||
@@ -93,10 +106,14 @@ class ErrorMessage
|
|||||||
?string $message = null,
|
?string $message = null,
|
||||||
array $context = [],
|
array $context = [],
|
||||||
?bool $log_error = null,
|
?bool $log_error = null,
|
||||||
|
?bool $log_warning = null,
|
||||||
): void {
|
): void {
|
||||||
if ($log_error === null) {
|
if ($log_error === null) {
|
||||||
$log_error = $this->log_error;
|
$log_error = $this->log_error;
|
||||||
}
|
}
|
||||||
|
if ($log_warning === null) {
|
||||||
|
$log_warning = $this->log_warning;
|
||||||
|
}
|
||||||
$original_level = $level;
|
$original_level = $level;
|
||||||
$level = MessageLevel::fromName($level)->name;
|
$level = MessageLevel::fromName($level)->name;
|
||||||
// if not string set, write message string if set, else level/error id
|
// if not string set, write message string if set, else level/error id
|
||||||
@@ -121,6 +138,14 @@ class ErrorMessage
|
|||||||
'level' => $original_level,
|
'level' => $original_level,
|
||||||
], $context));
|
], $context));
|
||||||
break;
|
break;
|
||||||
|
case 'warn':
|
||||||
|
if ($log_warning) {
|
||||||
|
$this->log->warning($message ?? $str, array_merge([
|
||||||
|
'id' => $error_id,
|
||||||
|
'level' => $original_level,
|
||||||
|
], $context));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
if ($log_error) {
|
if ($log_error) {
|
||||||
$this->log->error($message ?? $str, array_merge([
|
$this->log->error($message ?? $str, array_merge([
|
||||||
@@ -169,6 +194,8 @@ class ErrorMessage
|
|||||||
* @param array<mixed> $context Additionl info for abort/crash messages
|
* @param array<mixed> $context Additionl info for abort/crash messages
|
||||||
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
|
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
|
||||||
* else set for this call only
|
* else set for this call only
|
||||||
|
* @param bool|null $log_warning [=null] log level 'warning' to warning, if null use global,
|
||||||
|
* else set for this call only
|
||||||
*/
|
*/
|
||||||
public function setMessage(
|
public function setMessage(
|
||||||
string $level,
|
string $level,
|
||||||
@@ -181,6 +208,7 @@ class ErrorMessage
|
|||||||
?string $message = null,
|
?string $message = null,
|
||||||
array $context = [],
|
array $context = [],
|
||||||
?bool $log_error = null,
|
?bool $log_error = null,
|
||||||
|
?bool $log_warning = null,
|
||||||
): void {
|
): void {
|
||||||
$this->setErrorMsg(
|
$this->setErrorMsg(
|
||||||
$error_id ?? '',
|
$error_id ?? '',
|
||||||
@@ -192,7 +220,8 @@ class ErrorMessage
|
|||||||
$jump_target,
|
$jump_target,
|
||||||
$message,
|
$message,
|
||||||
$context,
|
$context,
|
||||||
$log_error
|
$log_error,
|
||||||
|
$log_warning
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +343,27 @@ class ErrorMessage
|
|||||||
{
|
{
|
||||||
return $this->log_error;
|
return $this->log_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the log warning flag
|
||||||
|
*
|
||||||
|
* @param bool $flag True to log level warning too, False for do not (Default)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setFlagLogWarning(bool $flag): void
|
||||||
|
{
|
||||||
|
$this->log_warning = $flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current log error flag
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getFlagLogWarning(): bool
|
||||||
|
{
|
||||||
|
return $this->log_warning;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace CoreLibs\Logging\Logger;
|
|||||||
enum MessageLevel: int
|
enum MessageLevel: int
|
||||||
{
|
{
|
||||||
case ok = 100;
|
case ok = 100;
|
||||||
|
case success = 150; // special for file uploads
|
||||||
case info = 200;
|
case info = 200;
|
||||||
case notice = 250;
|
case notice = 250;
|
||||||
case warn = 300;
|
case warn = 300;
|
||||||
@@ -30,6 +31,7 @@ enum MessageLevel: int
|
|||||||
{
|
{
|
||||||
return match (strtolower($name)) {
|
return match (strtolower($name)) {
|
||||||
'ok' => self::ok,
|
'ok' => self::ok,
|
||||||
|
'success' => self::success,
|
||||||
'info' => self::info,
|
'info' => self::info,
|
||||||
'notice' => self::notice,
|
'notice' => self::notice,
|
||||||
'warn', 'warning' => self::warn,
|
'warn', 'warning' => self::warn,
|
||||||
|
|||||||
@@ -194,13 +194,13 @@ class Elements
|
|||||||
"/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/",
|
"/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/",
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
return self::createEmail(
|
return self::createEmail(
|
||||||
$matches[1] ?? '',
|
$matches[1],
|
||||||
$matches[2] ?? '',
|
$matches[2],
|
||||||
$matches[3] ?? '',
|
$matches[3],
|
||||||
$matches[4] ?? '',
|
$matches[4],
|
||||||
$matches[5] ?? '',
|
$matches[5],
|
||||||
$matches[7] ?? '',
|
$matches[7] ?? '',
|
||||||
$matches[9] ?? ''
|
$matches[9] ?? '',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
$output
|
$output
|
||||||
|
|||||||
@@ -21,66 +21,82 @@ use SodiumException;
|
|||||||
|
|
||||||
class SymmetricEncryption
|
class SymmetricEncryption
|
||||||
{
|
{
|
||||||
|
/** @var SymmetricEncryption self instance */
|
||||||
|
private static SymmetricEncryption $instance;
|
||||||
|
|
||||||
|
/** @var string bin hex key */
|
||||||
|
private string $key = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* init class
|
||||||
|
* if key not passed, key must be set with createKey
|
||||||
|
*
|
||||||
|
* @param string|null|null $key
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
string|null $key = null
|
||||||
|
) {
|
||||||
|
if ($key != null) {
|
||||||
|
$this->setKey($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton self object.
|
||||||
|
* For function wrapper use
|
||||||
|
*
|
||||||
|
* @return SymmetricEncryption object
|
||||||
|
*/
|
||||||
|
public static function getInstance(string|null $key = null): self
|
||||||
|
{
|
||||||
|
if (empty(self::$instance)) {
|
||||||
|
self::$instance = new self($key);
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************
|
||||||
|
* MARK: PRIVATE
|
||||||
|
* *************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create key and check validity
|
* create key and check validity
|
||||||
*
|
*
|
||||||
* @param string $key The key from which the binary key will be created
|
* @param string $key The key from which the binary key will be created
|
||||||
* @return string Binary key string
|
* @return string Binary key string
|
||||||
*/
|
*/
|
||||||
public static function createKey(string $key): string
|
private function createKey(string $key): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$key = CreateKey::hex2bin($key);
|
$key = CreateKey::hex2bin($key);
|
||||||
} catch (SodiumException $e) {
|
} catch (SodiumException $e) {
|
||||||
throw new \UnexpectedValueException('Invalid hex key');
|
throw new \UnexpectedValueException('Invalid hex key: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
if (mb_strlen($key, '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
|
if (mb_strlen($key, '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
|
||||||
throw new \RangeException(
|
throw new \RangeException(
|
||||||
'Key is not the correct size (must be '
|
'Key is not the correct size (must be '
|
||||||
. 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes long).'
|
. SODIUM_CRYPTO_SECRETBOX_KEYBYTES . ' bytes long).'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt a message
|
* Decryption call
|
||||||
*
|
*
|
||||||
* @param string $message Message to encrypt
|
* @param string $encrypted Text to decrypt
|
||||||
* @param string $key Encryption key (as hex string)
|
* @param ?string $key Mandatory encryption key, will throw exception if empty
|
||||||
* @return string
|
* @return string Plain text
|
||||||
* @throws \Exception
|
|
||||||
* @throws \RangeException
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
public static function encrypt(string $message, string $key): string
|
private function decryptData(string $encrypted, ?string $key): string
|
||||||
{
|
{
|
||||||
$key = self::createKey($key);
|
if (empty($key)) {
|
||||||
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
throw new \UnexpectedValueException('Key not set');
|
||||||
|
}
|
||||||
$cipher = base64_encode(
|
$key = $this->createKey($key);
|
||||||
$nonce
|
|
||||||
. sodium_crypto_secretbox(
|
|
||||||
$message,
|
|
||||||
$nonce,
|
|
||||||
$key
|
|
||||||
)
|
|
||||||
);
|
|
||||||
sodium_memzero($message);
|
|
||||||
sodium_memzero($key);
|
|
||||||
return $cipher;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrypt a message
|
|
||||||
*
|
|
||||||
* @param string $encrypted Message encrypted with safeEncrypt()
|
|
||||||
* @param string $key Encryption key (as hex string)
|
|
||||||
* @return string
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public static function decrypt(string $encrypted, string $key): string
|
|
||||||
{
|
|
||||||
$key = self::createKey($key);
|
|
||||||
$decoded = base64_decode($encrypted);
|
$decoded = base64_decode($encrypted);
|
||||||
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
||||||
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||||
@@ -93,7 +109,7 @@ class SymmetricEncryption
|
|||||||
$key
|
$key
|
||||||
);
|
);
|
||||||
} catch (SodiumException $e) {
|
} catch (SodiumException $e) {
|
||||||
throw new \UnexpectedValueException('Invalid ciphertext (too short)');
|
throw new \UnexpectedValueException('Decipher message failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
if (!is_string($plain)) {
|
if (!is_string($plain)) {
|
||||||
throw new \UnexpectedValueException('Invalid Key');
|
throw new \UnexpectedValueException('Invalid Key');
|
||||||
@@ -102,6 +118,117 @@ class SymmetricEncryption
|
|||||||
sodium_memzero($key);
|
sodium_memzero($key);
|
||||||
return $plain;
|
return $plain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @param ?string $key Mandatory encryption key, will throw exception if empty
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
private function encryptData(string $message, ?string $key): string
|
||||||
|
{
|
||||||
|
if (empty($this->key) || $key === null) {
|
||||||
|
throw new \UnexpectedValueException('Key not set');
|
||||||
|
}
|
||||||
|
$key = $this->createKey($key);
|
||||||
|
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||||
|
try {
|
||||||
|
$cipher = base64_encode(
|
||||||
|
$nonce
|
||||||
|
. sodium_crypto_secretbox(
|
||||||
|
$message,
|
||||||
|
$nonce,
|
||||||
|
$key,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (SodiumException $e) {
|
||||||
|
throw new \UnexpectedValueException("Create encrypted message failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
sodium_memzero($message);
|
||||||
|
sodium_memzero($key);
|
||||||
|
return $cipher;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************
|
||||||
|
* MARK: PUBLIC
|
||||||
|
* *************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set a new key for encryption
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setKey(string $key)
|
||||||
|
{
|
||||||
|
if (empty($key)) {
|
||||||
|
throw new \UnexpectedValueException('Key cannot be empty');
|
||||||
|
}
|
||||||
|
$this->key = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt a message
|
||||||
|
* static version
|
||||||
|
*
|
||||||
|
* @param string $encrypted Message encrypted with safeEncrypt()
|
||||||
|
* @param string $key Encryption key (as hex string)
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
*/
|
||||||
|
public static function decryptKey(string $encrypted, string $key): string
|
||||||
|
{
|
||||||
|
return self::getInstance()->decryptData($encrypted, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt a message
|
||||||
|
*
|
||||||
|
* @param string $encrypted Message encrypted with safeEncrypt()
|
||||||
|
* @return string
|
||||||
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
*/
|
||||||
|
public function decrypt(string $encrypted): string
|
||||||
|
{
|
||||||
|
return $this->decryptData($encrypted, $this->key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
* static version
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @param string $key Encryption key (as hex string)
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
public static function encryptKey(string $message, string $key): string
|
||||||
|
{
|
||||||
|
return self::getInstance()->encryptData($message, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
public function encrypt(string $message): string
|
||||||
|
{
|
||||||
|
return $this->encryptData($message, $this->key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use CoreLibs\Template\HtmlBuilder\General\HtmlBuilderExcpetion;
|
|||||||
class Block
|
class Block
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Create Element
|
||||||
*
|
*
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param string $id
|
* @param string $id
|
||||||
@@ -86,7 +86,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Add multiple elements to the base element
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $base
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $base
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} ...$attach
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} ...$attach
|
||||||
@@ -101,7 +101,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Add multiple sub elements to the base element
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $sub
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $sub
|
||||||
@@ -117,7 +117,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Remove all sub element entries
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
||||||
* @return array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}
|
* @return array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}
|
||||||
@@ -131,7 +131,7 @@ class Block
|
|||||||
// CSS Elements
|
// CSS Elements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Add css entry to the css entries
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
||||||
* @param string ...$css
|
* @param string ...$css
|
||||||
@@ -144,7 +144,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Remove a css entry entry from the css array
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $element
|
||||||
* @param string ...$css
|
* @param string ...$css
|
||||||
@@ -157,7 +157,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Switch CSS entries
|
||||||
* scssel (switch) is not supported
|
* scssel (switch) is not supported
|
||||||
* use rcssel -> acssel
|
* use rcssel -> acssel
|
||||||
*
|
*
|
||||||
@@ -175,7 +175,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Build HTML from the content tree
|
||||||
* alias phfo
|
* alias phfo
|
||||||
*
|
*
|
||||||
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $tree
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $tree
|
||||||
@@ -231,7 +231,19 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Alias for phfo
|
||||||
|
*
|
||||||
|
* @param array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>} $tree
|
||||||
|
* @param bool $add_nl [default=false]
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function phfo(array $tree, bool $add_nl = false): string
|
||||||
|
{
|
||||||
|
return self::buildHtml($tree, $add_nl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build HTML elements from an array of elements
|
||||||
* alias phfa
|
* alias phfa
|
||||||
*
|
*
|
||||||
* @param array<array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}> $list
|
* @param array<array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}> $list
|
||||||
@@ -248,8 +260,7 @@ class Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* alias for buildHtmlFromList
|
||||||
* wrapper for buildHtmlFromList
|
|
||||||
*
|
*
|
||||||
* @param array<array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}> $list array of Elements to build string from
|
* @param array<array{tag:string,id:string,name:string,content:string,css:array<string>,options:array<string,string>,sub:array<mixed>}> $list array of Elements to build string from
|
||||||
* @param bool $add_nl [default=false] Optional output string line break
|
* @param bool $add_nl [default=false] Optional output string line break
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ class Element
|
|||||||
* @param bool $add_nl [default=false] Optional output string line breaks
|
* @param bool $add_nl [default=false] Optional output string line breaks
|
||||||
* @return string HTML as string
|
* @return string HTML as string
|
||||||
*/
|
*/
|
||||||
public function buildHtml(Element $tree = null, bool $add_nl = false): string
|
public function buildHtml(?Element $tree = null, bool $add_nl = false): string
|
||||||
{
|
{
|
||||||
// print "D01: " . microtime(true) . "<br>";
|
// print "D01: " . microtime(true) . "<br>";
|
||||||
if ($tree === null) {
|
if ($tree === null) {
|
||||||
@@ -533,7 +533,7 @@ class Element
|
|||||||
* @return string build html as string
|
* @return string build html as string
|
||||||
* @deprecated Do not use, use Element->buildHtml() instead
|
* @deprecated Do not use, use Element->buildHtml() instead
|
||||||
*/
|
*/
|
||||||
public static function printHtmlFromObject(Element $tree = null, bool $add_nl = false): string
|
public static function printHtmlFromObject(?Element $tree = null, bool $add_nl = false): string
|
||||||
{
|
{
|
||||||
// nothing ->bad
|
// nothing ->bad
|
||||||
if ($tree === null) {
|
if ($tree === null) {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class SmartyExtend extends \Smarty
|
|||||||
// call basic smarty
|
// call basic smarty
|
||||||
// or Smarty::__construct();
|
// or Smarty::__construct();
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// iinit lang
|
// init lang
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
// parse and read, legacy stuff
|
// parse and read, legacy stuff
|
||||||
$locale = $this->l10n->getLocaleAsArray();
|
$locale = $this->l10n->getLocaleAsArray();
|
||||||
@@ -203,7 +203,8 @@ class SmartyExtend extends \Smarty
|
|||||||
_bind_textdomain_codeset($this->domain, $this->encoding);
|
_bind_textdomain_codeset($this->domain, $this->encoding);
|
||||||
|
|
||||||
// register smarty variable
|
// register smarty variable
|
||||||
$this->registerPlugin('modifier', 'getvar', [&$this, 'getTemplateVars']);
|
// $this->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
|
||||||
|
$this->registerPlugin(self::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
|
||||||
|
|
||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
|
|
||||||
|
|||||||
14
www/vendor/composer/installed.json
vendored
14
www/vendor/composer/installed.json
vendored
@@ -35,17 +35,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gullevek/dotenv",
|
"name": "gullevek/dotenv",
|
||||||
"version": "v2.0.8",
|
"version": "v2.1.0",
|
||||||
"version_normalized": "2.0.8.0",
|
"version_normalized": "2.1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/gullevek/dotEnv.git",
|
"url": "https://github.com/gullevek/dotEnv.git",
|
||||||
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e"
|
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
|
"url": "https://api.github.com/repos/gullevek/dotEnv/zipball/b9feacaded4e48effff9da7d1173752aef3dc27f",
|
||||||
"reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e",
|
"reference": "b9feacaded4e48effff9da7d1173752aef3dc27f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
"phpstan/phpstan": "^1.10",
|
"phpstan/phpstan": "^1.10",
|
||||||
"phpunit/phpunit": "^9"
|
"phpunit/phpunit": "^9"
|
||||||
},
|
},
|
||||||
"time": "2023-03-03T00:32:02+00:00",
|
"time": "2024-08-21T02:41:15+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/gullevek/dotEnv/issues",
|
"issues": "https://github.com/gullevek/dotEnv/issues",
|
||||||
"source": "https://github.com/gullevek/dotEnv/tree/v2.0.8"
|
"source": "https://github.com/gullevek/dotEnv/tree/v2.1.0"
|
||||||
},
|
},
|
||||||
"install-path": "../gullevek/dotenv"
|
"install-path": "../gullevek/dotenv"
|
||||||
},
|
},
|
||||||
|
|||||||
6
www/vendor/composer/installed.php
vendored
6
www/vendor/composer/installed.php
vendored
@@ -29,9 +29,9 @@
|
|||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'gullevek/dotenv' => array(
|
'gullevek/dotenv' => array(
|
||||||
'pretty_version' => 'v2.0.8',
|
'pretty_version' => 'v2.1.0',
|
||||||
'version' => '2.0.8.0',
|
'version' => '2.1.0.0',
|
||||||
'reference' => 'e29f9fcd8853a09bb89b0eb8ee555b754ecee36e',
|
'reference' => 'b9feacaded4e48effff9da7d1173752aef3dc27f',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../gullevek/dotenv',
|
'install_path' => __DIR__ . '/../gullevek/dotenv',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|||||||
23
www/vendor/gullevek/dotenv/Readme.md
vendored
23
www/vendor/gullevek/dotenv/Readme.md
vendored
@@ -61,6 +61,29 @@ DOUBLE="I will be used"
|
|||||||
DOUBLE="This will be ignored"
|
DOUBLE="This will be ignored"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A prefix name can be set with `[PrefixName]`. Tne name rules are like for variables, but spaces
|
||||||
|
are allowed, but will be converted to "_".
|
||||||
|
The prefix is valid from the time set until the next prefix block appears or the file ends.
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
```ini
|
||||||
|
FOO="bar"
|
||||||
|
FOOBAR="bar bar"
|
||||||
|
[SecitonA]
|
||||||
|
FOO="other bar"
|
||||||
|
FOOBAR="other bar bar"
|
||||||
|
```
|
||||||
|
|
||||||
|
Will have environmen variables as
|
||||||
|
|
||||||
|
```php
|
||||||
|
$_ENV["FOO"];
|
||||||
|
$_ENV["FOOBAR"];
|
||||||
|
$_ENV["SecitonA.FOO"];
|
||||||
|
$_ENV["SecitonA.FOOBAR"];
|
||||||
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### Phan
|
### Phan
|
||||||
|
|||||||
13
www/vendor/gullevek/dotenv/src/DotEnv.php
vendored
13
www/vendor/gullevek/dotenv/src/DotEnv.php
vendored
@@ -22,6 +22,9 @@ class DotEnv
|
|||||||
* if there are two variables with the same name only the first is used
|
* if there are two variables with the same name only the first is used
|
||||||
* variables are case sensitive
|
* variables are case sensitive
|
||||||
*
|
*
|
||||||
|
* [] Grouping Block Name as prefix until next or end if set,
|
||||||
|
* space replaced by _, all other var rules apply
|
||||||
|
*
|
||||||
* @param string $path Folder to file, default is __DIR__
|
* @param string $path Folder to file, default is __DIR__
|
||||||
* @param string $env_file What file to load, default is .env
|
* @param string $env_file What file to load, default is .env
|
||||||
* @return int -1 other error
|
* @return int -1 other error
|
||||||
@@ -56,10 +59,14 @@ class DotEnv
|
|||||||
$status = 1;
|
$status = 1;
|
||||||
$block = false;
|
$block = false;
|
||||||
$var = '';
|
$var = '';
|
||||||
|
$prefix_name = '';
|
||||||
while ($line = fgets($fp)) {
|
while ($line = fgets($fp)) {
|
||||||
// main match for variable = value part
|
// [] block must be a single line, or it will be ignored
|
||||||
if (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
|
if (preg_match("/^\s*\[([\w_.\s]+)\]/", $line, $matches)) {
|
||||||
$var = $matches[1];
|
$prefix_name = preg_replace("/\s+/", "_", $matches[1]) . ".";
|
||||||
|
} elseif (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
|
||||||
|
// main match for variable = value part
|
||||||
|
$var = $prefix_name . $matches[1];
|
||||||
$value = $matches[2];
|
$value = $matches[2];
|
||||||
$quotes = $matches[3];
|
$quotes = $matches[3];
|
||||||
// write only if env is not set yet, and write only the first time
|
// write only if env is not set yet, and write only the first time
|
||||||
|
|||||||
Reference in New Issue
Block a user