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:
@@ -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::__hash(d): " . $to_crc . "/"
|
||||
. 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>";
|
||||
}
|
||||
// static use
|
||||
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_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
||||
print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>";
|
||||
|
||||
@@ -85,7 +85,7 @@ foreach ($images as $image) {
|
||||
$image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image;
|
||||
list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image));
|
||||
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
|
||||
Image::correctImageOrientation($image);
|
||||
// thumbnail tests
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php // phpcs:ignore warning
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* @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 ->name: " . Flag::per_class->name . "<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>";
|
||||
|
||||
@@ -82,6 +84,26 @@ try {
|
||||
'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>'
|
||||
. '<div style="width:100%; font-family: monospace;">'
|
||||
// . '<pre>'
|
||||
|
||||
@@ -66,49 +66,58 @@ print "<!DOCTYPE html>";
|
||||
print "<html><head><title>TEST CLASS</title><head>";
|
||||
print "<body>";
|
||||
|
||||
print '<div><a href="class_test.db.php">Class Test: DB</a></div>';
|
||||
print '<div><a href="class_test.db.single.php">Class Test: DB SINGLE</a></div>';
|
||||
print '<div><a href="class_test.db.dbReturn.php">Class Test: DB dbReturn</a></div>';
|
||||
print '<div><a href="class_test.convert.colors.php">Class Test: CONVERT COLORS</a></div>';
|
||||
print '<div><a href="class_test.check.colors.php">Class Test: CHECK COLORS</a></div>';
|
||||
print '<div><a href="class_test.mime.php">Class Test: MIME</a></div>';
|
||||
print '<div><a href="class_test.json.php">Class Test: JSON</a></div>';
|
||||
print '<div><a href="class_test.token.php">Class Test: FORM TOKEN</a></div>';
|
||||
print '<div><a href="class_test.password.php">Class Test: PASSWORD</a></div>';
|
||||
print '<div><a href="class_test.encryption.php">Class Test: ENCRYPTION</a></div>';
|
||||
print '<div><a href="class_test.math.php">Class Test: MATH</a></div>';
|
||||
print '<div><a href="class_test.html.php">Class Test: HTML/ELEMENTS</a></div>';
|
||||
print '<div><a href="class_test.email.php">Class Test: EMAIL</a></div>';
|
||||
print '<div><a href="class_test.create_email.php">Class Test: CREATE EMAIL</a></div>';
|
||||
print '<div><a href="class_test.uids.php">Class Test: UIDS</a></div>';
|
||||
print '<div><a href="class_test.phpv.php">Class Test: PHP VERSION</a></div>';
|
||||
print '<div><a href="class_test.hash.php">Class Test: HASH</a></div>';
|
||||
print '<div><a href="class_test.encoding.php">Class Test: ENCODING (CHECK/CONVERT/MIME)</a></div>';
|
||||
print '<div><a href="class_test.image.php">Class Test: IMAGE</a></div>';
|
||||
print '<div><a href="class_test.byte.php">Class Test: BYTE CONVERT</a></div>';
|
||||
print '<div><a href="class_test.strings.php">Class Test: STRING CONVERT</a></div>';
|
||||
print '<div><a href="class_test.datetime.php">Class Test: DATE/TIME</a></div>';
|
||||
print '<div><a href="class_test.array.php">Class Test: ARRAY HANDLER</a></div>';
|
||||
print '<div><a href="class_test.file.php">Class Test: FILE</a></div>';
|
||||
print '<div><a href="class_test.randomkey.php">Class Test: RANDOM KEY</a></div>';
|
||||
print '<div><a href="class_test.system.php">Class Test: SYSTEM</a></div>';
|
||||
print '<div><a href="class_test.readenvfile.php">Class Test: READ ENV FILE</a></div>';
|
||||
print '<div><a href="class_test.runningtime.php">Class Test: RUNNING TIME</a></div>';
|
||||
print '<div><a href="class_test.memoryusage.php">Class Test: MEMORY USAGE</a></div>';
|
||||
print '<div><a href="class_test.debug.php">Class Test: DEBUG</a></div>';
|
||||
print '<div><a href="class_test.logging.php">Class Test: LOGGING</a></div>';
|
||||
print '<div><a href="class_test.output.form.php">Class Test: OUTPUT FORM</a></div>';
|
||||
print '<div><a href="class_test.admin.backend.php">Class Test: BACKEND ADMIN CLASS</a></div>';
|
||||
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
|
||||
print '<div><a href="class_test.varistype.php">Class Test: SET VAR TYPE</a></div>';
|
||||
print '<div><a href="class_test.session.php">Class Test: SESSION</a></div>';
|
||||
print '<div><a href="class_test.session.read.php">Class Test: SESSION: READ</a></div>';
|
||||
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>';
|
||||
print '<div><a href="class_test.login.php">Class Test: LOGIN</a></div>';
|
||||
print '<div><a href="class_test.autoloader.php">Class Test: AUTOLOADER</a></div>';
|
||||
print '<div><a href="class_test.config.link.php">Class Test: CONFIG LINK</a></div>';
|
||||
print '<div><a href="class_test.config.direct.php">Class Test: CONFIG DIRECT</a></div>';
|
||||
print '<div><a href="subfolder/class_test.config.direct.php">Class Test: CONFIG DIRECT SUB</a></div>';
|
||||
// key: file name, value; name
|
||||
$test_files = [
|
||||
'class_test.db.php' => 'Class Test: DB',
|
||||
'class_test.db.single.php' => 'Class Test: DB SINGLE',
|
||||
'class_test.db.dbReturn.php' => 'Class Test: DB dbReturn',
|
||||
'class_test.convert.colors.php' => 'Class Test: CONVERT COLORS',
|
||||
'class_test.check.colors.php' => 'Class Test: CHECK COLORS',
|
||||
'class_test.mime.php' => 'Class Test: MIME',
|
||||
'class_test.json.php' => 'Class Test: JSON',
|
||||
'class_test.token.php' => 'Class Test: FORM TOKEN',
|
||||
'class_test.password.php' => 'Class Test: PASSWORD',
|
||||
'class_test.encryption.php' => 'Class Test: ENCRYPTION',
|
||||
'class_test.math.php' => 'Class Test: MATH',
|
||||
'class_test.html.php' => 'Class Test: HTML/ELEMENTS',
|
||||
'class_test.email.php' => 'Class Test: EMAIL',
|
||||
'class_test.create_email.php' => 'Class Test: CREATE EMAIL',
|
||||
'class_test.uids.php' => 'Class Test: UIDS',
|
||||
'class_test.phpv.php' => 'Class Test: PHP VERSION',
|
||||
'class_test.hash.php' => 'Class Test: HASH',
|
||||
'class_test.encoding.php' => 'Class Test: ENCODING (CHECK/CONVERT/MIME)',
|
||||
'class_test.image.php' => 'Class Test: IMAGE',
|
||||
'class_test.byte.php' => 'Class Test: BYTE CONVERT',
|
||||
'class_test.strings.php' => 'Class Test: STRING CONVERT',
|
||||
'class_test.datetime.php' => 'Class Test: DATE/TIME',
|
||||
'class_test.array.php' => 'Class Test: ARRAY HANDLER',
|
||||
'class_test.file.php' => 'Class Test: FILE',
|
||||
'class_test.randomkey.php' => 'Class Test: RANDOM KEY',
|
||||
'class_test.system.php' => 'Class Test: SYSTEM',
|
||||
'class_test.readenvfile.php' => 'Class Test: READ ENV FILE',
|
||||
'class_test.runningtime.php' => 'Class Test: RUNNING TIME',
|
||||
'class_test.memoryusage.php' => 'Class Test: MEMORY USAGE',
|
||||
'class_test.debug.php' => 'Class Test: DEBUG',
|
||||
'class_test.logging.php' => 'Class Test: LOGGING',
|
||||
'class_test.output.form.php' => 'Class Test: OUTPUT FORM',
|
||||
'class_test.admin.backend.php' => 'Class Test: BACKEND ADMIN CLASS',
|
||||
'class_test.lang.php' => 'Class Test: LANG/L10n',
|
||||
'class_test.varistype.php' => 'Class Test: SET VAR TYPE',
|
||||
'class_test.session.php' => 'Class Test: SESSION',
|
||||
'class_test.session.read.php' => 'Class Test: SESSION: READ',
|
||||
'class_test.smarty.php' => 'Class Test: SMARTY',
|
||||
'class_test.login.php' => 'Class Test: LOGIN',
|
||||
'class_test.autoloader.php' => 'Class Test: AUTOLOADER',
|
||||
'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 "L: " . Support::dumpVar($locale) . "<br>";
|
||||
|
||||
@@ -39,11 +39,16 @@ print "UUIDV4: " . $_uids->uuidv4() . "<br>";
|
||||
print "UNIQID (d): " . $_uids->uniqId() . "<br>";
|
||||
print "UNIQID (md5): " . $_uids->uniqId('md5') . "<br>";
|
||||
print "UNIQID (sha256): " . $_uids->uniqId('sha256') . "<br>";
|
||||
// statc
|
||||
// static
|
||||
print "S::UUIDV4: " . $uids_class::uuidv4() . "<br>";
|
||||
print "S::UNIQID (d): " . $uids_class::uniqId() . "<br>";
|
||||
print "S::UNIQID (md5): " . $uids_class::uniqId('md5') . "<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
|
||||
print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>";
|
||||
print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";
|
||||
|
||||
@@ -73,65 +73,65 @@ use CoreLibs\Convert\Json;
|
||||
|
||||
class Login
|
||||
{
|
||||
/** @var string the user id var*/
|
||||
private $euid;
|
||||
/** @var ?int the user id var*/
|
||||
private ?int $euid;
|
||||
/** @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 */
|
||||
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 */
|
||||
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
|
||||
/** @var bool */
|
||||
private $permission_okay = false;
|
||||
private bool $permission_okay = false;
|
||||
/** @var string pressed login */
|
||||
private $login = '';
|
||||
private string $login = '';
|
||||
/** @var string master action command */
|
||||
private $action;
|
||||
private string $action;
|
||||
/** @var string login name */
|
||||
private $username;
|
||||
private string $username;
|
||||
/** @var string login password */
|
||||
private $password;
|
||||
private string $password;
|
||||
/** @var string logout button */
|
||||
private $logout;
|
||||
private string $logout;
|
||||
/** @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 */
|
||||
private $password_change_ok = false;
|
||||
private bool $password_change_ok = false;
|
||||
// can we reset password and mail to user with new password set screen
|
||||
/** @var bool */
|
||||
private $password_forgot = false;
|
||||
private bool $password_forgot = false;
|
||||
/** @var bool password forgot mail send ok */
|
||||
// private $password_forgot_ok = false;
|
||||
/** @var string */
|
||||
private $change_password;
|
||||
private string $change_password;
|
||||
/** @var string */
|
||||
private $pw_username;
|
||||
private string $pw_username;
|
||||
/** @var string */
|
||||
private $pw_old_password;
|
||||
private string $pw_old_password;
|
||||
/** @var string */
|
||||
private $pw_new_password;
|
||||
private string $pw_new_password;
|
||||
/** @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 */
|
||||
private $pw_change_deny_users = [];
|
||||
private array $pw_change_deny_users = [];
|
||||
/** @var string */
|
||||
private $logout_target = '';
|
||||
private string $logout_target = '';
|
||||
/** @var int */
|
||||
private $max_login_error_count = -1;
|
||||
private int $max_login_error_count = -1;
|
||||
/** @var array<string> */
|
||||
private $lock_deny_users = [];
|
||||
private array $lock_deny_users = [];
|
||||
/** @var string */
|
||||
private $page_name = '';
|
||||
private string $page_name = '';
|
||||
|
||||
/** @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 */
|
||||
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
|
||||
// it will be set back to 255
|
||||
/** @var int */
|
||||
private $password_max_length = 255;
|
||||
private int $password_max_length = 255;
|
||||
|
||||
/** @var int minum password length */
|
||||
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 */
|
||||
private $password_valid_chars = [
|
||||
private array $password_valid_chars = [
|
||||
// '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{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,
|
||||
// which holds the string
|
||||
/** @var int */
|
||||
private $login_error = 0;
|
||||
private int $login_error = 0;
|
||||
/** @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
|
||||
// rom the outside (translation)
|
||||
/** @var array<mixed> */
|
||||
private $login_template = [
|
||||
private array $login_template = [
|
||||
'strings' => [],
|
||||
'password_change' => '',
|
||||
'template' => ''
|
||||
@@ -180,24 +180,24 @@ class Login
|
||||
|
||||
// acl vars
|
||||
/** @var array<mixed> */
|
||||
private $acl = [];
|
||||
private array $acl = [];
|
||||
/** @var array<mixed> */
|
||||
private $default_acl_list = [];
|
||||
private array $default_acl_list = [];
|
||||
/** @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 */
|
||||
private $default_acl_level = 0;
|
||||
private int $default_acl_level = 0;
|
||||
// login html, if we are on an ajax page
|
||||
/** @var string|null */
|
||||
private $login_html = '';
|
||||
private ?string $login_html = '';
|
||||
/** @var bool */
|
||||
private $login_is_ajax_page = false;
|
||||
private bool $login_is_ajax_page = false;
|
||||
|
||||
// settings
|
||||
/** @var array<string,mixed> options */
|
||||
private $options = [];
|
||||
private array $options = [];
|
||||
/** @var array<string,string> locale options: locale, domain, encoding (opt), path */
|
||||
private $locale = [
|
||||
private array $locale = [
|
||||
'locale' => '',
|
||||
'domain' => '',
|
||||
'encoding' => '',
|
||||
@@ -205,13 +205,13 @@ class Login
|
||||
];
|
||||
|
||||
/** @var \CoreLibs\Logging\Logging logger */
|
||||
public $log;
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
/** @var \CoreLibs\DB\IO database */
|
||||
public $db;
|
||||
public \CoreLibs\DB\IO $db;
|
||||
/** @var \CoreLibs\Language\L10n language */
|
||||
public $l;
|
||||
public \CoreLibs\Language\L10n $l;
|
||||
/** @var \CoreLibs\Create\Session session class */
|
||||
public $session;
|
||||
public \CoreLibs\Create\Session $session;
|
||||
|
||||
/**
|
||||
* constructor, does ALL, opens db, works through connection checks,
|
||||
@@ -883,7 +883,7 @@ class Login
|
||||
}
|
||||
// normal user processing
|
||||
// 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
|
||||
$this->loginCheckPermissions();
|
||||
if ($this->login_error == 0) {
|
||||
@@ -1048,7 +1048,7 @@ class Login
|
||||
}
|
||||
// build master unit array
|
||||
$unit_access[$res['edit_access_id']] = [
|
||||
'id' => $res['edit_access_id'],
|
||||
'id' => (int)$res['edit_access_id'],
|
||||
'acl_level' => $res['level'],
|
||||
'acl_type' => $res['type'],
|
||||
'name' => $res['name'],
|
||||
@@ -2110,7 +2110,7 @@ HTML;
|
||||
// unset session vars set/used in this login
|
||||
$this->session->sessionDestroy();
|
||||
// unset euid
|
||||
$this->euid = '';
|
||||
$this->euid = null;
|
||||
// then prints the login screen again
|
||||
$this->permission_okay = false;
|
||||
}
|
||||
@@ -2498,7 +2498,7 @@ HTML;
|
||||
*/
|
||||
public function loginGetEuid(): string
|
||||
{
|
||||
return $this->euid;
|
||||
return (string)$this->euid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,83 +35,83 @@ class Backend
|
||||
{
|
||||
// page name
|
||||
/** @var array<mixed> */
|
||||
public $menu = [];
|
||||
public array $menu = [];
|
||||
/** @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
|
||||
/** @var array<string> */
|
||||
public $action_list = [
|
||||
public array $action_list = [
|
||||
'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag',
|
||||
'action_menu', 'action_value', 'action_error', 'action_loaded'
|
||||
];
|
||||
/** @var string */
|
||||
public $action;
|
||||
public string $action;
|
||||
/** @var string|int */
|
||||
public $action_id;
|
||||
public string|int $action_id;
|
||||
/** @var string|int */
|
||||
public $action_sub_id;
|
||||
public string|int $action_sub_id;
|
||||
/** @var string|int|bool */
|
||||
public $action_yes;
|
||||
public string|int|bool $action_yes;
|
||||
/** @var string */
|
||||
public $action_flag;
|
||||
public string $action_flag;
|
||||
/** @var string */
|
||||
public $action_menu;
|
||||
public string $action_menu;
|
||||
/** @var string */
|
||||
public $action_loaded;
|
||||
public string $action_loaded;
|
||||
/** @var string */
|
||||
public $action_value;
|
||||
public string $action_value;
|
||||
/** @var string */
|
||||
public $action_error;
|
||||
public string $action_error;
|
||||
// ACL array variable if we want to set acl data from outisde
|
||||
/** @var array<mixed> */
|
||||
public $acl = [];
|
||||
public array $acl = [];
|
||||
/** @var int */
|
||||
public $default_acl;
|
||||
public int $default_acl;
|
||||
// queue key
|
||||
/** @var string */
|
||||
public $queue_key;
|
||||
public string $queue_key;
|
||||
// the current active edit access id
|
||||
/** @var int */
|
||||
public $edit_access_id;
|
||||
/** @var int|null */
|
||||
public int|null $edit_access_id;
|
||||
/** @var string */
|
||||
public $page_name;
|
||||
public string $page_name;
|
||||
// error/warning/info messages
|
||||
/** @var array<mixed> */
|
||||
public $messages = [];
|
||||
public array $messages = [];
|
||||
/** @var bool */
|
||||
public $error = false;
|
||||
public bool $error = false;
|
||||
/** @var bool */
|
||||
public $warning = false;
|
||||
public bool $warning = false;
|
||||
/** @var bool */
|
||||
public $info = false;
|
||||
public bool $info = false;
|
||||
// internal lang & encoding vars
|
||||
/** @var string */
|
||||
public $lang_dir = '';
|
||||
public string $lang_dir = '';
|
||||
/** @var string */
|
||||
public $lang;
|
||||
public string $lang;
|
||||
/** @var string */
|
||||
public $lang_short;
|
||||
public string $lang_short;
|
||||
/** @var string */
|
||||
public $domain;
|
||||
public string $domain;
|
||||
/** @var string */
|
||||
public $encoding;
|
||||
public string $encoding;
|
||||
/** @var \CoreLibs\Logging\Logging logger */
|
||||
public $log;
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
/** @var \CoreLibs\DB\IO database */
|
||||
public $db;
|
||||
public \CoreLibs\DB\IO $db;
|
||||
/** @var \CoreLibs\Language\L10n language */
|
||||
public $l;
|
||||
public \CoreLibs\Language\L10n $l;
|
||||
/** @var \CoreLibs\Create\Session session class */
|
||||
public $session;
|
||||
public \CoreLibs\Create\Session $session;
|
||||
// smarty publics [end processing in smarty class]
|
||||
/** @var array<mixed> */
|
||||
public $DATA;
|
||||
public array $DATA = [];
|
||||
/** @var array<mixed> */
|
||||
public $HEADER;
|
||||
public array $HEADER = [];
|
||||
/** @var array<mixed> */
|
||||
public $DEBUG_DATA;
|
||||
public array $DEBUG_DATA = [];
|
||||
/** @var array<mixed> */
|
||||
public $CONTENT_DATA;
|
||||
public array $CONTENT_DATA = [];
|
||||
|
||||
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
||||
/**
|
||||
|
||||
@@ -20,23 +20,23 @@ use SmartyException;
|
||||
class EditBase
|
||||
{
|
||||
/** @var array<mixed> */
|
||||
private $HEADER = [];
|
||||
private array $HEADER = [];
|
||||
/** @var array<mixed> */
|
||||
private $DATA = [];
|
||||
private array $DATA = [];
|
||||
/** @var array<mixed> */
|
||||
private $DEBUG_DATA = [];
|
||||
private array $DEBUG_DATA = [];
|
||||
|
||||
/** @var string the template name */
|
||||
private $EDIT_TEMPLATE = '';
|
||||
private string $EDIT_TEMPLATE = '';
|
||||
|
||||
/** @var \CoreLibs\Template\SmartyExtend smarty system */
|
||||
private $smarty;
|
||||
private \CoreLibs\Template\SmartyExtend $smarty;
|
||||
/** @var \CoreLibs\Output\Form\Generate form generate system */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
public $log;
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
/** @var \CoreLibs\ACL\Login */
|
||||
public $login;
|
||||
public \CoreLibs\ACL\Login $login;
|
||||
|
||||
/**
|
||||
* construct form generator
|
||||
|
||||
@@ -58,30 +58,30 @@ class Basic
|
||||
{
|
||||
// page and host name
|
||||
/** @var string */
|
||||
public $page_name;
|
||||
public string $page_name;
|
||||
/** @var string */
|
||||
public $host_name;
|
||||
public string $host_name;
|
||||
/** @var int */
|
||||
public $host_port;
|
||||
public int $host_port;
|
||||
// logging interface, Debug\Logging class
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
public $log;
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
/** @var \CoreLibs\Create\Session */
|
||||
public $session;
|
||||
public \CoreLibs\Create\Session $session;
|
||||
|
||||
// email valid checks
|
||||
/** @var array<mixed> */
|
||||
public $email_regex_check = [];
|
||||
public array $email_regex_check = [];
|
||||
/** @var string */
|
||||
public $email_regex; // regex var for email check
|
||||
public string $email_regex; // regex var for email check
|
||||
|
||||
// data path for files
|
||||
/** @var array<mixed> */
|
||||
public $data_path = [];
|
||||
public array $data_path = [];
|
||||
|
||||
// ajax flag
|
||||
/** @var bool */
|
||||
protected $ajax_page_flag = false;
|
||||
protected bool $ajax_page_flag = false;
|
||||
|
||||
/**
|
||||
* main Basic constructor to init and check base settings
|
||||
|
||||
@@ -8,7 +8,7 @@ class Email
|
||||
{
|
||||
// this is for error check parts in where the email regex failed
|
||||
/** @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}@"
|
||||
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER
|
||||
1 => "@(.*)@(.*)", // double @
|
||||
@@ -21,7 +21,7 @@ class Email
|
||||
];
|
||||
// for above position, description string below
|
||||
/** @var array<int,string> */
|
||||
private static $email_regex_check_message = [
|
||||
private static array $email_regex_check_message = [
|
||||
0 => 'Invalid email address',
|
||||
1 => 'Double @ mark in email address',
|
||||
2 => 'Invalid email part before @ sign',
|
||||
@@ -33,7 +33,7 @@ class Email
|
||||
];
|
||||
// the array with the mobile types that are valid
|
||||
/** @var array<string,string> */
|
||||
private static $mobile_email_type = [
|
||||
private static array $mobile_email_type = [
|
||||
'.*@docomo\.ne\.jp$' => 'keitai_docomo',
|
||||
// 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',
|
||||
@@ -72,7 +72,7 @@ class Email
|
||||
];
|
||||
// short list for mobile email types
|
||||
/** @var array<string,string> */
|
||||
private static $mobile_email_type_short = [
|
||||
private static array $mobile_email_type_short = [
|
||||
'keitai_docomo' => 'docomo',
|
||||
'keitai_kddi_ezweb' => 'kddi',
|
||||
'keitai_kddi' => 'kddi',
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CoreLibs\Check;
|
||||
class Encoding
|
||||
{
|
||||
/** @var int<min, -1>|int<1, max>|string */
|
||||
private static $mb_error_char = '';
|
||||
private static int|string $mb_error_char = '';
|
||||
|
||||
/**
|
||||
* set error char
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace CoreLibs\Convert;
|
||||
class MimeAppName
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
private static $mime_apps = [];
|
||||
private static array $mime_apps = [];
|
||||
|
||||
/**
|
||||
* constructor: init mime list
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CoreLibs\Create;
|
||||
class Email
|
||||
{
|
||||
/** @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',
|
||||
'EUC-JP',
|
||||
'SJIS',
|
||||
@@ -25,7 +25,7 @@ class Email
|
||||
'JIS-ms',
|
||||
];
|
||||
/** @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.
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace CoreLibs\Create;
|
||||
|
||||
class Hash
|
||||
{
|
||||
public const DEFAULT_HASH = 'adler32';
|
||||
public const STANDARD_HASH_LONG = 'ripemd160';
|
||||
public const STANDARD_HASH_SHORT = 'adler32';
|
||||
|
||||
@@ -58,7 +59,7 @@ class Hash
|
||||
/**
|
||||
* replacemend for __crc32b call (alternate)
|
||||
* 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
|
||||
*
|
||||
* @param string $string string to hash
|
||||
@@ -67,15 +68,15 @@ class Hash
|
||||
*/
|
||||
public static function __hash(
|
||||
string $string,
|
||||
string $hash_type = self::STANDARD_HASH_SHORT
|
||||
string $hash_type = self::DEFAULT_HASH
|
||||
): string {
|
||||
// if not empty, check if in valid list
|
||||
if (
|
||||
!in_array(
|
||||
$hash_type,
|
||||
['crc32b', 'adler32', 'fnv132', 'fnv1a32', 'joaat']
|
||||
)
|
||||
empty($hash_type) ||
|
||||
!in_array($hash_type, hash_algos())
|
||||
) {
|
||||
$hash_type = 'adler32';
|
||||
// fallback to default hash type if none set or invalid
|
||||
$hash_type = self::DEFAULT_HASH;
|
||||
}
|
||||
return hash($hash_type, $string);
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ class RandomKey
|
||||
{
|
||||
// key generation
|
||||
/** @var string */
|
||||
private static $key_range = '';
|
||||
private static string $key_range = '';
|
||||
/** @var int */
|
||||
private static $one_key_length;
|
||||
private static int $one_key_length;
|
||||
/** @var int */
|
||||
private static $key_length = 4; // default key length
|
||||
private static int $key_length = 4; // default key length
|
||||
/** @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
|
||||
@@ -100,7 +100,9 @@ class RandomKey
|
||||
public static function randomKeyGen(int $key_length = -1): string
|
||||
{
|
||||
// init random key strings if not set
|
||||
if (!is_numeric(self::$one_key_length)) {
|
||||
if (
|
||||
!isset(self::$one_key_length)
|
||||
) {
|
||||
self::initRandomKeyData();
|
||||
}
|
||||
$use_key_length = 0;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace CoreLibs\Create;
|
||||
class Session
|
||||
{
|
||||
/** @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
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Create uniqIds
|
||||
*
|
||||
* If convert ID to hash:
|
||||
* https://github.com/vinkla/hashids
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CoreLibs\Create;
|
||||
@@ -7,10 +14,39 @@ namespace CoreLibs\Create;
|
||||
class Uids
|
||||
{
|
||||
// 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';
|
||||
/** @var string */
|
||||
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
|
||||
* Code take from class here:
|
||||
@@ -20,7 +56,7 @@ class Uids
|
||||
*/
|
||||
public static function uuidv4(): string
|
||||
{
|
||||
return sprintf(
|
||||
/* return sprintf(
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
// 32 bits for "time_low"
|
||||
mt_rand(0, 0xffff),
|
||||
@@ -38,49 +74,62 @@ class Uids
|
||||
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
|
||||
* add uuidv4 subcall to the uuid function too
|
||||
* creates a uniq id
|
||||
* creates a uniq id based on lengths
|
||||
*
|
||||
* @param string $type uniq id type, currently md5 or sha256 allowed
|
||||
* if not set will use DEFAULT_HASH if set
|
||||
* @return string uniq id
|
||||
* @param int|string $length Either length in int, or fallback type for length
|
||||
* for string type md5 (32), sha256 (64)
|
||||
* 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
|
||||
{
|
||||
$uniq_id = '';
|
||||
switch ($type) {
|
||||
public static function uniqId(
|
||||
int|string $length = self::DEFAULT_UNNIQ_ID_LENGTH,
|
||||
bool $force_length = false
|
||||
): string {
|
||||
if (is_int($length)) {
|
||||
return self::uniqIdL($length, $force_length);
|
||||
}
|
||||
switch ($length) {
|
||||
case 'md5':
|
||||
$uniq_id = md5(uniqid((string)rand(), true));
|
||||
$length = 32;
|
||||
break;
|
||||
case self::DEFAULT_HASH:
|
||||
$uniq_id = hash(self::DEFAULT_HASH, uniqid((string)rand(), true));
|
||||
case 'sha256':
|
||||
$length = 64;
|
||||
break;
|
||||
case self::STANDARD_HASH_LONG:
|
||||
$uniq_id = hash(self::STANDARD_HASH_LONG, uniqid((string)rand(), true));
|
||||
$length = 40;
|
||||
break;
|
||||
case self::STANDARD_HASH_SHORT:
|
||||
$uniq_id = hash(self::STANDARD_HASH_SHORT, uniqid((string)rand(), true));
|
||||
$length = 8;
|
||||
break;
|
||||
default:
|
||||
// if not empty, check if in valid list
|
||||
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));
|
||||
$length = 64;
|
||||
break;
|
||||
}
|
||||
return $uniq_id;
|
||||
return self::uniqIdL($length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,16 +39,16 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
{
|
||||
// main calss variables
|
||||
/** @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 */
|
||||
public $table_name; // the table_name
|
||||
public string $table_name; // the table_name
|
||||
/** @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 */
|
||||
public $pk_id; // the PK id
|
||||
public int|string|null $pk_id; // the PK id
|
||||
// security values
|
||||
/** @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
|
||||
|
||||
@@ -298,101 +298,98 @@ class IO
|
||||
// can bet set from outside
|
||||
// encoding to
|
||||
/** @var string */
|
||||
private $to_encoding = '';
|
||||
/** @var string */
|
||||
private $query; // the query string at the moment
|
||||
/** @var array<mixed> */
|
||||
private $params; // current params for query
|
||||
private string $to_encoding = '';
|
||||
/** @var string the query string at the moment */
|
||||
private string $query;
|
||||
/** @var array<mixed> current params for query */
|
||||
private array $params;
|
||||
// only inside
|
||||
// basic vars
|
||||
/** @var \PgSql\Connection|false|null */ // replace object with PgSql\Connection|
|
||||
private $dbh; // the dbh handler, if disconnected by command is null, bool:false on error,
|
||||
/** @var bool */
|
||||
private $db_debug = false; // DB_DEBUG ... (if set prints out debug msgs)
|
||||
/** @var string */
|
||||
private $db_name; // the DB connected to
|
||||
/** @var string */
|
||||
private $db_user; // the username used
|
||||
/** @var string */
|
||||
private $db_pwd; // the password used
|
||||
/** @var string */
|
||||
private $db_host; // the hostname
|
||||
/** @var int */
|
||||
private $db_port; // default db port
|
||||
/** @var string */
|
||||
private $db_schema; // optional DB schema, if not set uses public
|
||||
/** @var string */
|
||||
private $db_encoding; // optional auto encoding convert, not used if not set
|
||||
/** @var string */
|
||||
private $db_type; // type of db (mysql,postgres,...)
|
||||
/** @var string */
|
||||
private $db_ssl; // ssl flag (for postgres only), disable, allow, prefer, require
|
||||
// the dbh handler, if disconnected by command is null, bool:false on error,
|
||||
/** @var \PgSql\Connection|false|null */
|
||||
private \PgSql\Connection|false|null $dbh;
|
||||
/** @var bool DB_DEBUG ... (if set prints out debug msgs) */
|
||||
private bool $db_debug = false;
|
||||
/** @var string the DB connected to */
|
||||
private string $db_name;
|
||||
/** @var string the username used */
|
||||
private string $db_user;
|
||||
/** @var string the password used*/
|
||||
private string $db_pwd;
|
||||
/** @var string the hostname */
|
||||
private string $db_host;
|
||||
/** @var int default db port */
|
||||
private int $db_port;
|
||||
/** @var string optional DB schema, if not set uses public*/
|
||||
private string $db_schema;
|
||||
/** @var string optional auto encoding convert, not used if not set */
|
||||
private string $db_encoding;
|
||||
/** @var string type of db (mysql,postgres,...) */
|
||||
private string $db_type;
|
||||
/** @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)
|
||||
// cursor array for cached readings
|
||||
/** @var array<mixed,mixed> */
|
||||
private $cursor_ext; // hash of hashes
|
||||
/** @var array<string,mixed> extended cursoers string index with content */
|
||||
private array $cursor_ext;
|
||||
// per query vars
|
||||
/** @var \PgSql\Result|false */ // replace object with PgSql\Result
|
||||
private $cursor; // actual cursor (DBH)
|
||||
/** @var int */
|
||||
private $num_rows; // how many rows have been found
|
||||
/** @var int */
|
||||
private $num_fields; // how many fields has the query
|
||||
/** @var \PgSql\Result|false actual cursor (DBH) */
|
||||
private \PgSql\Result|false $cursor;
|
||||
/** @var int how many rows have been found */
|
||||
private int $num_rows;
|
||||
/** @var int how many fields has the query */
|
||||
private int $num_fields;
|
||||
/** @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 */
|
||||
private $field_types = [];
|
||||
/** @var array<mixed> */
|
||||
private $insert_id_arr = []; // always return as array, even if only one
|
||||
/** @var string */
|
||||
private $insert_id_pk_name; // primary key name for insert recovery from insert_id_arr
|
||||
private array $field_types = [];
|
||||
/** @var array<mixed> always return as array, even if only one */
|
||||
private array $insert_id_arr = [];
|
||||
/** @var string primary key name for insert recovery from insert_id_arr */
|
||||
private string $insert_id_pk_name;
|
||||
// other vars
|
||||
/** @var string */
|
||||
private $nbsp = ''; // used by print_array recursion function
|
||||
/** @var string used by print_array recursion function */
|
||||
private string $nbsp = '';
|
||||
// error & warning id
|
||||
/** @var string */
|
||||
private $error_id;
|
||||
private string $error_id;
|
||||
/** @var string */
|
||||
private $warning_id;
|
||||
private string $warning_id;
|
||||
/** @var string */
|
||||
private $error_history_id;
|
||||
private string $error_history_id;
|
||||
/** @var array<mixed> Stores warning and errors combinded with detail info */
|
||||
private $error_history_long = [];
|
||||
// error thrown on class init if we cannot connect to db
|
||||
/** @var bool */
|
||||
protected $db_connection_closed = false;
|
||||
private array $error_history_long = [];
|
||||
/** @var bool error thrown on class init if we cannot connect to db */
|
||||
protected bool $db_connection_closed = false;
|
||||
// sub include with the database functions
|
||||
/** @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
|
||||
/** @var int */
|
||||
private $MAX_QUERY_CALL;
|
||||
/** @var int */
|
||||
public const DEFAULT_MAX_QUERY_CALL = 20; // default
|
||||
private int $MAX_QUERY_CALL;
|
||||
/** @var int maxium query calls allowed in a dbReturnRow loop before we error out */
|
||||
public const DEFAULT_MAX_QUERY_CALL = 20;
|
||||
/** @var array<mixed> */
|
||||
private $query_called = [];
|
||||
private array $query_called = [];
|
||||
// error string
|
||||
/** @var array<mixed> */
|
||||
protected $error_string = [];
|
||||
protected array $error_string = [];
|
||||
// prepared list
|
||||
/** @var array<mixed> */
|
||||
private $prepare_cursor = [];
|
||||
private array $prepare_cursor = [];
|
||||
// primary key per table list
|
||||
// format is 'table' => 'pk_name'
|
||||
/** @var array<mixed> */
|
||||
private $pk_name_table = [];
|
||||
// internal primary key name, for cross calls in async
|
||||
/** @var string */
|
||||
private $pk_name;
|
||||
// if we use RETURNING in the INSERT call
|
||||
/** @var bool */
|
||||
private $returning_id = false;
|
||||
// if a sync is running holds the hash key of the query
|
||||
/** @var string */
|
||||
private $async_running;
|
||||
private array $pk_name_table = [];
|
||||
/** @var string internal primary key name, for cross calls in async */
|
||||
private string $pk_name;
|
||||
/** @var bool if we use RETURNING in the INSERT call */
|
||||
private bool $returning_id = false;
|
||||
/** @var string if a sync is running holds the hash key of the query */
|
||||
private string $async_running;
|
||||
// logging class, must be public so settings can be changed
|
||||
/** @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
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace CoreLibs\DB\SQL;
|
||||
class PgSQL implements Interface\SqlFunctions
|
||||
{
|
||||
/** @var string */
|
||||
private $last_error_query;
|
||||
private string $last_error_query;
|
||||
/** @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
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace CoreLibs\Debug;
|
||||
class FileWriter
|
||||
{
|
||||
/** @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 */
|
||||
private static $debug_folder;
|
||||
private static string $debug_folder;
|
||||
|
||||
/**
|
||||
* Set a debug log folder, if not set BASE+LOG folders are set
|
||||
|
||||
@@ -13,13 +13,13 @@ use CoreLibs\Convert\Byte;
|
||||
class MemoryUsage
|
||||
{
|
||||
/** @var int */
|
||||
private static $start_memory = 0;
|
||||
private static int $start_memory = 0;
|
||||
/** @var int */
|
||||
private static $set_memory = 0;
|
||||
private static int $set_memory = 0;
|
||||
/** @var int */
|
||||
private static $previous_memory = 0;
|
||||
private static int $previous_memory = 0;
|
||||
/** @var bool */
|
||||
private static $debug_memory = false;
|
||||
private static bool $debug_memory = false;
|
||||
|
||||
/**
|
||||
* set memory flag, or return set memory flag
|
||||
|
||||
@@ -12,18 +12,18 @@ class RunningTime
|
||||
{
|
||||
// hr
|
||||
/** @var float */
|
||||
private static $hr_start_time;
|
||||
private static float $hr_start_time;
|
||||
/** @var float */
|
||||
private static $hr_end_time;
|
||||
private static float $hr_end_time;
|
||||
/** @var float */
|
||||
private static $hr_last_time;
|
||||
private static float $hr_last_time;
|
||||
// normal
|
||||
/** @var float */
|
||||
private static $start_time;
|
||||
private static float $start_time;
|
||||
/** @var float */
|
||||
private static $end_time;
|
||||
private static float $end_time;
|
||||
/** @var string */
|
||||
private static $running_time_string;
|
||||
private static string $running_time_string;
|
||||
|
||||
/**
|
||||
* sub calculation for running time based on out time.
|
||||
@@ -79,7 +79,7 @@ class RunningTime
|
||||
public static function hrRunningTime(string $out_time = 'ms'): float
|
||||
{
|
||||
// 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_last_time = self::$hr_start_time;
|
||||
$run_time = 0;
|
||||
@@ -137,7 +137,7 @@ class RunningTime
|
||||
list($micro, $timestamp) = explode(' ', microtime());
|
||||
$running_time = 0;
|
||||
// set start & end time
|
||||
if (!self::$start_time) {
|
||||
if (empty(self::$start_time)) {
|
||||
// always reset running time string on first call
|
||||
self::$running_time_string = '';
|
||||
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 .= ' ' . $micro . ($simple ? ', ' : '<br>');
|
||||
// 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;
|
||||
self::$running_time_string .= ($simple ? 'Run: ' : "<b>Script running time</b>: ") . $running_time . " s";
|
||||
// reset start & end time after run
|
||||
|
||||
@@ -21,7 +21,7 @@ class Support
|
||||
*/
|
||||
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);
|
||||
// if microtime flag is -1 no round, if 0, no microtime, if >= 1, round that size
|
||||
if ($set_microtime == -1) {
|
||||
@@ -158,19 +158,32 @@ class Support
|
||||
* var_dump based
|
||||
* Recommended debug output
|
||||
*
|
||||
* @param mixed $data Anything
|
||||
* @param bool $no_html If true strip all html tags (for text print)
|
||||
* @return string A text string
|
||||
* @param mixed $data Anything
|
||||
* @param bool $no_html [default=false] If true strip all html tags
|
||||
* (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();
|
||||
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
|
||||
// "path ... CoreLibs/Debug/Support.php:<number>:
|
||||
// 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(
|
||||
'|<small>(/.*:\d+:)</small>|',
|
||||
'<small>' . $caller_file_number . ':</small>',
|
||||
|
||||
@@ -54,14 +54,15 @@ class System
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$host = $_SERVER['HTTP_HOST'] ?? 'NOHOST:NOPORT';
|
||||
list($host_name, $port) = array_pad(explode(':', $host), 2, self::DEFAULT_PORT);
|
||||
return [$host_name, $port];
|
||||
$host = $_SERVER['HTTP_HOST'] ?? 'NOHOST:0';
|
||||
[$host_name, $port] = array_pad(explode(':', $host), 2, self::DEFAULT_PORT);
|
||||
return [$host_name, (int)$port];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace CoreLibs\Language\Core;
|
||||
class CachedFileReader extends \CoreLibs\Language\Core\StringReader
|
||||
{
|
||||
/** @var int */
|
||||
public $error = 0;
|
||||
public int $error = 0;
|
||||
/** @var string */
|
||||
public $fd_str = '';
|
||||
public string $fd_str = '';
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace CoreLibs\Language\Core;
|
||||
class FileReader
|
||||
{
|
||||
/** @var int */
|
||||
public $fr_pos;
|
||||
public int $fr_pos;
|
||||
/** @var resource|bool */
|
||||
public $fr_fd;
|
||||
public mixed $fr_fd; // no resource type yet
|
||||
/** @var int */
|
||||
public $fr_length;
|
||||
public int $fr_length;
|
||||
/** @var int */
|
||||
public $error = 0;
|
||||
public int $error = 0;
|
||||
|
||||
/**
|
||||
* file read constructor
|
||||
|
||||
@@ -41,31 +41,31 @@ class GetTextReader
|
||||
{
|
||||
// public:
|
||||
/** @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:
|
||||
/** @var int */
|
||||
private $BYTEORDER = 0; // 0: low endian, 1: big endian
|
||||
private int $BYTEORDER = 0; // 0: low endian, 1: big endian
|
||||
/** @var FileReader */
|
||||
private $STREAM;
|
||||
private FileReader $STREAM;
|
||||
/** @var bool */
|
||||
private $short_circuit = false;
|
||||
private bool $short_circuit = false;
|
||||
/** @var bool */
|
||||
private $enable_cache = false;
|
||||
private bool $enable_cache = false;
|
||||
/** @var int */
|
||||
private $originals = 0; // offset of original table
|
||||
private int $originals = 0; // offset of original table
|
||||
/** @var int */
|
||||
private $translations = 0; // offset of translation table
|
||||
private int $translations = 0; // offset of translation table
|
||||
/** @var string */
|
||||
private $pluralheader = ''; // cache header field for plural forms
|
||||
private string $pluralheader = ''; // cache header field for plural forms
|
||||
/** @var int */
|
||||
private $total = 0; // total string count
|
||||
private int $total = 0; // total string count
|
||||
/** @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 */
|
||||
private $table_translations = null; // table for translated strings (offsets)
|
||||
private array|null $table_translations = null; // table for translated strings (offsets)
|
||||
/** @var array<mixed> */
|
||||
private $cache_translations = []; // original -> translation mapping
|
||||
private array $cache_translations = []; // original -> translation mapping
|
||||
|
||||
/* Methods */
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace CoreLibs\Language\Core;
|
||||
class StringReader
|
||||
{
|
||||
/** @var int */
|
||||
public $sr_pos;
|
||||
public int $sr_pos;
|
||||
/** @var string */
|
||||
public $sr_str;
|
||||
public string $sr_str;
|
||||
|
||||
/**
|
||||
* constructor for string reader
|
||||
|
||||
@@ -35,42 +35,42 @@ class L10n
|
||||
/** @var string the default fallback encoding if nothing is set */
|
||||
public const DEFAULT_CHARSET = 'UTF-8';
|
||||
/** @var string the current locale */
|
||||
private $locale = '';
|
||||
private string $locale = '';
|
||||
/** @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 */
|
||||
private $domain = '';
|
||||
private string $domain = '';
|
||||
/** @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 */
|
||||
private $encoding = '';
|
||||
private string $encoding = '';
|
||||
/** @var array<string,array<string,GetTextReader>> locale > domain = translator */
|
||||
private $domains = [];
|
||||
private array $domains = [];
|
||||
/** @var array<string,string> bound paths for domains */
|
||||
private $paths = ['' => './'];
|
||||
private array $paths = ['' => './'];
|
||||
|
||||
// files
|
||||
/** @var string the full path to the mo file to loaded */
|
||||
private $mofile = '';
|
||||
private string $mofile = '';
|
||||
/** @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 */
|
||||
private $base_content_path = '';
|
||||
private string $base_content_path = '';
|
||||
|
||||
// errors
|
||||
/** @var bool if load of mo file was unsuccessful */
|
||||
private $load_failure = false;
|
||||
private bool $load_failure = false;
|
||||
|
||||
// object holders
|
||||
/** @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 */
|
||||
private $l10n;
|
||||
private GetTextReader|null $l10n = null;
|
||||
/**
|
||||
* @static
|
||||
* @var L10n self class
|
||||
*/
|
||||
private static $instance;
|
||||
private static L10n $instance;
|
||||
|
||||
/**
|
||||
* class constructor call for language getstring
|
||||
@@ -124,7 +124,6 @@ class L10n
|
||||
*/
|
||||
public static function getInstance(): L10n
|
||||
{
|
||||
/** @phpstan-ignore-next-line */
|
||||
if (empty(self::$instance)) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
@@ -253,6 +252,13 @@ class L10n
|
||||
// dummy
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -673,6 +679,7 @@ class L10n
|
||||
// fallback passthrough
|
||||
if ($this->l10n === null) {
|
||||
echo $text;
|
||||
return;
|
||||
}
|
||||
echo $this->l10n->translate($text);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
* DESCRIPTION:
|
||||
* 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);
|
||||
@@ -81,38 +86,38 @@ class Logging
|
||||
|
||||
// options
|
||||
/** @var array<mixed> */
|
||||
private $options = [];
|
||||
private array $options = [];
|
||||
|
||||
/** @var Level set level */
|
||||
private $log_level;
|
||||
private Level $log_level;
|
||||
|
||||
// page and host name
|
||||
/** @var string */
|
||||
private $host_name;
|
||||
private string $host_name;
|
||||
/** @var int */
|
||||
private $host_port;
|
||||
private int $host_port;
|
||||
/** @var string unique ID set on class init and used in logging as prefix */
|
||||
private $running_uid = '';
|
||||
private string $running_uid = '';
|
||||
|
||||
// log file name
|
||||
/** @var string */
|
||||
private $log_folder = '';
|
||||
private string $log_folder = '';
|
||||
/** @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 */
|
||||
private $log_file_name_ext = 'log';
|
||||
private string $log_file_name_ext = 'log';
|
||||
/** @var string log file name with folder, for actual writing */
|
||||
private $log_file_name = '';
|
||||
private string $log_file_name = '';
|
||||
/** @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 */
|
||||
private $log_file_prefix = 'error_msg';
|
||||
private string $log_file_prefix = 'error_msg';
|
||||
/** @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 */
|
||||
private $log_file_unique_id = '';
|
||||
private string $log_file_unique_id = '';
|
||||
/** @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)
|
||||
@@ -123,9 +128,9 @@ class Logging
|
||||
* 32: split log per set log level
|
||||
*/
|
||||
/** @var int bitwise set for log flags */
|
||||
private $log_flags = 0;
|
||||
private int $log_flags = 0;
|
||||
/** @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_date' => Flag::per_date,
|
||||
'log_per_group' => Flag::per_group,
|
||||
@@ -323,10 +328,10 @@ class Logging
|
||||
private function initHostName(): void
|
||||
{
|
||||
// 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
|
||||
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 = [],
|
||||
string $group_id = '',
|
||||
): 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
|
||||
$class = Support::getCallerClass();
|
||||
// method/function: prepareLog->(debug|info|...)->[THIS]
|
||||
$method = Support::getCallerMethod(3);
|
||||
if ($method !== null) {
|
||||
$class .= '::' . $method;
|
||||
}
|
||||
// get timestamp
|
||||
$timestamp = Support::printTime();
|
||||
|
||||
@@ -562,7 +575,7 @@ class Logging
|
||||
// build log string
|
||||
return '[' . $timestamp . '] '
|
||||
. '[' . $this->host_name . '] '
|
||||
. '[' . System::getPageName(System::FULL_PATH) . '] '
|
||||
. '[' . $file_line . '] '
|
||||
. '[' . $this->running_uid . '] '
|
||||
. '{' . $class . '} '
|
||||
. '<' . strtoupper($group_str) . '> '
|
||||
@@ -598,7 +611,6 @@ class Logging
|
||||
. implode(', ', Level::NAMES + Level::VALUES)
|
||||
);
|
||||
}
|
||||
|
||||
return $levelEnum;
|
||||
}
|
||||
|
||||
@@ -710,7 +722,10 @@ class Logging
|
||||
if (empty($this->log_file_unique_id) || $override == true) {
|
||||
$this->log_file_unique_id =
|
||||
date('Y-m-d_His') . '_U_'
|
||||
. substr(hash('sha1', uniqid((string)mt_rand(), true)), 0, 8);
|
||||
. substr(hash(
|
||||
'sha1',
|
||||
random_bytes(63)
|
||||
), 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -226,84 +226,84 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// for the load statetment describes which elements from
|
||||
// the load query should be shown and i which format
|
||||
/** @var array<mixed> */
|
||||
public $field_array = [];
|
||||
public array $field_array = [];
|
||||
/** @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 */
|
||||
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 */
|
||||
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 */
|
||||
public $msg; // the error msg
|
||||
public string $msg; // the error msg
|
||||
/** @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 */
|
||||
public $warning; // warning flag, for information (saved, loaded, etc)
|
||||
public int $warning; // warning flag, for information (saved, loaded, etc)
|
||||
/** @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 */
|
||||
private $int_pk_name; // primary key, only internal usage
|
||||
private string $int_pk_name; // primary key, only internal usage
|
||||
/** @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[]
|
||||
/** @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> */
|
||||
public $table_array = [];
|
||||
public array $table_array = [];
|
||||
/** @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 */
|
||||
public $mobile_phone = false;
|
||||
public bool $mobile_phone = false;
|
||||
/** @var string */
|
||||
public $email_regex;
|
||||
public string $email_regex;
|
||||
// buttons and checkboxes
|
||||
/** @var string */
|
||||
public $archive;
|
||||
public string $archive;
|
||||
/** @var string */
|
||||
public $new;
|
||||
public string $new;
|
||||
/** @var string */
|
||||
public $really_new;
|
||||
public string $really_new;
|
||||
/** @var string */
|
||||
public $delete;
|
||||
public string $delete;
|
||||
/** @var string */
|
||||
public $really_delete;
|
||||
public string $really_delete;
|
||||
/** @var string */
|
||||
public $save;
|
||||
public string $save;
|
||||
/** @var string */
|
||||
public $remove_button;
|
||||
public string $remove_button;
|
||||
// security values
|
||||
/** @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) */
|
||||
private $acl_admin = 0;
|
||||
private int $acl_admin = 0;
|
||||
/** @var array<mixed> */
|
||||
public $security_level;
|
||||
public array $security_level;
|
||||
/** @var array<string,mixed> Login ACL */
|
||||
public $login_acl = [];
|
||||
public array $login_acl = [];
|
||||
// layout publics
|
||||
/** @var int */
|
||||
public $table_width;
|
||||
public int $table_width;
|
||||
// internal lang & encoding vars
|
||||
/** @var string */
|
||||
public $lang_dir = '';
|
||||
public string $lang_dir = '';
|
||||
/** @var string */
|
||||
public $lang;
|
||||
public string $lang;
|
||||
/** @var string */
|
||||
public $lang_short;
|
||||
public string $lang_short;
|
||||
/** @var string */
|
||||
public $domain;
|
||||
public string $domain;
|
||||
/** @var string */
|
||||
public $encoding;
|
||||
public string $encoding;
|
||||
// language
|
||||
/** @var \CoreLibs\Language\L10n */
|
||||
public $l;
|
||||
public \CoreLibs\Language\L10n $l;
|
||||
// log
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
public $log;
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
|
||||
// now some default error msgs (english)
|
||||
/** @var array<mixed> */
|
||||
public $language_array = [];
|
||||
public array $language_array = [];
|
||||
|
||||
/**
|
||||
* construct form generator
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditAccess implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditGroups implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditLanguages implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditMenuGroup implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditPages implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditSchemas implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditUsers implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace CoreLibs\Output\Form\TableArrays;
|
||||
class EditVisibleGroup implements Interface\TableArraysInterface
|
||||
{
|
||||
/** @var \CoreLibs\Output\Form\Generate */
|
||||
private $form;
|
||||
private \CoreLibs\Output\Form\Generate $form;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -23,13 +23,13 @@ class ProgressBar
|
||||
// private vars
|
||||
|
||||
/** @var string */
|
||||
public $code; // unique code
|
||||
public string $code; // unique code
|
||||
/** @var string */
|
||||
public $status = 'new'; // current status (new,show,hide)
|
||||
public string $status = 'new'; // current status (new,show,hide)
|
||||
/** @var float|int */
|
||||
public $step = 0; // current step
|
||||
public float|int $step = 0; // current step
|
||||
/** @var array<string,null|int|float> */
|
||||
public $position = [ // current bar position
|
||||
public array $position = [ // current bar position
|
||||
'left' => null,
|
||||
'top' => null,
|
||||
'width' => null,
|
||||
@@ -37,43 +37,43 @@ class ProgressBar
|
||||
];
|
||||
|
||||
/** @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 */
|
||||
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
|
||||
|
||||
/** @var int */
|
||||
public $min = 0; // minimal steps
|
||||
public int $min = 0; // minimal steps
|
||||
/** @var int */
|
||||
public $max = 100; // maximal steps
|
||||
public int $max = 100; // maximal steps
|
||||
|
||||
/** @var int */
|
||||
public $left = 5; // bar position from left
|
||||
public int $left = 5; // bar position from left
|
||||
/** @var int */
|
||||
public $top = 5; // bar position from top
|
||||
public int $top = 5; // bar position from top
|
||||
/** @var int */
|
||||
public $width = 300; // bar width
|
||||
public int $width = 300; // bar width
|
||||
/** @var int */
|
||||
public $height = 25; // bar height
|
||||
public int $height = 25; // bar height
|
||||
/** @var int */
|
||||
public $pedding = 0; // bar pedding
|
||||
public int $pedding = 0; // bar pedding
|
||||
/** @var string */
|
||||
public $color = '#0033ff'; // bar color
|
||||
public string $color = '#0033ff'; // bar color
|
||||
/** @var string */
|
||||
public $bgr_color = '#c0c0c0'; // bar background color
|
||||
public string $bgr_color = '#c0c0c0'; // bar background color
|
||||
/** @var string */
|
||||
public $bgr_color_master = '#ffffff'; // master div background color
|
||||
public string $bgr_color_master = '#ffffff'; // master div background color
|
||||
/** @var int */
|
||||
public $border = 1; // bar border width
|
||||
public int $border = 1; // bar border width
|
||||
/** @var string */
|
||||
public $brd_color = '#000000'; // bar border color
|
||||
public string $brd_color = '#000000'; // bar border color
|
||||
|
||||
/** @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> */
|
||||
public $frame = ['show' => false]; // ProgressBar Frame
|
||||
public array $frame = ['show' => false]; // ProgressBar Frame
|
||||
/* 'show' => false, # frame show (true/false)
|
||||
'left' => 200, # frame position from left
|
||||
'top' => 100, # frame position from top
|
||||
@@ -86,7 +86,7 @@ class ProgressBar
|
||||
|
||||
/** @#var array{string}{string: string|int} */
|
||||
/** @var mixed[][] */
|
||||
public $label = []; // ProgressBar Labels
|
||||
public array $label = []; // ProgressBar Labels
|
||||
/* 'name' => [ # label name
|
||||
'type' => 'text', # label type (text,button,step,percent,crossbar)
|
||||
'value' => 'Please wait ...', # label value
|
||||
@@ -105,7 +105,7 @@ class ProgressBar
|
||||
|
||||
/** @var string */
|
||||
// output strings
|
||||
public $prefix_message = '';
|
||||
public string $prefix_message = '';
|
||||
|
||||
/**
|
||||
* progress bar constructor
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -24,134 +24,132 @@ class SmartyExtend extends \Smarty
|
||||
{
|
||||
// internal translation engine
|
||||
/** @var \CoreLibs\Language\L10n */
|
||||
public $l10n;
|
||||
public \CoreLibs\Language\L10n $l10n;
|
||||
|
||||
// lang & encoding
|
||||
/** @var string */
|
||||
public $lang_dir = '';
|
||||
public string $lang_dir = '';
|
||||
/** @var string */
|
||||
public $lang;
|
||||
public string $lang;
|
||||
/** @var string */
|
||||
public $locale_set;
|
||||
public string $lang_short;
|
||||
/** @var string */
|
||||
public $lang_short;
|
||||
public string $domain;
|
||||
/** @var string */
|
||||
public $domain;
|
||||
/** @var string */
|
||||
public $encoding;
|
||||
public string $encoding;
|
||||
// page name
|
||||
/** @var string */
|
||||
public $page_name;
|
||||
public string $page_name;
|
||||
|
||||
// array for data parsing
|
||||
/** @var array<mixed> */
|
||||
public $HEADER = [];
|
||||
public array $HEADER = [];
|
||||
/** @var array<mixed> */
|
||||
public $DATA = [];
|
||||
public array $DATA = [];
|
||||
/** @var array<mixed> */
|
||||
public $DEBUG_DATA = [];
|
||||
public array $DEBUG_DATA = [];
|
||||
/** @var array<mixed> */
|
||||
private $CONTENT_DATA = [];
|
||||
private array $CONTENT_DATA = [];
|
||||
// control vars
|
||||
/** @var bool */
|
||||
public $USE_PROTOTYPE = USE_PROTOTYPE;
|
||||
public bool $USE_PROTOTYPE = USE_PROTOTYPE;
|
||||
/** @var bool */
|
||||
public $USE_JQUERY = USE_JQUERY;
|
||||
public bool $USE_JQUERY = USE_JQUERY;
|
||||
/** @var bool */
|
||||
public $USE_SCRIPTACULOUS = USE_SCRIPTACULOUS;
|
||||
public bool $USE_SCRIPTACULOUS = USE_SCRIPTACULOUS;
|
||||
// sub content input vars
|
||||
/** @var bool */
|
||||
public $USE_TINY_MCE = false;
|
||||
public bool $USE_TINY_MCE = false;
|
||||
/** @var bool */
|
||||
public $JS_DATEPICKR = false;
|
||||
public bool $JS_DATEPICKR = false;
|
||||
/** @var bool */
|
||||
public $JS_FLATPICKR = false;
|
||||
public bool $JS_FLATPICKR = false;
|
||||
/** @var bool */
|
||||
public $JS_FILE_UPLOADER = false;
|
||||
public bool $JS_FILE_UPLOADER = false;
|
||||
/** @var bool */
|
||||
public $DEBUG_TMPL = false;
|
||||
public bool $DEBUG_TMPL = false;
|
||||
/** @var bool */
|
||||
public $USE_INCLUDE_TEMPLATE = false;
|
||||
public bool $USE_INCLUDE_TEMPLATE = false;
|
||||
// cache & compile
|
||||
/** @var string */
|
||||
public $CACHE_ID = '';
|
||||
public string $CACHE_ID = '';
|
||||
/** @var string */
|
||||
public $COMPILE_ID = '';
|
||||
public string $COMPILE_ID = '';
|
||||
// template vars
|
||||
/** @var string */
|
||||
public $MASTER_TEMPLATE_NAME;
|
||||
public string $MASTER_TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $PAGE_FILE_NAME;
|
||||
public string $PAGE_FILE_NAME;
|
||||
/** @var string */
|
||||
public $CONTENT_INCLUDE;
|
||||
public string $CONTENT_INCLUDE;
|
||||
/** @var string */
|
||||
public $FORM_NAME;
|
||||
public string $FORM_NAME;
|
||||
/** @var string */
|
||||
public $FORM_ACTION;
|
||||
public string $FORM_ACTION;
|
||||
/** @var string */
|
||||
public $L_TITLE;
|
||||
public string $L_TITLE;
|
||||
/** @var string|int */
|
||||
public $PAGE_WIDTH;
|
||||
public string|int $PAGE_WIDTH;
|
||||
// smarty include/set var
|
||||
/** @var string */
|
||||
public $TEMPLATE_PATH;
|
||||
public string $TEMPLATE_PATH;
|
||||
/** @var string */
|
||||
public $TEMPLATE_NAME;
|
||||
public string $TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $INC_TEMPLATE_NAME;
|
||||
public string $INC_TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $JS_TEMPLATE_NAME;
|
||||
public string $JS_TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $CSS_TEMPLATE_NAME;
|
||||
public string $CSS_TEMPLATE_NAME;
|
||||
/** @var string|null */
|
||||
public $TEMPLATE_TRANSLATE;
|
||||
public string|null $TEMPLATE_TRANSLATE;
|
||||
/** @var string|null */
|
||||
public $JS_TRANSLATE;
|
||||
public string|null $JS_TRANSLATE;
|
||||
// core group
|
||||
/** @var string */
|
||||
public $JS_CORE_TEMPLATE_NAME;
|
||||
public string $JS_CORE_TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $CSS_CORE_TEMPLATE_NAME;
|
||||
public string $CSS_CORE_TEMPLATE_NAME;
|
||||
/** @var string */
|
||||
public $JS_CORE_INCLUDE;
|
||||
public string $JS_CORE_INCLUDE;
|
||||
/** @var string */
|
||||
public $CSS_CORE_INCLUDE;
|
||||
public string $CSS_CORE_INCLUDE;
|
||||
// local names
|
||||
/** @var string */
|
||||
public $JS_SPECIAL_TEMPLATE_NAME = '';
|
||||
public string $JS_SPECIAL_TEMPLATE_NAME = '';
|
||||
/** @var string */
|
||||
public $CSS_SPECIAL_TEMPLATE_NAME = '';
|
||||
public string $CSS_SPECIAL_TEMPLATE_NAME = '';
|
||||
/** @var string */
|
||||
public $JS_INCLUDE;
|
||||
public string $JS_INCLUDE;
|
||||
/** @var string */
|
||||
public $CSS_INCLUDE;
|
||||
public string $CSS_INCLUDE;
|
||||
/** @var string */
|
||||
public $JS_SPECIAL_INCLUDE;
|
||||
public string $JS_SPECIAL_INCLUDE;
|
||||
/** @var string */
|
||||
public $CSS_SPECIAL_INCLUDE;
|
||||
public string $CSS_SPECIAL_INCLUDE;
|
||||
/** @var string */
|
||||
public $ADMIN_JAVASCRIPT;
|
||||
public string $ADMIN_JAVASCRIPT;
|
||||
/** @var string */
|
||||
public $ADMIN_STYLESHEET;
|
||||
public string $ADMIN_STYLESHEET;
|
||||
/** @var string */
|
||||
public $FRONTEND_JAVASCRIPT;
|
||||
public string $FRONTEND_JAVASCRIPT;
|
||||
/** @var string */
|
||||
public $FRONTEND_STYLESHEET;
|
||||
public string $FRONTEND_STYLESHEET;
|
||||
// other smarty folder vars
|
||||
/** @var string */
|
||||
public $INCLUDES;
|
||||
public string $INCLUDES;
|
||||
/** @var string */
|
||||
public $JAVASCRIPT;
|
||||
public string $JAVASCRIPT;
|
||||
/** @var string */
|
||||
public $CSS;
|
||||
public string $CSS;
|
||||
/** @var string */
|
||||
public $FONT;
|
||||
public string $FONT;
|
||||
/** @var string */
|
||||
public $PICTURES;
|
||||
public string $PICTURES;
|
||||
/** @var string */
|
||||
public $CACHE_PICTURES;
|
||||
public string $CACHE_PICTURES;
|
||||
/** @var string */
|
||||
public $CACHE_PICTURES_ROOT;
|
||||
public string $CACHE_PICTURES_ROOT;
|
||||
|
||||
// constructor class, just sets the language stuff
|
||||
/**
|
||||
@@ -222,6 +220,7 @@ class SmartyExtend extends \Smarty
|
||||
// core CS
|
||||
$this->CSS_CORE_INCLUDE = '';
|
||||
if (
|
||||
!empty($this->CSS_CORE_TEMPLATE_NAME) &&
|
||||
file_exists($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
|
||||
$this->JS_CORE_INCLUDE = '';
|
||||
if (
|
||||
!empty($this->JS_CORE_TEMPLATE_NAME) &&
|
||||
file_exists($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
|
||||
if (empty($this->TEMPLATE_TRANSLATE)) {
|
||||
$this->TEMPLATE_TRANSLATE = 'jsTranslate-'
|
||||
. $this->locale_set . '.' . $this->encoding
|
||||
. $this->l10n->getLocaleSet() . '.' . $this->encoding
|
||||
. '.tpl';
|
||||
} else {
|
||||
// we assume we have some fixed set
|
||||
@@ -408,12 +408,12 @@ class SmartyExtend extends \Smarty
|
||||
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
|
||||
$this->TEMPLATE_TRANSLATE = str_replace(
|
||||
'.tpl',
|
||||
'-' . $this->locale_set . '.' . $this->encoding . '.tpl',
|
||||
'-' . $this->l10n->getLocaleSet() . '.' . $this->encoding . '.tpl',
|
||||
$this->TEMPLATE_TRANSLATE
|
||||
);
|
||||
} else {
|
||||
$this->TEMPLATE_TRANSLATE .= '-'
|
||||
. $this->locale_set . '.' . $this->encoding
|
||||
. $this->l10n->getLocaleSet() . '.' . $this->encoding
|
||||
. '.tpl';
|
||||
}
|
||||
}
|
||||
@@ -423,7 +423,7 @@ class SmartyExtend extends \Smarty
|
||||
}
|
||||
if (empty($this->JS_TRANSLATE)) {
|
||||
$this->JS_TRANSLATE = 'translate-'
|
||||
. $this->locale_set . '.' . $this->encoding . '.js';
|
||||
. $this->l10n->getLocaleSet() . '.' . $this->encoding . '.js';
|
||||
} else {
|
||||
// we assume we have some fixed set
|
||||
// we must add _<locale>.<encoding>
|
||||
@@ -432,12 +432,12 @@ class SmartyExtend extends \Smarty
|
||||
if (strpos($this->JS_TRANSLATE, '.js')) {
|
||||
$this->JS_TRANSLATE = str_replace(
|
||||
'.js',
|
||||
'-' . $this->locale_set . '.' . $this->encoding . '.js',
|
||||
'-' . $this->l10n->getLocaleSet() . '.' . $this->encoding . '.js',
|
||||
$this->JS_TRANSLATE
|
||||
);
|
||||
} else {
|
||||
$this->JS_TRANSLATE .= '-'
|
||||
. $this->locale_set . '.' . $this->encoding
|
||||
. $this->l10n->getLocaleSet() . '.' . $this->encoding
|
||||
. '.js';
|
||||
}
|
||||
}
|
||||
@@ -675,10 +675,12 @@ class SmartyExtend extends \Smarty
|
||||
$this->HEADER['DEFAULT_ENCODING'] = $set_default_encoding;
|
||||
|
||||
// form name
|
||||
$this->DATA['FORM_NAME'] = !$this->FORM_NAME ?
|
||||
$this->DATA['FORM_NAME'] = empty($this->FORM_NAME) ?
|
||||
str_replace('.php', '', $this->page_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
|
||||
if ($admin_call === true) {
|
||||
// depreacte call globals cms on null 4mcs
|
||||
@@ -735,7 +737,7 @@ class SmartyExtend extends \Smarty
|
||||
}
|
||||
// html 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)))
|
||||
. (!empty($set_g_title) ? '-' . $this->l10n->__($set_g_title) : '') :
|
||||
$this->l10n->__($this->L_TITLE);
|
||||
|
||||
Reference in New Issue
Block a user