Convert all classes to strict variable types

All variable declarations in all classes have a strict type set

Exception: constants (will be setable from PHP 8.3 on), resources (no type)

Debug\LoggingLegacy is kept as is, will be deprecated
This commit is contained in:
Clemens Schwaighofer
2023-05-31 15:58:06 +09:00
parent f72055909b
commit 75c4c98de8
45 changed files with 685 additions and 514 deletions

View File

@@ -21,45 +21,83 @@ final class CoreLibsCreateUidsTest extends TestCase
public function uniqIdProvider(): array public function uniqIdProvider(): array
{ {
return [ return [
// number length
'too short' => [
0 => 1,
1 => 4,
2 => null
],
'valid length: 10' => [
0 => 10,
1 => 10,
2 => null
],
'valid length: 9, auto length' => [
0 => 9,
1 => 8,
2 => null
],
'valid length: 9, force length' => [
0 => 9,
1 => 9,
2 => true,
],
'very long: 512' => [
0 => 512,
1 => 512,
2 => null
],
// below is all legacy
'md5 hash' => [ 'md5 hash' => [
0 => 'md5', 0 => 'md5',
1 => 32, 1 => 32,
2 => null
], ],
'sha256 hash' => [ 'sha256 hash' => [
0 => 'sha256', 0 => 'sha256',
1 => 64 1 => 64,
2 => null
], ],
'ripemd160 hash' => [ 'ripemd160 hash' => [
0 => 'ripemd160', 0 => 'ripemd160',
1 => 40 1 => 40,
2 => null
], ],
'adler32 hash' => [ 'adler32 hash' => [
0 => 'adler32', 0 => 'adler32',
1 => 8 1 => 8,
2 => null
], ],
'not in list hash but valid' => [ 'not in list, set default length' => [
0 => 'sha3-512', 0 => 'sha3-512',
1 => strlen(hash('sha3-512', 'A')) 1 => 64,
2 => null
], ],
'default hash not set' => [ 'default hash not set' => [
0 => null, 0 => null,
1 => 64, 1 => 64,
2 => null
], ],
'invalid name' => [ 'invalid name' => [
0 => 'iamnotavalidhash', 0 => 'iamnotavalidhash',
1 => 64, 1 => 64,
2 => null
], ],
'auto: ' . \CoreLibs\Create\Uids::DEFAULT_HASH => [ // auto calls
0 => \CoreLibs\Create\Uids::DEFAULT_HASH, 'auto: ' . \CoreLibs\Create\Uids::DEFAULT_UNNIQ_ID_LENGTH => [
1 => strlen(hash(\CoreLibs\Create\Uids::DEFAULT_HASH, 'A')) 0 => \CoreLibs\Create\Uids::DEFAULT_UNNIQ_ID_LENGTH,
1 => 64,
2 => null
], ],
'auto: ' . \CoreLibs\Create\Uids::STANDARD_HASH_LONG => [ 'auto: ' . \CoreLibs\Create\Uids::STANDARD_HASH_LONG => [
0 => \CoreLibs\Create\Uids::STANDARD_HASH_LONG, 0 => \CoreLibs\Create\Uids::STANDARD_HASH_LONG,
1 => strlen(hash(\CoreLibs\Create\Uids::STANDARD_HASH_LONG, 'A')) 1 => strlen(hash(\CoreLibs\Create\Uids::STANDARD_HASH_LONG, 'A')),
2 => null
], ],
'auto: ' . \CoreLibs\Create\Uids::STANDARD_HASH_SHORT => [ 'auto: ' . \CoreLibs\Create\Uids::STANDARD_HASH_SHORT => [
0 => \CoreLibs\Create\Uids::STANDARD_HASH_SHORT, 0 => \CoreLibs\Create\Uids::STANDARD_HASH_SHORT,
1 => strlen(hash(\CoreLibs\Create\Uids::STANDARD_HASH_SHORT, 'A')) 1 => strlen(hash(\CoreLibs\Create\Uids::STANDARD_HASH_SHORT, 'A')),
2 => null
], ],
]; ];
} }
@@ -105,25 +143,26 @@ final class CoreLibsCreateUidsTest extends TestCase
* *
* @covers ::uniqId * @covers ::uniqId
* @dataProvider uniqIdProvider * @dataProvider uniqIdProvider
* @testdox uniqId $input will be length $expected [$_dataName] * @testdox uniqId $input will be length $expected (Force $flag) [$_dataName]
* *
* @param string|null $input * @param int|string|null $input
* @param string $expected * @param string $expected
* @param bool|null $flag
* @return void * @return void
*/ */
public function testUniqId(?string $input, int $expected): void public function testUniqId(int|string|null $input, int $expected, ?bool $flag): void
{ {
if ($input === null) { if ($input === null) {
$this->assertEquals( $uniq_id_length = strlen(\CoreLibs\Create\Uids::uniqId());
$expected, } elseif ($flag === null) {
strlen(\CoreLibs\Create\Uids::uniqId()) $uniq_id_length = strlen(\CoreLibs\Create\Uids::uniqId($input));
);
} else { } else {
$this->assertEquals( $uniq_id_length = strlen(\CoreLibs\Create\Uids::uniqId($input, $flag));
$expected,
strlen(\CoreLibs\Create\Uids::uniqId($input))
);
} }
$this->assertEquals(
$expected,
$uniq_id_length
);
} }
/** /**

View File

@@ -92,15 +92,15 @@ final class CoreLibsLoggingLoggingTest extends TestCase
'override' => [], 'override' => [],
], ],
// no log file id set -> error, // no log file id set -> error,
/* 'nothing set' => [ 'nothing set' => [
'options' => [], 'options' => [],
'expected' => [ 'expected' => [
'log_folder' => getcwd() . DIRECTORY_SEPARATOR, 'log_folder' => getcwd() . DIRECTORY_SEPARATOR,
'log_level' => Level::Debug, 'log_level' => Level::Debug,
'log_file_id' => 'NOHOST-NOPORT_PHPUnit-TextUI-Command', 'log_file_id' => 'NOHOST-0_PHPUnit-TextUI-Command',
], ],
'override' => [] 'override' => []
] */ ]
]; ];
} }
@@ -674,7 +674,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
$log->getLogFolder() . $log->getLogFile() $log->getLogFolder() . $log->getLogFile()
) ?: ''; ) ?: '';
$log_level = $log->getLoggingLevel()->getName(); $log_level = $log->getLoggingLevel()->getName();
// [2023-05-30 15:51:39.36128800] [NOHOST:NOPORT] // [2023-05-30 15:51:39.36128800] [NOHOST:0]
// [www/vendor/bin/phpunit] [7b9d0747] {PHPUnit\TextUI\Command} // [www/vendor/bin/phpunit] [7b9d0747] {PHPUnit\TextUI\Command}
// <DEBUG:G> D // <DEBUG:G> D
$this->assertMatchesRegularExpression( $this->assertMatchesRegularExpression(

View File

@@ -43,12 +43,19 @@ print "S::__SHA1SHORT(off): $to_crc: " . $hash_class::__sha1short($to_crc) . "<b
print "S::__SHA1SHORT(on): $to_crc: " . $hash_class::__sha1short($to_crc, true) . "<br>"; print "S::__SHA1SHORT(on): $to_crc: " . $hash_class::__sha1short($to_crc, true) . "<br>";
print "S::__hash(d): " . $to_crc . "/" print "S::__hash(d): " . $to_crc . "/"
. Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>"; . Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat'] as $__hash_c) { foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'sha512'] as $__hash_c) {
print "S::__hash($__hash_c): $to_crc: " . $hash_class::__hash($to_crc, $__hash_c) . "<br>"; print "S::__hash($__hash_c): $to_crc: " . $hash_class::__hash($to_crc, $__hash_c) . "<br>";
} }
// static use // static use
print "U-S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>"; print "U-S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
echo "<hr>";
$text = 'Some String Text';
$type = 'crc32b';
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
print "Class: " . $type . ": " . Hash::__hash($text, $type) . "<br>";
echo "<hr>";
print "<br>CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>"; print "<br>CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
print "<br>CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>"; print "<br>CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>"; print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>";

View File

@@ -85,7 +85,7 @@ foreach ($images as $image) {
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image; $image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image;
list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image)); list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image));
echo "<div><b>IMAGE INFO</b>: " . $height . "x" . $width . ", TYPE: " echo "<div><b>IMAGE INFO</b>: " . $height . "x" . $width . ", TYPE: "
. \CoreLibs\Debug\Support::printArray($img_type) . " [" . $finfo->file($image) . "]</div>"; . \CoreLibs\Debug\Support::dumpVar($img_type) . " [" . $finfo->file($image) . "]</div>";
// rotate image first // rotate image first
Image::correctImageOrientation($image); Image::correctImageOrientation($image);
// thumbnail tests // thumbnail tests

View File

@@ -1,4 +1,4 @@
<?php // phpcs:ignore warning <?php // phpcs:ignore PSR1.Files.SideEffects
/** /**
* @phan-file-suppress PhanTypeSuspiciousStringExpression * @phan-file-suppress PhanTypeSuspiciousStringExpression
@@ -48,6 +48,8 @@ print "Flag: per_run (from int): " . Flag::fromValue(2)->getName() . "<br>";
print "Flag: per_run getName(): " . Flag::per_class->getName() . "<br>"; print "Flag: per_run getName(): " . Flag::per_class->getName() . "<br>";
print "Flag: per_run ->name: " . Flag::per_class->name . "<br>"; print "Flag: per_run ->name: " . Flag::per_class->name . "<br>";
print "Flag: per_run ->value: " . Flag::per_class->value . "<br>"; print "Flag: per_run ->value: " . Flag::per_class->value . "<br>";
$log->setLogUniqueId();
print "LogUniqId: " . $log->getLogUniqueId() . "<br>";
print "DUMP: " . $log->dV(['something' => 'error']) . "<br>"; print "DUMP: " . $log->dV(['something' => 'error']) . "<br>";
@@ -82,6 +84,26 @@ try {
'log_file_id' => 'a', 'log_file_id' => 'a',
]); */ ]); */
// @codingStandardsIgnoreLine
Class TestP
{
/** @var \CoreLibs\Logging\Logging */
public $log;
public function __construct(
\CoreLibs\Logging\Logging $log
) {
$this->log = $log;
}
public function test(): void
{
$this->log->info('TestL::test call');
}
}
$tl = new TestP($log);
$tl->test();
print '<hr>' print '<hr>'
. '<div style="width:100%; font-family: monospace;">' . '<div style="width:100%; font-family: monospace;">'
// . '<pre>' // . '<pre>'

View File

