Compare commits

...

73 Commits

Author SHA1 Message Date
Clemens Schwaighofer
40e6444c2a CoreLibs update 2026-01-06 18:22:17 +09:00
Clemens Schwaighofer
4b015505ff admin libs update 2025-06-05 18:13:10 +09:00
Clemens Schwaighofer
e90387c1fc Composer update 2025-05-15 15:35:13 +09:00
Clemens Schwaighofer
3fb7169531 CoreLibs update 2025-01-16 10:25:19 +09:00
Clemens Schwaighofer
e4dd73d0e9 Composer package update 2024-12-18 10:38:34 +09:00
Clemens Schwaighofer
e71c53b887 Composer package update 2024-12-13 10:48:28 +09:00
Clemens Schwaighofer
16addc4f4b CoreLibs version update 2024-12-05 14:06:44 +09:00
Clemens Schwaighofer
7e845d3954 v9.22.0 update 2024-12-03 13:29:31 +09:00
Clemens Schwaighofer
6fcb7a44e0 Composer corelibs update 2024-11-27 14:36:02 +09:00
Clemens Schwaighofer
e82e4f6079 Admin pages update 2024-11-27 14:35:30 +09:00
Clemens Schwaighofer
231897cf5b phpstan 2.0 update 2024-11-18 18:33:45 +09:00
Clemens Schwaighofer
17da804073 Composer package update 2024-11-18 14:55:46 +09:00
Clemens Schwaighofer
96ad4b0f48 Update admin pages 2024-11-06 13:33:25 +09:00
Clemens Schwaighofer
1386afb552 Composer git pull update 2024-11-06 10:47:54 +09:00
Clemens Schwaighofer
86a9ad8789 Admin pages updates 2024-10-16 14:13:17 +09:00
Clemens Schwaighofer
0c4c018ffa Composer update 2024-09-20 13:39:21 +09:00
Clemens Schwaighofer
8b36807a2e admin files updates 2024-09-20 13:39:00 +09:00
Clemens Schwaighofer
8daef88e5e Composer dev update 2024-09-03 12:09:22 +09:00
Clemens Schwaighofer
a59fa7a2c9 Admin tests update 2024-09-03 12:08:37 +09:00
Clemens Schwaighofer
14c8197a7f Composer update 2024-08-05 13:27:37 +09:00
Clemens Schwaighofer
79bd7fa256 admin class test pages fixes 2024-08-05 13:07:52 +09:00
Clemens Schwaighofer
9ba09b22f5 Class test php udpate 2024-07-29 16:00:19 +09:00
Clemens Schwaighofer
e88ad00d7f Corelibs composer update 2024-05-22 10:54:29 +09:00
Clemens Schwaighofer
9b80fde0d7 Remove composer vendor 2024-05-22 10:54:10 +09:00
Clemens Schwaighofer
f99e8bb70c admin updates 2024-05-22 10:52:28 +09:00
Clemens Schwaighofer
b48894d000 Composer update 2024-03-21 12:41:50 +09:00
Clemens Schwaighofer
5ebe7dc06c Code updates 2024-03-07 15:02:25 +09:00
Clemens Schwaighofer
2e6b7b2f5b Composer basic updates 2024-03-06 18:27:39 +09:00
Clemens Schwaighofer
897406456a admin updates 2023-11-29 10:47:55 +09:00
Clemens Schwaighofer
edb0620308 admin files updates 2023-10-31 10:22:44 +09:00
Clemens Schwaighofer
90edcbf8c8 Admin pages updates 2023-10-16 16:11:34 +09:00
Clemens Schwaighofer
40f267f3dd composer update 2023-10-12 17:15:28 +09:00
Clemens Schwaighofer
c8aee19deb composer local test update 2023-09-15 18:23:25 +09:00
Clemens Schwaighofer
74c8b8d71e CoreLibs update 2023-09-11 13:40:26 +09:00
Clemens Schwaighofer
c0db3be770 Composer libs update 2023-09-01 18:36:22 +09:00
Clemens Schwaighofer
e74bd04d6f Composer updates 2023-08-28 09:54:33 +09:00
Clemens Schwaighofer
3662b1ab1b Composer updates 2023-07-14 15:11:43 +09:00
Clemens Schwaighofer
7abce87653 composer test update 2023-07-04 12:56:10 +09:00
Clemens Schwaighofer
b3e35b5d94 CoreLibs updates 2023-06-16 13:25:07 +09:00
Clemens Schwaighofer
6429b77bda class_test calls 2023-06-16 13:19:16 +09:00
Clemens Schwaighofer
3c8bdab8fa CoreLibs update 2023-06-05 18:33:54 +09:00
Clemens Schwaighofer
3cf6fee548 Bug fixes and updates 2023-06-01 08:48:28 +09:00
Clemens Schwaighofer
f5a9757ae3 composer test update 2023-05-31 16:43:30 +09:00
Clemens Schwaighofer
3d6b461b20 composer update, composer corelibs update, admin pages update 2023-05-31 16:17:14 +09:00
Clemens Schwaighofer
513b115d57 Composer update 2023-05-30 18:31:24 +09:00
Clemens Schwaighofer
eb16f433e8 Composer updates 2023-05-24 15:54:53 +09:00
Clemens Schwaighofer
8f94201478 admin files updates 2023-05-18 15:18:57 +09:00
Clemens Schwaighofer
1b2359a934 Commposer update 2023-05-18 15:18:09 +09:00
Clemens Schwaighofer
d6187005f4 Composer update 2023-04-26 15:41:39 +09:00
Clemens Schwaighofer
f0e6b5b8e9 Composer package update 2023-04-26 14:45:48 +09:00
Clemens Schwaighofer
6b400978ac ComposerLib update 2023-04-11 11:02:26 +09:00
Clemens Schwaighofer
2754a718fa Composer test upgrades 2023-04-10 14:36:37 +09:00
Clemens Schwaighofer
37c3b6afeb Update corelibs for composer test 2023-04-10 09:05:07 +09:00
Clemens Schwaighofer
516b11f2f1 Composer test update 2023-04-03 15:05:22 +09:00
Clemens Schwaighofer
75a42558fd CoreLibs update v8.1.2 2023-03-29 10:02:20 +09:00
Clemens Schwaighofer
48271a8659 Composer update 2023-03-28 16:48:36 +09:00
Clemens Schwaighofer
35d3032df5 CoreLibs DB\IO params methods 2023-03-28 15:39:13 +09:00
Clemens Schwaighofer
7be8bb06c9 CoreLibs update 2023-03-13 09:30:32 +09:00
Clemens Schwaighofer
2aab94a842 CoreLibs composer v8.0.5 update test 2023-03-10 15:29:38 +09:00
Clemens Schwaighofer
1cbe4e5c06 Composer CoreLibs update 2023-03-09 17:00:10 +09:00
Clemens Schwaighofer
137fb9a986 Composer path composer packages update 2023-02-28 18:08:57 +09:00
Clemens Schwaighofer
e1357f5d39 Composer install updates 2023-02-28 12:06:28 +09:00
Clemens Schwaighofer
8766d4db77 Reinstall smarty with fixed autoloader 2023-02-17 13:01:41 +09:00
Clemens Schwaighofer
b696338324 Install Smarty Composer package 2023-02-17 11:23:53 +09:00
Clemens Schwaighofer
43e66edfd1 Composer installed CoreLibs 2023-02-16 17:13:30 +09:00
Clemens Schwaighofer
0e99700bbe Composer vendor name change 2023-02-16 13:04:20 +09:00
Clemens Schwaighofer
2f0b9fb360 Move Fonts folder from lib to includes 2023-02-16 12:32:15 +09:00
Clemens Schwaighofer
c7cc3c2938 Move all dev tools from www composer to outside master composer 2023-02-13 16:36:51 +09:00
Clemens Schwaighofer
f508b607a6 Add new class for auto set vars to certain types or null
Convert\VarSetType for always return type expected (eg string will be string)
or Convert\VarSetTypeNull to return string or null on failure

