CoreLibs update
This commit is contained in:
@@ -273,8 +273,8 @@ $query_insert = <<<SQL
|
|||||||
INSERT INTO
|
INSERT INTO
|
||||||
test_foo
|
test_foo
|
||||||
(
|
(
|
||||||
test, some_bool, string_a, number_a, number_a_numeric,
|
test, some_bool, string_a, number_a, numeric_a,
|
||||||
some_time, some_timestamp, json_string
|
some_internval, some_timestamp, json_string
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5,
|
$1, $2, $3, $4, $5,
|
||||||
$6, $7, $8
|
$6, $7, $8
|
||||||
@@ -283,8 +283,8 @@ RETURNING test
|
|||||||
SQL;
|
SQL;
|
||||||
$query_select = <<<SQL
|
$query_select = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test, some_bool, string_a, number_a, number_a_numeric,
|
test, some_bool, string_a, number_a, numeric_a,
|
||||||
some_time, some_time, some_timestamp, json_string
|
some_time, some_internval, some_timestamp, json_string
|
||||||
FROM
|
FROM
|
||||||
test_foo
|
test_foo
|
||||||
WHERE
|
WHERE
|
||||||
@@ -554,7 +554,7 @@ print "<b>PREPARE QUERIES</b><br>";
|
|||||||
// READ PREPARE
|
// READ PREPARE
|
||||||
$q_prep = <<<SQL
|
$q_prep = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $1
|
WHERE test = $1
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -582,7 +582,7 @@ if ($db->dbPrepare('sel_test_foo', $q_prep) === false) {
|
|||||||
|
|
||||||
// sel test with ANY () type
|
// sel test with ANY () type
|
||||||
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
$q_prep = "SELECT test_foo_id, test, some_bool, string_a, number_a, "
|
||||||
. "number_a_numeric, some_time "
|
. "numeric_a, some_time "
|
||||||
. "FROM test_foo "
|
. "FROM test_foo "
|
||||||
. "WHERE test = ANY($1) "
|
. "WHERE test = ANY($1) "
|
||||||
. "ORDER BY test_foo_id DESC LIMIT 5";
|
. "ORDER BY test_foo_id DESC LIMIT 5";
|
||||||
@@ -618,7 +618,7 @@ $test_bar = $db->dbEscapeLiteral('SOMETHING DIFFERENT');
|
|||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
-- comment
|
-- comment
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $test_bar
|
WHERE test = $test_bar
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -631,7 +631,7 @@ print "DB RETURN PARAMS<br>";
|
|||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
SELECT test_foo_id, test, some_bool, string_a, number_a,
|
||||||
-- comment
|
-- comment
|
||||||
number_a_numeric, some_time
|
numeric_a, some_time
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE test = $1
|
WHERE test = $1
|
||||||
ORDER BY test_foo_id DESC LIMIT 5
|
ORDER BY test_foo_id DESC LIMIT 5
|
||||||
@@ -646,7 +646,7 @@ echo "<hr>";
|
|||||||
print "DB RETURN PARAMS LIKE<br>";
|
print "DB RETURN PARAMS LIKE<br>";
|
||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
test_foo_id, test, some_bool, string_a, number_a, numeric_a
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE string_a LIKE $1;
|
WHERE string_a LIKE $1;
|
||||||
SQL;
|
SQL;
|
||||||
@@ -660,7 +660,7 @@ echo "<hr>";
|
|||||||
print "DB RETURN PARAMS ANY<br>";
|
print "DB RETURN PARAMS ANY<br>";
|
||||||
$q = <<<SQL
|
$q = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id, test, some_bool, string_a, number_a, number_a_numeric
|
test_foo_id, test, some_bool, string_a, number_a, numeric_a
|
||||||
FROM test_foo
|
FROM test_foo
|
||||||
WHERE string_a = ANY($1);
|
WHERE string_a = ANY($1);
|
||||||
SQL;
|
SQL;
|
||||||
|
|||||||
@@ -174,6 +174,26 @@ while (is_array($res = $db->dbReturnParams($query, [$query_value]))) {
|
|||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
|
||||||
|
echo "<b>CASE part</b><br>";
|
||||||
|
$query = <<<SQL
|
||||||
|
UPDATE
|
||||||
|
test_foo
|
||||||
|
SET
|
||||||
|
some_timestamp = NOW(),
|
||||||
|
-- if not 1 set, else keep at one
|
||||||
|
smallint_a = (CASE
|
||||||
|
WHEN smallint_a <> 1 THEN $1
|
||||||
|
ELSE 1::INT
|
||||||
|
END)::INT
|
||||||
|
WHERE
|
||||||
|
string_a = $2
|
||||||
|
SQL;
|
||||||
|
echo "QUERY: <pre>" . $query . "</pre>";
|
||||||
|
$res = $db->dbExecParams($query, [1, 'foobar']);
|
||||||
|
print "ERROR: " . $db->dbGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
|
||||||
// test connectors: = , <> () for query detection
|
// test connectors: = , <> () for query detection
|
||||||
|
|
||||||
// convert placeholder tests
|
// convert placeholder tests
|
||||||
@@ -237,7 +257,7 @@ SQL,
|
|||||||
SQL,
|
SQL,
|
||||||
'params' => [1, 2, 3, 4, 5, 6],
|
'params' => [1, 2, 3, 4, 5, 6],
|
||||||
'direction' => 'pg'
|
'direction' => 'pg'
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$db->dbSetConvertPlaceholder(true);
|
$db->dbSetConvertPlaceholder(true);
|
||||||
|
|||||||
@@ -57,6 +57,43 @@ if (($dbh = $db->dbGetDbh()) instanceof \PgSql\Connection) {
|
|||||||
print "<b>TRUNCATE test_foo</b><br>";
|
print "<b>TRUNCATE test_foo</b><br>";
|
||||||
$db->dbExec("TRUNCATE test_foo");
|
$db->dbExec("TRUNCATE test_foo");
|
||||||
|
|
||||||
|
/*
|
||||||
|
BELOW IS THE FULL TABLE WITH ALL PostgreSQL Types
|
||||||
|
=> \d test_foo
|
||||||
|
Table "public.test_foo"
|
||||||
|
Column | Type | Nullable | Default
|
||||||
|
------------------+-----------------------------+----------+-----------------------------------------------
|
||||||
|
test | character varying | |
|
||||||
|
some_bool | boolean | |
|
||||||
|
string_a | character varying | |
|
||||||
|
number_a | integer | |
|
||||||
|
numeric_a | numeric | |
|
||||||
|
some_internval | interval | |
|
||||||
|
test_foo_id | integer | not null | generated always as identity
|
||||||
|
json_string | jsonb | |
|
||||||
|
some_timestamp | timestamp without time zone | |
|
||||||
|
some_binary | bytea | |
|
||||||
|
null_var | character varying | |
|
||||||
|
smallint_a | smallint | |
|
||||||
|
number_real | real | |
|
||||||
|
number_double | double precision | |
|
||||||
|
number_serial | integer | not null | nextval('test_foo_number_serial_seq'::regclass)
|
||||||
|
array_char_1 | character varying[] | |
|
||||||
|
array_char_2 | character varying[] | |
|
||||||
|
array_int_1 | integer[] | |
|
||||||
|
array_int_2 | integer[] | |
|
||||||
|
composite_item | inventory_item | |
|
||||||
|
array_composite | inventory_item[] | |
|
||||||
|
numeric_3 | numeric(3,0) | |
|
||||||
|
identity_always | bigint | not null | generated always as identity
|
||||||
|
identitiy_default | bigint | not null | generated by default as identity
|
||||||
|
uuid_var | uuid | | gen_random_uuid()
|
||||||
|
some_date | date | |
|
||||||
|
some_time | time without time zone | |
|
||||||
|
bigint_a | bigint | |
|
||||||
|
default_uuid | uuid | | gen_random_uuid()
|
||||||
|
*/
|
||||||
|
|
||||||
/* $q = <<<SQL
|
/* $q = <<<SQL
|
||||||
INSERT INTO test_foo (test, array_composite) VALUES ('C', '{"(a,1,1.5)","(b,2,2.5)"}')
|
INSERT INTO test_foo (test, array_composite) VALUES ('C', '{"(a,1,1.5)","(b,2,2.5)"}')
|
||||||
SQL;
|
SQL;
|
||||||
@@ -90,7 +127,7 @@ $query_params = [
|
|||||||
|
|
||||||
$query_insert = <<<SQL
|
$query_insert = <<<SQL
|
||||||
INSERT INTO test_foo (
|
INSERT INTO test_foo (
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_int_1,
|
array_char_1, array_int_1,
|
||||||
array_composite,
|
array_composite,
|
||||||
@@ -106,7 +143,7 @@ INSERT INTO test_foo (
|
|||||||
)
|
)
|
||||||
RETURNING
|
RETURNING
|
||||||
test_foo_id,
|
test_foo_id,
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_int_1,
|
array_char_1, array_int_1,
|
||||||
array_composite,
|
array_composite,
|
||||||
@@ -127,8 +164,8 @@ echo "<hr>";
|
|||||||
$query_select = <<<SQL
|
$query_select = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
test_foo_id,
|
test_foo_id,
|
||||||
test, some_bool, string_a, number_a, number_a_numeric, smallint_a,
|
test, some_bool, string_a, number_a, numeric_a, smallint_a,
|
||||||
number_real, number_double, number_numeric_3, number_serial,
|
number_real, number_double, numeric_3, number_serial,
|
||||||
some_time, some_timestamp, json_string, null_var,
|
some_time, some_timestamp, json_string, null_var,
|
||||||
array_char_1, array_char_2, array_int_1, array_int_2, array_composite,
|
array_char_1, array_char_2, array_int_1, array_int_2, array_composite,
|
||||||
composite_item, (composite_item).*,
|
composite_item, (composite_item).*,
|
||||||
|
|||||||
@@ -29,15 +29,17 @@ $table_arrays = [];
|
|||||||
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
||||||
// form fields mtaching up with db fields
|
// form fields mtaching up with db fields
|
||||||
'table_array' => [
|
'table_array' => [
|
||||||
|
'foo',
|
||||||
|
'bar'
|
||||||
],
|
],
|
||||||
// laod query
|
// laod query
|
||||||
'load_query' => '',
|
'load_query' => 'SELECT uuid_nr, foo, bar FROM test',
|
||||||
// database table to load from
|
// database table to load from
|
||||||
'table_name' => '',
|
'table_name' => 'test',
|
||||||
// for load dro pdown, format output
|
// for load dro pdown, format output
|
||||||
'show_fields' => [
|
'show_fields' => [
|
||||||
[
|
[
|
||||||
'name' => 'name'
|
'name' => 'foo'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'enabled',
|
'name' => 'enabled',
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ print "<body>";
|
|||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
|
print "PHP Version: " . PHP_VERSION . "<br>";
|
||||||
|
|
||||||
$password = 'something1234';
|
$password = 'something1234';
|
||||||
$enc_password = $_password->passwordSet($password);
|
$enc_password = $_password->passwordSet($password);
|
||||||
print "PASSWORD: $password: " . $enc_password . "<br>";
|
print "PASSWORD: $password: " . $enc_password . "<br>";
|
||||||
@@ -51,6 +53,20 @@ print "PASSWORD REHASH: " . (string)$password_class::passwordRehashCheck($enc_pa
|
|||||||
// direct static
|
// direct static
|
||||||
print "S::PASSWORD VERFIY: " . (string)PwdChk::passwordVerify($password, $enc_password) . "<br>";
|
print "S::PASSWORD VERFIY: " . (string)PwdChk::passwordVerify($password, $enc_password) . "<br>";
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 80400) {
|
||||||
|
$rehash_test = '$2y$10$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
$rehash_test_throw = '$2y$12$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
} else {
|
||||||
|
$rehash_test = '$2y$12$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
$rehash_test_throw = '$2y$10$EgWJ2WE73DWi.hIyFRCdpejLXTvHbmTK3LEOclO1tAvXAXUNuUS4W';
|
||||||
|
}
|
||||||
|
if (PwdChk::passwordRehashCheck($rehash_test)) {
|
||||||
|
print "Bad password [BAD]<br>";
|
||||||
|
}
|
||||||
|
if (PwdChk::passwordRehashCheck($rehash_test_throw)) {
|
||||||
|
print "Bad password [OK]<br>";
|
||||||
|
}
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME: Smarty Class must be updated for PHP 8.4
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
error_reporting(E_ALL | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||||
@@ -33,6 +35,7 @@ $l10n = new \CoreLibs\Language\L10n(
|
|||||||
);
|
);
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend(
|
$smarty = new CoreLibs\Template\SmartyExtend(
|
||||||
$l10n,
|
$l10n,
|
||||||
|
$log,
|
||||||
CACHE_ID,
|
CACHE_ID,
|
||||||
COMPILE_ID,
|
COMPILE_ID,
|
||||||
);
|
);
|
||||||
@@ -45,6 +48,7 @@ $adm = new CoreLibs\Admin\Backend(
|
|||||||
);
|
);
|
||||||
$adm->DATA['adm_set'] = 'SET from admin class';
|
$adm->DATA['adm_set'] = 'SET from admin class';
|
||||||
|
|
||||||
|
|
||||||
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
$PAGE_NAME = 'TEST CLASS: SMARTY';
|
||||||
print "<!DOCTYPE html>";
|
print "<!DOCTYPE html>";
|
||||||
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
print "<html><head><title>" . $PAGE_NAME . "</title></head>";
|
||||||
|
|||||||
13
www/composer.lock
generated
13
www/composer.lock
generated
@@ -12,7 +12,7 @@
|
|||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
||||||
"reference": "4ee141f8df16ecf8b4d32fb8763959e88ccc6914"
|
"reference": "a092217201ffac165dfcf72077c1fec14c759885"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
@@ -63,6 +63,13 @@
|
|||||||
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.5.2/egrajp-smarty-extended.4.5.2.zip",
|
"url": "https://git.egplusww.jp/api/packages/Composer/composer/files/egrajp%2Fsmarty-extended/4.5.2/egrajp-smarty-extended.4.5.2.zip",
|
||||||
"shasum": "a2c67a5047aad349a2cfa54240a44da449df9c4c"
|
"shasum": "a2c67a5047aad349a2cfa54240a44da449df9c4c"
|
||||||
},
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"php": "^7.4 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"egrajp/corelibs-composer-all": "^9"
|
||||||
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
@@ -200,7 +207,7 @@
|
|||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": {},
|
||||||
"platform-dev": [],
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
11
www/vendor/composer/InstalledVersions.php
vendored
11
www/vendor/composer/InstalledVersions.php
vendored
@@ -322,6 +322,7 @@ class InstalledVersions
|
|||||||
}
|
}
|
||||||
|
|
||||||
$installed = array();
|
$installed = array();
|
||||||
|
$copiedLocalDir = false;
|
||||||
|
|
||||||
if (self::$canGetVendors) {
|
if (self::$canGetVendors) {
|
||||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||||
@@ -330,9 +331,11 @@ class InstalledVersions
|
|||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
$required = require $vendorDir.'/composer/installed.php';
|
$required = require $vendorDir.'/composer/installed.php';
|
||||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
self::$installedByVendor[$vendorDir] = $required;
|
||||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
$installed[] = $required;
|
||||||
self::$installed = $installed[count($installed) - 1];
|
if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
|
self::$installed = $required;
|
||||||
|
$copiedLocalDir = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,7 +353,7 @@ class InstalledVersions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$installed !== array()) {
|
if (self::$installed !== array() && !$copiedLocalDir) {
|
||||||
$installed[] = self::$installed;
|
$installed[] = self::$installed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
www/vendor/composer/installed.json
vendored
2
www/vendor/composer/installed.json
vendored
@@ -7,7 +7,7 @@
|
|||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
"url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All",
|
||||||
"reference": "4ee141f8df16ecf8b4d32fb8763959e88ccc6914"
|
"reference": "a092217201ffac165dfcf72077c1fec14c759885"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
|
|||||||
2
www/vendor/composer/installed.php
vendored
2
www/vendor/composer/installed.php
vendored
@@ -13,7 +13,7 @@
|
|||||||
'egrajp/corelibs-composer-all' => array(
|
'egrajp/corelibs-composer-all' => array(
|
||||||
'pretty_version' => 'dev-development',
|
'pretty_version' => 'dev-development',
|
||||||
'version' => 'dev-development',
|
'version' => 'dev-development',
|
||||||
'reference' => '4ee141f8df16ecf8b4d32fb8763959e88ccc6914',
|
'reference' => 'a092217201ffac165dfcf72077c1fec14c759885',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all',
|
'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
9.24.1
|
9.25.3
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\Admin;
|
namespace CoreLibs\Admin;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use SmartyException;
|
|
||||||
|
|
||||||
class EditBase
|
class EditBase
|
||||||
{
|
{
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
@@ -63,6 +60,7 @@ class EditBase
|
|||||||
// smarty template engine (extended Translation version)
|
// smarty template engine (extended Translation version)
|
||||||
$this->smarty = new \CoreLibs\Template\SmartyExtend(
|
$this->smarty = new \CoreLibs\Template\SmartyExtend(
|
||||||
$l10n,
|
$l10n,
|
||||||
|
$log,
|
||||||
$options['cache_id'] ?? '',
|
$options['cache_id'] ?? '',
|
||||||
$options['compile_id'] ?? '',
|
$options['compile_id'] ?? '',
|
||||||
);
|
);
|
||||||
@@ -538,8 +536,7 @@ class EditBase
|
|||||||
* builds the smarty content and runs smarty display output
|
* builds the smarty content and runs smarty display output
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws \Smarty\Exception
|
||||||
* @throws SmartyException
|
|
||||||
*/
|
*/
|
||||||
public function editBaseRun(
|
public function editBaseRun(
|
||||||
?string $template_dir = null,
|
?string $template_dir = null,
|
||||||
|
|||||||
@@ -363,11 +363,12 @@ class Session
|
|||||||
* set the auto write close flag
|
* set the auto write close flag
|
||||||
*
|
*
|
||||||
* @param bool $flag
|
* @param bool $flag
|
||||||
* @return void
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function setAutoWriteClose(bool $flag): void
|
public function setAutoWriteClose(bool $flag): Session
|
||||||
{
|
{
|
||||||
$this->auto_write_close = $flag;
|
$this->auto_write_close = $flag;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -513,14 +514,15 @@ class Session
|
|||||||
*
|
*
|
||||||
* @param string $name array name in _SESSION
|
* @param string $name array name in _SESSION
|
||||||
* @param mixed $value value to set (can be anything)
|
* @param mixed $value value to set (can be anything)
|
||||||
* @return void
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function set(string $name, mixed $value): void
|
public function set(string $name, mixed $value): Session
|
||||||
{
|
{
|
||||||
$this->checkValidSessionEntryKey($name);
|
$this->checkValidSessionEntryKey($name);
|
||||||
$this->restartSession();
|
$this->restartSession();
|
||||||
$_SESSION[$name] = $value;
|
$_SESSION[$name] = $value;
|
||||||
$this->closeSessionCall();
|
$this->closeSessionCall();
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -577,16 +579,17 @@ class Session
|
|||||||
* unset one _SESSION entry 'name' if exists
|
* unset one _SESSION entry 'name' if exists
|
||||||
*
|
*
|
||||||
* @param string $name _SESSION key name to remove
|
* @param string $name _SESSION key name to remove
|
||||||
* @return void
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function unset(string $name): void
|
public function unset(string $name): Session
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION[$name])) {
|
if (!isset($_SESSION[$name])) {
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
$this->restartSession();
|
$this->restartSession();
|
||||||
unset($_SESSION[$name]);
|
unset($_SESSION[$name]);
|
||||||
$this->closeSessionCall();
|
$this->closeSessionCall();
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ class ConvertPlaceholder
|
|||||||
. '&&|' // array overlap
|
. '&&|' // array overlap
|
||||||
. '\-\|\-|' // range overlap for array
|
. '\-\|\-|' // range overlap for array
|
||||||
. '[^-]-{1}|' // single -, used in JSON too
|
. '[^-]-{1}|' // single -, used in JSON too
|
||||||
. '->|->>|#>|#>>|@>|<@|@@|@\?|\?{1}|\?\||\?&|#-'; //JSON searches, Array searchs, etc
|
. '->|->>|#>|#>>|@>|<@|@@|@\?|\?{1}|\?\||\?&|#-|' // JSON searches, Array searchs, etc
|
||||||
|
. 'THEN|ELSE' // command parts (CASE)
|
||||||
|
;
|
||||||
/** @var string the main regex including the pattern query split */
|
/** @var string the main regex including the pattern query split */
|
||||||
private const PATTERN_ELEMENT = '(?:\'.*?\')?\s*(?:' . self::PATTERN_QUERY_SPLIT . ')\s*';
|
private const PATTERN_ELEMENT = '(?:\'.*?\')?\s*(?:' . self::PATTERN_QUERY_SPLIT . ')\s*';
|
||||||
/** @var string comment regex
|
/** @var string comment regex
|
||||||
|
|||||||
@@ -209,13 +209,13 @@ class SymmetricEncryption
|
|||||||
* set a new key for encryption
|
* set a new key for encryption
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return void
|
* @return SymmetricEncryption
|
||||||
* @throws \UnexpectedValueException key cannot be empty
|
* @throws \UnexpectedValueException key cannot be empty
|
||||||
*/
|
*/
|
||||||
public function setKey(
|
public function setKey(
|
||||||
#[\SensitiveParameter]
|
#[\SensitiveParameter]
|
||||||
string $key
|
string $key
|
||||||
) {
|
): SymmetricEncryption {
|
||||||
if (empty($key)) {
|
if (empty($key)) {
|
||||||
throw new \UnexpectedValueException('Key cannot be empty');
|
throw new \UnexpectedValueException('Key cannot be empty');
|
||||||
}
|
}
|
||||||
@@ -224,6 +224,7 @@ class SymmetricEncryption
|
|||||||
// set key
|
// set key
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
sodium_memzero($key);
|
sodium_memzero($key);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\Template;
|
namespace CoreLibs\Template;
|
||||||
|
|
||||||
// leading slash if this is in lib\Smarty
|
class SmartyExtend extends \Smarty\Smarty
|
||||||
class SmartyExtend extends \Smarty
|
|
||||||
{
|
{
|
||||||
// internal translation engine
|
// internal translation engine
|
||||||
/** @var \CoreLibs\Language\L10n */
|
/** @var \CoreLibs\Language\L10n language class */
|
||||||
public \CoreLibs\Language\L10n $l10n;
|
public \CoreLibs\Language\L10n $l10n;
|
||||||
|
/** @var \CoreLibs\Logging\Logging $log logging class */
|
||||||
|
public \CoreLibs\Logging\Logging $log;
|
||||||
|
|
||||||
// lang & encoding
|
// lang & encoding
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -157,14 +158,18 @@ class SmartyExtend extends \Smarty
|
|||||||
* calls L10 for pass on internaly in smarty
|
* calls L10 for pass on internaly in smarty
|
||||||
* also registers the getvar caller plugin
|
* also registers the getvar caller plugin
|
||||||
*
|
*
|
||||||
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
* @param \CoreLibs\Language\L10n $l10n l10n language class
|
||||||
* @param string|null $cache_id
|
* @param \CoreLibs\Logging\Logging $log Logger class
|
||||||
* @param string|null $compile_id
|
* @param string|null $cache_id [default=null]
|
||||||
|
* @param string|null $compile_id [default=null]
|
||||||
|
* @param array<string,mixed> $options [default=[]]
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\CoreLibs\Language\L10n $l10n,
|
\CoreLibs\Language\L10n $l10n,
|
||||||
|
\CoreLibs\Logging\Logging $log,
|
||||||
?string $cache_id = null,
|
?string $cache_id = null,
|
||||||
?string $compile_id = null
|
?string $compile_id = null,
|
||||||
|
array $options = []
|
||||||
) {
|
) {
|
||||||
// trigger deprecation
|
// trigger deprecation
|
||||||
if (
|
if (
|
||||||
@@ -177,14 +182,33 @@ class SmartyExtend extends \Smarty
|
|||||||
E_USER_DEPRECATED
|
E_USER_DEPRECATED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// set variables (to be deprecated)
|
// set variables from global constants (deprecated)
|
||||||
$cache_id = $cache_id ??
|
if ($cache_id === null && defined('CACHE_ID')) {
|
||||||
(defined('CACHE_ID') ? CACHE_ID : '');
|
trigger_error(
|
||||||
$compile_id = $compile_id ??
|
'SmartyExtended: No cache_id set and CACHE_ID constant set, this is deprecated',
|
||||||
(defined('COMPILE_ID') ? COMPILE_ID : '');
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
$cache_id = CACHE_ID;
|
||||||
|
}
|
||||||
|
if ($compile_id === null && defined('COMPILE_ID')) {
|
||||||
|
trigger_error(
|
||||||
|
'SmartyExtended: No compile_id set and COMPILE_ID constant set, this is deprecated',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
$compile_id = COMPILE_ID;
|
||||||
|
}
|
||||||
|
if (empty($cache_id)) {
|
||||||
|
throw new \BadMethodCallException('cache_id parameter is not set');
|
||||||
|
}
|
||||||
|
if (empty($compile_id)) {
|
||||||
|
throw new \BadMethodCallException('compile_id parameter is not set');
|
||||||
|
}
|
||||||
|
|
||||||
// call basic smarty
|
// call basic smarty
|
||||||
// or Smarty::__construct();
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->log = $log;
|
||||||
|
|
||||||
// init lang
|
// init lang
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
// parse and read, legacy stuff
|
// parse and read, legacy stuff
|
||||||
@@ -194,7 +218,6 @@ class SmartyExtend extends \Smarty
|
|||||||
$this->lang_short = $locale['lang_short'];
|
$this->lang_short = $locale['lang_short'];
|
||||||
$this->domain = $locale['domain'];
|
$this->domain = $locale['domain'];
|
||||||
$this->lang_dir = $locale['path'];
|
$this->lang_dir = $locale['path'];
|
||||||
|
|
||||||
// opt load functions so we can use legacy init for smarty run perhaps
|
// opt load functions so we can use legacy init for smarty run perhaps
|
||||||
\CoreLibs\Language\L10n::loadFunctions();
|
\CoreLibs\Language\L10n::loadFunctions();
|
||||||
_setlocale(LC_MESSAGES, $locale['locale']);
|
_setlocale(LC_MESSAGES, $locale['locale']);
|
||||||
@@ -203,7 +226,6 @@ class SmartyExtend extends \Smarty
|
|||||||
_bind_textdomain_codeset($this->domain, $this->encoding);
|
_bind_textdomain_codeset($this->domain, $this->encoding);
|
||||||
|
|
||||||
// register smarty variable
|
// register smarty variable
|
||||||
// $this->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
|
|
||||||
$this->registerPlugin(self::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
|
$this->registerPlugin(self::PLUGIN_MODIFIER, 'getvar', [&$this, 'getTemplateVars']);
|
||||||
|
|
||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
@@ -211,6 +233,77 @@ class SmartyExtend extends \Smarty
|
|||||||
// set internal settings
|
// set internal settings
|
||||||
$this->CACHE_ID = $cache_id;
|
$this->CACHE_ID = $cache_id;
|
||||||
$this->COMPILE_ID = $compile_id;
|
$this->COMPILE_ID = $compile_id;
|
||||||
|
// set options
|
||||||
|
$this->setOptions($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set options
|
||||||
|
*
|
||||||
|
* @param array<string,mixed> $options
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function setOptions(array $options): void
|
||||||
|
{
|
||||||
|
// set escape html if option is set
|
||||||
|
if (!empty($options['escape_html'])) {
|
||||||
|
$this->setEscapeHtml(true);
|
||||||
|
}
|
||||||
|
// load plugins
|
||||||
|
// plugin array:
|
||||||
|
// 'file': string, path to plugin content to load
|
||||||
|
// 'type': a valid smarty type see Smarty PLUGIN_ constants for correct names
|
||||||
|
// 'tag': the smarty tag
|
||||||
|
// 'callback': the function to call in 'file'
|
||||||
|
if (!empty($options['plugins'])) {
|
||||||
|
foreach ($options['plugins'] as $plugin) {
|
||||||
|
// file is readable
|
||||||
|
if (
|
||||||
|
empty($plugin['file']) ||
|
||||||
|
!is_file($plugin['file']) ||
|
||||||
|
!is_readable($plugin['file'])
|
||||||
|
) {
|
||||||
|
$this->log->warning('SmartyExtended plugin load failed, file not accessable', [
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// tag is alphanumeric
|
||||||
|
if (!preg_match("/^\w+$/", $plugin['tag'] ?? '')) {
|
||||||
|
$this->log->warning('SmartyExtended plugin load failed, invalid tag', [
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// callback is alphanumeric
|
||||||
|
if (!preg_match("/^\w+$/", $plugin['callback'] ?? '')) {
|
||||||
|
$this->log->warning('SmartyExtended plugin load failed, invalid callback', [
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
/** @phan-suppress-next-line PhanNoopNew */
|
||||||
|
new \ReflectionClassConstant($this, $plugin['type']);
|
||||||
|
} catch (\ReflectionException $e) {
|
||||||
|
$this->log->error('SmartyExtended plugin load failed, type is not valid', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
require $plugin['file'];
|
||||||
|
$this->registerPlugin($plugin['type'], $plugin['tag'], $plugin['callback']);
|
||||||
|
} catch (\Smarty\Exception $e) {
|
||||||
|
$this->log->error('SmartyExtended plugin load failed with exception', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5196,6 +5196,27 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
SQL,
|
SQL,
|
||||||
'count' => 1,
|
'count' => 1,
|
||||||
'convert' => false,
|
'convert' => false,
|
||||||
|
],
|
||||||
|
'update with case' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
UPDATE table_with_primary_key SET
|
||||||
|
row_int = $1::INT,
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $2 ELSE 'bar'::VARCHAR END
|
||||||
|
WHERE
|
||||||
|
row_varchar = $3
|
||||||
|
SQL,
|
||||||
|
'count' => 3,
|
||||||
|
'convert' => false,
|
||||||
|
],
|
||||||
|
'select with case' => [
|
||||||
|
'query' => <<<SQL
|
||||||
|
SELECT row_int
|
||||||
|
FROM table_with_primary_key
|
||||||
|
WHERE
|
||||||
|
row_varchar = CASE WHEN row_int = 1 THEN $1 ELSE $2 END
|
||||||
|
SQL,
|
||||||
|
'count' => 2,
|
||||||
|
'convert' => false,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsSecurityPasswordTest extends TestCase
|
final class CoreLibsSecurityPasswordTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function passwordProvider(): array
|
public function passwordProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -21,6 +26,11 @@ final class CoreLibsSecurityPasswordTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: we need different hash types for PHP versions
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function passwordRehashProvider(): array
|
public function passwordRehashProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -63,6 +73,10 @@ final class CoreLibsSecurityPasswordTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testPasswordRehashCheck(string $input, bool $expected): void
|
public function testPasswordRehashCheck(string $input, bool $expected): void
|
||||||
{
|
{
|
||||||
|
// in PHP 8.4 the length is $12
|
||||||
|
if (PHP_VERSION_ID > 80400) {
|
||||||
|
$input = str_replace('$2y$10$', '$2y$12$', $input);
|
||||||
|
}
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Security\Password::passwordRehashCheck($input)
|
\CoreLibs\Security\Password::passwordRehashCheck($input)
|
||||||
|
|||||||
Reference in New Issue
Block a user