Compare commits

...

12 Commits

Author SHA1 Message Date
Clemens Schwaighofer
06c2ea5e0d Admin\Backend: make sure we do not access unset ->action vars 2024-10-16 12:34:48 +09:00
Clemens Schwaighofer
2e9239ec23 Ingore node_modules/ folder 2024-10-16 12:18:51 +09:00
Clemens Schwaighofer
0c89840dba Admin\Backend move _POST action read to sub function and trigger not auto loading it
On default it still auto loads the _POST vars for backwards compatible, but add a load class
flag to ignore it "init_action_vars"

also add a get vor tha "acl" array adbGetAcl()
2024-10-16 12:15:19 +09:00
Clemens Schwaighofer
db144493f3 Message system: allow warning level to be logged
Like error messages, they are written to the log if debug is on or the
flag is explicit set
2024-09-24 15:10:53 +09:00
Clemens Schwaighofer
5cec54d508 Add "Success" to message logging levels, fixes for PHP 8.4, other preg_match fixes
The Logger/MessageLevel gets "success" as level 110 to something a bit
heigher than "ok" which is the general "OK" for anything ending without
an error. The "success" is currently only used in file uploads with the
java script ajax file uploader

Fix any "type $var = null" with correctly "?type $var = null" for PHP 8.4 (phphan)

Fix preg match no return catches for DB IO compare version and for language
look up.
2024-09-20 13:33:19 +09:00
Clemens Schwaighofer
8e60c992f1 Fixes phan/phpstan 2024-09-03 12:06:01 +09:00
Clemens Schwaighofer
1b5437b675 Add testing for new added bom utf8 replace 2024-09-03 11:58:36 +09:00
Clemens Schwaighofer
ef80cba561 Add new functions: get IPs, strip UTF8 BOM from text, text updates
Add the following new static methods

Convert\Strings::stripUTF8BomBytes: removes the UTF8 BOM bytes from the beginning of a line
Used for CSV files created in Excel for the first header entry (line 0/row 0)

Get\Systen::getIpAddresses: gets all IP addresses for the the current access user
and returns an array

Moved the frontend folder detection from the first load config to the config.path.php

Cleaned up the translations JS scripts
2024-09-03 09:49:01 +09:00
Clemens Schwaighofer
2d71e760e8 Composer update 2024-08-21 11:45:17 +09:00
Clemens Schwaighofer
a8d07634ff Add soba.egplusww.jp as local development host, jshint esversion update to 11 2024-08-07 13:41:09 +09:00
Clemens Schwaighofer
aa2b60973e HTML::htmlent and HTML::checked updates
Changed Params form ENT_COMPAT | ENT_HTML401 to ENT_QUOTES | ENT_HTML5
Flags can be overwritten on call

Logic clean up for return flow

HTML::checked gets logic updated with less nested ifs
2024-08-05 13:24:37 +09:00
Clemens Schwaighofer
554dd5f73c Fix not closed <head> block in all admin test files 2024-08-05 12:53:48 +09:00
89 changed files with 539 additions and 225 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.libs .libs
node_modules/

View File

@@ -1,9 +1,9 @@
<?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.10.0" location="./tools/phpcbf" copy="false"/> <phar name="phpcbf" version="^3.7.2" installed="3.10.3" location="./tools/phpcbf" copy="false"/>
<phar name="phpcs" version="^3.7.2" installed="3.10.0" 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.11.1" 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.24.0" location="./tools/psalm" copy="false"/> <phar name="psalm" version="^5.15.0" installed="5.24.0" location="./tools/psalm" copy="false"/>
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/> <phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>

View File

@@ -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__

View File

@@ -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;

View File

@@ -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__

View File

@@ -0,0 +1 @@
Asset Type,Epic,File Name
1 Asset Type Epic File Name

View File

@@ -0,0 +1 @@
Asset Type,Epic,File Name
1 Asset Type Epic File Name

View File

@@ -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__

View File

@@ -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,

View File

@@ -1 +1 @@
/home/clemens/.phive/phars/phpcbf-3.10.0.phar /home/clemens/.phive/phars/phpcbf-3.10.3.phar

View File

@@ -1 +1 @@
/home/clemens/.phive/phars/phpcs-3.10.0.phar /home/clemens/.phive/phars/phpcs-3.10.3.phar

View File

@@ -1 +1 @@
/home/clemens/.phive/phars/phpstan-1.11.1.phar /home/clemens/.phive/phars/phpstan-1.12.4.phar

View File

@@ -1 +1 @@
/home/clemens/.phive/phars/phpunit-9.6.19.phar /home/clemens/.phive/phars/phpunit-9.6.21.phar

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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]', '==========================================>');

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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(

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>";

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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>';

View File

@@ -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)

View File

@@ -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>';

View File

@@ -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
View File

@@ -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",

View File

@@ -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,

View File

@@ -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 = [

View File

@@ -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;

View File

@@ -117,18 +117,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 +153,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,7 +172,7 @@ 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);
} }
} }
@@ -195,6 +197,29 @@ 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
* *
@@ -257,14 +282,14 @@ class Backend
"NULL" : "NULL" :
"'" . $this->session->getSessionId() . "'") "'" . $this->session->getSessionId() . "'")
. ", " . ", "
. "'" . $this->db->dbEscapeString($this->action) . "', " . "'" . $this->db->dbEscapeString($this->action ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_id) . "', " . "'" . $this->db->dbEscapeString($this->action_id ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_yes) . "', " . "'" . $this->db->dbEscapeString($this->action_yes ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_flag) . "', " . "'" . $this->db->dbEscapeString($this->action_flag ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_menu) . "', " . "'" . $this->db->dbEscapeString($this->action_menu ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_loaded) . "', " . "'" . $this->db->dbEscapeString($this->action_loaded ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_value) . "', " . "'" . $this->db->dbEscapeString($this->action_value ?? '') . "', "
. "'" . $this->db->dbEscapeString($this->action_error) . "')"; . "'" . $this->db->dbEscapeString($this->action_error ?? '') . "')";
$this->db->dbExec($q, 'NULL'); $this->db->dbExec($q, 'NULL');
} }
@@ -504,9 +529,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';

View 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);

View File

@@ -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 (

View File

@@ -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;
} }

View File

@@ -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);
} }

View File

@@ -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__

View File

@@ -1896,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];
@@ -1908,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;
@@ -2402,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,

View File

@@ -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__

View File

@@ -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 {

View File

@@ -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__

View File

@@ -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,

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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"
}, },

View File

@@ -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(),

View File

@@ -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

View File

@@ -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