The return value for failure if not matching type can be set for both, but
only for Convert\VarSetTypeNull the return value can be set to null.
2023-02-08 12:12:46 +09:00
Clemens Schwaighofer
f94b350ba4 Install phan/phpstan local 2023-02-08 12:02:18 +09:00
Clemens Schwaighofer
53eef03387 Fixes in DB\IO query detection regex
- start with allow whitespace in front
- returning allows more white space types between keyword and parameter list
2023-02-02 10:27:07 +09:00
Clemens Schwaighofer
5a81445a28 DB\IO table match regex fix
UPDATE with SET can have spaces with variable length before
2023-01-27 11:31:26 +09:00
Clemens Schwaighofer
4bbbd653cd DB\IO fix for regex query detection
Fix for basic query detection:
Simeple starts with
SELECT/WITH/SHOW
INSERT INTO/UPDATE/DELETE FROM
UPDATE

Above does no complex query detection, just if the string starts with this

Fix form table detection for primary key auto set trial.
2023-01-27 11:12:46 +09:00
2039 changed files with 152450 additions and 115723 deletions

3
.gitignore vendored
View File

@@ -0,0 +1,3 @@
composer.lock
vendor/
.env

View File

@@ -0,0 +1,256 @@
<?php
/*
* Run is_<type> checks and return default value if not this type
* This will return default null on invalid entries
*/
declare(strict_types=1);
namespace CoreLibs\Convert\Extends;
class VarSetTypeMain
{
/**
* If input variable is string then returns it, else returns default set
* if not null is true, then null as return is allowed, else return is
* converted to string
*
* @param mixed $val Input variable
* @param string|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return string|null Input var or default value
*/
protected static function setStrMain(
mixed $val,
?string $default = null,
bool $to_null = false
): ?string {
if (is_string($val)) {
return $val;
}
if ($to_null === false) {
return (string)$default;
}
return $default;
}
/**
* Will convert input data to string if possible.
* Runs for string/int/float/bool/null
* Will skip array/object/resource/callable/etc and use default for that
*
* @param mixed $val Input variable
* @param string|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return string|null Converted input data to string/null
*/
protected static function makeStrMain(
mixed $val,
string $default = null,
bool $to_null = false
): ?string {
// int/float/string/bool/null, everything else is ignored
// no: array/object/resource/callable
if (
is_int($val) ||
is_float($val) ||
is_string($val) ||
is_bool($val) ||
is_null($val)
) {
return (string)$val;
}
if ($to_null === false) {
return (string)$default;
}
return $default;
}
/**
* If input variable is int, return it, else return default value. If to_null
* is true then null as return is allowed, else only int is returned
*
* @param mixed $val Input variable
* @param int|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return int|null Input var or default value
*/
protected static function setIntMain(
mixed $val,
?int $default = null,
bool $to_null = false
): ?int {
if (is_int($val)) {
return $val;
}
if ($to_null === false) {
return (int)$default;
}
return $default;
}
/**
* Convert input to int via filter_var. If not convertable return default value.
* If to_null is set to true null return is allowed
* NOTE: this is only a drastic fallback and not recommned for special use.
* It will try to check via filter_var if we can get an int value and then use
* intval to convert it.
* Reason is that filter_var will convert eg 1.5 to 15 instead 1
* One is very wrong, the other is at least better, but not perfect
*
* @param mixed $val Input variable
* @param int|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return int|null Converted input data to int/null
*/
protected static function makeIntMain(
mixed $val,
int $default = null,
bool $to_null = false
): ?int {
// if we can filter it to a valid int, we can convert it
// we so avoid object, array, etc
if (
filter_var(
$val,
FILTER_SANITIZE_NUMBER_INT
) !== false
) {
return intval($val);
}
if ($to_null === false) {
return (int)$default;
}
return $default;
}
/**
* If input is float return it, else set to default value. If to_null is set
* to true, allow null return
*
* @param mixed $val Input variable
* @param float|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return float|null Input var or default value
*/
protected static function setFloatMain(
mixed $val,
?float $default = null,
bool $to_null = false
): ?float {
if (is_float($val)) {
return $val;
}
if ($to_null === false) {
return (float)$default;
}
return $default;
}
/**
* Convert intput var to float via filter_var. If failed to so return default.
* If to_null is set to true allow null return
*
* @param mixed $val Input variable
* @param float|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return float|null Converted intput data to float/null
*/
protected static function makeFloatMain(
mixed $val,
float $default = null,
bool $to_null = false
): ?float {
if (
(
$val = filter_var(
$val,
FILTER_SANITIZE_NUMBER_FLOAT,
FILTER_FLAG_ALLOW_FRACTION
)
) !== false
) {
return (float)$val;
}
if ($to_null === false) {
return (float)$default;
}
return $default;
}
/**
* If input var is array return it, else return default value. If to_null is
* set to true, allow null return
*
* @param mixed $val Input variable
* @param array<mixed>|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return array<mixed>|null Input var or default value
*/
protected static function setArrayMain(
mixed $val,
?array $default = null,
bool $to_null = false
): ?array {
if (is_array($val)) {
return $val;
}
if ($to_null === false) {
return (array)$default;
}
return $default;
}
/**
* If input var is bool return it, else return default value. If to_null is
* set to true will allow null return.
*
* @param mixed $val Input variable
* @param bool|null $default Default value
* @param bool $to_null Convert to null (default no)
* @return bool|null Input var or default value
*/
protected static function setBoolMain(
mixed $val,
?bool $default = null,
bool $to_null = false
): ?bool {
if (is_bool($val)) {
return $val;
}
if ($to_null === false) {
return (bool)$default;
}
return $default;
}
/**
* Convert anything to bool. If it is a string it will try to use the filter_var
* to convert know true/false strings.
* Else it uses (bool) to convert the rest
* If null is allowed, will return null
*
* @param mixed $val Input variable
* @param bool $default Default value if to_null if false
* @param bool $to_null Convert to null (default no)
* @return bool|null Converted input data to bool/ null
*/
protected static function makeBoolMain(
mixed $val,
bool $default = false,
bool $to_null = false
): ?bool {
$boolvar = is_string($val) ?
filter_var(
$val,
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE
) :
(bool)$val;
return $boolvar === null && !$to_null ? $default : $boolvar;
}
}
// __END__

