Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f9559fbb | ||
|
|
770d6f30a4 | ||
|
|
f94f6cbe87 | ||
|
|
9b69390fa2 | ||
|
|
0524d8ac1b | ||
|
|
e933022671 | ||
|
|
c549d34e65 | ||
|
|
f4ff31721b | ||
|
|
21ac91d2e6 | ||
|
|
2d98d26d0b | ||
|
|
3fda1bef60 | ||
|
|
4f1104c36e | ||
|
|
db1007ef12 |
@@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phive xmlns="https://phar.io/phive">
|
<phive xmlns="https://phar.io/phive">
|
||||||
<phar name="phpunit" version="^9.6" installed="9.6.17" location="./tools/phpunit" copy="false"/>
|
<phar name="phpunit" version="^9.6" installed="9.6.19" location="./tools/phpunit" copy="false"/>
|
||||||
<phar name="phpcbf" version="^3.7.2" installed="3.9.0" location="./tools/phpcbf" copy="false"/>
|
<phar name="phpcbf" version="^3.7.2" installed="3.10.0" location="./tools/phpcbf" copy="false"/>
|
||||||
<phar name="phpcs" version="^3.7.2" installed="3.9.0" location="./tools/phpcs" copy="false"/>
|
<phar name="phpcs" version="^3.7.2" installed="3.10.0" location="./tools/phpcs" copy="false"/>
|
||||||
<phar name="phpstan" version="^1.10.37" installed="1.10.59" location="./tools/phpstan" copy="false"/>
|
<phar name="phpstan" version="^1.10.37" installed="1.11.1" 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.22.2" location="./tools/psalm" copy="false"/>
|
<phar name="psalm" version="^5.15.0" installed="5.24.0" location="./tools/psalm" copy="false"/>
|
||||||
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
<phar name="phpdox" version="^0.12.0" installed="0.12.0" location="./tools/phpdox" copy="false"/>
|
||||||
<phar name="phpdocumentor" version="^3.4.2" installed="3.4.3" location="./tools/phpDocumentor" copy="false"/>
|
<phar name="phpdocumentor" version="^3.4.2" installed="3.4.3" location="./tools/phpDocumentor" copy="false"/>
|
||||||
<phar name="php-cs-fixer" version="^3.34.1" installed="3.51.0" location="./tools/php-cs-fixer" copy="false"/>
|
<phar name="php-cs-fixer" version="^3.34.1" installed="3.57.2" location="./tools/php-cs-fixer" copy="false"/>
|
||||||
</phive>
|
</phive>
|
||||||
|
|||||||
2
.shellcheckrc
Normal file
2
.shellcheckrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
shell=bash
|
||||||
|
external-sources=true
|
||||||
@@ -28,7 +28,7 @@ if [ "${target}" == '' ]; then
|
|||||||
# default is admin
|
# default is admin
|
||||||
TEXTDOMAIN=admin;
|
TEXTDOMAIN=admin;
|
||||||
fi;
|
fi;
|
||||||
js_folder="layout/${TEXTDOMAIN}/javascript/";
|
js_folder="${TEXTDOMAIN}/layout/javascript/";
|
||||||
|
|
||||||
error=0;
|
error=0;
|
||||||
# this checks if the TEXTDOMAIN target actually exists
|
# this checks if the TEXTDOMAIN target actually exists
|
||||||
|
|||||||
@@ -12,23 +12,25 @@ if [ "${1}" = "t" ] || [ "${2}" = "t" ]; then
|
|||||||
opt_testdox="--testdox";
|
opt_testdox="--testdox";
|
||||||
fi;
|
fi;
|
||||||
php_bin="";
|
php_bin="";
|
||||||
if [ ! -z "${1}" ]; then
|
if [ -n "${1}" ]; then
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
||||||
|
"8.3") php_bin="/usr/bin/php8.4 "; ;;
|
||||||
*) echo "Not support PHP: ${1}"; exit; ;;
|
*) echo "Not support PHP: ${1}"; exit; ;;
|
||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
if [ ! -z "${2}" ] && [ -z "${php_bin}" ]; then
|
if [ -n "${2}" ] && [ -z "${php_bin}" ]; then
|
||||||
case "${2}" in
|
case "${2}" in
|
||||||
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
# "7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
# "7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
# "8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
# "8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
"8.2") php_bin="/usr/bin/php8.2 "; ;;
|
||||||
|
"8.3") php_bin="/usr/bin/php8.3 "; ;;
|
||||||
*) echo "Not support PHP: ${1}"; exit; ;;
|
*) echo "Not support PHP: ${1}"; exit; ;;
|
||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
@@ -33,15 +33,14 @@ final class CoreLibsConvertMimeEncodeTest extends TestCase
|
|||||||
'The quick brown fox jumps over the lazy sheep that sleeps in the ravine '
|
'The quick brown fox jumps over the lazy sheep that sleeps in the ravine '
|
||||||
. 'and has no idea what is going on here',
|
. 'and has no idea what is going on here',
|
||||||
'UTF-8',
|
'UTF-8',
|
||||||
'The quick brown fox jumps over the lazy sheep that sleeps in the ravine '
|
"The quick brown fox jumps over the lazy sheep that sleeps in the ravine and\r\n"
|
||||||
. 'and has no idea what is going on here'
|
. ' has no idea what is going on here'
|
||||||
],
|
],
|
||||||
'standard with special chars UTF-8' => [
|
'standard with special chars UTF-8' => [
|
||||||
'This is ümläßtと漢字もカタカナ!!^$%&',
|
'This is ümläßtと漢字もカタカナ!!^$%&',
|
||||||
'UTF-8',
|
'UTF-8',
|
||||||
'This is =?UTF-8?B?w7xtbMOkw59044Go5ryi5a2X44KC44Kr44K/44Kr44OK77yBIV4k?='
|
"This is =?UTF-8?B?w7xtbMOkw59044Go5ryi5a2X44KC44Kr44K/44Kr44OK77yBIV4k?=\r\n"
|
||||||
. "\r\n"
|
. ' =?UTF-8?B?JSY=?='
|
||||||
. ' =?UTF-8?B?JQ==?=&'
|
|
||||||
],
|
],
|
||||||
'35 chars and space at the end UTF-8' => [
|
'35 chars and space at the end UTF-8' => [
|
||||||
'12345678901234567890123456789012345 '
|
'12345678901234567890123456789012345 '
|
||||||
@@ -62,9 +61,8 @@ final class CoreLibsConvertMimeEncodeTest extends TestCase
|
|||||||
. 'is there a space?',
|
. 'is there a space?',
|
||||||
'UTF-8',
|
'UTF-8',
|
||||||
"=?UTF-8?B?44Kr44K/44Kr44OK44Kr44K/44Kr44OK44GL44Gq44Kr44K/44Kr44OK44Kr?=\r\n"
|
"=?UTF-8?B?44Kr44K/44Kr44OK44Kr44K/44Kr44OK44GL44Gq44Kr44K/44Kr44OK44Kr?=\r\n"
|
||||||
. " =?UTF-8?B?44K/44Kr44OK?=\r\n"
|
. " =?UTF-8?B?44K/44Kr44OK44GL44Gq44Kr44K/44Kr44OK44Kr44K/44Kr44OK44GL44Gq?=\r\n"
|
||||||
. " =?UTF-8?B?44GL44Gq44Kr44K/44Kr44OK44Kr44K/44Kr44OK44GL44Gq44Kr44K/44Kr?=\r\n"
|
. " =?UTF-8?B?44Kr44K/44Kr44OK44Kr44K/IGlzIHRoZXJlIGEgc3BhY2U/?="
|
||||||
. " =?UTF-8?B?44OK44Kr44K/?= is there a =?UTF-8?B?c3BhY2U/?="
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -85,16 +83,28 @@ final class CoreLibsConvertMimeEncodeTest extends TestCase
|
|||||||
// print "MIME: -" . $encoded . "-\n";
|
// print "MIME: -" . $encoded . "-\n";
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$encoded
|
$encoded,
|
||||||
|
"__mbMimeEncode"
|
||||||
);
|
);
|
||||||
$decoded = mb_decode_mimeheader($encoded);
|
$decoded = mb_decode_mimeheader($encoded);
|
||||||
// print "INPUT : " . $input . "\n";
|
// print "ENCODED: " . $encoded . "\n";
|
||||||
// print "DECODED: " . $decoded . "\n";
|
// print "INPUT : " . $input . " | " . mb_strlen($input) . "\n";
|
||||||
|
// print "DECODED: " . $decoded . " | " . mb_strlen($decoded) . "\n";
|
||||||
|
// $test_enc = mb_encode_mimeheader($input, $encoding);
|
||||||
|
// $test_dec = mb_decode_mimeheader($test_enc);
|
||||||
|
// print "TEST ENC: " . $test_enc . "\n";
|
||||||
// back compare decoded
|
// back compare decoded
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$input,
|
$input,
|
||||||
$decoded
|
$decoded,
|
||||||
|
"mb_decode_mimeheader"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// $this->assertEquals(
|
||||||
|
// $input,
|
||||||
|
// $test_dec,
|
||||||
|
// 'mb_encode_to_decode'
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,34 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testEncryptDecryptSuccess(string $input, string $expected): void
|
public function testEncryptDecryptSuccess(string $input, string $expected): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt($input, $key);
|
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
// test class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class call',
|
||||||
|
);
|
||||||
|
|
||||||
|
// test indirect
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($input);
|
||||||
|
$decrypted = SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$decrypted,
|
||||||
|
'Class Instance call',
|
||||||
|
);
|
||||||
|
|
||||||
|
// test static
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($input, $key);
|
||||||
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$decrypted
|
$decrypted,
|
||||||
|
'Static call',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +108,24 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testEncryptFailed(string $input, string $exception_message): void
|
public function testEncryptFailed(string $input, string $exception_message): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt($input, $key);
|
|
||||||
$wrong_key = CreateKey::generateRandomKey();
|
$wrong_key = CreateKey::generateRandomKey();
|
||||||
|
|
||||||
|
// wrong key in class call
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($input);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($encrypted, $wrong_key);
|
$crypt->setKey($key);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($input);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($wrong_key)->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($input, $key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::decryptKey($encrypted, $wrong_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +143,6 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
'too short hex key' => [
|
'too short hex key' => [
|
||||||
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
'key' => '1cabd5cba9e042f12522f4ff2de5c31d233b',
|
||||||
'excpetion_message' => 'Key is not the correct size (must be '
|
'excpetion_message' => 'Key is not the correct size (must be '
|
||||||
. 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes long).'
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -126,13 +161,33 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWrongKey(string $key, string $exception_message): void
|
public function testWrongKey(string $key, string $exception_message): void
|
||||||
{
|
{
|
||||||
$this->expectExceptionMessage($exception_message);
|
|
||||||
SymmetricEncryption::encrypt('test', $key);
|
|
||||||
// we must encrypt valid thing first so we can fail with the wrong kjey
|
|
||||||
$enc_key = CreateKey::generateRandomKey();
|
$enc_key = CreateKey::generateRandomKey();
|
||||||
$encrypted = SymmetricEncryption::encrypt('test', $enc_key);
|
|
||||||
|
// class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($encrypted, $key);
|
$crypt->encrypt('test');
|
||||||
|
$crypt->setKey($enc_key);
|
||||||
|
$encrypted = $crypt->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
$crypt->setKey($key);
|
||||||
|
$crypt->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($key)->encrypt('test');
|
||||||
|
// we must encrypt valid thing first so we can fail with the wrong key
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($enc_key)->encrypt('test');
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::encryptKey('test', $key);
|
||||||
|
// we must encrypt valid thing first so we can fail with the wrong key
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey('test', $enc_key);
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +200,7 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
return [
|
return [
|
||||||
'too short ciphertext' => [
|
'too short ciphertext' => [
|
||||||
'input' => 'short',
|
'input' => 'short',
|
||||||
'exception_message' => 'Invalid ciphertext (too short)'
|
'exception_message' => 'Decipher message failed: '
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -164,8 +219,18 @@ final class CoreLibsSecuritySymmetricEncryptionTest extends TestCase
|
|||||||
public function testWrongCiphertext(string $input, string $exception_message): void
|
public function testWrongCiphertext(string $input, string $exception_message): void
|
||||||
{
|
{
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
|
// class
|
||||||
|
$crypt = new SymmetricEncryption($key);
|
||||||
$this->expectExceptionMessage($exception_message);
|
$this->expectExceptionMessage($exception_message);
|
||||||
SymmetricEncryption::decrypt($input, $key);
|
$crypt->decrypt($input);
|
||||||
|
|
||||||
|
// class instance
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::getInstance($key)->decrypt($input);
|
||||||
|
|
||||||
|
// class static
|
||||||
|
$this->expectExceptionMessage($exception_message);
|
||||||
|
SymmetricEncryption::decryptKey($input, $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
includes:
|
includes:
|
||||||
- phpstan-conditional.php
|
- phpstan-conditional.php
|
||||||
parameters:
|
parameters:
|
||||||
tmpDir: /tmp/phpstan-corelibs
|
tmpDir: %currentWorkingDirectory%/tmp/phpstan-corelibs
|
||||||
level: 8 # max is now 9
|
level: 8 # max is now 9
|
||||||
checkMissingCallableSignature: true
|
checkMissingCallableSignature: true
|
||||||
treatPhpDocTypesAsCertain: false
|
treatPhpDocTypesAsCertain: false
|
||||||
|
|||||||
2
tmp/.gitignore
vendored
Normal file
2
tmp/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/php-cs-fixer-3.51.0.phar
|
/home/clemens/.phive/phars/php-cs-fixer-3.57.2.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpcbf-3.9.0.phar
|
/home/clemens/.phive/phars/phpcbf-3.10.0.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpcs-3.9.0.phar
|
/home/clemens/.phive/phars/phpcs-3.10.0.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpstan-1.10.59.phar
|
/home/clemens/.phive/phars/phpstan-1.11.1.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/phpunit-9.6.17.phar
|
/home/clemens/.phive/phars/phpunit-9.6.19.phar
|
||||||
@@ -1 +1 @@
|
|||||||
/home/clemens/.phive/phars/psalm-5.22.2.phar
|
/home/clemens/.phive/phars/psalm-5.24.0.phar
|
||||||
@@ -21,7 +21,7 @@ ob_end_flush();
|
|||||||
use CoreLibs\Combined\ArrayHandler;
|
use CoreLibs\Combined\ArrayHandler;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
use CoreLibs\Convert\SetVarType;
|
use CoreLibs\Convert\SetVarType;
|
||||||
use PHPUnit\Framework\Constraint\ArrayHasKey;
|
// use PHPUnit\Framework\Constraint\ArrayHasKey;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
|
|||||||
@@ -451,6 +451,7 @@ function intervalStringFormatDeprecated(
|
|||||||
$value = $interval->days;
|
$value = $interval->days;
|
||||||
$skip = true;
|
$skip = true;
|
||||||
} else {
|
} else {
|
||||||
|
/** @phan-suppress-next-line PhanUndeclaredProperty */
|
||||||
$value = $interval->$part;
|
$value = $interval->$part;
|
||||||
}
|
}
|
||||||
if ($value == 0 && $skip_last_zero === true) {
|
if ($value == 0 && $skip_last_zero === true) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ $LOG_FILE_ID = 'classTest-db-query-placeholder';
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Debug\Support;
|
use CoreLibs\Debug\Support;
|
||||||
use CoreLibs\DB\Support\ConvertPlaceholder;
|
// use CoreLibs\DB\Support\ConvertPlaceholder;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ require 'config.php';
|
|||||||
$LOG_FILE_ID = 'classTest-db-query-placeholders';
|
$LOG_FILE_ID = 'classTest-db-query-placeholders';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Debug\Support;
|
// use CoreLibs\Debug\Support;
|
||||||
|
|
||||||
$log = new CoreLibs\Logging\Logging([
|
$log = new CoreLibs\Logging\Logging([
|
||||||
'log_folder' => BASE . LOG,
|
'log_folder' => BASE . LOG,
|
||||||
|
|||||||
@@ -40,16 +40,33 @@ $key = CreateKey::generateRandomKey();
|
|||||||
print "Secret Key: " . $key . "<br>";
|
print "Secret Key: " . $key . "<br>";
|
||||||
|
|
||||||
$string = "I a some deep secret";
|
$string = "I a some deep secret";
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
//
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
$crypt = new SymmetricEncryption($key);
|
||||||
|
$encrypted = $crypt->encrypt($string);
|
||||||
|
$decrypted = $crypt->decrypt($encrypted);
|
||||||
|
print "[C] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[C] Decrytped: " . $decrypted . "<br>";
|
||||||
|
$encrypted = SymmetricEncryption::getInstance($key)->encrypt($string);
|
||||||
|
$decrypted = SymmetricEncryption::getInstance($key)->decrypt($encrypted);
|
||||||
|
print "[S] Original: " . $string . "<br>";
|
||||||
|
print "[S] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[S] Decrytped: " . $decrypted . "<br>";
|
||||||
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
|
print "[SS] Encrypted: " . $encrypted . "<br>";
|
||||||
|
print "[SS] Decrytped: " . $decrypted . "<br>";
|
||||||
|
|
||||||
print "Original: " . $string . "<br>";
|
print "<br>INIT KEY MISSING<br>";
|
||||||
print "Encrypted: " . $encrypted . "<br>";
|
try {
|
||||||
print "Decrytped: " . $decrypted . "<br>";
|
$crypt = new SymmetricEncryption();
|
||||||
|
$encrypted = $crypt->decrypt($string);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
print("Error: " . $e->getMessage() . "<br>");
|
||||||
|
}
|
||||||
|
|
||||||
print "<br>WRONG CIPHERTEXT<br>";
|
print "<br>WRONG CIPHERTEXT<br>";
|
||||||
try {
|
try {
|
||||||
$decrypted = SymmetricEncryption::decrypt('flupper', $key);
|
$decrypted = SymmetricEncryption::decryptKey('flupper', $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -57,7 +74,7 @@ try {
|
|||||||
print "<br>SHORT and WRONG KEY<br>";
|
print "<br>SHORT and WRONG KEY<br>";
|
||||||
$key = 'wrong_key';
|
$key = 'wrong_key';
|
||||||
try {
|
try {
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -65,7 +82,7 @@ try {
|
|||||||
print "<br>INVALID HEX KEY<br>";
|
print "<br>INVALID HEX KEY<br>";
|
||||||
$key = '1cabd5cba9e042f12522f4ff2de5c31d233b';
|
$key = '1cabd5cba9e042f12522f4ff2de5c31d233b';
|
||||||
try {
|
try {
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
@@ -73,25 +90,21 @@ try {
|
|||||||
print "<br>WRONG KEY TO DECRYPT<br>";
|
print "<br>WRONG KEY TO DECRYPT<br>";
|
||||||
$key = CreateKey::generateRandomKey();
|
$key = CreateKey::generateRandomKey();
|
||||||
$string = "I a some deep secret";
|
$string = "I a some deep secret";
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
$encrypted = SymmetricEncryption::encryptKey($string, $key);
|
||||||
$key = CreateKey::generateRandomKey();
|
|
||||||
try {
|
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<br>WRONG KEY TO DECRYPT<br>";
|
|
||||||
$key = CreateKey::generateRandomKey();
|
|
||||||
$string = "I a some deep secret";
|
|
||||||
$encrypted = SymmetricEncryption::encrypt($string, $key);
|
|
||||||
$key = 'wrong_key';
|
$key = 'wrong_key';
|
||||||
try {
|
try {
|
||||||
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);
|
$decrypted = SymmetricEncryption::decryptKey($encrypted, $key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print "Error: " . $e->getMessage() . "<br>";
|
print "Error: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// echo "<hr>";
|
||||||
|
// $key = CreateKey::generateRandomKey();
|
||||||
|
// $se = new SymmetricEncryption($key);
|
||||||
|
// $string = "I a some deep secret";
|
||||||
|
// $encrypted = $se->encrypt($string);
|
||||||
|
// $decrypted = $se->decrypt($encrypted);
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ $smarty->DATA['drop_down_test'] = [
|
|||||||
'foobar' => 'Foo Bar',
|
'foobar' => 'Foo Bar',
|
||||||
];
|
];
|
||||||
$smarty->DATA['drop_down_test_selected'] = 'bar';
|
$smarty->DATA['drop_down_test_selected'] = 'bar';
|
||||||
$smarty->DATA['drop_down_test_nested'] = [
|
$smarty->DATA['drop_down_test_nested'] = [
|
||||||
'' => '選択してください',
|
'' => '選択してください',
|
||||||
'4/25(木)' => [
|
'4/25(木)' => [
|
||||||
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
||||||
|
|||||||
8
www/composer.lock
generated
8
www/composer.lock
generated
@@ -8,11 +8,11 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "egrajp/smarty-extended",
|
"name": "egrajp/smarty-extended",
|
||||||
"version": "4.4.1",
|
"version": "4.5.2",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.4.1/egrajp-smarty-extended.4.4.1.zip",
|
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.5.2/egrajp-smarty-extended.4.5.2.zip",
|
||||||
"shasum": "edd7a0960e49bfcc709e0a525729aaaf9ed0db75"
|
"shasum": "a2c67a5047aad349a2cfa54240a44da449df9c4c"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"templating"
|
"templating"
|
||||||
],
|
],
|
||||||
"time": "2024-03-06T18:43:44+09:00"
|
"time": "2024-04-16T18:25:27+09:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gullevek/dotenv",
|
"name": "gullevek/dotenv",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class MimeEncode
|
|||||||
/**
|
/**
|
||||||
* wrapper function for mb mime convert
|
* wrapper function for mb mime convert
|
||||||
* for correct conversion with long strings
|
* for correct conversion with long strings
|
||||||
|
* NOTE: This is only a wrapper for mb_encode_mimeheader to stay compatible
|
||||||
*
|
*
|
||||||
* @param string $string string to encode
|
* @param string $string string to encode
|
||||||
* @param string $encoding target encoding
|
* @param string $encoding target encoding
|
||||||
@@ -29,38 +30,9 @@ class MimeEncode
|
|||||||
$current_internal_encoding = mb_internal_encoding();
|
$current_internal_encoding = mb_internal_encoding();
|
||||||
// set internal encoding, so the mimeheader encode works correctly
|
// set internal encoding, so the mimeheader encode works correctly
|
||||||
mb_internal_encoding($encoding);
|
mb_internal_encoding($encoding);
|
||||||
// if a subject, make a work around for the broken mb_mimencode
|
// use the internal convert to mime header
|
||||||
$pos = 0;
|
// it works from PHP 8.2 on
|
||||||
// after 36 single bytes characters,
|
$string = mb_encode_mimeheader($string, $encoding, 'B', $line_break);
|
||||||
// if then comes MB, it is broken
|
|
||||||
// has to 2 x 36 < 74 so the mb_encode_mimeheader
|
|
||||||
// 74 hardcoded split does not get triggered
|
|
||||||
$split = 36;
|
|
||||||
$_string = '';
|
|
||||||
while ($pos < mb_strlen($string, $encoding)) {
|
|
||||||
$output = mb_strimwidth($string, $pos, $split, "", $encoding);
|
|
||||||
$pos += mb_strlen($output, $encoding);
|
|
||||||
// if the strinlen is 0 here, get out of the loop
|
|
||||||
if (!mb_strlen($output, $encoding)) {
|
|
||||||
$pos += mb_strlen($string, $encoding);
|
|
||||||
}
|
|
||||||
$_string_encoded = mb_encode_mimeheader($output, $encoding);
|
|
||||||
// only make linebreaks if we have mime encoded code inside
|
|
||||||
// the space only belongs in the second line
|
|
||||||
if ($_string && preg_match("/^=\?/", $_string_encoded)) {
|
|
||||||
$_string .= $line_break . " ";
|
|
||||||
} elseif (
|
|
||||||
// hack for plain text with space at the end
|
|
||||||
mb_strlen($output, $encoding) == $split &&
|
|
||||||
mb_substr($output, -1, 1, $encoding) == " "
|
|
||||||
) {
|
|
||||||
// if output ends with space, add one more
|
|
||||||
$_string_encoded .= " ";
|
|
||||||
}
|
|
||||||
$_string .= $_string_encoded;
|
|
||||||
}
|
|
||||||
// strip out any spaces BEFORE a line break
|
|
||||||
$string = str_replace(" " . $line_break, $line_break, $_string);
|
|
||||||
// before we end, reset internal encoding
|
// before we end, reset internal encoding
|
||||||
mb_internal_encoding($current_internal_encoding);
|
mb_internal_encoding($current_internal_encoding);
|
||||||
// return mime encoded string
|
// return mime encoded string
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
|||||||
*/
|
*/
|
||||||
public function getPkId(): int|string|null
|
public function getPkId(): int|string|null
|
||||||
{
|
{
|
||||||
return $this->pk_id;
|
return $this->pk_id ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1324,8 +1324,12 @@ class IO
|
|||||||
// /s for matching new line in . list
|
// /s for matching new line in . list
|
||||||
// [disabled, we don't used ^ or $] /m for multi line match
|
// [disabled, we don't used ^ or $] /m for multi line match
|
||||||
// Matches in 1:, must be array_filtered to remove empty, count with array_unique
|
// Matches in 1:, must be array_filtered to remove empty, count with array_unique
|
||||||
|
$query_split = '[(=,?-]|->|->>|#>|#>>|@>|<@|\?\|\?\&|\|\||#-';
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/(?:\'.*?\')?\s*(?:\?\?|<>|[(=,])\s*(?:\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))/s',
|
'/'
|
||||||
|
. '(?:\'.*?\')?\s*(?:\?\?|<>|' . $query_split . ')\s*'
|
||||||
|
. '(?:\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))'
|
||||||
|
. '/s',
|
||||||
$query,
|
$query,
|
||||||
$match
|
$match
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -39,9 +39,11 @@ class ConvertPlaceholder
|
|||||||
): array {
|
): array {
|
||||||
$convert_to = strtolower($convert_to);
|
$convert_to = strtolower($convert_to);
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
$query_split = '[(=,?-]|->|->>|#>|#>>|@>|<@|\?\|\?\&|\|\||#-';
|
||||||
$pattern = '/'
|
$pattern = '/'
|
||||||
// prefix string part, must match towards
|
// prefix string part, must match towards
|
||||||
. '(?:\'.*?\')?\s*(?:\?\?|[(=,])\s*'
|
// seperator for ( = , ? - [and json/jsonb in pg doc section 9.15]
|
||||||
|
. '(?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*'
|
||||||
// match for replace part
|
// match for replace part
|
||||||
. '(?:'
|
. '(?:'
|
||||||
// digit -> ignore
|
// digit -> ignore
|
||||||
@@ -96,7 +98,10 @@ class ConvertPlaceholder
|
|||||||
$type = 'named';
|
$type = 'named';
|
||||||
$matches_return = $named_matches;
|
$matches_return = $named_matches;
|
||||||
// only check for :named
|
// only check for :named
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(:\w+))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(:\w+))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
@@ -134,7 +139,10 @@ class ConvertPlaceholder
|
|||||||
// order and data stays the same
|
// order and data stays the same
|
||||||
$params_new = $params;
|
$params_new = $params;
|
||||||
// only check for ?
|
// only check for ?
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(?:(?:\?\?)?\s*(\?{1})))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(?:(?:\?\?)?\s*(\?{1})))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
@@ -163,7 +171,10 @@ class ConvertPlaceholder
|
|||||||
$type = 'numbered';
|
$type = 'numbered';
|
||||||
$matches_return = $numbered_matches;
|
$matches_return = $numbered_matches;
|
||||||
// only check for $n
|
// only check for $n
|
||||||
$pattern_replace = '/((?:\'.*?\')?\s*(?:\?\?|[(=,])\s*)(\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))/s';
|
$pattern_replace = '/'
|
||||||
|
. '((?:\'.*?\')?\s*(?:\?\?|' . $query_split . ')\s*)'
|
||||||
|
. '(\d+|(?:\'.*?\')|(\$[1-9]{1}(?:[0-9]{1,})?))'
|
||||||
|
. '/s';
|
||||||
// 0: full
|
// 0: full
|
||||||
// 1: pre part
|
// 1: pre part
|
||||||
// 2: keep part UNLESS '3' is set
|
// 2: keep part UNLESS '3' is set
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class CachedFileReader extends \CoreLibs\Language\Core\StringReader
|
|||||||
if (!is_resource($fd)) {
|
if (!is_resource($fd)) {
|
||||||
$this->error = 3; // Cannot read file, probably permissions
|
$this->error = 3; // Cannot read file, probably permissions
|
||||||
} else {
|
} else {
|
||||||
$this->fd_str = fread($fd, filesize($filename) ?: 0) ?: '';
|
$this->fd_str = fread($fd, filesize($filename) ?: 1) ?: '';
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1507,7 +1507,7 @@ class Generate
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!empty($this->reference_array[$key]['mandatory']) &&
|
!empty($this->reference_array[$key]['mandatory']) &&
|
||||||
!$this->reference_array[$key]['selected'][0]
|
empty($this->reference_array[$key]['selected'][0])
|
||||||
) {
|
) {
|
||||||
$this->msg .= sprintf(
|
$this->msg .= sprintf(
|
||||||
$this->l->__('Please select at least one Element from field <b>%s</b>!<br>'),
|
$this->l->__('Please select at least one Element from field <b>%s</b>!<br>'),
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class EditPages implements Interface\TableArraysInterface
|
|||||||
'value' => $_POST['name'] ?? '',
|
'value' => $_POST['name'] ?? '',
|
||||||
'output_name' => 'Page name',
|
'output_name' => 'Page name',
|
||||||
'mandatory' => 1,
|
'mandatory' => 1,
|
||||||
|
'error_check' => 'unique',
|
||||||
'type' => 'text'
|
'type' => 'text'
|
||||||
],
|
],
|
||||||
'order_number' => [
|
'order_number' => [
|
||||||
|
|||||||
@@ -21,58 +21,82 @@ use SodiumException;
|
|||||||
|
|
||||||
class SymmetricEncryption
|
class SymmetricEncryption
|
||||||
{
|
{
|
||||||
|
/** @var SymmetricEncryption self instance */
|
||||||
|
private static SymmetricEncryption $instance;
|
||||||
|
|
||||||
|
/** @var string bin hex key */
|
||||||
|
private string $key = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt a message
|
* init class
|
||||||
|
* if key not passed, key must be set with createKey
|
||||||
*
|
*
|
||||||
* @param string $message Message to encrypt
|
* @param string|null|null $key
|
||||||
* @param string $key Encryption key (as hex string)
|
|
||||||
* @return string
|
|
||||||
* @throws \Exception
|
|
||||||
* @throws \RangeException
|
|
||||||
*/
|
*/
|
||||||
public static function encrypt(string $message, string $key): string
|
public function __construct(
|
||||||
|
string|null $key = null
|
||||||
|
) {
|
||||||
|
if ($key != null) {
|
||||||
|
$this->setKey($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton self object.
|
||||||
|
* For function wrapper use
|
||||||
|
*
|
||||||
|
* @return SymmetricEncryption object
|
||||||
|
*/
|
||||||
|
public static function getInstance(string|null $key = null): self
|
||||||
|
{
|
||||||
|
if (empty(self::$instance)) {
|
||||||
|
self::$instance = new self($key);
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************
|
||||||
|
* MARK: PRIVATE
|
||||||
|
* *************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create key and check validity
|
||||||
|
*
|
||||||
|
* @param string $key The key from which the binary key will be created
|
||||||
|
* @return string Binary key string
|
||||||
|
*/
|
||||||
|
private function createKey(string $key): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$key = CreateKey::hex2bin($key);
|
$key = CreateKey::hex2bin($key);
|
||||||
} catch (SodiumException $e) {
|
} catch (SodiumException $e) {
|
||||||
throw new \UnexpectedValueException('Invalid hex key');
|
throw new \UnexpectedValueException('Invalid hex key: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
if (mb_strlen($key, '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
|
if (mb_strlen($key, '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
|
||||||
throw new \RangeException(
|
throw new \RangeException(
|
||||||
'Key is not the correct size (must be '
|
'Key is not the correct size (must be '
|
||||||
. 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes long).'
|
. SODIUM_CRYPTO_SECRETBOX_KEYBYTES . ' bytes long).'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
return $key;
|
||||||
|
|
||||||
$cipher = base64_encode(
|
|
||||||
$nonce
|
|
||||||
. sodium_crypto_secretbox(
|
|
||||||
$message,
|
|
||||||
$nonce,
|
|
||||||
$key
|
|
||||||
)
|
|
||||||
);
|
|
||||||
sodium_memzero($message);
|
|
||||||
sodium_memzero($key);
|
|
||||||
return $cipher;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt a message
|
* Decryption call
|
||||||
*
|
*
|
||||||
* @param string $encrypted Message encrypted with safeEncrypt()
|
* @param string $encrypted Text to decrypt
|
||||||
* @param string $key Encryption key (as hex string)
|
* @param ?string $key Mandatory encryption key, will throw exception if empty
|
||||||
* @return string
|
* @return string Plain text
|
||||||
* @throws \Exception
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
public static function decrypt(string $encrypted, string $key): string
|
private function decryptData(string $encrypted, ?string $key): string
|
||||||
{
|
{
|
||||||
try {
|
if (empty($key)) {
|
||||||
$key = CreateKey::hex2bin($key);
|
throw new \UnexpectedValueException('Key not set');
|
||||||
} catch (SodiumException $e) {
|
|
||||||
throw new \Exception('Invalid hex key');
|
|
||||||
}
|
}
|
||||||
|
$key = $this->createKey($key);
|
||||||
$decoded = base64_decode($encrypted);
|
$decoded = base64_decode($encrypted);
|
||||||
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
||||||
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||||
@@ -85,7 +109,7 @@ class SymmetricEncryption
|
|||||||
$key
|
$key
|
||||||
);
|
);
|
||||||
} catch (SodiumException $e) {
|
} catch (SodiumException $e) {
|
||||||
throw new \UnexpectedValueException('Invalid ciphertext (too short)');
|
throw new \UnexpectedValueException('Decipher message failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
if (!is_string($plain)) {
|
if (!is_string($plain)) {
|
||||||
throw new \UnexpectedValueException('Invalid Key');
|
throw new \UnexpectedValueException('Invalid Key');
|
||||||
@@ -94,6 +118,117 @@ class SymmetricEncryption
|
|||||||
sodium_memzero($key);
|
sodium_memzero($key);
|
||||||
return $plain;
|
return $plain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @param ?string $key Mandatory encryption key, will throw exception if empty
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
private function encryptData(string $message, ?string $key): string
|
||||||
|
{
|
||||||
|
if (empty($this->key) || $key === null) {
|
||||||
|
throw new \UnexpectedValueException('Key not set');
|
||||||
|
}
|
||||||
|
$key = $this->createKey($key);
|
||||||
|
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||||
|
try {
|
||||||
|
$cipher = base64_encode(
|
||||||
|
$nonce
|
||||||
|
. sodium_crypto_secretbox(
|
||||||
|
$message,
|
||||||
|
$nonce,
|
||||||
|
$key,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (SodiumException $e) {
|
||||||
|
throw new \UnexpectedValueException("Create encrypted message failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
sodium_memzero($message);
|
||||||
|
sodium_memzero($key);
|
||||||
|
return $cipher;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************
|
||||||
|
* MARK: PUBLIC
|
||||||
|
* *************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set a new key for encryption
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setKey(string $key)
|
||||||
|
{
|
||||||
|
if (empty($key)) {
|
||||||
|
throw new \UnexpectedValueException('Key cannot be empty');
|
||||||
|
}
|
||||||
|
$this->key = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt a message
|
||||||
|
* static version
|
||||||
|
*
|
||||||
|
* @param string $encrypted Message encrypted with safeEncrypt()
|
||||||
|
* @param string $key Encryption key (as hex string)
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
*/
|
||||||
|
public static function decryptKey(string $encrypted, string $key): string
|
||||||
|
{
|
||||||
|
return self::getInstance()->decryptData($encrypted, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt a message
|
||||||
|
*
|
||||||
|
* @param string $encrypted Message encrypted with safeEncrypt()
|
||||||
|
* @return string
|
||||||
|
* @throws \RangeException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
*/
|
||||||
|
public function decrypt(string $encrypted): string
|
||||||
|
{
|
||||||
|
return $this->decryptData($encrypted, $this->key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
* static version
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @param string $key Encryption key (as hex string)
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
public static function encryptKey(string $message, string $key): string
|
||||||
|
{
|
||||||
|
return self::getInstance()->encryptData($message, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt a message
|
||||||
|
*
|
||||||
|
* @param string $message Message to encrypt
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \RangeException
|
||||||
|
*/
|
||||||
|
public function encrypt(string $message): string
|
||||||
|
{
|
||||||
|
return $this->encryptData($message, $this->key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class SmartyExtend extends \Smarty
|
|||||||
// call basic smarty
|
// call basic smarty
|
||||||
// or Smarty::__construct();
|
// or Smarty::__construct();
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// iinit lang
|
// init lang
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
// parse and read, legacy stuff
|
// parse and read, legacy stuff
|
||||||
$locale = $this->l10n->getLocaleAsArray();
|
$locale = $this->l10n->getLocaleAsArray();
|
||||||
|
|||||||
10
www/vendor/composer/installed.json
vendored
10
www/vendor/composer/installed.json
vendored
@@ -2,14 +2,14 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "egrajp/smarty-extended",
|
"name": "egrajp/smarty-extended",
|
||||||
"version": "4.4.1",
|
"version": "4.5.2",
|
||||||
"version_normalized": "4.4.1.0",
|
"version_normalized": "4.5.2.0",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.4.1/egrajp-smarty-extended.4.4.1.zip",
|
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.5.2/egrajp-smarty-extended.4.5.2.zip",
|
||||||
"shasum": "edd7a0960e49bfcc709e0a525729aaaf9ed0db75"
|
"shasum": "a2c67a5047aad349a2cfa54240a44da449df9c4c"
|
||||||
},
|
},
|
||||||
"time": "2024-03-06T18:43:44+09:00",
|
"time": "2024-04-16T18:25:27+09:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
4
www/vendor/composer/installed.php
vendored
4
www/vendor/composer/installed.php
vendored
@@ -20,8 +20,8 @@
|
|||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'egrajp/smarty-extended' => array(
|
'egrajp/smarty-extended' => array(
|
||||||
'pretty_version' => '4.4.1',
|
'pretty_version' => '4.5.2',
|
||||||
'version' => '4.4.1.0',
|
'version' => '4.5.2.0',
|
||||||
'reference' => null,
|
'reference' => null,
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../egrajp/smarty-extended',
|
'install_path' => __DIR__ . '/../egrajp/smarty-extended',
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4.3.4
|
4.5.1
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ if [ "${go_flag}" != "go" ]; then
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "[START]";
|
echo "[START]";
|
||||||
|
|
||||||
# gitea
|
# gitea
|
||||||
if [ ! -z "${GITEA_UPLOAD_FILENAME}" ] &&
|
if [ ! -z "${GITEA_UPLOAD_FILENAME}" ] &&
|
||||||
[ ! -z "${GITEA_URL_DL}" ] && [ ! -z "${GITEA_URL_PUSH}" ] &&
|
[ ! -z "${GITEA_URL_DL}" ] && [ ! -z "${GITEA_URL_PUSH}" ] &&
|
||||||
@@ -82,6 +83,7 @@ if [ ! -z "${GITLAB_URL}" ] && [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then
|
|||||||
else
|
else
|
||||||
echo "Missing GITLAB_DEPLOY_TOKEN environment variable";
|
echo "Missing GITLAB_DEPLOY_TOKEN environment variable";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "";
|
echo "";
|
||||||
echo "[DONE]";
|
echo "[DONE]";
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '4.4.1';
|
const SMARTY_VERSION = '4.5.1';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -109,9 +109,11 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
if (!is_object($compiler->smarty->security_policy)
|
if (!is_object($compiler->smarty->security_policy)
|
||||||
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
||||||
) {
|
) {
|
||||||
trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' .
|
if (!in_array($modifier, ['time', 'join', 'is_array', 'in_array'])) {
|
||||||
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
trigger_error('Using unregistered function "' . $modifier . '" in a template is deprecated and will be ' .
|
||||||
'a custom modifier.', E_USER_DEPRECATED);
|
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||||
|
'a custom modifier.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
$output = "{$modifier}({$params})";
|
$output = "{$modifier}({$params})";
|
||||||
}
|
}
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
|
|||||||
@@ -640,7 +640,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $name . '(' . implode(',', $parameter) . ')';
|
|
||||||
|
if (
|
||||||
|
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name)
|
||||||
|
&& !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name])
|
||||||
|
&& !in_array($name, ['time', 'join', 'is_array', 'in_array'])
|
||||||
|
) {
|
||||||
|
trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' .
|
||||||
|
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||||
|
'a custom modifier.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name . '(' . implode(',', $parameter) . ')';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->trigger_template_error("unknown function '{$name}'");
|
$this->trigger_template_error("unknown function '{$name}'");
|
||||||
|
|||||||
@@ -2425,6 +2425,9 @@ public static $yy_action = array(
|
|||||||
if (isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor])) {
|
if (isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor])) {
|
||||||
$this->_retvalue = $this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor].'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1];
|
$this->_retvalue = $this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor].'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1];
|
||||||
} else {
|
} else {
|
||||||
|
trigger_error('Using unregistered static method "' . $this->yystack[$this->yyidx + -2]->minor.'::'.$this->yystack[$this->yyidx + 0]->minor[0] . '" in a template is deprecated and will be ' .
|
||||||
|
'removed in a future release. Use Smarty::registerClass to explicitly register ' .
|
||||||
|
'a class for access.', E_USER_DEPRECATED);
|
||||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1];
|
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class Smarty_Security
|
|||||||
*
|
*
|
||||||
* @param string $function_name
|
* @param string $function_name
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
*
|
* @deprecated
|
||||||
* @return boolean true if function is trusted
|
* @return boolean true if function is trusted
|
||||||
*/
|
*/
|
||||||
public function isTrustedPhpFunction($function_name, $compiler)
|
public function isTrustedPhpFunction($function_name, $compiler)
|
||||||
|
|||||||
Reference in New Issue
Block a user