@@ -66,49 +66,58 @@ print "<!DOCTYPE html>";
print "<html><head><title>TEST CLASS</title><head>"; print "<html><head><title>TEST CLASS</title><head>";
print "<body>"; print "<body>";
print '<div><a href="class_test.db.php">Class Test: DB</a></div>'; // key: file name, value; name
print '<div><a href="class_test.db.single.php">Class Test: DB SINGLE</a></div>'; $test_files = [
print '<div><a href="class_test.db.dbReturn.php">Class Test: DB dbReturn</a></div>'; 'class_test.db.php' => 'Class Test: DB',
print '<div><a href="class_test.convert.colors.php">Class Test: CONVERT COLORS</a></div>'; 'class_test.db.single.php' => 'Class Test: DB SINGLE',
print '<div><a href="class_test.check.colors.php">Class Test: CHECK COLORS</a></div>'; 'class_test.db.dbReturn.php' => 'Class Test: DB dbReturn',
print '<div><a href="class_test.mime.php">Class Test: MIME</a></div>'; 'class_test.convert.colors.php' => 'Class Test: CONVERT COLORS',
print '<div><a href="class_test.json.php">Class Test: JSON</a></div>'; 'class_test.check.colors.php' => 'Class Test: CHECK COLORS',
print '<div><a href="class_test.token.php">Class Test: FORM TOKEN</a></div>'; 'class_test.mime.php' => 'Class Test: MIME',
print '<div><a href="class_test.password.php">Class Test: PASSWORD</a></div>'; 'class_test.json.php' => 'Class Test: JSON',
print '<div><a href="class_test.encryption.php">Class Test: ENCRYPTION</a></div>'; 'class_test.token.php' => 'Class Test: FORM TOKEN',
print '<div><a href="class_test.math.php">Class Test: MATH</a></div>'; 'class_test.password.php' => 'Class Test: PASSWORD',
print '<div><a href="class_test.html.php">Class Test: HTML/ELEMENTS</a></div>'; 'class_test.encryption.php' => 'Class Test: ENCRYPTION',
print '<div><a href="class_test.email.php">Class Test: EMAIL</a></div>'; 'class_test.math.php' => 'Class Test: MATH',
print '<div><a href="class_test.create_email.php">Class Test: CREATE EMAIL</a></div>'; 'class_test.html.php' => 'Class Test: HTML/ELEMENTS',
print '<div><a href="class_test.uids.php">Class Test: UIDS</a></div>'; 'class_test.email.php' => 'Class Test: EMAIL',
print '<div><a href="class_test.phpv.php">Class Test: PHP VERSION</a></div>'; 'class_test.create_email.php' => 'Class Test: CREATE EMAIL',
print '<div><a href="class_test.hash.php">Class Test: HASH</a></div>'; 'class_test.uids.php' => 'Class Test: UIDS',
print '<div><a href="class_test.encoding.php">Class Test: ENCODING (CHECK/CONVERT/MIME)</a></div>'; 'class_test.phpv.php' => 'Class Test: PHP VERSION',
print '<div><a href="class_test.image.php">Class Test: IMAGE</a></div>'; 'class_test.hash.php' => 'Class Test: HASH',
print '<div><a href="class_test.byte.php">Class Test: BYTE CONVERT</a></div>'; 'class_test.encoding.php' => 'Class Test: ENCODING (CHECK/CONVERT/MIME)',
print '<div><a href="class_test.strings.php">Class Test: STRING CONVERT</a></div>'; 'class_test.image.php' => 'Class Test: IMAGE',
print '<div><a href="class_test.datetime.php">Class Test: DATE/TIME</a></div>'; 'class_test.byte.php' => 'Class Test: BYTE CONVERT',
print '<div><a href="class_test.array.php">Class Test: ARRAY HANDLER</a></div>'; 'class_test.strings.php' => 'Class Test: STRING CONVERT',
print '<div><a href="class_test.file.php">Class Test: FILE</a></div>'; 'class_test.datetime.php' => 'Class Test: DATE/TIME',
print '<div><a href="class_test.randomkey.php">Class Test: RANDOM KEY</a></div>'; 'class_test.array.php' => 'Class Test: ARRAY HANDLER',
print '<div><a href="class_test.system.php">Class Test: SYSTEM</a></div>'; 'class_test.file.php' => 'Class Test: FILE',
print '<div><a href="class_test.readenvfile.php">Class Test: READ ENV FILE</a></div>'; 'class_test.randomkey.php' => 'Class Test: RANDOM KEY',
print '<div><a href="class_test.runningtime.php">Class Test: RUNNING TIME</a></div>'; 'class_test.system.php' => 'Class Test: SYSTEM',
print '<div><a href="class_test.memoryusage.php">Class Test: MEMORY USAGE</a></div>'; 'class_test.readenvfile.php' => 'Class Test: READ ENV FILE',
print '<div><a href="class_test.debug.php">Class Test: DEBUG</a></div>'; 'class_test.runningtime.php' => 'Class Test: RUNNING TIME',
print '<div><a href="class_test.logging.php">Class Test: LOGGING</a></div>'; 'class_test.memoryusage.php' => 'Class Test: MEMORY USAGE',
print '<div><a href="class_test.output.form.php">Class Test: OUTPUT FORM</a></div>'; 'class_test.debug.php' => 'Class Test: DEBUG',
print '<div><a href="class_test.admin.backend.php">Class Test: BACKEND ADMIN CLASS</a></div>'; 'class_test.logging.php' => 'Class Test: LOGGING',
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>'; 'class_test.output.form.php' => 'Class Test: OUTPUT FORM',
print '<div><a href="class_test.varistype.php">Class Test: SET VAR TYPE</a></div>'; 'class_test.admin.backend.php' => 'Class Test: BACKEND ADMIN CLASS',
print '<div><a href="class_test.session.php">Class Test: SESSION</a></div>'; 'class_test.lang.php' => 'Class Test: LANG/L10n',
print '<div><a href="class_test.session.read.php">Class Test: SESSION: READ</a></div>'; 'class_test.varistype.php' => 'Class Test: SET VAR TYPE',
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>'; 'class_test.session.php' => 'Class Test: SESSION',
print '<div><a href="class_test.login.php">Class Test: LOGIN</a></div>'; 'class_test.session.read.php' => 'Class Test: SESSION: READ',
print '<div><a href="class_test.autoloader.php">Class Test: AUTOLOADER</a></div>'; 'class_test.smarty.php' => 'Class Test: SMARTY',
print '<div><a href="class_test.config.link.php">Class Test: CONFIG LINK</a></div>'; 'class_test.login.php' => 'Class Test: LOGIN',
print '<div><a href="class_test.config.direct.php">Class Test: CONFIG DIRECT</a></div>'; 'class_test.autoloader.php' => 'Class Test: AUTOLOADER',
print '<div><a href="subfolder/class_test.config.direct.php">Class Test: CONFIG DIRECT SUB</a></div>'; 'class_test.config.link.php' => 'Class Test: CONFIG LINK',
'class_test.config.direct.php' => 'Class Test: CONFIG DIRECT',
'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB',
];
asort($test_files);
foreach ($test_files as $file => $name) {
print '<div><a href="' . $file . '">' . $name . '</a></div>';
}
print "<hr>"; print "<hr>";
print "L: " . Support::dumpVar($locale) . "<br>"; print "L: " . Support::dumpVar($locale) . "<br>";

View File

@@ -39,11 +39,16 @@ print "UUIDV4: " . $_uids->uuidv4() . "<br>";
print "UNIQID (d): " . $_uids->uniqId() . "<br>"; print "UNIQID (d): " . $_uids->uniqId() . "<br>";
print "UNIQID (md5): " . $_uids->uniqId('md5') . "<br>"; print "UNIQID (md5): " . $_uids->uniqId('md5') . "<br>";
print "UNIQID (sha256): " . $_uids->uniqId('sha256') . "<br>"; print "UNIQID (sha256): " . $_uids->uniqId('sha256') . "<br>";
// statc // static
print "S::UUIDV4: " . $uids_class::uuidv4() . "<br>"; print "S::UUIDV4: " . $uids_class::uuidv4() . "<br>";
print "S::UNIQID (d): " . $uids_class::uniqId() . "<br>"; print "S::UNIQID (d): " . $uids_class::uniqId() . "<br>";
print "S::UNIQID (md5): " . $uids_class::uniqId('md5') . "<br>"; print "S::UNIQID (md5): " . $uids_class::uniqId('md5') . "<br>";
print "S::UNIQID (sha256): " . $uids_class::uniqId('sha256') . "<br>"; print "S::UNIQID (sha256): " . $uids_class::uniqId('sha256') . "<br>";
// with direct length
print "S:UNIQID (0->4): " . Uids::uniqId(0) . "<br>";
print "S:UNIQID (9->8): " . Uids::uniqId(9) . "<br>";
print "S:UNIQID (9,true): " . Uids::uniqId(9, true) . "<br>";
print "S:UNIQID (512): " . Uids::uniqId(512) . "<br>";
// uniq ids // uniq ids
print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>"; print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>";
print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>"; print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";

View File