View File

@@ -0,0 +1,136 @@
<?php
/*
* Run is_<type> checks and return default value if not this type
* This will return a default value as always what is expected and never null
* Use this for santize output from multi return functions where we know what
* will come back
*/
declare(strict_types=1);
namespace CoreLibs\Convert;
use CoreLibs\Convert\Extends\VarSetTypeMain;
class VarSetType extends Extends\VarSetTypeMain
{
/**
* Check is input is string, if not return default string.
* Will always return string
*
* @param mixed $val Input value
* @param string $default Default override value
* @return string Input value or default as string
*/
public static function setStr(mixed $val, string $default = ''): string
{
return (string)VarSetTypeMain::setStrMain($val, $default, false);
}
/**
* Convert input to string if possible.
* Will only work on string/int/float/bool/null types
* Will always return string
*
* @param mixed $val Input value
* @param string $default Default override value
* @return string Input value as string or default as string
*/
public static function makeStr(mixed $val, string $default = ''): string
{
return (string)VarSetTypeMain::makeStrMain($val, $default, false);
}
/**
* Check if input is int, if not return default int value 0.
* Will always return int.
*
* @param mixed $val Input value
* @param int $default Default override value
* @return int Input value or default as int
*/
public static function setInt(mixed $val, int $default = 0): int
{
return (int)VarSetTypeMain::setIntMain($val, $default, false);
}
/**
* Convert intput to int if possible, if not return default value 0.
* Will always return int.
*
* @param mixed $val Input value
* @param int $default Default override value
* @return int Input value as int or default as int
*/
public static function makeInt(mixed $val, int $default = 0): int
{
return (int)VarSetTypeMain::makeIntMain($val, $default, false);
}
/**
* Check if input is float, if not return default value value 0.0.
* Will always return float
*
* @param mixed $val Input value
* @param float $default Default override value
* @return float Input value or default as float
*/
public static function setFloat(mixed $val, float $default = 0.0): float
{
return (float)VarSetTypeMain::setFloatMain($val, $default, false);
}
/**
* Convert input to float, if not possible return default value 0.0.
* Will always return float
*
* @param mixed $val Input value
* @param float $default Default override value
* @return float Input value as float or default as float
*/
public static function makeFloat(mixed $val, float $default = 0.0): float
{
return (float)VarSetTypeMain::makeFloatMain($val, $default, false);
}
/**
* Check if input is array, if not return default empty array.
* Will always return array.
*
* @param mixed $val Input value
* @param array<mixed> $default Default override value
* @return array<mixed> Input value or default as array
*/
public static function setArray(mixed $val, array $default = []): array
{
return (array)VarSetTypeMain::setArrayMain($val, $default, false);
}
/**
* Check if input is bool, if not will return default value false.
* Will aways return bool.
*
* @param mixed $val Input value
* @param bool $default Default override value
* @return bool Input value or default as bool
*/
public static function setBool(mixed $val, bool $default = false): bool
{
return (bool)VarSetTypeMain::setBoolMain($val, $default, false);
}
/**
* Convert anything to bool
*
* @param mixed $val Input value
* @param bool $default Default override value
* @return bool Input value as bool or default as bool
*/
public static function makeBool(mixed $val, bool $default = false): bool
{
return (bool)VarSetTypeMain::makeBoolMain($val, $default, false);
}
}
// __END__

View File

@@ -0,0 +1,130 @@
<?php
/*
* Run is_<type> checks and return default value if not this type
* This will return default null on invalid entries
*/
declare(strict_types=1);
namespace CoreLibs\Convert;
use CoreLibs\Convert\Extends\VarSetTypeMain;
class VarSetTypeNull extends Extends\VarSetTypeMain
{
/**
* Check is input is string, if not return default string.
* Will return null if no string as default.
*
* @param mixed $val Input value
* @param string|null $default Default override value
* @return string|null Input value or default as string/null
*/
public static function setStr(mixed $val, ?string $default = null): ?string
{
return VarSetTypeMain::setStrMain($val, $default, true);
}
/**
* Convert input to string if possible.
* Will only work on string/int/float/bool/null types.
* Will return null if convert failed as default.
*
* @param mixed $val Input value
* @param string|null $default Default override value
* @return string|null Input value as string or default as string/null
*/
public static function makeStr(mixed $val, string $default = null): ?string
{
return VarSetTypeMain::makeStrMain($val, $default, true);
}
/**
* Check if input is int, if not return default value null.
*
* @param mixed $val Input value
* @param int|null $default Default override value
* @return int|null Input value or default as int/null
*/
public static function setInt(mixed $val, ?int $default = null): ?int
{
return VarSetTypeMain::setIntMain($val, $default, true);
}
/**
* Convert intput to int if possible, if not return default value value null.
*
* @param mixed $val Input value $val
* @param int|null $default Default override value
* @return int|null Input value as int or default as int/null
*/
public static function makeInt(mixed $val, int $default = null): ?int
{
return VarSetTypeMain::makeIntMain($val, $default, true);
}
/**
* Check if input is float, if not return default value value null.
*
* @param mixed $val Input value $val
* @param float|null $default Default override value
* @return float|null Input value or default as float/null
*/
public static function setFloat(mixed $val, ?float $default = null): ?float
{
return VarSetTypeMain::setFloatMain($val, $default, true);
}
/**
* Convert input to float, if not possible return default value null.
*
* @param mixed $val Input value $val
* @param float|null $default Default override value
* @return float|null Input value as float or default as float/null
*/
public static function makeFloat(mixed $val, float $default = null): ?float
{
return VarSetTypeMain::makeFloatMain($val, $default, true);
}
/**
* Check if input is array, if not return default value null.
*
* @param mixed $val Input value $val
* @param array<mixed>|null $default Default override value
* @return array<mixed>|null Input value or default as array/null
*/
public static function setArray(mixed $val, ?array $default = null): ?array
{
return VarSetTypeMain::setArrayMain($val, $default, true);
}
/**
* Check if input is bool, if not will return default value null.
*
* @param mixed $val Input value $val
* @param bool|null $default Default override value
* @return bool|null Input value or default as bool/null
*/
public static function setBool(mixed $val, ?bool $default = null): ?bool
{
return VarSetTypeMain::setBoolMain($val, $default, true);
}
/**
* Convert anything to bool
*
* @param mixed $val Input value $val
* @return bool|null Input value as bool or default as bool/null
*/
public static function makeBool(mixed $val): ?bool
{
// note that the default value here is irrelevant, we return null
// on unsetable string var
return VarSetTypeMain::makeBoolMain($val, false, true);
}
}
// __END__