@@ -73,65 +73,65 @@ use CoreLibs\Convert\Json;
class Login class Login
{ {
/** @var string the user id var*/ /** @var ?int the user id var*/
private $euid; private ?int $euid;
/** @var string _GET/_POST loginUserId parameter for non password login */ /** @var string _GET/_POST loginUserId parameter for non password login */
private $login_user_id = ''; private string $login_user_id = '';
/** @var string source, either _GET or _POST or empty */ /** @var string source, either _GET or _POST or empty */
private $login_user_id_source = ''; private string $login_user_id_source = '';
/** @var bool set to true if illegal characters where found in the login user id string */ /** @var bool set to true if illegal characters where found in the login user id string */
private $login_user_id_unclear = false; private bool $login_user_id_unclear = false;
// is set to one if login okay, or EUID is set and user is okay to access this page // is set to one if login okay, or EUID is set and user is okay to access this page
/** @var bool */ /** @var bool */
private $permission_okay = false; private bool $permission_okay = false;
/** @var string pressed login */ /** @var string pressed login */
private $login = ''; private string $login = '';
/** @var string master action command */ /** @var string master action command */
private $action; private string $action;
/** @var string login name */ /** @var string login name */
private $username; private string $username;
/** @var string login password */ /** @var string login password */
private $password; private string $password;
/** @var string logout button */ /** @var string logout button */
private $logout; private string $logout;
/** @var bool if this is set to true, the user can change passwords */ /** @var bool if this is set to true, the user can change passwords */
private $password_change = false; private bool $password_change = false;
/** @var bool password change was successful */ /** @var bool password change was successful */
private $password_change_ok = false; private bool $password_change_ok = false;
// can we reset password and mail to user with new password set screen // can we reset password and mail to user with new password set screen
/** @var bool */ /** @var bool */
private $password_forgot = false; private bool $password_forgot = false;
/** @var bool password forgot mail send ok */ /** @var bool password forgot mail send ok */
// private $password_forgot_ok = false; // private $password_forgot_ok = false;
/** @var string */ /** @var string */
private $change_password; private string $change_password;
/** @var string */ /** @var string */
private $pw_username; private string $pw_username;
/** @var string */ /** @var string */
private $pw_old_password; private string $pw_old_password;
/** @var string */ /** @var string */
private $pw_new_password; private string $pw_new_password;
/** @var string */ /** @var string */
private $pw_new_password_confirm; private string $pw_new_password_confirm;
/** @var array<string> array of users for which the password change is forbidden */ /** @var array<string> array of users for which the password change is forbidden */
private $pw_change_deny_users = []; private array $pw_change_deny_users = [];
/** @var string */ /** @var string */
private $logout_target = ''; private string $logout_target = '';
/** @var int */ /** @var int */
private $max_login_error_count = -1; private int $max_login_error_count = -1;
/** @var array<string> */ /** @var array<string> */
private $lock_deny_users = []; private array $lock_deny_users = [];
/** @var string */ /** @var string */
private $page_name = ''; private string $page_name = '';
/** @var int if we have password change we need to define some rules */ /** @var int if we have password change we need to define some rules */
private $password_min_length = 9; private int $password_min_length = 9;
/** @var int an true maxium min, can never be set below this */ /** @var int an true maxium min, can never be set below this */
private $password_min_length_max = 9; private int $password_min_length_max = 9;
// max length is fixed as 255 (for input type max), if set highter // max length is fixed as 255 (for input type max), if set highter
// it will be set back to 255 // it will be set back to 255
/** @var int */ /** @var int */
private $password_max_length = 255; private int $password_max_length = 255;
/** @var int minum password length */ /** @var int minum password length */
public const PASSWORD_MIN_LENGTH = 9; public const PASSWORD_MIN_LENGTH = 9;
@@ -158,7 +158,7 @@ class Login
. "$/"; . "$/";
/** @var array<string> can have several regexes, if nothing set, all is ok */ /** @var array<string> can have several regexes, if nothing set, all is ok */
private $password_valid_chars = [ private array $password_valid_chars = [
// '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$', // '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$',
// '^(?.*(\pL)u)(?=.*(\pN)u)(?=.*([^\pL\pN])u).{8,}', // '^(?.*(\pL)u)(?=.*(\pN)u)(?=.*([^\pL\pN])u).{8,}',
]; ];
@@ -166,13 +166,13 @@ class Login
// login error code, can be matched to the array login_error_msg, // login error code, can be matched to the array login_error_msg,
// which holds the string // which holds the string
/** @var int */ /** @var int */
private $login_error = 0; private int $login_error = 0;
/** @var array<mixed> all possible login error conditions */ /** @var array<mixed> all possible login error conditions */
private $login_error_msg = []; private array $login_error_msg = [];
// this is an array holding all strings & templates passed // this is an array holding all strings & templates passed
// rom the outside (translation) // rom the outside (translation)
/** @var array<mixed> */ /** @var array<mixed> */
private $login_template = [ private array $login_template = [
'strings' => [], 'strings' => [],
'password_change' => '', 'password_change' => '',
'template' => '' 'template' => ''
@@ -180,24 +180,24 @@ class Login
// acl vars // acl vars
/** @var array<mixed> */ /** @var array<mixed> */
private $acl = []; private array $acl = [];
/** @var array<mixed> */ /** @var array<mixed> */
private $default_acl_list = []; private array $default_acl_list = [];
/** @var array<string,int> Reverse list to lookup level from type */ /** @var array<string,int> Reverse list to lookup level from type */
private $default_acl_list_type = []; private array $default_acl_list_type = [];
/** @var int default ACL level to be based on if nothing set */ /** @var int default ACL level to be based on if nothing set */
private $default_acl_level = 0; private int $default_acl_level = 0;
// login html, if we are on an ajax page // login html, if we are on an ajax page
/** @var string|null */ /** @var string|null */
private $login_html = ''; private ?string $login_html = '';
/** @var bool */ /** @var bool */
private $login_is_ajax_page = false; private bool $login_is_ajax_page = false;
// settings // settings
/** @var array<string,mixed> options */ /** @var array<string,mixed> options */
private $options = []; private array $options = [];
/** @var array<string,string> locale options: locale, domain, encoding (opt), path */ /** @var array<string,string> locale options: locale, domain, encoding (opt), path */
private $locale = [ private array $locale = [
'locale' => '', 'locale' => '',
'domain' => '', 'domain' => '',
'encoding' => '', 'encoding' => '',
@@ -205,13 +205,13 @@ class Login
]; ];
/** @var \CoreLibs\Logging\Logging logger */ /** @var \CoreLibs\Logging\Logging logger */
public $log; public \CoreLibs\Logging\Logging $log;
/** @var \CoreLibs\DB\IO database */ /** @var \CoreLibs\DB\IO database */
public $db; public \CoreLibs\DB\IO $db;
/** @var \CoreLibs\Language\L10n language */ /** @var \CoreLibs\Language\L10n language */
public $l; public \CoreLibs\Language\L10n $l;
/** @var \CoreLibs\Create\Session session class */ /** @var \CoreLibs\Create\Session session class */
public $session; public \CoreLibs\Create\Session $session;
/** /**
* constructor, does ALL, opens db, works through connection checks, * constructor, does ALL, opens db, works through connection checks,
@@ -883,7 +883,7 @@ class Login
} }
// normal user processing // normal user processing
// set class var and session var // set class var and session var
$_SESSION['EUID'] = $this->euid = $res['edit_user_id']; $_SESSION['EUID'] = $this->euid = (int)$res['edit_user_id'];
// check if user is okay // check if user is okay
$this->loginCheckPermissions(); $this->loginCheckPermissions();
if ($this->login_error == 0) { if ($this->login_error == 0) {
@@ -1048,7 +1048,7 @@ class Login
} }
// build master unit array // build master unit array
$unit_access[$res['edit_access_id']] = [ $unit_access[$res['edit_access_id']] = [
'id' => $res['edit_access_id'], 'id' => (int)$res['edit_access_id'],
'acl_level' => $res['level'], 'acl_level' => $res['level'],
'acl_type' => $res['type'], 'acl_type' => $res['type'],
'name' => $res['name'], 'name' => $res['name'],
@@ -2110,7 +2110,7 @@ HTML;
// unset session vars set/used in this login // unset session vars set/used in this login
$this->session->sessionDestroy(); $this->session->sessionDestroy();
// unset euid // unset euid
$this->euid = ''; $this->euid = null;
// then prints the login screen again // then prints the login screen again
$this->permission_okay = false; $this->permission_okay = false;
} }
@@ -2498,7 +2498,7 @@ HTML;
*/ */
public function loginGetEuid(): string public function loginGetEuid(): string
{ {
return $this->euid; return (string)$this->euid;
} }
} }

View File

@@ -35,83 +35,83 @@ class Backend
{ {
// page name // page name
/** @var array<mixed> */ /** @var array<mixed> */
public $menu = []; public array $menu = [];
/** @var int|string */ /** @var int|string */
public $menu_show_flag = 0; // top menu flag (mostly string) public int|string $menu_show_flag = 0; // top menu flag (mostly string)
// action ids // action ids
/** @var array<string> */ /** @var array<string> */
public $action_list = [ public array $action_list = [
'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag', 'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag',
'action_menu', 'action_value', 'action_error', 'action_loaded' 'action_menu', 'action_value', 'action_error', 'action_loaded'
]; ];
/** @var string */ /** @var string */
public $action; public string $action;
/** @var string|int */ /** @var string|int */
public $action_id; public string|int $action_id;
/** @var string|int */ /** @var string|int */
public $action_sub_id; public string|int $action_sub_id;
/** @var string|int|bool */ /** @var string|int|bool */
public $action_yes; public string|int|bool $action_yes;
/** @var string */ /** @var string */
public $action_flag; public string $action_flag;
/** @var string */ /** @var string */
public $action_menu; public string $action_menu;
/** @var string */ /** @var string */
public $action_loaded; public string $action_loaded;
/** @var string */ /** @var string */
public $action_value; public string $action_value;
/** @var string */ /** @var string */
public $action_error; public string $action_error;
// ACL array variable if we want to set acl data from outisde // ACL array variable if we want to set acl data from outisde
/** @var array<mixed> */ /** @var array<mixed> */
public $acl = []; public array $acl = [];
/** @var int */ /** @var int */
public $default_acl; public int $default_acl;
// queue key // queue key
/** @var string */ /** @var string */
public $queue_key; public string $queue_key;
// the current active edit access id // the current active edit access id
/** @var int */ /** @var int|null */
public $edit_access_id; public int|null $edit_access_id;
/** @var string */ /** @var string */
public $page_name; public string $page_name;
// error/warning/info messages // error/warning/info messages
/** @var array<mixed> */ /** @var array<mixed> */
public $messages = []; public array $messages = [];
/** @var bool */ /** @var bool */
public $error = false; public bool $error = false;
/** @var bool */ /** @var bool */
public $warning = false; public bool $warning = false;
/** @var bool */ /** @var bool */
public $info = false; public bool $info = false;
// internal lang & encoding vars // internal lang & encoding vars
/** @var string */ /** @var string */
public $lang_dir = ''; public string $lang_dir = '';
/** @var string */ /** @var string */
public $lang; public string $lang;
/** @var string */ /** @var string */
public $lang_short; public string $lang_short;
/** @var string */ /** @var string */
public $domain; public string $domain;
/** @var string */ /** @var string */
public $encoding; public string $encoding;
/** @var \CoreLibs\Logging\Logging logger */ /** @var \CoreLibs\Logging\Logging logger */
public $log; public \CoreLibs\Logging\Logging $log;
/** @var \CoreLibs\DB\IO database */ /** @var \CoreLibs\DB\IO database */
public $db; public \CoreLibs\DB\IO $db;
/** @var \CoreLibs\Language\L10n language */ /** @var \CoreLibs\Language\L10n language */
public $l; public \CoreLibs\Language\L10n $l;
/** @var \CoreLibs\Create\Session session class */ /** @var \CoreLibs\Create\Session session class */
public $session; public \CoreLibs\Create\Session $session;
// smarty publics [end processing in smarty class] // smarty publics [end processing in smarty class]
/** @var array<mixed> */ /** @var array<mixed> */
public $DATA; public array $DATA = [];
/** @var array<mixed> */ /** @var array<mixed> */
public $HEADER; public array $HEADER = [];
/** @var array<mixed> */ /** @var array<mixed> */
public $DEBUG_DATA; public array $DEBUG_DATA = [];
/** @var array<mixed> */ /** @var array<mixed> */
public $CONTENT_DATA; public array $CONTENT_DATA = [];
// CONSTRUCTOR / DECONSTRUCTOR |====================================> // CONSTRUCTOR / DECONSTRUCTOR |====================================>
/** /**

View File

@@ -20,23 +20,23 @@ use SmartyException;
class EditBase class EditBase
{ {
/** @var array<mixed> */ /** @var array<mixed> */
private $HEADER = []; private array $HEADER = [];
/** @var array<mixed> */ /** @var array<mixed> */
private $DATA = []; private array $DATA = [];
/** @var array<mixed> */ /** @var array<mixed> */
private $DEBUG_DATA = []; private array $DEBUG_DATA = [];
/** @var string the template name */ /** @var string the template name */
private $EDIT_TEMPLATE = ''; private string $EDIT_TEMPLATE = '';
/** @var \CoreLibs\Template\SmartyExtend smarty system */ /** @var \CoreLibs\Template\SmartyExtend smarty system */
private $smarty; private \CoreLibs\Template\SmartyExtend $smarty;
/** @var \CoreLibs\Output\Form\Generate form generate system */ /** @var \CoreLibs\Output\Form\Generate form generate system */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** @var \CoreLibs\Logging\Logging */ /** @var \CoreLibs\Logging\Logging */
public $log; public \CoreLibs\Logging\Logging $log;
/** @var \CoreLibs\ACL\Login */ /** @var \CoreLibs\ACL\Login */
public $login; public \CoreLibs\ACL\Login $login;
/** /**
* construct form generator * construct form generator

View File

@@ -58,30 +58,30 @@ class Basic
{ {
// page and host name // page and host name
/** @var string */ /** @var string */
public $page_name; public string $page_name;
/** @var string */ /** @var string */
public $host_name; public string $host_name;
/** @var int */ /** @var int */
public $host_port; public int $host_port;
// logging interface, Debug\Logging class // logging interface, Debug\Logging class
/** @var \CoreLibs\Logging\Logging */ /** @var \CoreLibs\Logging\Logging */
public $log; public \CoreLibs\Logging\Logging $log;
/** @var \CoreLibs\Create\Session */ /** @var \CoreLibs\Create\Session */
public $session; public \CoreLibs\Create\Session $session;
// email valid checks // email valid checks
/** @var array<mixed> */ /** @var array<mixed> */
public $email_regex_check = []; public array $email_regex_check = [];
/** @var string */ /** @var string */
public $email_regex; // regex var for email check public string $email_regex; // regex var for email check
// data path for files // data path for files
/** @var array<mixed> */ /** @var array<mixed> */
public $data_path = []; public array $data_path = [];
// ajax flag // ajax flag
/** @var bool */ /** @var bool */
protected $ajax_page_flag = false; protected bool $ajax_page_flag = false;
/** /**
* main Basic constructor to init and check base settings * main Basic constructor to init and check base settings

View File

@@ -8,7 +8,7 @@ class Email
{ {
// this is for error check parts in where the email regex failed // this is for error check parts in where the email regex failed
/** @var array<int,string> */ /** @var array<int,string> */
private static $email_regex_check = [ private static array $email_regex_check = [
0 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@" 0 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER . "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER
1 => "@(.*)@(.*)", // double @ 1 => "@(.*)@(.*)", // double @
@@ -21,7 +21,7 @@ class Email
]; ];
// for above position, description string below // for above position, description string below
/** @var array<int,string> */ /** @var array<int,string> */
private static $email_regex_check_message = [ private static array $email_regex_check_message = [
0 => 'Invalid email address', 0 => 'Invalid email address',
1 => 'Double @ mark in email address', 1 => 'Double @ mark in email address',
2 => 'Invalid email part before @ sign', 2 => 'Invalid email part before @ sign',
@@ -33,7 +33,7 @@ class Email
]; ];
// the array with the mobile types that are valid // the array with the mobile types that are valid
/** @var array<string,string> */ /** @var array<string,string> */
private static $mobile_email_type = [ private static array $mobile_email_type = [
'.*@docomo\.ne\.jp$' => 'keitai_docomo', '.*@docomo\.ne\.jp$' => 'keitai_docomo',
// correct are a[2-4], b2, c[1-9], e[2-9], h[2-4], t[1-9] // correct are a[2-4], b2, c[1-9], e[2-9], h[2-4], t[1-9]
'.*@([a-z0-9]{2}\.)?ezweb\.ne\.jp$' => 'keitai_kddi_ezweb', '.*@([a-z0-9]{2}\.)?ezweb\.ne\.jp$' => 'keitai_kddi_ezweb',
@@ -72,7 +72,7 @@ class Email
]; ];
// short list for mobile email types // short list for mobile email types
/** @var array<string,string> */ /** @var array<string,string> */
private static $mobile_email_type_short = [ private static array $mobile_email_type_short = [
'keitai_docomo' => 'docomo', 'keitai_docomo' => 'docomo',
'keitai_kddi_ezweb' => 'kddi', 'keitai_kddi_ezweb' => 'kddi',
'keitai_kddi' => 'kddi', 'keitai_kddi' => 'kddi',

View File

@@ -11,7 +11,7 @@ namespace CoreLibs\Check;
class Encoding class Encoding
{ {
/** @var int<min, -1>|int<1, max>|string */ /** @var int<min, -1>|int<1, max>|string */
private static $mb_error_char = ''; private static int|string $mb_error_char = '';
/** /**
* set error char * set error char

View File

@@ -12,7 +12,7 @@ namespace CoreLibs\Convert;
class MimeAppName class MimeAppName
{ {
/** @var array<string,string> */ /** @var array<string,string> */
private static $mime_apps = []; private static array $mime_apps = [];
/** /**
* constructor: init mime list * constructor: init mime list

View File

@@ -14,7 +14,7 @@ namespace CoreLibs\Create;
class Email class Email
{ {
/** @var array<string> allowed list for encodings that can do KV folding */ /** @var array<string> allowed list for encodings that can do KV folding */
private static $encoding_kv_allowed = [ private static array $encoding_kv_allowed = [
'UTF-8', 'UTF-8',
'EUC-JP', 'EUC-JP',
'SJIS', 'SJIS',
@@ -25,7 +25,7 @@ class Email
'JIS-ms', 'JIS-ms',
]; ];
/** @var string normaly this does not need to be changed */ /** @var string normaly this does not need to be changed */
private static $mb_convert_kana_mode = 'KV'; private static string $mb_convert_kana_mode = 'KV';
/** /**
* create mime encoded email part for to/from emails. * create mime encoded email part for to/from emails.

View File

@@ -10,6 +10,7 @@ namespace CoreLibs\Create;
class Hash class Hash
{ {
public const DEFAULT_HASH = 'adler32';
public const STANDARD_HASH_LONG = 'ripemd160'; public const STANDARD_HASH_LONG = 'ripemd160';
public const STANDARD_HASH_SHORT = 'adler32'; public const STANDARD_HASH_SHORT = 'adler32';
@@ -58,7 +59,7 @@ class Hash
/** /**
* replacemend for __crc32b call (alternate) * replacemend for __crc32b call (alternate)
* defaults to adler 32 * defaults to adler 32
* allowed crc32b, adler32, fnv132, fnv1a32, joaat * allowed: any in hash algos list, default to adler 32
* all that create 8 char long hashes * all that create 8 char long hashes
* *
* @param string $string string to hash * @param string $string string to hash
@@ -67,15 +68,15 @@ class Hash
*/ */
public static function __hash( public static function __hash(
string $string, string $string,
string $hash_type = self::STANDARD_HASH_SHORT string $hash_type = self::DEFAULT_HASH
): string { ): string {
// if not empty, check if in valid list
if ( if (
!in_array( empty($hash_type) ||
$hash_type, !in_array($hash_type, hash_algos())
['crc32b', 'adler32', 'fnv132', 'fnv1a32', 'joaat']
)
) { ) {
$hash_type = 'adler32'; // fallback to default hash type if none set or invalid
$hash_type = self::DEFAULT_HASH;
} }
return hash($hash_type, $string); return hash($hash_type, $string);
} }

View File

@@ -12,13 +12,13 @@ class RandomKey
{ {
// key generation // key generation
/** @var string */ /** @var string */
private static $key_range = ''; private static string $key_range = '';
/** @var int */ /** @var int */
private static $one_key_length; private static int $one_key_length;
/** @var int */ /** @var int */
private static $key_length = 4; // default key length private static int $key_length = 4; // default key length
/** @var int */ /** @var int */
private static $max_key_length = 256; // max allowed length private static int $max_key_length = 256; // max allowed length
/** /**
* if launched as class, init random key data first * if launched as class, init random key data first
@@ -100,7 +100,9 @@ class RandomKey
public static function randomKeyGen(int $key_length = -1): string public static function randomKeyGen(int $key_length = -1): string
{ {
// init random key strings if not set // init random key strings if not set
if (!is_numeric(self::$one_key_length)) { if (
!isset(self::$one_key_length)
) {
self::initRandomKeyData(); self::initRandomKeyData();
} }
$use_key_length = 0; $use_key_length = 0;

View File

@@ -16,7 +16,7 @@ namespace CoreLibs\Create;
class Session class Session
{ {
/** @var string list for errors */ /** @var string list for errors */
private $session_intern_error_str = ''; private string $session_intern_error_str = '';
/** /**
* init a session, if array is empty or array does not have session_name set * init a session, if array is empty or array does not have session_name set

View File

@@ -1,5 +1,12 @@
<?php <?php
/**
* Create uniqIds
*
* If convert ID to hash:
* https://github.com/vinkla/hashids
*/
declare(strict_types=1); declare(strict_types=1);
namespace CoreLibs\Create; namespace CoreLibs\Create;
@@ -7,10 +14,39 @@ namespace CoreLibs\Create;
class Uids class Uids
{ {
// what to use as a default hash if non ise set and no DEFAULT_HASH is defined // what to use as a default hash if non ise set and no DEFAULT_HASH is defined
public const DEFAULT_HASH = 'sha256';
/** @var int */
public const DEFAULT_UNNIQ_ID_LENGTH = 64;
/** @var string */
public const STANDARD_HASH_LONG = 'ripemd160'; public const STANDARD_HASH_LONG = 'ripemd160';
/** @var string */
public const STANDARD_HASH_SHORT = 'adler32'; public const STANDARD_HASH_SHORT = 'adler32';
/**
* Create unique id, lower length is for
*
* @param int $length Length for uniq id, min is 4 characters
* Uneven lengths will return lower bound (9 -> 8)
* @param bool $force_length [default=false] if set to true and we have
* uneven length, then we shorten to this length
* @return string Uniq id
*/
private static function uniqIdL(int $length = 64, bool $force_length = false): string
{
$uniqid_length = ($length < 4) ? 4 : $length;
if ($force_length) {
$uniqid_length++;
}
/** @var int<1,max> make sure that internal this is correct */
$random_bytes_length = ($uniqid_length - ($uniqid_length % 2)) / 2;
$uniqid = bin2hex(random_bytes($random_bytes_length));
// if not forced shorten return next lower length
if (!$force_length) {
return $uniqid;
}
return substr($uniqid, 0, $length);
}
/** /**
* creates psuedo random uuid v4 * creates psuedo random uuid v4
* Code take from class here: * Code take from class here:
@@ -20,7 +56,7 @@ class Uids
*/ */
public static function uuidv4(): string public static function uuidv4(): string
{ {
return sprintf( /* return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x', '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low" // 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
@@ -38,49 +74,62 @@ class Uids
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff) mt_rand(0, 0xffff)
); ); */
$data = random_bytes(16);
assert(strlen($data) == 16);
// 0-1: 32 bits for "time_low"
// 2: 16 bits for "time_mid"
// 3: 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
// 4: 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
// 5-7: 48 bits for "node"
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
} }
/** /**
* TODO: make this a proper uniq ID creation * creates a uniq id based on lengths
* add uuidv4 subcall to the uuid function too
* creates a uniq id
* *
* @param string $type uniq id type, currently md5 or sha256 allowed * @param int|string $length Either length in int, or fallback type for length
* if not set will use DEFAULT_HASH if set * for string type md5 (32), sha256 (64)
* @return string uniq id * STANDARD_HASH_LONG: ripemd160 (40)
* STANDARD_HASH_SHORT: adler32 (8)
* It is recommended to use the integer
* @param bool $force_length [default=false] if set to true and we have
* uneven length, then we shorten to this length
* @return string Uniq id
*/ */
public static function uniqId(string $type = ''): string public static function uniqId(
{ int|string $length = self::DEFAULT_UNNIQ_ID_LENGTH,
$uniq_id = ''; bool $force_length = false
switch ($type) { ): string {
if (is_int($length)) {
return self::uniqIdL($length, $force_length);
}
switch ($length) {
case 'md5': case 'md5':
$uniq_id = md5(uniqid((string)rand(), true)); $length = 32;
break; break;
case self::DEFAULT_HASH: case 'sha256':
$uniq_id = hash(self::DEFAULT_HASH, uniqid((string)rand(), true)); $length = 64;
break; break;
case self::STANDARD_HASH_LONG: case self::STANDARD_HASH_LONG:
$uniq_id = hash(self::STANDARD_HASH_LONG, uniqid((string)rand(), true)); $length = 40;
break; break;
case self::STANDARD_HASH_SHORT: case self::STANDARD_HASH_SHORT:
$uniq_id = hash(self::STANDARD_HASH_SHORT, uniqid((string)rand(), true)); $length = 8;
break; break;
default: default:
// if not empty, check if in valid list $length = 64;
if (
!empty($type) &&
in_array($type, hash_algos())
) {
$hash = $type;
} else {
// fallback to default hash type if none set or invalid
$hash = self::DEFAULT_HASH;
}
$uniq_id = hash($hash, uniqid((string)rand(), true));
break; break;
} }
return $uniq_id; return self::uniqIdL($length);
} }
/** /**

View File

@@ -39,16 +39,16 @@ class ArrayIO extends \CoreLibs\DB\IO
{ {
// main calss variables // main calss variables
/** @var array<mixed> */ /** @var array<mixed> */
public $table_array; // the array from the table to work on public array $table_array; // the array from the table to work on
/** @var string */ /** @var string */
public $table_name; // the table_name public string $table_name; // the table_name
/** @var string */ /** @var string */
public $pk_name = ''; // the primary key from this table public string $pk_name = ''; // the primary key from this table
/** @var int|string|null */ /** @var int|string|null */
public $pk_id; // the PK id public int|string|null $pk_id; // the PK id
// security values // security values
/** @var int base acl for current page */ /** @var int base acl for current page */
private $base_acl_level = 0; private int $base_acl_level = 0;
/** /**
* constructor for the array io class, set the * constructor for the array io class, set the

View File

@@ -298,101 +298,98 @@ class IO
// can bet set from outside // can bet set from outside
// encoding to // encoding to
/** @var string */ /** @var string */
private $to_encoding = ''; private string $to_encoding = '';
/** @var string */ /** @var string the query string at the moment */
private $query; // the query string at the moment private string $query;
/** @var array<mixed> */ /** @var array<mixed> current params for query */
private $params; // current params for query private array $params;
// only inside // only inside
// basic vars // basic vars
/** @var \PgSql\Connection|false|null */ // replace object with PgSql\Connection| // the dbh handler, if disconnected by command is null, bool:false on error,
private $dbh; // the dbh handler, if disconnected by command is null, bool:false on error, /** @var \PgSql\Connection|false|null */
/** @var bool */ private \PgSql\Connection|false|null $dbh;
private $db_debug = false; // DB_DEBUG ... (if set prints out debug msgs) /** @var bool DB_DEBUG ... (if set prints out debug msgs) */
/** @var string */ private bool $db_debug = false;
private $db_name; // the DB connected to /** @var string the DB connected to */
/** @var string */ private string $db_name;
private $db_user; // the username used /** @var string the username used */
/** @var string */ private string $db_user;
private $db_pwd; // the password used /** @var string the password used*/
/** @var string */ private string $db_pwd;
private $db_host; // the hostname /** @var string the hostname */
/** @var int */ private string $db_host;
private $db_port; // default db port /** @var int default db port */
/** @var string */ private int $db_port;
private $db_schema; // optional DB schema, if not set uses public /** @var string optional DB schema, if not set uses public*/
/** @var string */ private string $db_schema;
private $db_encoding; // optional auto encoding convert, not used if not set /** @var string optional auto encoding convert, not used if not set */
/** @var string */ private string $db_encoding;
private $db_type; // type of db (mysql,postgres,...) /** @var string type of db (mysql,postgres,...) */
/** @var string */ private string $db_type;
private $db_ssl; // ssl flag (for postgres only), disable, allow, prefer, require /** @var string ssl flag (for postgres only), disable, allow, prefer, require */
private string $db_ssl;
// FOR BELOW: (This should be private and only readable through some method) // FOR BELOW: (This should be private and only readable through some method)
// cursor array for cached readings // cursor array for cached readings
/** @var array<mixed,mixed> */ /** @var array<string,mixed> extended cursoers string index with content */
private $cursor_ext; // hash of hashes private array $cursor_ext;
// per query vars // per query vars
/** @var \PgSql\Result|false */ // replace object with PgSql\Result /** @var \PgSql\Result|false actual cursor (DBH) */
private $cursor; // actual cursor (DBH) private \PgSql\Result|false $cursor;
/** @var int */ /** @var int how many rows have been found */
private $num_rows; // how many rows have been found private int $num_rows;
/** @var int */ /** @var int how many fields has the query */
private $num_fields; // how many fields has the query private int $num_fields;
/** @var array<string> array with the field names of the current query */ /** @var array<string> array with the field names of the current query */
private $field_names = []; private array $field_names = [];
/** @var array<string> field type names */ /** @var array<string> field type names */
private $field_types = []; private array $field_types = [];
/** @var array<mixed> */ /** @var array<mixed> always return as array, even if only one */
private $insert_id_arr = []; // always return as array, even if only one private array $insert_id_arr = [];
/** @var string */ /** @var string primary key name for insert recovery from insert_id_arr */
private $insert_id_pk_name; // primary key name for insert recovery from insert_id_arr private string $insert_id_pk_name;
// other vars // other vars
/** @var string */ /** @var string used by print_array recursion function */
private $nbsp = ''; // used by print_array recursion function private string $nbsp = '';
// error & warning id // error & warning id
/** @var string */ /** @var string */
private $error_id; private string $error_id;
/** @var string */ /** @var string */
private $warning_id; private string $warning_id;
/** @var string */ /** @var string */
private $error_history_id; private string $error_history_id;
/** @var array<mixed> Stores warning and errors combinded with detail info */ /** @var array<mixed> Stores warning and errors combinded with detail info */
private $error_history_long = []; private array $error_history_long = [];
// error thrown on class init if we cannot connect to db /** @var bool error thrown on class init if we cannot connect to db */
/** @var bool */ protected bool $db_connection_closed = false;
protected $db_connection_closed = false;
// sub include with the database functions // sub include with the database functions
/** @var \CoreLibs\DB\SQL\PgSQL if we have other DB types we need to add them here */ /** @var \CoreLibs\DB\SQL\PgSQL if we have other DB types we need to add them here */
private $db_functions; private \CoreLibs\DB\SQL\PgSQL $db_functions;
// endless loop protection // endless loop protection
/** @var int */ /** @var int */
private $MAX_QUERY_CALL; private int $MAX_QUERY_CALL;
/** @var int */ /** @var int maxium query calls allowed in a dbReturnRow loop before we error out */
public const DEFAULT_MAX_QUERY_CALL = 20; // default public const DEFAULT_MAX_QUERY_CALL = 20;
/** @var array<mixed> */ /** @var array<mixed> */
private $query_called = []; private array $query_called = [];
// error string // error string
/** @var array<mixed> */ /** @var array<mixed> */
protected $error_string = []; protected array $error_string = [];
// prepared list // prepared list
/** @var array<mixed> */ /** @var array<mixed> */
private $prepare_cursor = []; private array $prepare_cursor = [];
// primary key per table list // primary key per table list
// format is 'table' => 'pk_name' // format is 'table' => 'pk_name'
/** @var array<mixed> */ /** @var array<mixed> */
private $pk_name_table = []; private array $pk_name_table = [];
// internal primary key name, for cross calls in async /** @var string internal primary key name, for cross calls in async */
/** @var string */ private string $pk_name;
private $pk_name; /** @var bool if we use RETURNING in the INSERT call */
// if we use RETURNING in the INSERT call private bool $returning_id = false;
/** @var bool */ /** @var string if a sync is running holds the hash key of the query */
private $returning_id = false; private string $async_running;
// if a sync is running holds the hash key of the query
/** @var string */
private $async_running;
// logging class, must be public so settings can be changed // logging class, must be public so settings can be changed
/** @var \CoreLibs\Logging\Logging */ /** @var \CoreLibs\Logging\Logging */
public $log; public \CoreLibs\Logging\Logging $log;
/** /**
* main DB concstructor with auto connection to DB and failure set on failed connection * main DB concstructor with auto connection to DB and failure set on failed connection

View File

@@ -59,9 +59,9 @@ namespace CoreLibs\DB\SQL;
class PgSQL implements Interface\SqlFunctions class PgSQL implements Interface\SqlFunctions
{ {
/** @var string */ /** @var string */
private $last_error_query; private string $last_error_query;
/** @var \PgSql\Connection|false */ /** @var \PgSql\Connection|false */
private $dbh = false; private \PgSql\Connection|false $dbh = false;
/** /**
* queries last error query and returns true or false if error was set * queries last error query and returns true or false if error was set

View File

@@ -12,9 +12,9 @@ namespace CoreLibs\Debug;
class FileWriter class FileWriter
{ {
/** @var string */ /** @var string */
private static $debug_filename = 'debug_file.log'; // where to write output private static string $debug_filename = 'debug_file.log'; // where to write output
/** @var string */ /** @var string */
private static $debug_folder; private static string $debug_folder;
/** /**
* Set a debug log folder, if not set BASE+LOG folders are set * Set a debug log folder, if not set BASE+LOG folders are set

View File

@@ -13,13 +13,13 @@ use CoreLibs\Convert\Byte;
class MemoryUsage class MemoryUsage
{ {
/** @var int */ /** @var int */
private static $start_memory = 0; private static int $start_memory = 0;
/** @var int */ /** @var int */
private static $set_memory = 0; private static int $set_memory = 0;
/** @var int */ /** @var int */
private static $previous_memory = 0; private static int $previous_memory = 0;
/** @var bool */ /** @var bool */
private static $debug_memory = false; private static bool $debug_memory = false;
/** /**
* set memory flag, or return set memory flag * set memory flag, or return set memory flag

View File

@@ -12,18 +12,18 @@ class RunningTime
{ {
// hr // hr
/** @var float */ /** @var float */
private static $hr_start_time; private static float $hr_start_time;
/** @var float */ /** @var float */
private static $hr_end_time; private static float $hr_end_time;
/** @var float */ /** @var float */
private static $hr_last_time; private static float $hr_last_time;
// normal // normal
/** @var float */ /** @var float */
private static $start_time; private static float $start_time;
/** @var float */ /** @var float */
private static $end_time; private static float $end_time;
/** @var string */ /** @var string */
private static $running_time_string; private static string $running_time_string;
/** /**
* sub calculation for running time based on out time. * sub calculation for running time based on out time.
@@ -79,7 +79,7 @@ class RunningTime
public static function hrRunningTime(string $out_time = 'ms'): float public static function hrRunningTime(string $out_time = 'ms'): float
{ {
// if start time not set, set start time // if start time not set, set start time
if (!self::$hr_start_time) { if (empty(self::$hr_start_time)) {
self::$hr_start_time = hrtime(true); self::$hr_start_time = hrtime(true);
self::$hr_last_time = self::$hr_start_time; self::$hr_last_time = self::$hr_start_time;
$run_time = 0; $run_time = 0;
@@ -137,7 +137,7 @@ class RunningTime
list($micro, $timestamp) = explode(' ', microtime()); list($micro, $timestamp) = explode(' ', microtime());
$running_time = 0; $running_time = 0;
// set start & end time // set start & end time
if (!self::$start_time) { if (empty(self::$start_time)) {
// always reset running time string on first call // always reset running time string on first call
self::$running_time_string = ''; self::$running_time_string = '';
self::$start_time = ((float)$micro + (float)$timestamp); self::$start_time = ((float)$micro + (float)$timestamp);
@@ -149,7 +149,7 @@ class RunningTime
self::$running_time_string .= date('Y-m-d H:i:s', (int)$timestamp); self::$running_time_string .= date('Y-m-d H:i:s', (int)$timestamp);
self::$running_time_string .= ' ' . $micro . ($simple ? ', ' : '<br>'); self::$running_time_string .= ' ' . $micro . ($simple ? ', ' : '<br>');
// if both are set // if both are set
if (self::$start_time && self::$end_time) { if (!empty(self::$start_time) && !empty(self::$end_time)) {
$running_time = self::$end_time - self::$start_time; $running_time = self::$end_time - self::$start_time;
self::$running_time_string .= ($simple ? 'Run: ' : "<b>Script running time</b>: ") . $running_time . " s"; self::$running_time_string .= ($simple ? 'Run: ' : "<b>Script running time</b>: ") . $running_time . " s";
// reset start & end time after run // reset start & end time after run

View File

@@ -21,7 +21,7 @@ class Support
*/ */
public static function printTime(int $set_microtime = -1): string public static function printTime(int $set_microtime = -1): string
{ {
list($microtime, $timestamp) = explode(' ', microtime()); [$microtime, $timestamp] = explode(' ', microtime());
$string = date("Y-m-d H:i:s", (int)$timestamp); $string = date("Y-m-d H:i:s", (int)$timestamp);
// if microtime flag is -1 no round, if 0, no microtime, if >= 1, round that size // if microtime flag is -1 no round, if 0, no microtime, if >= 1, round that size
if ($set_microtime == -1) { if ($set_microtime == -1) {
@@ -158,19 +158,32 @@ class Support
* var_dump based * var_dump based
* Recommended debug output * Recommended debug output
* *
* @param mixed $data Anything * @param mixed $data Anything
* @param bool $no_html If true strip all html tags (for text print) * @param bool $no_html [default=false] If true strip all html tags
* @return string A text string * (for text print)
* @return string A text string
*/ */
public static function dumpVar(mixed $data, bool $no_html = false): string public static function dumpVar(
{ mixed $data,
bool $no_html = false,
): string {
// dump data
ob_start(); ob_start();
var_dump($data); var_dump($data);
$debug_dump = ob_get_clean() ?: '[FAILED TO GET var_dump() data]'; $debug_dump = ob_get_clean() ?: '[FAILED TO GET var_dump() data]';
// check if the original caller is dV, if yes, up the caller level for
// the file line get by 1, so we get file + pos from the dV call and
// not this call
$caller_level = 1;
$caller_list = self::getCallerMethodList();
if ($caller_list[0] == 'dV') {
echo "Raise caller level<br>: " . $caller_list[0] . "<br>";
$caller_level = 2;
}
// we need to strip the string in <small></small that is // we need to strip the string in <small></small that is
// "path ... CoreLibs/Debug/Support.php:<number>: // "path ... CoreLibs/Debug/Support.php:<number>:
// and replace it with the caller methods and location // and replace it with the caller methods and location
$caller_file_number = self::getCallerFileLine(); $caller_file_number = self::getCallerFileLine($caller_level);
$debug_dump = preg_replace( $debug_dump = preg_replace(
'|<small>(/.*:\d+:)</small>|', '|<small>(/.*:\d+:)</small>|',
'<small>' . $caller_file_number . ':</small>', '<small>' . $caller_file_number . ':</small>',

View File

@@ -54,14 +54,15 @@ class System
/** /**
* get the host name without the port as given by the SELF var * get the host name without the port as given by the SELF var
* if no host name found will set to NOHOST:0
* *
* @return array<mixed> host name/port name * @return array{string,int} host name/port number
*/ */
public static function getHostName(): array public static function getHostName(): array
{ {
$host = $_SERVER['HTTP_HOST'] ?? 'NOHOST:NOPORT'; $host = $_SERVER['HTTP_HOST'] ?? 'NOHOST:0';
list($host_name, $port) = array_pad(explode(':', $host), 2, self::DEFAULT_PORT); [$host_name, $port] = array_pad(explode(':', $host), 2, self::DEFAULT_PORT);
return [$host_name, $port]; return [$host_name, (int)$port];
} }
/** /**

View File

@@ -29,9 +29,9 @@ namespace CoreLibs\Language\Core;
class CachedFileReader extends \CoreLibs\Language\Core\StringReader class CachedFileReader extends \CoreLibs\Language\Core\StringReader
{ {
/** @var int */ /** @var int */
public $error = 0; public int $error = 0;
/** @var string */ /** @var string */
public $fd_str = ''; public string $fd_str = '';
/** /**
* Undocumented function * Undocumented function

View File

@@ -27,13 +27,13 @@ namespace CoreLibs\Language\Core;
class FileReader class FileReader
{ {
/** @var int */ /** @var int */
public $fr_pos; public int $fr_pos;
/** @var resource|bool */ /** @var resource|bool */
public $fr_fd; public mixed $fr_fd; // no resource type yet
/** @var int */ /** @var int */
public $fr_length; public int $fr_length;
/** @var int */ /** @var int */
public $error = 0; public int $error = 0;
/** /**
* file read constructor * file read constructor

View File

@@ -41,31 +41,31 @@ class GetTextReader
{ {
// public: // public:
/** @var int */ /** @var int */
public $error = 0; // public variable that holds error code (0 if no error) public int $error = 0; // public variable that holds error code (0 if no error)
// private: // private:
/** @var int */ /** @var int */
private $BYTEORDER = 0; // 0: low endian, 1: big endian private int $BYTEORDER = 0; // 0: low endian, 1: big endian
/** @var FileReader */ /** @var FileReader */
private $STREAM; private FileReader $STREAM;
/** @var bool */ /** @var bool */
private $short_circuit = false; private bool $short_circuit = false;
/** @var bool */ /** @var bool */
private $enable_cache = false; private bool $enable_cache = false;
/** @var int */ /** @var int */
private $originals = 0; // offset of original table private int $originals = 0; // offset of original table
/** @var int */ /** @var int */
private $translations = 0; // offset of translation table private int $translations = 0; // offset of translation table
/** @var string */ /** @var string */
private $pluralheader = ''; // cache header field for plural forms private string $pluralheader = ''; // cache header field for plural forms
/** @var int */ /** @var int */
private $total = 0; // total string count private int $total = 0; // total string count
/** @var array<mixed>|null */ /** @var array<mixed>|null */
private $table_originals = null; // table for original strings (offsets) private array|null $table_originals = null; // table for original strings (offsets)
/** @var array<mixed>|null */ /** @var array<mixed>|null */
private $table_translations = null; // table for translated strings (offsets) private array|null $table_translations = null; // table for translated strings (offsets)
/** @var array<mixed> */ /** @var array<mixed> */
private $cache_translations = []; // original -> translation mapping private array $cache_translations = []; // original -> translation mapping
/* Methods */ /* Methods */

View File

@@ -27,9 +27,9 @@ namespace CoreLibs\Language\Core;
class StringReader class StringReader
{ {
/** @var int */ /** @var int */
public $sr_pos; public int $sr_pos;
/** @var string */ /** @var string */
public $sr_str; public string $sr_str;
/** /**
* constructor for string reader * constructor for string reader

View File

@@ -35,42 +35,42 @@ class L10n
/** @var string the default fallback encoding if nothing is set */ /** @var string the default fallback encoding if nothing is set */
public const DEFAULT_CHARSET = 'UTF-8'; public const DEFAULT_CHARSET = 'UTF-8';
/** @var string the current locale */ /** @var string the current locale */
private $locale = ''; private string $locale = '';
/** @var string the SET locale as WHERE the domain file is */ /** @var string the SET locale as WHERE the domain file is */
private $locale_set = ''; private string $locale_set = '';
/** @var string the default selected/active domain */ /** @var string the default selected/active domain */
private $domain = ''; private string $domain = '';
/** @var string encoding, as from locale or set from outside */ /** @var string encoding, as from locale or set from outside */
private $override_encoding = self::DEFAULT_CHARSET; private string $override_encoding = self::DEFAULT_CHARSET;
/** @var string encoding set during the parse Locale */ /** @var string encoding set during the parse Locale */
private $encoding = ''; private string $encoding = '';
/** @var array<string,array<string,GetTextReader>> locale > domain = translator */ /** @var array<string,array<string,GetTextReader>> locale > domain = translator */
private $domains = []; private array $domains = [];
/** @var array<string,string> bound paths for domains */ /** @var array<string,string> bound paths for domains */
private $paths = ['' => './']; private array $paths = ['' => './'];
// files // files
/** @var string the full path to the mo file to loaded */ /** @var string the full path to the mo file to loaded */
private $mofile = ''; private string $mofile = '';
/** @var string base path to search level */ /** @var string base path to search level */
private $base_locale_path = ''; private string $base_locale_path = '';
/** @var string dynamic set path to where the mo file is actually */ /** @var string dynamic set path to where the mo file is actually */
private $base_content_path = ''; private string $base_content_path = '';
// errors // errors
/** @var bool if load of mo file was unsuccessful */ /** @var bool if load of mo file was unsuccessful */
private $load_failure = false; private bool $load_failure = false;
// object holders // object holders
/** @var FileReader|bool reader class for file reading, false for short circuit */ /** @var FileReader|bool reader class for file reading, false for short circuit */
private $input = false; private FileReader|bool $input = false;
/** @var GetTextReader reader class for MO data */ /** @var GetTextReader reader class for MO data */
private $l10n; private GetTextReader|null $l10n = null;
/** /**
* @static * @static
* @var L10n self class * @var L10n self class
*/ */
private static $instance; private static L10n $instance;
/** /**
* class constructor call for language getstring * class constructor call for language getstring
@@ -124,7 +124,6 @@ class L10n
*/ */
public static function getInstance(): L10n public static function getInstance(): L10n
{ {
/** @phpstan-ignore-next-line */
if (empty(self::$instance)) { if (empty(self::$instance)) {
self::$instance = new self(); self::$instance = new self();
} }
@@ -253,6 +252,13 @@ class L10n
// dummy // dummy
$this->l10n = new GetTextReader($this->input); $this->l10n = new GetTextReader($this->input);
} }
// if this is still null here, we abort
if ($this->l10n === null) {
throw new \Exception(
"Could not create CoreLibs\Language\Core\GetTextReader object",
E_USER_ERROR
);
}
return $this->l10n; return $this->l10n;
} }
@@ -673,6 +679,7 @@ class L10n
// fallback passthrough // fallback passthrough
if ($this->l10n === null) { if ($this->l10n === null) {
echo $text; echo $text;
return;
} }
echo $this->l10n->translate($text); echo $this->l10n->translate($text);
} }

View File

@@ -6,7 +6,12 @@
* DESCRIPTION: * DESCRIPTION:
* Logging class * Logging class
* *
* NOTE: This is Logging2 for testing simpler build * Build on the old logging class but can no longer print to screen
* Adds all standard logging levels
*
* Will be superseeded or will be inbetween to Monolog:
* https://github.com/Seldaek/monolog
* CoreLibs\Logging\Logger\Level is a direct copy from Monolog
*/ */
declare(strict_types=1); declare(strict_types=1);
@@ -81,38 +86,38 @@ class Logging
// options // options
/** @var array<mixed> */ /** @var array<mixed> */
private $options = []; private array $options = [];
/** @var Level set level */ /** @var Level set level */
private $log_level; private Level $log_level;
// page and host name // page and host name
/** @var string */ /** @var string */
private $host_name; private string $host_name;
/** @var int */ /** @var int */
private $host_port; private int $host_port;
/** @var string unique ID set on class init and used in logging as prefix */ /** @var string unique ID set on class init and used in logging as prefix */
private $running_uid = ''; private string $running_uid = '';
// log file name // log file name
/** @var string */ /** @var string */
private $log_folder = ''; private string $log_folder = '';
/** @var string a alphanumeric name that has to be set as global definition */ /** @var string a alphanumeric name that has to be set as global definition */
private $log_file_id = ''; private string $log_file_id = '';
/** @var string log file name extension */ /** @var string log file name extension */
private $log_file_name_ext = 'log'; private string $log_file_name_ext = 'log';
/** @var string log file name with folder, for actual writing */ /** @var string log file name with folder, for actual writing */
private $log_file_name = ''; private string $log_file_name = '';
/** @var int set in bytes */ /** @var int set in bytes */
private $log_max_filesize = 0; private int $log_max_filesize = 0;
/** @var string used if no log id set or found */ /** @var string used if no log id set or found */
private $log_file_prefix = 'error_msg'; private string $log_file_prefix = 'error_msg';
/** @var string */ /** @var string */
private $log_print_file = '{LOGID}{LEVEL}{GROUP}{CLASS}{PAGENAME}{DATE_RUNID}'; private string $log_print_file = '{LOGID}{LEVEL}{GROUP}{CLASS}{PAGENAME}{DATE_RUNID}';
/** @var string a unique ID set only once for call derived from this class */ /** @var string a unique ID set only once for call derived from this class */
private $log_file_unique_id = ''; private string $log_file_unique_id = '';
/** @var string Y-m-d file in file name */ /** @var string Y-m-d file in file name */
private $log_file_date = ''; private string $log_file_date = '';
/** /**
* 1: create a new log file per run (time stamp + unique ID) * 1: create a new log file per run (time stamp + unique ID)
@@ -123,9 +128,9 @@ class Logging
* 32: split log per set log level * 32: split log per set log level
*/ */
/** @var int bitwise set for log flags */ /** @var int bitwise set for log flags */
private $log_flags = 0; private int $log_flags = 0;
/** @var array<string,Flag> valid log flag names */ /** @var array<string,Flag> valid log flag names */
private $log_valid_flags = [ private array $log_valid_flags = [
'log_per_run' => Flag::per_run, 'log_per_run' => Flag::per_run,
'log_per_date' => Flag::per_date, 'log_per_date' => Flag::per_date,
'log_per_group' => Flag::per_group, 'log_per_group' => Flag::per_group,
@@ -323,10 +328,10 @@ class Logging
private function initHostName(): void private function initHostName(): void
{ {
// set host name // set host name
list($this->host_name , $this->host_port) = System::getHostName(); [$this->host_name, $this->host_port] = System::getHostName();
// add port to host name if not port 80 // add port to host name if not port 80
if ($this->host_port != 80) { if ($this->host_port != 80) {
$this->host_name .= ':' . $this->host_port; $this->host_name .= ':' . (string)$this->host_port;
} }
} }
@@ -543,8 +548,16 @@ class Logging
array $context = [], array $context = [],
string $group_id = '', string $group_id = '',
): string { ): string {
// file + line: call not this but one before (the one that calls this)
$file_line = Support::getCallerFileLine(2) ??
System::getPageName(System::FULL_PATH);
// get the last class entry and wrie that // get the last class entry and wrie that
$class = Support::getCallerClass(); $class = Support::getCallerClass();
// method/function: prepareLog->(debug|info|...)->[THIS]
$method = Support::getCallerMethod(3);
if ($method !== null) {
$class .= '::' . $method;
}
// get timestamp // get timestamp
$timestamp = Support::printTime(); $timestamp = Support::printTime();
@@ -562,7 +575,7 @@ class Logging
// build log string // build log string
return '[' . $timestamp . '] ' return '[' . $timestamp . '] '
. '[' . $this->host_name . '] ' . '[' . $this->host_name . '] '
. '[' . System::getPageName(System::FULL_PATH) . '] ' . '[' . $file_line . '] '
. '[' . $this->running_uid . '] ' . '[' . $this->running_uid . '] '
. '{' . $class . '} ' . '{' . $class . '} '
. '<' . strtoupper($group_str) . '> ' . '<' . strtoupper($group_str) . '> '
@@ -598,7 +611,6 @@ class Logging
. implode(', ', Level::NAMES + Level::VALUES) . implode(', ', Level::NAMES + Level::VALUES)
); );
} }
return $levelEnum; return $levelEnum;
} }
@@ -710,7 +722,10 @@ class Logging
if (empty($this->log_file_unique_id) || $override == true) { if (empty($this->log_file_unique_id) || $override == true) {
$this->log_file_unique_id = $this->log_file_unique_id =
date('Y-m-d_His') . '_U_' date('Y-m-d_His') . '_U_'
. substr(hash('sha1', uniqid((string)mt_rand(), true)), 0, 8); . substr(hash(
'sha1',
random_bytes(63)
), 0, 8);
} }
} }

View File

@@ -226,84 +226,84 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// for the load statetment describes which elements from // for the load statetment describes which elements from
// the load query should be shown and i which format // the load query should be shown and i which format
/** @var array<mixed> */ /** @var array<mixed> */
public $field_array = []; public array $field_array = [];
/** @var string */ /** @var string */
public $load_query; // the query needed for loading a data set (one row in the table) public string $load_query; // the query needed for loading a data set (one row in the table)
/** @var string */ /** @var string */
public $col_name; // the name of the columen (before _<type>) [used for order button] public string $col_name; // the name of the columen (before _<type>) [used for order button]
/** @var int */ /** @var int */
public $yes; // the yes flag that triggers the template to show ALL and not only new/load public int $yes; // the yes flag that triggers the template to show ALL and not only new/load
/** @var string */ /** @var string */
public $msg; // the error msg public string $msg; // the error msg
/** @var int */ /** @var int */
public $error; // the error flag set for printing red error msg public int $error; // the error flag set for printing red error msg
/** @var int */ /** @var int */
public $warning; // warning flag, for information (saved, loaded, etc) public int $warning; // warning flag, for information (saved, loaded, etc)
/** @var string */ /** @var string */
public $archive_pk_name; // the pk name for the load select form public string $archive_pk_name; // the pk name for the load select form
/** @var string */ /** @var string */
private $int_pk_name; // primary key, only internal usage private string $int_pk_name; // primary key, only internal usage
/** @var array<mixed> */ /** @var array<mixed> */
public $reference_array = []; // reference arrays -> stored in $this->reference_array[$table_name] => []; public array $reference_array = []; // reference arrays -> stored in $this->reference_array[$table_name] => [];
// NOTE: should be changed to this @var mixed[] // NOTE: should be changed to this @var mixed[]
/** @var array<mixed> */ /** @var array<mixed> */
public $element_list; // element list for elements next to each other as a special sub group public array $element_list; // element list for elements next to each other as a special sub group
/** @var array<mixed> */ /** @var array<mixed> */
public $table_array = []; public array $table_array = [];
/** @var string */ /** @var string */
public $my_page_name; // the name of the page without .php extension public string $my_page_name; // the name of the page without .php extension
/** @var bool */ /** @var bool */
public $mobile_phone = false; public bool $mobile_phone = false;
/** @var string */ /** @var string */
public $email_regex; public string $email_regex;
// buttons and checkboxes // buttons and checkboxes
/** @var string */ /** @var string */
public $archive; public string $archive;
/** @var string */ /** @var string */
public $new; public string $new;
/** @var string */ /** @var string */
public $really_new; public string $really_new;
/** @var string */ /** @var string */
public $delete; public string $delete;
/** @var string */ /** @var string */
public $really_delete; public string $really_delete;
/** @var string */ /** @var string */
public $save; public string $save;
/** @var string */ /** @var string */
public $remove_button; public string $remove_button;
// security values // security values
/** @var int base acl for current page */ /** @var int base acl for current page */
private $base_acl_level = 0; private int $base_acl_level = 0;
/** @var int admin master flag (1/0) */ /** @var int admin master flag (1/0) */
private $acl_admin = 0; private int $acl_admin = 0;
/** @var array<mixed> */ /** @var array<mixed> */
public $security_level; public array $security_level;
/** @var array<string,mixed> Login ACL */ /** @var array<string,mixed> Login ACL */
public $login_acl = []; public array $login_acl = [];
// layout publics // layout publics
/** @var int */ /** @var int */
public $table_width; public int $table_width;
// internal lang & encoding vars // internal lang & encoding vars
/** @var string */ /** @var string */
public $lang_dir = ''; public string $lang_dir = '';
/** @var string */ /** @var string */
public $lang; public string $lang;
/** @var string */ /** @var string */
public $lang_short; public string $lang_short;
/** @var string */ /** @var string */
public $domain; public string $domain;
/** @var string */ /** @var string */
public $encoding; public string $encoding;
// language // language
/** @var \CoreLibs\Language\L10n */ /** @var \CoreLibs\Language\L10n */
public $l; public \CoreLibs\Language\L10n $l;
// log // log
/** @var \CoreLibs\Logging\Logging */ /** @var \CoreLibs\Logging\Logging */
public $log; public \CoreLibs\Logging\Logging $log;
// now some default error msgs (english) // now some default error msgs (english)
/** @var array<mixed> */ /** @var array<mixed> */
public $language_array = []; public array $language_array = [];
/** /**
* construct form generator * construct form generator

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditAccess implements Interface\TableArraysInterface class EditAccess implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditGroups implements Interface\TableArraysInterface class EditGroups implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditLanguages implements Interface\TableArraysInterface class EditLanguages implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditMenuGroup implements Interface\TableArraysInterface class EditMenuGroup implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditPages implements Interface\TableArraysInterface class EditPages implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditSchemas implements Interface\TableArraysInterface class EditSchemas implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditUsers implements Interface\TableArraysInterface class EditUsers implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
class EditVisibleGroup implements Interface\TableArraysInterface class EditVisibleGroup implements Interface\TableArraysInterface
{ {
/** @var \CoreLibs\Output\Form\Generate */ /** @var \CoreLibs\Output\Form\Generate */
private $form; private \CoreLibs\Output\Form\Generate $form;
/** /**
* constructor * constructor

View File

@@ -23,13 +23,13 @@ class ProgressBar
// private vars // private vars
/** @var string */ /** @var string */
public $code; // unique code public string $code; // unique code
/** @var string */ /** @var string */
public $status = 'new'; // current status (new,show,hide) public string $status = 'new'; // current status (new,show,hide)
/** @var float|int */ /** @var float|int */
public $step = 0; // current step public float|int $step = 0; // current step
/** @var array<string,null|int|float> */ /** @var array<string,null|int|float> */
public $position = [ // current bar position public array $position = [ // current bar position
'left' => null, 'left' => null,
'top' => null, 'top' => null,
'width' => null, 'width' => null,
@@ -37,43 +37,43 @@ class ProgressBar
]; ];
/** @var int */ /** @var int */
public $clear_buffer_size = 1; // we need to send this before the lfush to get browser output public int $clear_buffer_size = 1; // we need to send this before the lfush to get browser output
/** @var int */ /** @var int */
public $clear_buffer_size_init = 1024 * 1024; // if I don't send that junk, it won't send anything public int $clear_buffer_size_init = 1024 * 1024; // if I don't send that junk, it won't send anything
// public vars // public vars
/** @var int */ /** @var int */
public $min = 0; // minimal steps public int $min = 0; // minimal steps
/** @var int */ /** @var int */
public $max = 100; // maximal steps public int $max = 100; // maximal steps
/** @var int */ /** @var int */
public $left = 5; // bar position from left public int $left = 5; // bar position from left
/** @var int */ /** @var int */
public $top = 5; // bar position from top public int $top = 5; // bar position from top
/** @var int */ /** @var int */
public $width = 300; // bar width public int $width = 300; // bar width
/** @var int */ /** @var int */
public $height = 25; // bar height public int $height = 25; // bar height
/** @var int */ /** @var int */
public $pedding = 0; // bar pedding public int $pedding = 0; // bar pedding
/** @var string */ /** @var string */
public $color = '#0033ff'; // bar color public string $color = '#0033ff'; // bar color
/** @var string */ /** @var string */
public $bgr_color = '#c0c0c0'; // bar background color public string $bgr_color = '#c0c0c0'; // bar background color
/** @var string */ /** @var string */
public $bgr_color_master = '#ffffff'; // master div background color public string $bgr_color_master = '#ffffff'; // master div background color
/** @var int */ /** @var int */
public $border = 1; // bar border width public int $border = 1; // bar border width
/** @var string */ /** @var string */
public $brd_color = '#000000'; // bar border color public string $brd_color = '#000000'; // bar border color
/** @var string */ /** @var string */
public $direction = 'right'; // direction of motion (right,left,up,down) public string $direction = 'right'; // direction of motion (right,left,up,down)
/** @var array<string,string|bool|int> */ /** @var array<string,string|bool|int> */
public $frame = ['show' => false]; // ProgressBar Frame public array $frame = ['show' => false]; // ProgressBar Frame
/* 'show' => false, # frame show (true/false) /* 'show' => false, # frame show (true/false)
'left' => 200, # frame position from left 'left' => 200, # frame position from left
'top' => 100, # frame position from top 'top' => 100, # frame position from top
@@ -86,7 +86,7 @@ class ProgressBar
/** @#var array{string}{string: string|int} */ /** @#var array{string}{string: string|int} */
/** @var mixed[][] */ /** @var mixed[][] */
public $label = []; // ProgressBar Labels public array $label = []; // ProgressBar Labels
/* 'name' => [ # label name /* 'name' => [ # label name
'type' => 'text', # label type (text,button,step,percent,crossbar) 'type' => 'text', # label type (text,button,step,percent,crossbar)
'value' => 'Please wait ...', # label value 'value' => 'Please wait ...', # label value
@@ -105,7 +105,7 @@ class ProgressBar
/** @var string */ /** @var string */
// output strings // output strings
public $prefix_message = ''; public string $prefix_message = '';
/** /**
* progress bar constructor * progress bar constructor

View File

@@ -2,7 +2,9 @@
/** /**
* very simple symmetric encryption * very simple symmetric encryption
* Better use: https://paragonie.com/project/halite * Better use:
* https://paragonie.com/project/halite
* https://github.com/paragonie/halite
* *
* current code is just to encrypt and decrypt * current code is just to encrypt and decrypt
* *

View File

@@ -24,134 +24,132 @@ class SmartyExtend extends \Smarty
{ {
// internal translation engine // internal translation engine
/** @var \CoreLibs\Language\L10n */ /** @var \CoreLibs\Language\L10n */
public $l10n; public \CoreLibs\Language\L10n $l10n;
// lang & encoding // lang & encoding
/** @var string */ /** @var string */
public $lang_dir = ''; public string $lang_dir = '';
/** @var string */ /** @var string */
public $lang; public string $lang;
/** @var string */ /** @var string */
public $locale_set; public string $lang_short;
/** @var string */ /** @var string */
public $lang_short; public string $domain;
/** @var string */ /** @var string */
public $domain; public string $encoding;
/** @var string */
public $encoding;
// page name // page name
/** @var string */ /** @var string */
public $page_name; public string $page_name;
// array for data parsing // array for data parsing
/** @var array<mixed> */ /** @var array<mixed> */
public $HEADER = []; public array $HEADER = [];
/** @var array<mixed> */ /** @var array<mixed> */
public $DATA = []; public array $DATA = [];
/** @var array<mixed> */ /** @var array<mixed> */
public $DEBUG_DATA = []; public array $DEBUG_DATA = [];
/** @var array<mixed> */ /** @var array<mixed> */
private $CONTENT_DATA = []; private array $CONTENT_DATA = [];
// control vars // control vars
/** @var bool */ /** @var bool */
public $USE_PROTOTYPE = USE_PROTOTYPE; public bool $USE_PROTOTYPE = USE_PROTOTYPE;
/** @var bool */ /** @var bool */
public $USE_JQUERY = USE_JQUERY; public bool $USE_JQUERY = USE_JQUERY;
/** @var bool */ /** @var bool */
public $USE_SCRIPTACULOUS = USE_SCRIPTACULOUS; public bool $USE_SCRIPTACULOUS = USE_SCRIPTACULOUS;
// sub content input vars // sub content input vars
/** @var bool */ /** @var bool */
public $USE_TINY_MCE = false; public bool $USE_TINY_MCE = false;
/** @var bool */ /** @var bool */
public $JS_DATEPICKR = false; public bool $JS_DATEPICKR = false;
/** @var bool */ /** @var bool */
public $JS_FLATPICKR = false; public bool $JS_FLATPICKR = false;
/** @var bool */ /** @var bool */
public $JS_FILE_UPLOADER = false; public bool $JS_FILE_UPLOADER = false;
/** @var bool */ /** @var bool */
public $DEBUG_TMPL = false; public bool $DEBUG_TMPL = false;
/** @var bool */ /** @var bool */
public $USE_INCLUDE_TEMPLATE = false; public bool $USE_INCLUDE_TEMPLATE = false;
// cache & compile // cache & compile
/** @var string */ /** @var string */
public $CACHE_ID = ''; public string $CACHE_ID = '';
/** @var string */ /** @var string */
public $COMPILE_ID = ''; public string $COMPILE_ID = '';
// template vars // template vars
/** @var string */ /** @var string */
public $MASTER_TEMPLATE_NAME; public string $MASTER_TEMPLATE_NAME;
/** @var string */ /** @var string */
public $PAGE_FILE_NAME; public string $PAGE_FILE_NAME;
/** @var string */ /** @var string */
public $CONTENT_INCLUDE; public string $CONTENT_INCLUDE;
/** @var string */ /** @var string */
public $FORM_NAME; public string $FORM_NAME;
/** @var string */ /** @var string */
public $FORM_ACTION; public string $FORM_ACTION;
/** @var string */ /** @var string */
public $L_TITLE; public string $L_TITLE;
/** @var string|int */ /** @var string|int */
public $PAGE_WIDTH; public string|int $PAGE_WIDTH;
// smarty include/set var // smarty include/set var
/** @var string */ /** @var string */
public $TEMPLATE_PATH; public string $TEMPLATE_PATH;
/** @var string */ /** @var string */
public $TEMPLATE_NAME; public string $TEMPLATE_NAME;
/** @var string */ /** @var string */
public $INC_TEMPLATE_NAME; public string $INC_TEMPLATE_NAME;
/** @var string */ /** @var string */
public $JS_TEMPLATE_NAME; public string $JS_TEMPLATE_NAME;
/** @var string */ /** @var string */
public $CSS_TEMPLATE_NAME; public string $CSS_TEMPLATE_NAME;
/** @var string|null */ /** @var string|null */
public $TEMPLATE_TRANSLATE; public string|null $TEMPLATE_TRANSLATE;
/** @var string|null */ /** @var string|null */
public $JS_TRANSLATE; public string|null $JS_TRANSLATE;
// core group // core group
/** @var string */ /** @var string */
public $JS_CORE_TEMPLATE_NAME; public string $JS_CORE_TEMPLATE_NAME;
/** @var string */ /** @var string */
public $CSS_CORE_TEMPLATE_NAME; public string $CSS_CORE_TEMPLATE_NAME;
/** @var string */ /** @var string */
public $JS_CORE_INCLUDE; public string $JS_CORE_INCLUDE;
/** @var string */ /** @var string */
public $CSS_CORE_INCLUDE; public string $CSS_CORE_INCLUDE;
// local names // local names
/** @var string */ /** @var string */
public $JS_SPECIAL_TEMPLATE_NAME = ''; public string $JS_SPECIAL_TEMPLATE_NAME = '';
/** @var string */ /** @var string */
public $CSS_SPECIAL_TEMPLATE_NAME = ''; public string $CSS_SPECIAL_TEMPLATE_NAME = '';
/** @var string */ /** @var string */
public $JS_INCLUDE; public string $JS_INCLUDE;
/** @var string */ /** @var string */
public $CSS_INCLUDE; public string $CSS_INCLUDE;
/** @var string */ /** @var string */
public $JS_SPECIAL_INCLUDE; public string $JS_SPECIAL_INCLUDE;
/** @var string */ /** @var string */
public $CSS_SPECIAL_INCLUDE; public string $CSS_SPECIAL_INCLUDE;
/** @var string */ /** @var string */
public $ADMIN_JAVASCRIPT; public string $ADMIN_JAVASCRIPT;
/** @var string */ /** @var string */
public $ADMIN_STYLESHEET; public string $ADMIN_STYLESHEET;
/** @var string */ /** @var string */
public $FRONTEND_JAVASCRIPT; public string $FRONTEND_JAVASCRIPT;
/** @var string */ /** @var string */
public $FRONTEND_STYLESHEET; public string $FRONTEND_STYLESHEET;
// other smarty folder vars // other smarty folder vars
/** @var string */ /** @var string */
public $INCLUDES; public string $INCLUDES;
/** @var string */ /** @var string */
public $JAVASCRIPT; public string $JAVASCRIPT;
/** @var string */ /** @var string */
public $CSS; public string $CSS;
/** @var string */ /** @var string */
public $FONT; public string $FONT;
/** @var string */ /** @var string */
public $PICTURES; public string $PICTURES;
/** @var string */ /** @var string */
public $CACHE_PICTURES; public string $CACHE_PICTURES;
/** @var string */ /** @var string */
public $CACHE_PICTURES_ROOT; public string $CACHE_PICTURES_ROOT;
// constructor class, just sets the language stuff // constructor class, just sets the language stuff
/** /**
@@ -222,6 +220,7 @@ class SmartyExtend extends \Smarty
// core CS // core CS
$this->CSS_CORE_INCLUDE = ''; $this->CSS_CORE_INCLUDE = '';
if ( if (
!empty($this->CSS_CORE_TEMPLATE_NAME) &&
file_exists($this->CSS . $this->CSS_CORE_TEMPLATE_NAME) && file_exists($this->CSS . $this->CSS_CORE_TEMPLATE_NAME) &&
is_file($this->CSS . $this->CSS_CORE_TEMPLATE_NAME) is_file($this->CSS . $this->CSS_CORE_TEMPLATE_NAME)
) { ) {
@@ -230,6 +229,7 @@ class SmartyExtend extends \Smarty
// core JS // core JS
$this->JS_CORE_INCLUDE = ''; $this->JS_CORE_INCLUDE = '';
if ( if (
!empty($this->JS_CORE_TEMPLATE_NAME) &&
file_exists($this->JAVASCRIPT . $this->JS_CORE_TEMPLATE_NAME) && file_exists($this->JAVASCRIPT . $this->JS_CORE_TEMPLATE_NAME) &&
is_file($this->JAVASCRIPT . $this->JS_CORE_TEMPLATE_NAME) is_file($this->JAVASCRIPT . $this->JS_CORE_TEMPLATE_NAME)
) { ) {
@@ -398,7 +398,7 @@ class SmartyExtend extends \Smarty
// javascript translate data as template for auto translate // javascript translate data as template for auto translate
if (empty($this->TEMPLATE_TRANSLATE)) { if (empty($this->TEMPLATE_TRANSLATE)) {
$this->TEMPLATE_TRANSLATE = 'jsTranslate-' $this->TEMPLATE_TRANSLATE = 'jsTranslate-'
. $this->locale_set . '.' . $this->encoding . $this->l10n->getLocaleSet() . '.' . $this->encoding
. '.tpl'; . '.tpl';
} else { } else {
// we assume we have some fixed set // we assume we have some fixed set
@@ -408,12 +408,12 @@ class SmartyExtend extends \Smarty
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) { if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
$this->TEMPLATE_TRANSLATE = str_replace( $this->TEMPLATE_TRANSLATE = str_replace(
'.tpl', '.tpl',
'-' . $this->locale_set . '.' . $this->encoding . '.tpl', '-' . $this->l10n->getLocaleSet() . '.' . $this->encoding . '.tpl',
$this->TEMPLATE_TRANSLATE $this->TEMPLATE_TRANSLATE
); );
} else { } else {
$this->TEMPLATE_TRANSLATE .= '-' $this->TEMPLATE_TRANSLATE .= '-'
. $this->locale_set . '.' . $this->encoding . $this->l10n->getLocaleSet() . '.' . $this->encoding
. '.tpl'; . '.tpl';
} }
} }
@@ -423,7 +423,7 @@ class SmartyExtend extends \Smarty
} }
if (empty($this->JS_TRANSLATE)) { if (empty($this->JS_TRANSLATE)) {
$this->JS_TRANSLATE = 'translate-' $this->JS_TRANSLATE = 'translate-'
. $this->locale_set . '.' . $this->encoding . '.js'; . $this->l10n->getLocaleSet() . '.' . $this->encoding . '.js';
} else { } else {
// we assume we have some fixed set // we assume we have some fixed set
// we must add _<locale>.<encoding> // we must add _<locale>.<encoding>
@@ -432,12 +432,12 @@ class SmartyExtend extends \Smarty
if (strpos($this->JS_TRANSLATE, '.js')) { if (strpos($this->JS_TRANSLATE, '.js')) {
$this->JS_TRANSLATE = str_replace( $this->JS_TRANSLATE = str_replace(
'.js', '.js',
'-' . $this->locale_set . '.' . $this->encoding . '.js', '-' . $this->l10n->getLocaleSet() . '.' . $this->encoding . '.js',
$this->JS_TRANSLATE $this->JS_TRANSLATE
); );
} else { } else {
$this->JS_TRANSLATE .= '-' $this->JS_TRANSLATE .= '-'
. $this->locale_set . '.' . $this->encoding . $this->l10n->getLocaleSet() . '.' . $this->encoding
. '.js'; . '.js';
} }
} }
@@ -675,10 +675,12 @@ class SmartyExtend extends \Smarty
$this->HEADER['DEFAULT_ENCODING'] = $set_default_encoding; $this->HEADER['DEFAULT_ENCODING'] = $set_default_encoding;
// form name // form name
$this->DATA['FORM_NAME'] = !$this->FORM_NAME ? $this->DATA['FORM_NAME'] = empty($this->FORM_NAME) ?
str_replace('.php', '', $this->page_name) : str_replace('.php', '', $this->page_name) :
$this->FORM_NAME; $this->FORM_NAME;
$this->DATA['FORM_ACTION'] = $this->FORM_ACTION; $this->DATA['FORM_ACTION'] = empty($this->FORM_ACTION) ?
'' :
$this->FORM_ACTION;
// special for admin // special for admin
if ($admin_call === true) { if ($admin_call === true) {
// depreacte call globals cms on null 4mcs // depreacte call globals cms on null 4mcs
@@ -735,7 +737,7 @@ class SmartyExtend extends \Smarty
} }
// html title // html title
// set local page title // set local page title
$this->HEADER['HTML_TITLE'] = !$this->L_TITLE ? $this->HEADER['HTML_TITLE'] = empty($this->L_TITLE) ?
ucfirst(str_replace('_', ' ', \CoreLibs\Get\System::getPageName(1))) ucfirst(str_replace('_', ' ', \CoreLibs\Get\System::getPageName(1)))
. (!empty($set_g_title) ? '-' . $this->l10n->__($set_g_title) : '') : . (!empty($set_g_title) ? '-' . $this->l10n->__($set_g_title) : '') :
$this->l10n->__($this->L_TITLE); $this->l10n->__($this->L_TITLE);