View File

@@ -277,7 +277,7 @@ class IO
/** @var string default hash type */
public const ERROR_HASH_TYPE = 'adler32';
/** @var string regex to get returning with matches at position 1 */
public const REGEX_RETURNING = '/\s?returning(?: (.+?));?$/i';
public const REGEX_RETURNING = '/\s+returning\s+(.+?);?$/i';
// recommend to set private/protected and only allow setting via method
// can bet set from outside
@@ -575,14 +575,14 @@ class IO
/**
* checks if query is a SELECT, SHOW or WITH, if not error, 0 return
* NOTE:
* Query needs to start with SELECT, SHOW or WITH. if starts with "with" it is ignored
* Query needs to start with SELECT, SHOW or WITH
* @param string $query query to check
* @return bool true if matching, false if not
*/
private function __checkQueryForSelect(string $query): bool
{
// perhaps allow spaces before select ?!?
if (preg_match("/^(select|show|with) /i", $query)) {
// change to string starts with?
if (preg_match("/^\s*(?:SELECT|SHOW|WITH)\s/i", $query)) {
return true;
}
return false;
@@ -599,10 +599,10 @@ class IO
*/
private function __checkQueryForInsert(string $query, bool $pure = false): bool
{
if ($pure && preg_match("/^insert /i", $query)) {
if ($pure && preg_match("/^\s*INSERT\s+?INTO\s/i", $query)) {
return true;
}
if (!$pure && preg_match("/^(insert|update|delete) /i", $query)) {
if (!$pure && preg_match("/^\s*(?:INSERT\s+?INTO|DELETE\s+?FROM|UPDATE)\s/i", $query)) {
return true;
}
return false;
@@ -616,7 +616,7 @@ class IO
*/
private function __checkQueryForUpdate(string $query): bool
{
if (preg_match("/^update /i", $query)) {
if (preg_match("/^\s*UPDATE\s?(.+)/i", $query)) {
return true;
}
return false;
@@ -881,12 +881,33 @@ class IO
private function __dbReturnTable(string $query): array
{
$matches = [];
if (preg_match("/^SELECT /i", $query)) {
preg_match("/ (FROM) \"?(([\w_]+)\.)?([\w_]+)\"? /i", $query, $matches);
$schema_table = [];
if ($this->__checkQueryForSelect($query)) {
// only selects the first one, this is more a fallback
// MATCHES 1 (call), 3 (schema), 4 (table)
preg_match("/\s+?(FROM)\s+?([\"'])?(?:([\w_]+)\.)?([\w_]+)(?:\2)?\s?/i", $query, $matches);
$schema_table = [
$matches[3] ?? '',
$matches[4] ?? '',
];
} else {
preg_match("/(INSERT INTO|DELETE FROM|UPDATE) \"?(([\w_]+)\.)?([\w_]+)\"? /i", $query, $matches);
preg_match(
// must start with
// INSERT INTO (table)
// DELETE FROM (table)
// UPDATE (table) SET
// MATCHES 1 (call), 4 (schema), 5 (table)
"/^\s*(INSERT\s+?INTO|DELETE\s+?FROM|(UPDATE))\s+?"
. "([\"'])?(?:([\w_]+)\.)?([\w_]+)(?:\3)?\s?(?(2)\s+?SET|)/i",
$query,
$matches
);
$schema_table = [
$matches[4] ?? '',
$matches[5] ?? ''
];
}
return [$matches[3] ?? '', $matches[4] ?? ''];
return $schema_table;
}
/**

View File

@@ -94,9 +94,11 @@ class Support
* @param bool $no_html set to true to use ##HTMLPRE##or html escape
* @return string
*/
public static function printToString($mixed, bool $no_html = false): string
public static function printToString(mixed $mixed, bool $no_html = false): string
{
if (is_bool($mixed)) {
if (is_null($mixed)) {
return (string)'NULL';
} elseif (is_bool($mixed)) {
return self::printBool($mixed, '', 'TRUE', 'FALSE');
} elseif (is_resource($mixed)) {
return (string)$mixed;

Some files were not shown because too many files have changed in this diff Show More