Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1212d8116 | ||
|
|
5230cbf5d3 | ||
|
|
a6b42f243f | ||
|
|
736f822363 | ||
|
|
ffd1a86dcc | ||
|
|
b3d783bf63 | ||
|
|
e0cc766cc7 | ||
|
|
f151509bfe | ||
|
|
e252a76c4c | ||
|
|
7005e07f4c | ||
|
|
a86ae3efc3 |
@@ -70,14 +70,14 @@ return [
|
||||
// Thus, both first-party and third-party code being used by
|
||||
// your application should be included in this list.
|
||||
'directory_list' => [
|
||||
// Change this to include the folders you wish to analyze
|
||||
// (and the folders of their dependencies)
|
||||
'www',
|
||||
// To speed up analysis, we recommend going back later and
|
||||
// limiting this to only the vendor/ subdirectories your
|
||||
// project depends on.
|
||||
// `phan --init` will generate a list of folders for you
|
||||
//'www/vendor',
|
||||
// Change this to include the folders you wish to analyze
|
||||
// (and the folders of their dependencies)
|
||||
'www',
|
||||
// To speed up analysis, we recommend going back later and
|
||||
// limiting this to only the vendor/ subdirectories your
|
||||
// project depends on.
|
||||
// `phan --init` will generate a list of folders for you
|
||||
//'www/vendor',
|
||||
],
|
||||
|
||||
|
||||
|
||||
@@ -147,4 +147,4 @@ BEGIN
|
||||
RETURN NULL;
|
||||
END
|
||||
$$
|
||||
LANGUAGE 'plpgsql'
|
||||
LANGUAGE 'plpgsql';
|
||||
|
||||
1
4dev/static_checker/phan.sh
Normal file
1
4dev/static_checker/phan.sh
Normal file
@@ -0,0 +1 @@
|
||||
phan --progress-bar -C --analyze-twice
|
||||
1
4dev/static_checker/phpstan.sh
Normal file
1
4dev/static_checker/phpstan.sh
Normal file
@@ -0,0 +1 @@
|
||||
phpstan
|
||||
10
README.md
10
README.md
@@ -33,3 +33,13 @@ last tested PHP 5.6 and PHP 7.0
|
||||
### namespace
|
||||
|
||||
The new namespace branch. This is the development area for the master branch
|
||||
|
||||
## Static checks
|
||||
|
||||
With phpstan
|
||||
`phpstan`
|
||||
|
||||
With phan
|
||||
`phan --progress-bar -C --analyze-twice`
|
||||
|
||||
pslam is setup but not configured
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
// Boostrap file for PHPstand
|
||||
// sets the _SERVER['HTTP_HOST'] var so we can have DB detection
|
||||
$_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp';
|
||||
// so www/includes/edit_base.php works
|
||||
require_once('www/lib/Smarty/SmartyBC.class.php');
|
||||
// for whatever reason it does not load that from the confing.master.php
|
||||
define('BASE_NAME', '');
|
||||
|
||||
// __END__
|
||||
|
||||
35
phpstan.neon
35
phpstan.neon
@@ -2,7 +2,7 @@
|
||||
|
||||
parameters:
|
||||
tmpDir: /tmp/phpstan-corelibs
|
||||
level: 1
|
||||
level: max
|
||||
paths:
|
||||
- %currentWorkingDirectory%/www
|
||||
bootstrapFiles:
|
||||
@@ -17,22 +17,17 @@ parameters:
|
||||
- www/lib/Smarty/Autoloader.php
|
||||
- www/lib/CoreLibs/Template/SmartyExtend.php
|
||||
excludes_analyse:
|
||||
# no check admin
|
||||
- www/admin/qq_file_upload_front.php
|
||||
- www/admin/qq_file_upload_ajax.php
|
||||
# do not check old qq file uploader tests
|
||||
- www/admin/qq_file_upload_*.php
|
||||
# ignore all test files
|
||||
- www/admin/class_test*php
|
||||
- www/admin/error_test.php
|
||||
# admin synlink files
|
||||
- www/admin/edit_access.php
|
||||
- www/admin/edit_groups.php
|
||||
- www/admin/edit_languages.php
|
||||
- www/admin/edit_menu_group.php
|
||||
- www/admin/edit_order.php
|
||||
- www/admin/edit_pages.php
|
||||
- www/admin/edit_schemes.php
|
||||
- www/admin/edit_users.php
|
||||
- www/admin/edit_visible_group.php
|
||||
- www/admin/edit_*.php
|
||||
# ignore admin header stuff
|
||||
- www/includes/admin_header.php # ignore the admin include stuff
|
||||
# - www/includes/admin_header.php # ignore the admin include stuff
|
||||
- www/includes/admin_footer.php # ignore the admin include stuff
|
||||
# deprecated files
|
||||
- www/includes/admin_set_paths.php # ignore the admin include stuff
|
||||
- www/includes/admin_smarty.php # ignore the admin include stuff
|
||||
# folders with data no check needed
|
||||
@@ -41,16 +36,18 @@ parameters:
|
||||
- www/log
|
||||
- www/media
|
||||
- www/tmp
|
||||
- www/lib/pChart
|
||||
- www/lib/pChart2.1.4
|
||||
- www/lib/Smarty
|
||||
- www/lib/smarty-3.1.30
|
||||
- www/lib/pChart*
|
||||
- www/lib/Smarty*
|
||||
- www/lib/smarty*
|
||||
# ignore composer
|
||||
- www/vendor
|
||||
# ignore the smartyextend
|
||||
- www/lib/CoreLibs/Template/SmartyExtend.php
|
||||
# ignore errores with
|
||||
# ignoreErrors:
|
||||
ignoreErrors:
|
||||
# -
|
||||
# message: '#Reflection error: [a-zA-Z0-9\\_]+ not found.#'
|
||||
# path: www/includes/edit_base.php
|
||||
#- 'error regex'
|
||||
#-
|
||||
# message: 'error regex'
|
||||
|
||||
@@ -33,7 +33,7 @@ use CoreLibs\Combined\ArrayHandler;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$basic = new CoreLibs\Basic();
|
||||
// $_array= new CoreLibs\Combined\ArrayHandler();
|
||||
// $_array = new CoreLibs\Combined\ArrayHandler();
|
||||
// $array_class = 'CoreLibs\Combination\ArrayHandler';
|
||||
|
||||
print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>";
|
||||
|
||||
@@ -33,7 +33,7 @@ use CoreLibs\Combined\DateTime;
|
||||
use CoreLibs\Debug\Support as DgS;
|
||||
|
||||
$basic = new CoreLibs\Basic();
|
||||
$datetime_class = 'CoreLibs\Combination\DateTime';
|
||||
$datetime_class = 'CoreLibs\Combined\DateTime';
|
||||
|
||||
print "<html><head><title>TEST CLASS: DATE/TIME</title><head>";
|
||||
print "<body>";
|
||||
|
||||
@@ -52,83 +52,117 @@ echo "DB_CONFIG_SET constant: <pre>" . print_r(DB_CONFIG, true) . "</pre><br>";
|
||||
// DB client encoding
|
||||
print "DB Client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||
|
||||
while ($res = $db->dbReturn("SELECT * FROM max_test", 0, true)) {
|
||||
while (is_array($res = $db->dbReturn("SELECT * FROM max_test", 0, true))) {
|
||||
print "TIME: " . $res['time'] . "<br>";
|
||||
}
|
||||
print "CACHED DATA: <pre>" . print_r($db->cursor_ext, true) . "</pre><br>";
|
||||
while ($res = $db->dbReturn("SELECT * FROM max_test")) {
|
||||
while (is_array($res = $db->dbReturn("SELECT * FROM max_test"))) {
|
||||
print "[CACHED] TIME: " . $res['time'] . "<br>";
|
||||
}
|
||||
// alternate check for valid data
|
||||
// while (($res = $db->dbReturn("SELECT * FROM max_test")) !== false) {
|
||||
// print "[CACHED] TIME: " . $res['time'] . "<br>";
|
||||
// }
|
||||
|
||||
print "<pre>";
|
||||
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST " . time() . "') RETURNING test");
|
||||
|
||||
// truncate test_foo table before testing
|
||||
print "<b>TRUNCATE test_foo</b><br>";
|
||||
$query = "TRUNCATE test_foo";
|
||||
$db->dbExec($query);
|
||||
print "<b>TRUNCATE test_foobar</b><br>";
|
||||
$query = "TRUNCATE test_foobar";
|
||||
$db->dbExec($query);
|
||||
|
||||
$status = $db->dbExec("INSERT INTO test_foo (test) VALUES ('FOO TEST " . time() . "') RETURNING test");
|
||||
print "DIRECT INSERT STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
// should throw deprecated error
|
||||
// $db->getReturningExt();
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: "
|
||||
. print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||
$db->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
|
||||
$status = $db->dbExecute("ins_foo", array('BAR TEST ' . time()));
|
||||
print "PREPARE INSERT STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
||||
. "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||
|
||||
// PREPARED INSERT
|
||||
$db->dbPrepare("ins_test_foo", "INSERT INTO test_foo (test) VALUES ($1) RETURNING test");
|
||||
$status = $db->dbExecute("ins_test_foo", array('BAR TEST ' . time()));
|
||||
print "PREPARE INSERT[ins_test_foo] STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: "
|
||||
. print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||
. print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo "
|
||||
. "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
|
||||
// returning test with multiple entries
|
||||
// $status = $db->db_exec(
|
||||
// "INSERT INTO foo (test) VALUES "
|
||||
// "INSERT INTO test_foo (test) VALUES "
|
||||
// . "('BAR 1 " . time() . "'), "
|
||||
// . "('BAR 2 " . time() . "'), "
|
||||
// . "('BAR 3 " . time() . "') "
|
||||
// . "RETURNING foo_id"
|
||||
// . "RETURNING test_foo_id"
|
||||
// );
|
||||
$status = $db->dbExec(
|
||||
"INSERT INTO foo (test) VALUES "
|
||||
"INSERT INTO test_foo (test) VALUES "
|
||||
. "('BAR 1 " . time() . "'), "
|
||||
. "('BAR 2 " . time() . "'), "
|
||||
. "('BAR 3 " . time() . "') "
|
||||
. "RETURNING foo_id, test"
|
||||
. "RETURNING test_foo_id, test"
|
||||
);
|
||||
print "DIRECT MULTIPLE INSERT STATUS: $status | "
|
||||
. "PRIMARY KEYS: " . print_r($db->dbGetInsertPK(), true) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
print "DIRECT MULTIPLE INSERT WITH RETURN STATUS: $status | "
|
||||
. "PRIMARY KEYS: " . print_r($db->dbGetInsertPK(), true) . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
// no returning, but not needed ;
|
||||
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST " . time() . "');");
|
||||
print "DIRECT INSERT STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
$status = $db->dbExec("INSERT INTO test_foo (test) VALUES ('FOO; TEST " . time() . "');");
|
||||
print "DIRECT INSERT NO RETURN STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
// UPDATE WITH RETURNING
|
||||
$status = $db->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test");
|
||||
print "UPDATE STATUS: $status | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
$status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT' WHERE test_foo_id = 3688452 RETURNING test");
|
||||
print "UPDATE WITH RETURN STATUS: $status | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
|
||||
// INSERT WITH NO RETURNING
|
||||
$status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITH DATA', 123)");
|
||||
print "INSERT WITH NO PRIMARY KEY NO RETURNING STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
$status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITH DATA', 123) RETURNING type, integer");
|
||||
print "INSERT WITH NO PRIMARY KEY WITH RETURNING STATUS: $status | "
|
||||
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
|
||||
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
|
||||
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
|
||||
|
||||
print "</pre>";
|
||||
|
||||
// REEAD PREPARE
|
||||
// READ PREPARE
|
||||
if (
|
||||
$db->dbPrepare(
|
||||
'sel_foo',
|
||||
"SELECT foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time "
|
||||
. "FROM foo ORDER BY foo_id DESC LIMIT 5"
|
||||
'sel_test_foo',
|
||||
"SELECT test_foo_id, test, some_bool, string_a, number_a, number_a_numeric, some_time "
|
||||
. "FROM test_foo ORDER BY test_foo_id DESC LIMIT 5"
|
||||
) === false
|
||||
) {
|
||||
print "Error in sel_foo prepare<br>";
|
||||
print "Error in sel_test_foo prepare<br>";
|
||||
} else {
|
||||
$max_rows = 6;
|
||||
// do not run this in dbFetchArray directly as
|
||||
// dbFetchArray(dbExecute(...))
|
||||
// this will end in an endless loop
|
||||
$cursor = $db->dbExecute('sel_foo', []);
|
||||
$cursor = $db->dbExecute('sel_test_foo', []);
|
||||
$i = 1;
|
||||
while (($res = $db->dbFetchArray($cursor, true)) !== false) {
|
||||
print "DB PREP EXEC FETCH ARR: " . $i . ": <pre>" . print_r($res, true) . "</pre><br>";
|
||||
@@ -138,14 +172,16 @@ if (
|
||||
|
||||
|
||||
# db write class test
|
||||
$table = 'foo';
|
||||
$table = 'test_foo';
|
||||
print "TABLE META DATA: " . DgS::printAr($db->dbShowTableMetaData($table)) . "<br>";
|
||||
// insert first, then use primary key to update
|
||||
$primary_key = ''; # unset
|
||||
$db_write_table = array('test', 'string_a', 'number_a', 'some_bool');
|
||||
// $db_write_table = array('test');
|
||||
$object_fields_not_touch = array();
|
||||
$object_fields_not_update = array();
|
||||
$data = array('test' => 'BOOL TEST SOMETHING ' . time(), 'string_a' => 'SOME TEXT', 'number_a' => 5);
|
||||
$db_write_table = ['test', 'string_a', 'number_a', 'some_bool'];
|
||||
$object_fields_not_touch = [];
|
||||
$object_fields_not_update = [];
|
||||
$data = [
|
||||
'test' => 'dbWriteDataExt: BOOL TEST SOMETHING ' . time(), 'string_a' => 'SOME TEXT', 'number_a' => 5
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
@@ -154,8 +190,10 @@ $primary_key = $db->dbWriteDataExt(
|
||||
$object_fields_not_update,
|
||||
$data
|
||||
);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST ON ' . time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
|
||||
print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got primary key $primary_key<br>";
|
||||
$data = [
|
||||
'test' => 'dbWriteDataExt: BOOL TEST ON ' . time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
@@ -164,8 +202,10 @@ $primary_key = $db->dbWriteDataExt(
|
||||
$object_fields_not_update,
|
||||
$data
|
||||
);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST OFF ' . time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
|
||||
print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got primary key $primary_key<br>";
|
||||
$data = [
|
||||
'test' => 'dbWriteDataExt: BOOL TEST OFF ' . time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
@@ -174,8 +214,10 @@ $primary_key = $db->dbWriteDataExt(
|
||||
$object_fields_not_update,
|
||||
$data
|
||||
);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array('test' => 'BOOL TEST UNSET ' . time());
|
||||
print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got primary key $primary_key<br>";
|
||||
$data = [
|
||||
'test' => 'dbWriteDataExt: BOOL TEST UNSET ' . time()
|
||||
];
|
||||
$primary_key = $db->dbWriteDataExt(
|
||||
$db_write_table,
|
||||
$primary_key,
|
||||
@@ -184,7 +226,7 @@ $primary_key = $db->dbWriteDataExt(
|
||||
$object_fields_not_update,
|
||||
$data
|
||||
);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
print "Wrote to DB tabel $table with data " . print_r($data, true) . " and got primary key $primary_key<br>";
|
||||
|
||||
// return Array Test
|
||||
$query = "SELECT type, sdate, integer FROM foobar";
|
||||
@@ -192,7 +234,8 @@ $data = $db->dbReturnArray($query, true);
|
||||
print "Full foobar list: <br><pre>" . print_r($data, true) . "</pre><br>";
|
||||
|
||||
# async test queries
|
||||
/* $db->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||
/*
|
||||
$db->dbExecAsync("SELECT test FROM test_foo, (SELECT pg_sleep(10)) as sub WHERE test_foo_id IN (27, 50, 67, 44, 10)");
|
||||
echo "WAITING FOR ASYNC: ";
|
||||
$chars = array('|', '/', '-', '\\');
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
@@ -213,7 +256,7 @@ while ($res = $db->dbFetchArray())
|
||||
echo "RES: " . $res['test'] . "<br>";
|
||||
}
|
||||
# test async insert
|
||||
$db->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST " . time() . "')");
|
||||
$db->dbExecAsync("INSERT INTO test_foo (Test) VALUES ('ASYNC TEST " . time() . "')");
|
||||
echo "WAITING FOR ASYNC INSERT: ";
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
{
|
||||
@@ -223,7 +266,12 @@ while (($ret = $db->dbCheckAsync()) === true)
|
||||
}
|
||||
print "<br>END STATUS: " . $ret . " | PK: " . $db->insert_id . "<br>";
|
||||
print "ASYNC PREVIOUS INSERTED: "
|
||||
. print_r($db->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = " . $db->insert_id), true) . "<br>"; */
|
||||
. print_r(
|
||||
$db->dbReturnRow("SELECT test_foo_id, test FROM test_foo WHERE test_foo_id = "
|
||||
. $db->insert_id),
|
||||
true
|
||||
) . "<br>";
|
||||
*/
|
||||
|
||||
$to_db_version = '9.1.9';
|
||||
print "VERSION DB: " . $db->dbVersion() . "<br>";
|
||||
@@ -233,16 +281,17 @@ print "DB Version equal $to_db_version: " . $db->dbCompareVersion('=' . $to_db_v
|
||||
print "DB Version bigger than $to_db_version: " . $db->dbCompareVersion('>=' . $to_db_version) . "<br>";
|
||||
print "DB Version bigger $to_db_version: " . $db->dbCompareVersion('>' . $to_db_version) . "<br>";
|
||||
|
||||
/* $q = "SELECT FOO FRO BAR";
|
||||
// $q = "Select * from foo";
|
||||
$foo = $db->dbExecAsync($q);
|
||||
/*
|
||||
$q = "Select * from test_foo";
|
||||
$test_foo = $db->dbExecAsync($q);
|
||||
print "[ERR] Query: " . $q . "<br>";
|
||||
print "[ERR] RESOURCE: $foo<br>";
|
||||
print "[ERR] RESOURCE: $test_foo<br>";
|
||||
while (($ret = $db->dbCheckAsync()) === true)
|
||||
{
|
||||
print "[ERR]: $ret<br>";
|
||||
sleep(5);
|
||||
} */
|
||||
}
|
||||
*/
|
||||
|
||||
// search path check
|
||||
$q = "SHOW search_path";
|
||||
@@ -256,7 +305,7 @@ $status = $db->dbExec(
|
||||
. "('TIME: " . time() . "', " . rand(1, 10) . ")"
|
||||
);
|
||||
print "OTHER SCHEMA INSERT STATUS: "
|
||||
. $status . " | PK NAME: " . $db->pk_name . ", PRIMARY KEY: " . $db->insert_id . "<br>";
|
||||
. $status . " | PK NAME: " . $db->dbGetInsertPKName() . ", PRIMARY KEY: " . $db->dbGetInsertPK() . "<br>";
|
||||
|
||||
print "<b>NULL TEST DB READ</b><br>";
|
||||
$q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'";
|
||||
|
||||
@@ -52,9 +52,6 @@ echo "LANGUAGE FILE: " . $l->__getMoFile() . "<br>";
|
||||
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
|
||||
// TODO: run compare check input must match output
|
||||
|
||||
// error message
|
||||
print $basic->log->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -32,6 +32,7 @@ $LOG_FILE_ID = 'classTest-form';
|
||||
ob_end_flush();
|
||||
|
||||
// define an array for page use
|
||||
$table_arrays = [];
|
||||
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
||||
// form fields mtaching up with db fields
|
||||
'table_array' => [
|
||||
|
||||
@@ -64,6 +64,10 @@ print '<div><a href="class_test.backend.php">Class Test: BACKEND ADMIN CLASS</a>
|
||||
print '<div><a href="class_test.lang.php">Class Test: LANG/L10n</a></div>';
|
||||
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</a></div>';
|
||||
|
||||
print "<hr>";
|
||||
// print all _ENV vars set
|
||||
print "<div>READ _ENV ARRAY:</div>";
|
||||
print "<pre>" . print_r(array_map('htmlentities', $_ENV), true) . "</pre>";
|
||||
// set + check edit access id
|
||||
$edit_access_id = 3;
|
||||
if (is_object($login) && isset($login->acl['unit'])) {
|
||||
|
||||
@@ -84,6 +84,7 @@ $options = [
|
||||
];
|
||||
|
||||
$smarty->DATA['drop_down_test'] = $options;
|
||||
$smarty->DATA['drop_down_test_selected'] = '';
|
||||
$smarty->DATA['loop_start'] = 2;
|
||||
// require BASE.INCLUDES.'admin_smarty.php';
|
||||
$smarty->setSmartyVarsAdmin();
|
||||
|
||||
8
www/configs/.env.example
Normal file
8
www/configs/.env.example
Normal file
@@ -0,0 +1,8 @@
|
||||
# Master configs
|
||||
BASE_NAME=
|
||||
G_TITLE=
|
||||
# DB configs
|
||||
DB_NAME_TEST=
|
||||
DB_USER_TEST=
|
||||
DB_PASS_TEST=
|
||||
DB_HOST_TEST=
|
||||
@@ -13,15 +13,15 @@ declare(strict_types=1);
|
||||
// please be VERY carefull only to change the right side
|
||||
$DB_CONFIG = [
|
||||
'test' => [
|
||||
'db_name' => 'clemens',
|
||||
'db_user' => 'clemens',
|
||||
'db_pass' => 'clemens',
|
||||
'db_host' => 'db.tokyo.tequila.jp',
|
||||
'db_name' => $_ENV['DB_NAME_TEST'] ?? '',
|
||||
'db_user' => $_ENV['DB_USER_TEST'] ?? '',
|
||||
'db_pass' => $_ENV['DB_PASS_TEST'] ?? '',
|
||||
'db_host' => $_ENV['DB_HOST_TEST'] ?? '',
|
||||
'db_port' => 5432,
|
||||
'db_schema' => 'public',
|
||||
'db_type' => 'pgsql',
|
||||
'db_encoding' => '',
|
||||
'db_ssl' => 'disable' // allow, disable, require, prefer
|
||||
'db_ssl' => 'allow' // allow, disable, require, prefer
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -41,8 +41,6 @@ define('IMAGES', 'images' . DS);
|
||||
define('ICONS', 'icons' . DS);
|
||||
// media (accessable from outside)
|
||||
define('MEDIA', 'media' . DS);
|
||||
// flash-root (below media or data)
|
||||
define('FLASH', 'flash' . DS);
|
||||
// uploads (anything to keep or data)
|
||||
define('UPLOADS', 'uploads' . DS);
|
||||
// files (binaries) (below media or data)
|
||||
@@ -86,7 +84,7 @@ define('DEFAULT_HASH', 'sha256');
|
||||
// default acl level
|
||||
define('DEFAULT_ACL_LEVEL', 80);
|
||||
// SSL host name
|
||||
// define('SSL_HOST', 'ssl.host.name');
|
||||
// define('SSL_HOST', $_ENV['SSL_HOST'] ?? '');
|
||||
// error page strictness, Default is 3
|
||||
// 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all
|
||||
// 2: if template not found, do not search, show error template
|
||||
@@ -133,15 +131,16 @@ define('USE_SCRIPTACULOUS', false);
|
||||
define('USE_JQUERY', true);
|
||||
|
||||
/************* LAYOUT WIDTHS *************/
|
||||
define('PAGE_WIDTH', 800);
|
||||
define('CONTENT_WIDTH', 800);
|
||||
define('PAGE_WIDTH', '100%');
|
||||
define('CONTENT_WIDTH', '100%');
|
||||
// the default template name
|
||||
define('MASTER_TEMPLATE_NAME', 'main_body.tpl');
|
||||
|
||||
/************* OVERALL CONTROL NAMES *************/
|
||||
// BELOW has HAS to be changed
|
||||
// base name for all session and log names
|
||||
define('BASE_NAME', 'CoreLibs');
|
||||
// only alphanumeric characters, strip all others
|
||||
define('BASE_NAME', preg_replace('/[^A-Za-z0-9]/', '', $_ENV['BASE_NAME'] ?? ''));
|
||||
|
||||
/************* SESSION NAMES *************/
|
||||
// server name HASH
|
||||
@@ -268,7 +267,7 @@ define('LOGIN_ENABLED', $SITE_CONFIG[HOST_NAME]['login_enabled']);
|
||||
define('SHOW_ALL_ERRORS', true);
|
||||
|
||||
/************* GENERAL PAGE TITLE ********/
|
||||
define('G_TITLE', '<OVERALL FALLBACK PAGE TITLE>');
|
||||
define('G_TITLE', $_ENV['G_TITLE'] ?? '');
|
||||
|
||||
/************ STYLE SHEETS / JS **********/
|
||||
define('ADMIN_STYLESHEET', 'edit.css');
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// DEFINE('SOME_ID', <SOME VALUE>);
|
||||
// define('SOME_ID', <SOME VALUE>);
|
||||
|
||||
/************* CONVERT *******************/
|
||||
// this only needed if the external thumbnail create is used
|
||||
|
||||
@@ -16,6 +16,13 @@ $CONFIG_PATH_PREFIX = '';
|
||||
for ($dir_pos = 0, $dir_max = count(explode(DIRECTORY_SEPARATOR, __DIR__)); $dir_pos <= $dir_max; $dir_pos++) {
|
||||
$CONFIG_PATH_PREFIX .= '..' . DIRECTORY_SEPARATOR;
|
||||
if (file_exists($CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php')) {
|
||||
// check if there is an read env file, load it
|
||||
if (file_exists($CONFIG_PATH_PREFIX . CONFIG_PATH . 'read_env_file.php')) {
|
||||
require $CONFIG_PATH_PREFIX . CONFIG_PATH . 'read_env_file.php';
|
||||
// load env variables first
|
||||
readEnvFile($CONFIG_PATH_PREFIX . CONFIG_PATH);
|
||||
}
|
||||
// then load master config file that loads all other config files
|
||||
require $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
|
||||
break;
|
||||
}
|
||||
@@ -26,7 +33,7 @@ if (!defined('DS')) {
|
||||
}
|
||||
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
||||
foreach (['admin', 'frontend'] as $folder) {
|
||||
if (strstr(getcwd(), DS . $folder)) {
|
||||
if (strstr(getcwd() ?: '', DS . $folder)) {
|
||||
define('CONTENT_PATH', $folder . DS);
|
||||
break;
|
||||
}
|
||||
|
||||
84
www/configs/read_env_file.php
Normal file
84
www/configs/read_env_file.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* parses .env file
|
||||
*
|
||||
* Rules for .env file
|
||||
* variable is any alphanumeric string followed by = on the same line
|
||||
* content starts with the first non space part
|
||||
* strings can be contained in "
|
||||
* strings MUST be contained in " if they are multiline
|
||||
* if string starts with " it will match until another " is found
|
||||
* anything AFTER " is ignored
|
||||
* if there are two variables with the same name only the first is used
|
||||
* variables are case sensitive
|
||||
*
|
||||
* @param string $path Folder to file, default is __DIR__
|
||||
* @param string $env_file What file to load, default is .env
|
||||
* @return int -1 other error
|
||||
* 0 for success full load
|
||||
* 1 for file loadable, but no data inside
|
||||
* 2 for file not readable
|
||||
* 3 for file not found
|
||||
*/
|
||||
function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int
|
||||
{
|
||||
// default -1;
|
||||
$status = -1;
|
||||
$env_file_target = $path . DIRECTORY_SEPARATOR . $env_file;
|
||||
// this is not a file -> abort
|
||||
if (!is_file($env_file_target)) {
|
||||
$status = 3;
|
||||
return $status;
|
||||
}
|
||||
// cannot open file -> abort
|
||||
if (($fp = fopen($env_file_target, 'r')) === false) {
|
||||
$status = 2;
|
||||
return $status;
|
||||
}
|
||||
// set to readable but not yet any data loaded
|
||||
$status = 1;
|
||||
$block = false;
|
||||
$var = '';
|
||||
while ($line = fgets($fp)) {
|
||||
// main match for variable = value part
|
||||
if (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
|
||||
$var = $matches[1];
|
||||
$value = $matches[2];
|
||||
$quotes = $matches[3];
|
||||
// wirte only if env is not set yet, and write only the first time
|
||||
if (empty($_ENV[$var])) {
|
||||
if (!empty($quotes)) {
|
||||
// match greedy for first to last so we move any " if there are
|
||||
if (preg_match('/^"(.*[^\\\])"/U', $value, $matches)) {
|
||||
$value = $matches[1];
|
||||
} else {
|
||||
// this is a multi line
|
||||
$block = true;
|
||||
// first " in string remove
|
||||
// add removed new line back because this is a multi line
|
||||
$value = ltrim($value, '"') . PHP_EOL;
|
||||
}
|
||||
}
|
||||
// if block is set, we strip line of slashes
|
||||
$_ENV[$var] = $block === true ? stripslashes($value) : $value;
|
||||
// set successful load
|
||||
$status = 0;
|
||||
}
|
||||
} elseif ($block === true) {
|
||||
// read line until there is a unescaped "
|
||||
// this also strips everything after the last "
|
||||
if (preg_match("/(.*[^\\\])\"/", $line, $matches)) {
|
||||
$block = false;
|
||||
// strip ending " and EVERYTHING that follows after that
|
||||
$line = $matches[1];
|
||||
}
|
||||
// strip line of slashes
|
||||
$_ENV[$var] .= stripslashes($line);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
return $status;
|
||||
}
|
||||
|
||||
// __END__
|
||||
@@ -3,3 +3,5 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require 'config.php';
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
//------------------------------ variable init start
|
||||
// for dev test we set full error reporting; writes everything, except E_ERROR into logs/php_error-<day>.log
|
||||
if ($DEBUG_ALL && $ENABLE_ERROR_HANDLING) {
|
||||
if (!empty($DEBUG_ALL) && !empty($ENABLE_ERROR_HANDLING)) {
|
||||
include BASE . LIBS . "Error.Handling.php";
|
||||
}
|
||||
// predefine vars
|
||||
@@ -82,7 +82,7 @@ if (!$login->login) {
|
||||
|
||||
// automatic hide for DEBUG messages on live server
|
||||
// can be overridden when setting DEBUG_ALL_OVERRIDE on top of the script (for emergency debugging of one page only)
|
||||
if ((TARGET == 'live' || TARGET == 'remote') && !$DEBUG_ALL_OVERRIDE) {
|
||||
if ((TARGET == 'live' || TARGET == 'remote') && !empty($DEBUG_ALL_OVERRIDE)) {
|
||||
foreach (['debug', 'echo', 'print'] as $target) {
|
||||
$login->log->setLogLevelAll($target, false);
|
||||
$cms->log->setLogLevelAll($target, false);
|
||||
|
||||
@@ -175,7 +175,7 @@ if ($form->my_page_name == 'edit_order') {
|
||||
$options_name = [];
|
||||
$options_selected = [];
|
||||
// DB read data for menu
|
||||
while ($res = $form->dbReturn($q)) {
|
||||
while (is_array($res = $form->dbReturn($q))) {
|
||||
$row_data[] = [
|
||||
"id" => $res[$table_name . "_id"],
|
||||
"name" => $res["name"],
|
||||
|
||||
@@ -100,10 +100,10 @@
|
||||
</script>
|
||||
<!-- /TinyMCE -->
|
||||
{/if}
|
||||
{popup_init src="`$js`/overlib/overlib.js"}
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin: 2px; width: {$table_width}px; margin-bottom: 10px;">
|
||||
{popup_init src="`$js`/overlib/overlib.js"}
|
||||
<div style="margin: 2px; width: {$table_width}; margin-bottom: 10px;">
|
||||
<div style="position: relative; height: 20px;" class="menu">
|
||||
<div style="position: absolute; width: 200px;">{t 1=$USER_NAME|upper}Hello %1{/t}</div>
|
||||
<div style="position: absolute; text-align: right; right: 0px; width: 120px;">
|
||||
@@ -127,13 +127,13 @@
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="pagename">
|
||||
<div id="pagename" class="pagename">
|
||||
{$page_name}
|
||||
</div>
|
||||
</div>
|
||||
{* error/warning *}
|
||||
{if $messages}
|
||||
<div style="margin: 2px; width: {$table_width}px;">
|
||||
<div style="margin: 2px; width: {$table_width};">
|
||||
{foreach from=$messages item=item key=key}
|
||||
<div class="{$item.class}">{$item.msg}</div>
|
||||
{/foreach}
|
||||
@@ -143,7 +143,7 @@
|
||||
|
||||
{* debug info *}
|
||||
{if $DEBUG}
|
||||
<div style="width:{$table_width}px;" class="debug_message">
|
||||
<div style="width:{$table_width};" class="debug_message">
|
||||
{$Id}<br>
|
||||
<b>{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}</b><br>
|
||||
{$debug_error_msg}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
/* global i18n */
|
||||
|
||||
// debug set
|
||||
/*var FRONTEND_DEBUG = false;
|
||||
var DEBUG = true;
|
||||
@@ -22,7 +24,8 @@ var GL_OB_BASE = 30;
|
||||
* @param {String} winName window name
|
||||
* @param {Object} features popup features
|
||||
*/
|
||||
function pop(theURL, winName, features) {
|
||||
function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
winName = window.open(theURL, winName, features);
|
||||
winName.focus();
|
||||
}
|
||||
@@ -31,7 +34,8 @@ function pop(theURL, winName, features) {
|
||||
* automatically resize a text area based on the amount of lines in it
|
||||
* @param {[string} ta_id element id
|
||||
*/
|
||||
function expandTA(ta_id) {
|
||||
function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var ta;
|
||||
// if a string comes, its a get by id, else use it as an element pass on
|
||||
if (!ta_id.length) {
|
||||
@@ -40,7 +44,7 @@ function expandTA(ta_id) {
|
||||
ta = document.getElementById(ta_id);
|
||||
}
|
||||
var maxChars = ta.cols;
|
||||
var theRows = ta.value.split("\n");
|
||||
var theRows = ta.value.split('\n');
|
||||
var numNewRows = 0;
|
||||
|
||||
for ( var i = 0; i < theRows.length; i++ ) {
|
||||
@@ -124,7 +128,7 @@ function setCenter(id, left, top)
|
||||
* @param {Number} [duration=500] animation time, default 500ms
|
||||
* @param {String} [base='body,html'] base element for offset scroll
|
||||
*/
|
||||
function goToPos(element, offset = 0, duration = 500, base = 'body,html')
|
||||
function goToPos(element, offset = 0, duration = 500, base = 'body,html') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
try {
|
||||
if ($('#' + element).length) {
|
||||
@@ -190,7 +194,7 @@ if (Number.prototype.round) {
|
||||
* @param {Number} x number to be formated
|
||||
* @return {String} formatted with , in thousands
|
||||
*/
|
||||
function numberWithCommas(x)
|
||||
function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var parts = x.toString().split('.');
|
||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
@@ -202,7 +206,7 @@ function numberWithCommas(x)
|
||||
* @param {String} string any string
|
||||
* @return {String} string with <br>
|
||||
*/
|
||||
function convertLBtoBR(string)
|
||||
function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
return string.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
||||
}
|
||||
@@ -214,14 +218,14 @@ function convertLBtoBR(string)
|
||||
*/
|
||||
if (!String.prototype.escapeHTML) {
|
||||
String.prototype.escapeHTML = function() {
|
||||
return this.replace(/[&<>"'\/]/g, function (s) {
|
||||
return this.replace(/[&<>"'/]/g, function (s) {
|
||||
var entityMap = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
"/": '/'
|
||||
'\'': ''',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
return entityMap[s];
|
||||
@@ -238,12 +242,12 @@ if (!String.prototype.unescapeHTML) {
|
||||
String.prototype.unescapeHTML = function() {
|
||||
return this.replace(/&[#\w]+;/g, function (s) {
|
||||
var entityMap = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
'/': "/"
|
||||
''': '\'',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
return entityMap[s];
|
||||
@@ -255,7 +259,7 @@ if (!String.prototype.unescapeHTML) {
|
||||
* returns current timestamp (unix timestamp)
|
||||
* @return {Number} timestamp (in milliseconds)
|
||||
*/
|
||||
function getTimestamp()
|
||||
function getTimestamp() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var date = new Date();
|
||||
return date.getTime();
|
||||
@@ -278,7 +282,7 @@ function dec2hex(dec)
|
||||
* @param {Number} len length of unique id string
|
||||
* @return {String} random string in length of len
|
||||
*/
|
||||
function generateId(len)
|
||||
function generateId(len) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var arr = new Uint8Array((len || 40) / 2);
|
||||
(window.crypto || window.msCrypto).getRandomValues(arr);
|
||||
@@ -291,7 +295,7 @@ function generateId(len)
|
||||
* after many runs it will create duplicates
|
||||
* @return {String} not true random string
|
||||
*/
|
||||
function randomIdF()
|
||||
function randomIdF() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
return Math.random().toString(36).substring(2);
|
||||
}
|
||||
@@ -301,7 +305,7 @@ function randomIdF()
|
||||
* @param {string} name Name of function to check if exists
|
||||
* @return {Boolean} true/false
|
||||
*/
|
||||
function isFunction(name)
|
||||
function isFunction(name) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
if (typeof window[name] !== 'undefined' &&
|
||||
typeof window[name] === 'function') {
|
||||
@@ -320,7 +324,7 @@ function isFunction(name)
|
||||
* hidden next are all the arguments
|
||||
* @return {mixed} Return values from functon
|
||||
*/
|
||||
function executeFunctionByName(functionName, context /*, args */)
|
||||
function executeFunctionByName(functionName, context /*, args */) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
var namespaces = functionName.split('.');
|
||||
@@ -362,7 +366,7 @@ function getObjectCount(object)
|
||||
*/
|
||||
function keyInObject(key, object)
|
||||
{
|
||||
return (Object.prototype.hasOwnProperty.call(object, key)) ? true : false;
|
||||
return Object.prototype.hasOwnProperty.call(object, key) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +375,7 @@ function keyInObject(key, object)
|
||||
* @param {Mixed} value any value (String, Number, etc)
|
||||
* @return {String} the key found for the first matching value
|
||||
*/
|
||||
function getKeyByValue(object, value)
|
||||
function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
return Object.keys(object).find(key => object[key] === value);
|
||||
// return Object.keys(object).find(function (key) {
|
||||
@@ -385,9 +389,9 @@ function getKeyByValue(object, value)
|
||||
* @param {Mixed} value any value (String, Number, etc)
|
||||
* @return {Boolean} true on value found, false on not found
|
||||
*/
|
||||
function valueInObject(object, value)
|
||||
function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
return (Object.keys(object).find(key => object[key] === value)) ? true : false;
|
||||
return Object.keys(object).find(key => object[key] === value) ? true : false;
|
||||
// return Object.keys(object).find(function (key) {
|
||||
// return object[key] === value;
|
||||
// }) ? true : false;
|
||||
@@ -403,7 +407,7 @@ function valueInObject(object, value)
|
||||
function deepCopyFunction(inObject)
|
||||
{
|
||||
var outObject, value, key;
|
||||
if (typeof inObject !== "object" || inObject === null) {
|
||||
if (typeof inObject !== 'object' || inObject === null) {
|
||||
return inObject; // Return the value if inObject is not an object
|
||||
}
|
||||
// Create an array or object to hold the values
|
||||
@@ -434,14 +438,15 @@ function exists(id)
|
||||
* @param {Number} bytes bytes in int
|
||||
* @return {String} string in GB/MB/KB
|
||||
*/
|
||||
function formatBytes(bytes)
|
||||
function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var i = -1;
|
||||
do {
|
||||
bytes = bytes / 1024;
|
||||
i++;
|
||||
} while (bytes > 99);
|
||||
return parseFloat(Math.round(bytes * Math.pow(10, 2)) / Math.pow(10, 2)) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
|
||||
return parseFloat(Math.round(bytes * Math.pow(10, 2)) / Math.pow(10, 2)) +
|
||||
['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +454,7 @@ function formatBytes(bytes)
|
||||
* @param {Number} bytes bytes in int
|
||||
* @return {String} string in GB/MB/KB
|
||||
*/
|
||||
function formatBytesLong(bytes)
|
||||
function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
@@ -461,7 +466,7 @@ function formatBytesLong(bytes)
|
||||
* @param {String|Number} bytes Any string with B/K/M/etc
|
||||
* @return {String|Number} A byte number, or original string as is
|
||||
*/
|
||||
function stringByteFormat(bytes)
|
||||
function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// if anything not string return
|
||||
if (!(typeof bytes === 'string' || bytes instanceof String)) {
|
||||
@@ -536,7 +541,7 @@ function errorCatch(err)
|
||||
* default empty. for console.log
|
||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||
*/
|
||||
function actionIndicator(loc, overlay = true)
|
||||
function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
if ($('#indicator').is(':visible')) {
|
||||
actionIndicatorHide(loc, overlay);
|
||||
@@ -613,7 +618,7 @@ function overlayBoxHide()
|
||||
/**
|
||||
* position the overlay block box and shows it
|
||||
*/
|
||||
function setOverlayBox()
|
||||
function setOverlayBox() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
if (!$('#overlayBox').is(':visible')) {
|
||||
$('#overlayBox').show();
|
||||
@@ -623,7 +628,7 @@ function setOverlayBox()
|
||||
/**
|
||||
* opposite of set, always hides overlay box
|
||||
*/
|
||||
function hideOverlayBox()
|
||||
function hideOverlayBox() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
if ($('#overlayBox').is(':visible')) {
|
||||
$('#overlayBox').hide();
|
||||
@@ -633,7 +638,7 @@ function hideOverlayBox()
|
||||
/**
|
||||
* the abort call, clears the action box and hides it and the overlay box
|
||||
*/
|
||||
function ClearCall()
|
||||
function ClearCall() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
$('#actionBox').html('');
|
||||
$('#actionBox').hide();
|
||||
@@ -654,7 +659,7 @@ function ClearCall()
|
||||
* - indicator is page centered
|
||||
* @param {String} loc ID string, only used for console log
|
||||
*/
|
||||
function showActionIndicator(loc)
|
||||
function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// console.log('Indicator: SHOW [%s]', loc);
|
||||
// check if indicator element exists
|
||||
@@ -692,7 +697,7 @@ function showActionIndicator(loc)
|
||||
* is set to this value
|
||||
* @param {String} loc ID string, only used for console log
|
||||
*/
|
||||
function hideActionIndicator(loc)
|
||||
function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// console.log('Indicator: HIDE [%s]', loc);
|
||||
// check if indicator is visible
|
||||
@@ -732,7 +737,7 @@ function checkOverlayExists()
|
||||
* if visible, add +1 to the GL_OB_S variable and
|
||||
* up zIndex by this value
|
||||
*/
|
||||
function showOverlayBoxLayers(el_id)
|
||||
function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// console.log('SHOW overlaybox: %s', GL_OB_S);
|
||||
// if overlay box is not visible show and set zIndex to 0
|
||||
@@ -789,7 +794,7 @@ function hideOverlayBoxLayers(el_id)
|
||||
/**
|
||||
* only for single action box
|
||||
*/
|
||||
function clearCallActionBox()
|
||||
function clearCallActionBox() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
$('#actionBox').html('');
|
||||
$('#actionBox').hide();
|
||||
@@ -872,7 +877,7 @@ function aelx(base, ...attach)
|
||||
* @param {Array} attach array of objects to attach
|
||||
* @return {Object} "none", technically there is no return needed, global attach
|
||||
*/
|
||||
function aelxar(base, attach)
|
||||
function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
for (var i = 0; i < attach.length; i ++) {
|
||||
// base.sub.push(Object.assign({}, attach[i]));
|
||||
@@ -886,7 +891,7 @@ function aelxar(base, attach)
|
||||
* @param {Object} base cel created element
|
||||
* @return {Object} returns reset base element
|
||||
*/
|
||||
function rel(base)
|
||||
function rel(base) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
base.sub = [];
|
||||
return base;
|
||||
@@ -930,7 +935,7 @@ function acssel(_element, css)
|
||||
* @param {String} acss style to add (name)
|
||||
* @return {Object} returns full element
|
||||
*/
|
||||
function scssel(_element, rcss, acss)
|
||||
function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
rcssel(_element, rcss);
|
||||
acssel(_element, acss);
|
||||
@@ -1008,7 +1013,7 @@ function phfo(tree)
|
||||
* @param {Array} list Array of cel created objects
|
||||
* @return {String} HTML String
|
||||
*/
|
||||
function phfa(list)
|
||||
function phfa(list) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var content = [];
|
||||
for (var i = 0; i < list.length; i ++) {
|
||||
@@ -1034,7 +1039,7 @@ function phfa(list)
|
||||
* 'values' all others are ignored
|
||||
* @return {String} html with build options block
|
||||
*/
|
||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '')
|
||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// wrapper to new call
|
||||
return html_options_block(name, data, selected, false, options_only, return_string, sort);
|
||||
@@ -1067,6 +1072,7 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl
|
||||
var element_option;
|
||||
var data_list = []; // for sorted output
|
||||
var value;
|
||||
var options = {};
|
||||
// var option;
|
||||
if (multiple > 0) {
|
||||
select_options.multiple = '';
|
||||
@@ -1139,7 +1145,7 @@ function html_options_block(name, data, selected = '', multiple = 0, options_onl
|
||||
* @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
|
||||
* all others are ignored
|
||||
*/
|
||||
function html_options_refill(name, data, sort = '')
|
||||
function html_options_refill(name, data, sort = '') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var element_option;
|
||||
var option_selected;
|
||||
@@ -1186,21 +1192,26 @@ function html_options_refill(name, data, sort = '')
|
||||
* or empty for none
|
||||
* @return {Object|String} parameter entry list
|
||||
*/
|
||||
function parseQueryString(query = '', return_key = '') {
|
||||
function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
if (!query) {
|
||||
query = window.location.search.substring(1);
|
||||
}
|
||||
var vars = query.split("&");
|
||||
var vars = query.split('&');
|
||||
var query_string = {};
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split("=");
|
||||
var pair = vars[i].split('=');
|
||||
var key = decodeURIComponent(pair[0]);
|
||||
var value = decodeURIComponent(pair[1]);
|
||||
// skip over run if there is nothing
|
||||
if (!key || value === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
// If first entry with this name
|
||||
if (typeof query_string[key] === "undefined") {
|
||||
if (typeof query_string[key] === 'undefined') {
|
||||
query_string[key] = decodeURIComponent(value);
|
||||
// If second entry with this name
|
||||
} else if (typeof query_string[key] === "string") {
|
||||
} else if (typeof query_string[key] === 'string') {
|
||||
var arr = [query_string[key], decodeURIComponent(value)];
|
||||
query_string[key] = arr;
|
||||
// If third or later entry with this name
|
||||
@@ -1220,26 +1231,59 @@ function parseQueryString(query = '', return_key = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* searchs the current url for a parameter
|
||||
* @param {String} key uid key to get data for
|
||||
* @return {String} value for the key or '' for not found
|
||||
* searches query parameters for entry and returns data either as string or array
|
||||
* if no search is given the whole parameters are returned as an object
|
||||
* if a parameter is set several times it will be returned as an array
|
||||
* if search parameter set and nothing found and empty string is returned
|
||||
* if no parametes exist and no serach is set and empty object is returned
|
||||
* @param {String} [search=''] if set searches for this entry, if empty
|
||||
* all parameters are returned
|
||||
* @param {String} [query=''] different query string to parse, if not
|
||||
* set (default) the current window href is used
|
||||
* @param {Bool} [single=false] if set to true then only the first found
|
||||
* will be returned
|
||||
* @return {Object|Array|String} if search is empty, object, if search is set
|
||||
* and only one entry, then string, else array
|
||||
* unless single is true
|
||||
*/
|
||||
function getQueryStringParam(key)
|
||||
function getQueryStringParam(search = '', query = '', single = false) // eslint-disable-line no-unused-vars
|
||||
{
|
||||
var url = new URL(window.location.href);
|
||||
var param = url.searchParams.get(key);
|
||||
if (param) {
|
||||
return param;
|
||||
} else {
|
||||
return '';
|
||||
if (!query) {
|
||||
query = window.location.href;
|
||||
}
|
||||
const url = new URL(query);
|
||||
let param = '';
|
||||
if (search) {
|
||||
let _params = url.searchParams.getAll(search);
|
||||
if (_params.length == 1 || single === true) {
|
||||
param = _params[0];
|
||||
} else if (_params.length > 1) {
|
||||
param = _params;
|
||||
}
|
||||
} else {
|
||||
// will be object, so declare it one
|
||||
param = {};
|
||||
// loop over paramenters
|
||||
for (const [key] of url.searchParams.entries()) {
|
||||
// check if not yet set
|
||||
if (typeof param[key] === 'undefined') {
|
||||
// get the parameters multiple
|
||||
let _params = url.searchParams.getAll(key);
|
||||
// if 1 set as string, else attach array as is
|
||||
param[key] = _params.length < 2 || single === true ?
|
||||
_params[0] :
|
||||
_params;
|
||||
}
|
||||
}
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
// *** MASTER logout call
|
||||
/**
|
||||
* submits basic data for form logout
|
||||
*/
|
||||
function loginLogout()
|
||||
function loginLogout() // eslint-disable-line no-unused-vars
|
||||
{
|
||||
const form = document.createElement('form');
|
||||
form.method = 'post';
|
||||
@@ -1259,7 +1303,7 @@ function loginLogout()
|
||||
* if not set mainHeader is assumed
|
||||
* this is the target div for the "loginRow"
|
||||
*/
|
||||
function createLoginRow(login_string, header_id = 'mainHeader')
|
||||
function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// if header does not exist, we do nothing
|
||||
if (exists(header_id)) {
|
||||
@@ -1293,7 +1337,8 @@ function createLoginRow(login_string, header_id = 'mainHeader')
|
||||
* if not set mainHeader is assumed
|
||||
* this is the target div for the "menuRow"
|
||||
*/
|
||||
function createNavMenu(nav_menu, header_id = 'mainHeader') {
|
||||
function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||
{
|
||||
// must be an object
|
||||
if (isObject(nav_menu) && getObjectCount(nav_menu) > 1) {
|
||||
// do we have more than one entry, if not, do not show (single page)
|
||||
|
||||
@@ -72,44 +72,70 @@ use CoreLibs\Check\Password;
|
||||
|
||||
class Login extends \CoreLibs\DB\IO
|
||||
{
|
||||
/** @var string */
|
||||
private $euid; // the user id var
|
||||
// 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;
|
||||
/** @var string */
|
||||
public $login; // pressed login
|
||||
/** @var string */
|
||||
private $action; // master action command
|
||||
/** @var string */
|
||||
private $username; // login name
|
||||
/** @var string */
|
||||
private $password; // login password
|
||||
/** @var string */
|
||||
private $logout; // logout button
|
||||
// login error code, can be matched to the array login_error_msg, which holds the string
|
||||
/** @var int */
|
||||
private $login_error = 0;
|
||||
/** @var bool */
|
||||
private $password_change = false; // if this is set to true, the user can change passwords
|
||||
/** @var bool */
|
||||
private $password_change_ok = false; // password change was successful
|
||||
// can we reset password and mail to user with new password set screen
|
||||
/** @var bool */
|
||||
private $password_forgot = false;
|
||||
/** @var bool */
|
||||
private $password_forgot_ok = false; // password forgot mail send ok
|
||||
/** @var string */
|
||||
private $change_password;
|
||||
/** @var string */
|
||||
private $pw_username;
|
||||
/** @var string */
|
||||
private $pw_old_password;
|
||||
/** @var string */
|
||||
private $pw_new_password;
|
||||
/** @var string */
|
||||
private $pw_new_password_confirm;
|
||||
/** @var array<string> */
|
||||
private $pw_change_deny_users = []; // array of users for which the password change is forbidden
|
||||
/** @var string */
|
||||
private $logout_target;
|
||||
/** @var int */
|
||||
private $max_login_error_count = -1;
|
||||
/** @var array<string> */
|
||||
private $lock_deny_users = [];
|
||||
|
||||
// if we have password change we need to define some rules
|
||||
/** @var int */
|
||||
private $password_min_length = PASSWORD_MIN_LENGTH;
|
||||
// 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 = PASSWORD_MAX_LENGTH;
|
||||
// can have several regexes, if nothing set, all is ok
|
||||
/** @var array<string> */
|
||||
private $password_valid_chars = [
|
||||
// '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$',
|
||||
// '^(?.*(\pL)u)(?=.*(\pN)u)(?=.*([^\pL\pN])u).{8,}',
|
||||
];
|
||||
|
||||
// all possible login error conditions
|
||||
/** @var array<mixed> */
|
||||
private $login_error_msg = [];
|
||||
// this is an array holding all strings & templates passed from the outside (translation)
|
||||
/** @var array<mixed> */
|
||||
private $login_template = [
|
||||
'strings' => [],
|
||||
'password_change' => '',
|
||||
@@ -117,18 +143,23 @@ class Login extends \CoreLibs\DB\IO
|
||||
];
|
||||
|
||||
// acl vars
|
||||
/** @var array<mixed> */
|
||||
public $acl = [];
|
||||
/** @var array<mixed> */
|
||||
public $default_acl_list = [];
|
||||
// login html, if we are on an ajax page
|
||||
/** @var string|null */
|
||||
private $login_html = '';
|
||||
/** @var bool */
|
||||
private $login_is_ajax_page = false;
|
||||
|
||||
// language
|
||||
/** @var \CoreLibs\Language\L10n */
|
||||
public $l;
|
||||
|
||||
/**
|
||||
* constructor, does ALL, opens db, works through connection checks, closes itself
|
||||
* @param array $db_config db config array
|
||||
* @param array<mixed> $db_config db config array
|
||||
*/
|
||||
public function __construct(array $db_config)
|
||||
{
|
||||
@@ -176,7 +207,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
// check what schema to use. if there is a login schema use this, else check
|
||||
// if there is a schema set in the config, or fall back to DB_SCHEMA
|
||||
// if this exists, if this also does not exists use public schema
|
||||
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) {
|
||||
if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) {
|
||||
$SCHEMA = LOGIN_DB_SCHEMA;
|
||||
} elseif (isset($db_config['db_schema']) && $db_config['db_schema']) {
|
||||
$SCHEMA = $db_config['db_schema'];
|
||||
@@ -225,7 +256,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
$_SESSION['DEFAULT_ACL_LIST'] = [];
|
||||
// read the current edit_access_right list into an array
|
||||
$q = "SELECT level, type, name FROM edit_access_right WHERE level >= 0 ORDER BY level";
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
// level to description format (numeric)
|
||||
$this->default_acl_list[$res['level']] = [
|
||||
'type' => $res['type'],
|
||||
@@ -387,8 +418,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
// password match is done in script, against old plain or new blowfish encypted
|
||||
. "(LOWER(username) = '" . $this->dbEscapeString(strtolower($this->username)) . "') ";
|
||||
$res = $this->dbReturn($q);
|
||||
// username is wrong, but we throw for wrong username and wrong password the same error
|
||||
if (!$this->cursor_ext[md5($q)]['num_rows']) {
|
||||
if (!is_array($res)) {
|
||||
$this->login_error = 1009;
|
||||
$this->permission_okay = false;
|
||||
} elseif (!$this->cursor_ext[md5($q)]['num_rows']) {
|
||||
// username is wrong, but we throw for wrong username and wrong password the same error
|
||||
$this->login_error = 1010;
|
||||
} else {
|
||||
// if login errors is half of max errors and the last login error
|
||||
@@ -426,7 +460,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
$_SESSION['EUID'] = $this->euid = $res['edit_user_id'];
|
||||
// check if user is okay
|
||||
$this->loginCheckPermissions();
|
||||
if (!$this->login_error) {
|
||||
if ($this->login_error == 0) {
|
||||
// now set all session vars and read page permissions
|
||||
$GLOBALS['DEBUG_ALL'] = $_SESSION['DEBUG_ALL'] = $res['debug'];
|
||||
$GLOBALS['DB_DEBUG'] = $_SESSION['DB_DEBUG'] = $res['db_debug'];
|
||||
@@ -470,6 +504,9 @@ class Login extends \CoreLibs\DB\IO
|
||||
. "AND epa.enabled = 1 AND epa.edit_group_id = " . $res["edit_group_id"] . " "
|
||||
. "ORDER BY ep.order_number";
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
if (!is_array($res)) {
|
||||
break;
|
||||
}
|
||||
// page id array for sub data readout
|
||||
$edit_page_ids[$res['edit_page_id']] = $res['cuid'];
|
||||
// create the array for pages
|
||||
@@ -496,22 +533,20 @@ class Login extends \CoreLibs\DB\IO
|
||||
$pages_acl[$res['filename']] = $res['level'];
|
||||
} // for each page
|
||||
// get the visible groups for all pages and write them to the pages
|
||||
$_edit_page_id = 0;
|
||||
$q = "SELECT epvg.edit_page_id, name, flag "
|
||||
. "FROM edit_visible_group evp, edit_page_visible_group epvg "
|
||||
. "WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id "
|
||||
. "AND epvg.edit_page_id IN (" . join(', ', array_keys($edit_page_ids)) . ") "
|
||||
. "ORDER BY epvg.edit_page_id";
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$pages[$edit_page_ids[$res['edit_page_id']]]['visible'][$res['name']] = $res['flag'];
|
||||
}
|
||||
// get the same for the query strings
|
||||
$_edit_page_id = 0;
|
||||
$q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs "
|
||||
. "WHERE enabled = 1 AND edit_page_id "
|
||||
. "IN (" . join(', ', array_keys($edit_page_ids)) . ") "
|
||||
. "ORDER BY eqs.edit_page_id";
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$pages[$edit_page_ids[$res['edit_page_id']]]['query'][] = [
|
||||
'name' => $res['name'],
|
||||
'value' => $res['value'],
|
||||
@@ -519,14 +554,13 @@ class Login extends \CoreLibs\DB\IO
|
||||
];
|
||||
}
|
||||
// get the page content and add them to the page
|
||||
$_edit_page_id = 0;
|
||||
$q = "SELECT epc.edit_page_id, epc.name, epc.uid, epc.order_number, "
|
||||
. "epc.online, ear.level, ear.type "
|
||||
. "FROM edit_page_content epc, edit_access_right ear "
|
||||
. "WHERE epc.edit_access_right_id = ear.edit_access_right_id AND "
|
||||
. "epc.edit_page_id IN (" . join(', ', array_keys($edit_page_ids)) . ") "
|
||||
. "ORDER BY epc.order_number";
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$pages[$edit_page_ids[$res['edit_page_id']]]['content'][$res['uid']] = [
|
||||
'name' => $res['name'],
|
||||
'uid' => $res['uid'],
|
||||
@@ -550,13 +584,13 @@ class Login extends \CoreLibs\DB\IO
|
||||
$unit_access = [];
|
||||
$eauid = [];
|
||||
$unit_acl = [];
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
// read edit access data fields and drop them into the unit access array
|
||||
$q_sub = "SELECT name, value "
|
||||
. "FROM edit_access_data "
|
||||
. "WHERE enabled = 1 AND edit_access_id = " . $res['edit_access_id'];
|
||||
$ea_data = [];
|
||||
while ($res_sub = $this->dbReturn($q_sub)) {
|
||||
while (is_array($res_sub = $this->dbReturn($q_sub))) {
|
||||
$ea_data[$res_sub['name']] = $res_sub['value'];
|
||||
}
|
||||
// build master unit array
|
||||
@@ -583,7 +617,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
$_SESSION['EAID'] = $eauid;
|
||||
} // user has permission to THIS page
|
||||
} // user was not enabled or other login error
|
||||
if ($this->login_error) {
|
||||
if ($this->login_error && is_array($res)) {
|
||||
$login_error_date_first = '';
|
||||
if ($res['login_error_count'] == 0) {
|
||||
$login_error_date_first = ", login_error_date_first = NOW()";
|
||||
@@ -633,6 +667,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
. "AND filename = '" . $this->page_name . "' "
|
||||
. "AND eg.enabled = 1 AND epa.enabled = 1";
|
||||
$res = $this->dbReturnRow($q);
|
||||
if (!is_array($res)) {
|
||||
$this->login_error = 109;
|
||||
$this->permission_okay = false;
|
||||
return $this->permission_okay;
|
||||
}
|
||||
// unset mem limit if debug is set to 1
|
||||
// if (
|
||||
// ($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] ||
|
||||
@@ -795,10 +834,14 @@ class Login extends \CoreLibs\DB\IO
|
||||
/**
|
||||
* checks if this edit access id is valid
|
||||
* @param int|null $edit_access_id access id pk to check
|
||||
* @return bool true/false: if the edit access is not in the valid list: false
|
||||
* @return bool true/false: if the edit access is not
|
||||
* in the valid list: false
|
||||
*/
|
||||
public function loginCheckEditAccess($edit_access_id): bool
|
||||
{
|
||||
if ($edit_access_id === null) {
|
||||
return false;
|
||||
}
|
||||
if (array_key_exists($edit_access_id, $this->acl['unit'])) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -943,7 +986,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* prints out login html part if no permission (error) is set
|
||||
* @return ?string html data for login page, or null for nothing
|
||||
* @return string|null html data for login page, or null for nothing
|
||||
*/
|
||||
private function loginPrintLogin()
|
||||
{
|
||||
@@ -958,7 +1001,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
$LOGOUT_TARGET = "";
|
||||
}
|
||||
|
||||
$html_string = $this->login_template['template'];
|
||||
$html_string = (string)$this->login_template['template'];
|
||||
|
||||
// if password change is okay
|
||||
if ($this->password_change) {
|
||||
@@ -1099,6 +1142,8 @@ class Login extends \CoreLibs\DB\IO
|
||||
$error_msgs = [
|
||||
// actually obsolete
|
||||
'100' => $this->l->__('Fatal Error: <b>[EUID] came in as GET/POST!</b>'),
|
||||
// query errors
|
||||
'1009' => $this->l->__('Fatal Error: <b>Login query reading failed<b>'),
|
||||
// user not found
|
||||
'1010' => $this->l->__('Fatal Error: <b>Login Failed - Wrong Username or Password</b>'),
|
||||
// blowfish password wrong
|
||||
@@ -1111,6 +1156,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
'103' => $this->l->__('Fatal Error: <b>You do not have the rights to access this Page</b>'),
|
||||
'104' => $this->l->__('Fatal Error: <b>Login Failed - User not enabled</b>'),
|
||||
'105' => $this->l->__('Fatal Error: <b>Login Failed - User is locked</b>'),
|
||||
'109' => $this->l->__('Fatal Error: <b>Check permission query reading failed</b>'),
|
||||
// actually this is an illegal user, but I mask it
|
||||
'220' => $this->l->__('Fatal Error: <b>Password change - The user could not be found</b>'),
|
||||
'200' => $this->l->__('Fatal Error: <b>Password change - Please enter username and old password</b>'),
|
||||
@@ -1123,7 +1169,8 @@ class Login extends \CoreLibs\DB\IO
|
||||
// for OK password change
|
||||
'300' => $this->l->__('Success: <b>Password change successful</b>'),
|
||||
// this is bad bad error
|
||||
'9999' => $this->l->__('Fatal Error: <b>necessary crypt engine could not be found</b>. Login is impossible')
|
||||
'9999' => $this->l->__('Fatal Error: <b>necessary crypt engine could not be found</b>. '
|
||||
. 'Login is impossible'),
|
||||
];
|
||||
|
||||
// if password change is okay
|
||||
@@ -1280,7 +1327,7 @@ EOM;
|
||||
'_FILES' => $_FILES,
|
||||
'error' => $this->login_error
|
||||
];
|
||||
$data_binary = $this->dbEscapeBytea(bzcompress(serialize($_data_binary)));
|
||||
$data_binary = $this->dbEscapeBytea((string)bzcompress(serialize($_data_binary)));
|
||||
// SQL querie for log entry
|
||||
$q = "INSERT INTO edit_log "
|
||||
. "(username, password, euid, event_date, event, error, data, data_binary, page, "
|
||||
@@ -1327,6 +1374,7 @@ EOM;
|
||||
public function loginCheckEditAccessId(?int $edit_access_id): ?int
|
||||
{
|
||||
if (
|
||||
$edit_access_id !== null &&
|
||||
isset($_SESSION['UNIT']) &&
|
||||
is_array($_SESSION['UNIT']) &&
|
||||
!array_key_exists($edit_access_id, $_SESSION['UNIT'])
|
||||
|
||||
@@ -34,51 +34,80 @@ namespace CoreLibs\Admin;
|
||||
class Backend extends \CoreLibs\DB\IO
|
||||
{
|
||||
// page name
|
||||
/** @var array<mixed> */
|
||||
public $menu = [];
|
||||
/** @var int|string */
|
||||
public $menu_show_flag = 0; // top menu flag (mostly string)
|
||||
// action ids
|
||||
/** @var array<string> */
|
||||
public $action_list = [
|
||||
'action', 'action_id', 'action_sub_id', 'action_yes', 'action_flag',
|
||||
'action_menu', 'action_value', 'action_error', 'action_loaded'
|
||||
];
|
||||
/** @var string */
|
||||
public $action;
|
||||
/** @var string|int */
|
||||
public $action_id;
|
||||
/** @var string|int */
|
||||
public $action_sub_id;
|
||||
/** @var string|int|bool */
|
||||
public $action_yes;
|
||||
/** @var string */
|
||||
public $action_flag;
|
||||
/** @var string */
|
||||
public $action_menu;
|
||||
/** @var string */
|
||||
public $action_loaded;
|
||||
/** @var string */
|
||||
public $action_value;
|
||||
/** @var string */
|
||||
public $action_error;
|
||||
// ACL array variable if we want to set acl data from outisde
|
||||
/** @var array<mixed> */
|
||||
public $acl = [];
|
||||
/** @var int */
|
||||
public $default_acl;
|
||||
// queue key
|
||||
/** @var string */
|
||||
public $queue_key;
|
||||
// the current active edit access id
|
||||
/** @var int */
|
||||
public $edit_access_id;
|
||||
// error/warning/info messages
|
||||
/** @var array<mixed> */
|
||||
public $messages = [];
|
||||
/** @var int */
|
||||
public $error = 0;
|
||||
/** @var int */
|
||||
public $warning = 0;
|
||||
/** @var int */
|
||||
public $info = 0;
|
||||
// internal lang & encoding vars
|
||||
/** @var string */
|
||||
public $lang_dir = '';
|
||||
/** @var string */
|
||||
public $lang;
|
||||
/** @var string */
|
||||
public $lang_short;
|
||||
/** @var string */
|
||||
public $encoding;
|
||||
// language
|
||||
/** @var \CoreLibs\Language\L10n */
|
||||
public $l;
|
||||
// smarty publics [end processing in smarty class]
|
||||
/** @var array<mixed> */
|
||||
public $DATA;
|
||||
/** @var array<mixed> */
|
||||
public $HEADER;
|
||||
/** @var array<mixed> */
|
||||
public $DEBUG_DATA;
|
||||
/** @var array<mixed> */
|
||||
public $CONTENT_DATA;
|
||||
|
||||
// CONSTRUCTOR / DECONSTRUCTOR |====================================>
|
||||
/**
|
||||
* main class constructor
|
||||
* @param array $db_config db config array
|
||||
* @param array<mixed> $db_config db config array
|
||||
*/
|
||||
public function __construct(array $db_config)
|
||||
{
|
||||
@@ -151,7 +180,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* set internal ACL from login ACL
|
||||
* @param array $acl login acl array
|
||||
* @param array<mixed> $acl login acl array
|
||||
*/
|
||||
public function setACL(array $acl): void
|
||||
{
|
||||
@@ -160,16 +189,16 @@ class Backend extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* writes all action vars plus other info into edit_log tabl
|
||||
* @param string $event any kind of event description,
|
||||
* @param string|array $data any kind of data related to that event
|
||||
* @param string $write_type write type can bei STRING or BINARY
|
||||
* @return void has no return
|
||||
* @param string $event any kind of event description,
|
||||
* @param string|array<mixed> $data any kind of data related to that event
|
||||
* @param string $write_type write type can bei STRING or BINARY
|
||||
* @return void
|
||||
*/
|
||||
public function adbEditLog(string $event = '', $data = '', string $write_type = 'STRING'): void
|
||||
{
|
||||
$data_binary = '';
|
||||
if ($write_type == 'BINARY') {
|
||||
$data_binary = $this->dbEscapeBytea(bzcompress(serialize($data)));
|
||||
$data_binary = $this->dbEscapeBytea((string)bzcompress(serialize($data)));
|
||||
$data = 'see bzip compressed data_binary field';
|
||||
}
|
||||
if ($write_type == 'STRING') {
|
||||
@@ -178,16 +207,15 @@ class Backend extends \CoreLibs\DB\IO
|
||||
}
|
||||
|
||||
// check schema
|
||||
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) {
|
||||
$SCHEMA = 'public';
|
||||
if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) {
|
||||
$SCHEMA = LOGIN_DB_SCHEMA;
|
||||
} elseif ($this->dbGetSchema()) {
|
||||
$SCHEMA = $this->dbGetSchema();
|
||||
} elseif (defined('PUBLIC_SCHEMA')) {
|
||||
$SCHEMA = PUBLIC_SCHEMA;
|
||||
} else {
|
||||
$SCHEMA = 'public';
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line for whatever reason $SCHEMA is seen as possible array */
|
||||
$q = "INSERT INTO " . $SCHEMA . ".edit_log "
|
||||
. "(euid, event_date, event, data, data_binary, page, "
|
||||
. "ip, user_agent, referer, script_name, query_string, server_name, http_host, "
|
||||
@@ -225,8 +253,8 @@ class Backend extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* menu creater (from login menu session pages)
|
||||
* @param int $flag visible flag trigger
|
||||
* @return array menu array for output on page (smarty)
|
||||
* @param int $flag visible flag trigger
|
||||
* @return array<mixed> menu array for output on page (smarty)
|
||||
*/
|
||||
public function adbTopMenu(int $flag = 0): array
|
||||
{
|
||||
@@ -373,10 +401,10 @@ class Backend extends \CoreLibs\DB\IO
|
||||
/**
|
||||
* @deprecated
|
||||
* creates out of a normal db_return array an assoc array
|
||||
* @param array $db_array input array
|
||||
* @param array<mixed> $db_array input array
|
||||
* @param string|int|bool $key key
|
||||
* @param string|int|bool $value value
|
||||
* @return array associative array
|
||||
* @return array<mixed> associative array
|
||||
* @deprecated \CoreLibs\Combined\ArrayHandler::genAssocArray()
|
||||
*/
|
||||
public function adbAssocArray(array $db_array, $key, $value): array
|
||||
@@ -407,16 +435,24 @@ class Backend extends \CoreLibs\DB\IO
|
||||
/**
|
||||
* @deprecated
|
||||
* converts picture to a thumbnail with max x and max y size
|
||||
* @param string $pic source image file with or without path
|
||||
* @param int $size_x maximum size width
|
||||
* @param int $size_y maximum size height
|
||||
* @param string $dummy empty, or file_type to show an icon instead of nothing if file is not found
|
||||
* @param string $path if source start is not ROOT path, if empty ROOT is choosen
|
||||
* @return string|bool thumbnail name, or false for error
|
||||
* @param string $pic source image file with or without path
|
||||
* @param int $size_x maximum size width
|
||||
* @param int $size_y maximum size height
|
||||
* @param string $dummy empty, or file_type to show an icon
|
||||
* instead of nothing if file is not found
|
||||
* @param string $path if source start is not ROOT path
|
||||
* if empty ROOT is choosen
|
||||
* @return string|bool thumbnail name, or false for error
|
||||
* @deprecated \CoreLibs\Output\Image::createThumbnail()
|
||||
*/
|
||||
public function adbCreateThumbnail($pic, $size_x, $size_y, $dummy = '', $path = "", $cache = "")
|
||||
{
|
||||
public function adbCreateThumbnail(
|
||||
string $pic,
|
||||
int $size_x,
|
||||
int $size_y,
|
||||
string $dummy = '',
|
||||
string $path = '',
|
||||
string $cache = ''
|
||||
) {
|
||||
trigger_error(
|
||||
'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Output\Image::createThumbnail()',
|
||||
E_USER_DEPRECATED
|
||||
@@ -426,10 +462,10 @@ class Backend extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* wrapper function to fill up the mssages array
|
||||
* @param string $level info/warning/error
|
||||
* @param string $msg string, can be printf formated
|
||||
* @param array $vars optional data for a possible printf formated msg
|
||||
* @return void has no return
|
||||
* @param string $level info/warning/error
|
||||
* @param string $msg string, can be printf formated
|
||||
* @param array<mixed> $vars optional data for a possible printf formated msg
|
||||
* @return void has no return
|
||||
*/
|
||||
public function adbMsg(string $level, string $msg, array $vars = []): void
|
||||
{
|
||||
@@ -475,7 +511,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
string $associate = null,
|
||||
string $file = null
|
||||
): void {
|
||||
if (defined('GLOBAL_DB_SCHEMA') && GLOBAL_DB_SCHEMA) {
|
||||
if (defined('GLOBAL_DB_SCHEMA') && !empty(GLOBAL_DB_SCHEMA)) {
|
||||
$SCHEMA = GLOBAL_DB_SCHEMA;
|
||||
} elseif ($this->dbGetSchema()) {
|
||||
$SCHEMA = $this->dbGetSchema();
|
||||
|
||||
@@ -57,24 +57,34 @@ namespace CoreLibs;
|
||||
class Basic
|
||||
{
|
||||
// page and host name
|
||||
/** @var string */
|
||||
public $page_name;
|
||||
/** @var string */
|
||||
public $host_name;
|
||||
/** @var int */
|
||||
public $host_port;
|
||||
// logging interface, Debug\Logging class
|
||||
/** @var \CoreLibs\Debug\Logging */
|
||||
public $log;
|
||||
|
||||
// email valid checks
|
||||
/** @var array<mixed> */
|
||||
public $email_regex_check = [];
|
||||
/** @var string */
|
||||
public $email_regex; // regex var for email check
|
||||
|
||||
// data path for files
|
||||
/** @var array<mixed> */
|
||||
public $data_path = [];
|
||||
|
||||
// session name
|
||||
/** @var string */
|
||||
private $session_name = '';
|
||||
/** @var string */
|
||||
private $session_id = '';
|
||||
|
||||
// ajax flag
|
||||
/** @var bool */
|
||||
protected $ajax_page_flag = false;
|
||||
|
||||
/**
|
||||
@@ -87,7 +97,7 @@ class Basic
|
||||
$abort = false;
|
||||
foreach (
|
||||
[
|
||||
'DS', 'DIR', 'BASE', 'ROOT', 'LIB', 'INCLUDES', 'LAYOUT', 'PICTURES', 'FLASH',
|
||||
'DS', 'DIR', 'BASE', 'ROOT', 'LIB', 'INCLUDES', 'LAYOUT', 'PICTURES', 'DATA',
|
||||
'VIDEOS', 'DOCUMENTS', 'PDFS', 'BINARIES', 'ICONS', 'UPLOADS', 'CSV', 'JS',
|
||||
'CSS', 'TABLE_ARRAYS', 'SMARTY', 'LANG', 'CACHE', 'TMP', 'LOG', 'TEMPLATES',
|
||||
'TEMPLATES_C', 'DEFAULT_LANG', 'DEFAULT_ENCODING', 'DEFAULT_HASH',
|
||||
@@ -115,7 +125,7 @@ class Basic
|
||||
// set the paths matching to the valid file types
|
||||
$this->data_path = [
|
||||
'P' => PICTURES,
|
||||
'F' => FLASH,
|
||||
'F' => DATA,
|
||||
'V' => VIDEOS,
|
||||
'D' => DOCUMENTS,
|
||||
'A' => PDFS,
|
||||
@@ -154,7 +164,7 @@ class Basic
|
||||
// start session
|
||||
session_start();
|
||||
// set internal session id, we can use that later for protection check
|
||||
$this->session_id = session_id();
|
||||
$this->session_id = session_id() ?: '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,14 +274,14 @@ class Basic
|
||||
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
||||
* @param string $type error, echo, print
|
||||
* @param string $flag on/off
|
||||
* array $array of levels to turn on/off debug
|
||||
* array<mixed> $array of levels to turn on/off debug
|
||||
* @return void has no return
|
||||
* @deprecated Use $basic->log->debugFor() instead
|
||||
*/
|
||||
public function debugFor(string $type, string $flag): void
|
||||
{
|
||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use $basic->log->debugFor() or use \CoreLibs\Debug\Logging() class', E_USER_DEPRECATED);
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal @phpstan-ignore-next-line */
|
||||
$this->log->debugFor(...[func_get_args()]);
|
||||
}
|
||||
|
||||
@@ -350,8 +360,8 @@ class Basic
|
||||
/**
|
||||
* merges the given error array with the one from this class
|
||||
* only merges visible ones
|
||||
* @param array $error_msg error array
|
||||
* @return void has no return
|
||||
* @param array<mixed> $error_msg error array
|
||||
* @return void
|
||||
* @deprecated Use $basic->log->mergeErrors() instead
|
||||
*/
|
||||
public function mergeErrors(array $error_msg = []): void
|
||||
@@ -391,8 +401,8 @@ class Basic
|
||||
|
||||
/**
|
||||
* prints a html formatted (pre) array
|
||||
* @param array $array any array
|
||||
* @return string formatted array for output with <pre> tag added
|
||||
* @param array<mixed> $array any array
|
||||
* @return string formatted array for output with <pre> tag added
|
||||
* @deprecated Use $this->log->prAr() instead
|
||||
*/
|
||||
public function printAr(array $array): string
|
||||
@@ -405,7 +415,8 @@ class Basic
|
||||
* eg for debugging, this function does this
|
||||
* call this method in the child method and you get the parent function that called
|
||||
* @param int $level debug level, default 2
|
||||
* @return ?string null or the function that called the function where this method is called
|
||||
* @return ?string null or the function that called the function
|
||||
* where this method is called
|
||||
* @deprecated Use \CoreLibs\Debug\Support::getCallerMethod() instead
|
||||
*/
|
||||
public static function getCallerMethod(int $level = 2): ?string
|
||||
@@ -471,7 +482,7 @@ class Basic
|
||||
* returns 'checked' or 'selected' if okay
|
||||
* $needle is a var, $haystack an array or a string
|
||||
* **** THE RETURN: VALUE WILL CHANGE TO A DEFAULT NULL IF NOT FOUND ****
|
||||
* @param array|string $haystack (search in) haystack can be an array or a string
|
||||
* @param array<mixed>|string $haystack (search in) haystack can be an array or a string
|
||||
* @param string $needle needle (search for)
|
||||
* @param int $type type: 0: returns selected, 1, returns checked
|
||||
* @return ?string returns checked or selected, else returns null
|
||||
@@ -504,7 +515,7 @@ class Basic
|
||||
|
||||
/**
|
||||
* get the host name without the port as given by the SELF var
|
||||
* @return array host name/port name
|
||||
* @return array<mixed> host name/port name
|
||||
* @deprecated Use \CoreLibs\Get\System::getHostName() instead
|
||||
*/
|
||||
public function getHostName(): array
|
||||
@@ -563,9 +574,9 @@ class Basic
|
||||
* searches key = value in an array / array
|
||||
* only returns the first one found
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array $haystack haystack (search in)
|
||||
* @param array<mixed> $haystack haystack (search in)
|
||||
* @param string|null $key_lookin the key to look out for, default empty
|
||||
* @return array array with the elements where the needle can be
|
||||
* @return array<mixed> array with the elements where the needle can be
|
||||
* found in the haystack array
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::arraySearchRecursive() instead
|
||||
*/
|
||||
@@ -577,11 +588,11 @@ class Basic
|
||||
|
||||
/**
|
||||
* recursive array search function, which returns all found not only the first one
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array $haystack haystack (search in)
|
||||
* @param string|int $key the key to look for in
|
||||
* @param array|null $path recursive call for previous path
|
||||
* @return ?array all array elements paths where the element was found
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array<mixed> $haystack haystack (search in)
|
||||
* @param string|int $key the key to look for in
|
||||
* @param array<mixed>|null $path recursive call for previous path
|
||||
* @return ?array<mixed> all array elements paths where the element was found
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::arraySearchRecursiveAll() instead
|
||||
*/
|
||||
public static function arraySearchRecursiveAll($needle, array $haystack, $key, ?array $path = null): ?array
|
||||
@@ -592,7 +603,7 @@ class Basic
|
||||
|
||||
/**
|
||||
* array search simple. looks for key, value Combined, if found, returns true
|
||||
* @param array $array array (search in)
|
||||
* @param array<mixed> $array array (search in)
|
||||
* @param string|int $key key (key to search in)
|
||||
* @param string|int $value value (what to find)
|
||||
* @return bool true on found, false on not found
|
||||
@@ -611,7 +622,7 @@ class Basic
|
||||
* ... etc
|
||||
* bool key flag: true: handle keys as string or int
|
||||
* default false: all keys are string
|
||||
* @return array|bool merged array
|
||||
* @return array<mixed>|bool merged array
|
||||
* @deprecated MUSER BE CONVERTED TO \CoreLibs\Combined\ArrayHandler::arrayMergeRecursive() instead
|
||||
*/
|
||||
public static function arrayMergeRecursive()
|
||||
@@ -625,9 +636,9 @@ class Basic
|
||||
* array_diff only checks elements from A that are not in B, but not the
|
||||
* other way around.
|
||||
* Note that like array_diff this only checks first level values not keys
|
||||
* @param array $a array to compare a
|
||||
* @param array $b array to compare b
|
||||
* @return array array with missing elements from a & b
|
||||
* @param array<mixed> $a array to compare a
|
||||
* @param array<mixed> $b array to compare b
|
||||
* @return array<mixed> array with missing elements from a & b
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::arrayDiff() instead
|
||||
*/
|
||||
public static function arrayDiff(array $a, array $b): array
|
||||
@@ -639,9 +650,9 @@ class Basic
|
||||
/**
|
||||
* search for the needle array elements in haystack and return the ones found as an array,
|
||||
* is there nothing found, it returns FALSE (boolean)
|
||||
* @param array $needle elements to search for
|
||||
* @param array $haystack array where the $needle elements should be searched int
|
||||
* @return array|bool either the found elements or false for nothing found or error
|
||||
* @param array<mixed> $needle elements to search for
|
||||
* @param array<mixed> $haystack array where the $needle elements should be searched int
|
||||
* @return array<mixed>|bool either the found elements or false for nothing found or error
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::inArrayAny() instead
|
||||
*/
|
||||
public static function inArrayAny(array $needle, array $haystack)
|
||||
@@ -652,11 +663,11 @@ class Basic
|
||||
|
||||
/**
|
||||
* creates out of a normal db_return array an assoc array
|
||||
* @param array $db_array return array from the database
|
||||
* @param array<mixed> $db_array return array from the database
|
||||
* @param string|int|bool $key key set, false for not set
|
||||
* @param string|int|bool $value value set, false for not set
|
||||
* @param bool $set_only flag to return all (default), or set only
|
||||
* @return array associative array
|
||||
* @return array<mixed> associative array
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::genAssocArray() instead
|
||||
*/
|
||||
public static function genAssocArray(array $db_array, $key, $value, bool $set_only = false): array
|
||||
@@ -668,7 +679,7 @@ class Basic
|
||||
/**
|
||||
* [NOTE]: This is an old function and is deprecated
|
||||
* wrapper for join, but checks if input is an array and if not returns null
|
||||
* @param array $array array to convert
|
||||
* @param array<mixed> $array array to convert
|
||||
* @param string $connect_char connection character
|
||||
* @return string joined string
|
||||
* @deprecated use join() instead
|
||||
@@ -685,8 +696,8 @@ class Basic
|
||||
/**
|
||||
* converts multi dimensional array to a flat array
|
||||
* does NOT preserve keys
|
||||
* @param array $array ulti dimensionial array
|
||||
* @return array flattened array
|
||||
* @param array<mixed> $array ulti dimensionial array
|
||||
* @return array<mixed> flattened array
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::flattenArray() instead
|
||||
*/
|
||||
public static function flattenArray(array $array): array
|
||||
@@ -697,8 +708,8 @@ class Basic
|
||||
|
||||
/**
|
||||
* will loop through an array recursivly and write the array keys back
|
||||
* @param array $array multidemnsional array to flatten
|
||||
* @return array flattened keys array
|
||||
* @param array<mixed> $array multidemnsional array to flatten
|
||||
* @return array<mixed> flattened keys array
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::flattenArrayKey() instead
|
||||
*/
|
||||
public static function flattenArrayKey(array $array/*, array $return = []*/): array
|
||||
@@ -710,9 +721,9 @@ class Basic
|
||||
/**
|
||||
* searches for key -> value in an array tree and writes the value one level up
|
||||
* this will remove this leaf will all other values
|
||||
* @param array $array array (nested)
|
||||
* @param array<mixed> $array array (nested)
|
||||
* @param string|int $search key to find that has no sub leaf and will be pushed up
|
||||
* @return array modified, flattened array
|
||||
* @return array<mixed> modified, flattened array
|
||||
* @deprecated Use \CoreLibs\Combined\ArrayHandler::arrayFlatForKey() instead
|
||||
*/
|
||||
public static function arrayFlatForKey(array $array, $search): array
|
||||
@@ -923,7 +934,7 @@ class Basic
|
||||
* @param string $start_date valid start date (y/m/d)
|
||||
* @param string $end_date valid end date (y/m/d)
|
||||
* @param bool $return_named return array type, false (default), true for named
|
||||
* @return array 0/overall, 1/weekday, 2/weekend
|
||||
* @return array<mixed> 0/overall, 1/weekday, 2/weekend
|
||||
* @deprecated Use \CoreLibs\Combined\DateTime::calcDaysInterval() instead
|
||||
*/
|
||||
public static function calcDaysInterval($start_date, $end_date, bool $return_named = false): array
|
||||
@@ -1033,7 +1044,7 @@ class Basic
|
||||
* @param string $string string to test
|
||||
* @param string $from_encoding encoding of string to test
|
||||
* @param string $to_encoding target encoding
|
||||
* @return bool|array false if no error or array with failed characters
|
||||
* @return bool|array<mixed> false if no error or array with failed characters
|
||||
* @deprecated use \CoreLibs\Language\Encoding::checkConvertEncoding() instead
|
||||
*/
|
||||
public function checkConvertEncoding(string $string, string $from_encoding, string $to_encoding)
|
||||
@@ -1228,7 +1239,8 @@ class Basic
|
||||
* @param string $hexStr RGB hexstring
|
||||
* @param bool $returnAsString flag to return as string
|
||||
* @param string $seperator string seperator: default: ","
|
||||
* @return string|array|bool false on error or array with RGB or a string with the seperator
|
||||
* @return string|array<mixed>|bool false on error or array with RGB or
|
||||
* a string with the seperator
|
||||
* @deprecated use \CoreLibs\Convert\Colors::hex2rgb() instead
|
||||
*/
|
||||
public static function hex2rgb(string $hexStr, bool $returnAsString = false, string $seperator = ',')
|
||||
@@ -1275,7 +1287,7 @@ class Basic
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array Hue, Sat, Brightness/Value
|
||||
* @return array<mixed> Hue, Sat, Brightness/Value
|
||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hsb() instead
|
||||
*/
|
||||
public static function rgb2hsb(int $red, int $green, int $blue): array
|
||||
@@ -1289,7 +1301,7 @@ class Basic
|
||||
* @param int $H hue 0-360
|
||||
* @param float $S saturation 0-1 (float)
|
||||
* @param float $V brightness/value 0-1 (float)
|
||||
* @return array 0 red/1 green/2 blue array
|
||||
* @return array<mixed> 0 red/1 green/2 blue array
|
||||
* @deprecated use \CoreLibs\Convert\Colors::hsb2rgb() instead
|
||||
*/
|
||||
public static function hsb2rgb(int $H, float $S, float $V): array
|
||||
@@ -1305,7 +1317,7 @@ class Basic
|
||||
* @param int $r red 0-255
|
||||
* @param int $g green 0-255
|
||||
* @param int $b blue 0-255
|
||||
* @return array hue/sat/luminance
|
||||
* @return array<mixed> hue/sat/luminance
|
||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hsl() instead
|
||||
*/
|
||||
public static function rgb2hsl(int $r, int $g, int $b): array
|
||||
@@ -1319,7 +1331,7 @@ class Basic
|
||||
* @param int $h hue: 0-360 (degrees)
|
||||
* @param float $s saturation: 0-1
|
||||
* @param float $l luminance: 0-1
|
||||
* @return array red/blue/green 0-255 each
|
||||
* @return array<mixed> red/blue/green 0-255 each
|
||||
* @deprecated use \CoreLibs\Convert\Colors::hsl2rgb() instead
|
||||
*/
|
||||
public static function hsl2rgb(int $h, float $s, float $l): array
|
||||
@@ -1538,7 +1550,7 @@ class Basic
|
||||
* @param string|null $json a json string, or null data
|
||||
* @param bool $override if set to true, then on json error
|
||||
* set original value as array
|
||||
* @return array returns an array from the json values
|
||||
* @return array<mixed> returns an array from the json values
|
||||
* @deprecated use \CoreLibs\Check\Jason::jsonConvertToArray() instead
|
||||
*/
|
||||
public function jsonConvertToArray(?string $json, bool $override = false): array
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace CoreLibs\Check;
|
||||
class Email
|
||||
{
|
||||
// this is for error check parts in where the email regex failed
|
||||
/** @var array<int,string> */
|
||||
private static $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
|
||||
@@ -19,6 +20,7 @@ class Email
|
||||
7 => "@.*\.$" // ends with a dot, top level, domain missing
|
||||
];
|
||||
// the array with the mobile types that are valid
|
||||
/** @var array<string,string> */
|
||||
private static $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]
|
||||
@@ -57,6 +59,7 @@ class Email
|
||||
'.*@emobile-s\.ne\.jp$' => 'keitai_willcom_emnet' # e-mobile, group will willcom
|
||||
];
|
||||
// short list for mobile email types
|
||||
/** @var array<string,string> */
|
||||
private static $mobile_email_type_short = [
|
||||
'keitai_docomo' => 'docomo',
|
||||
'keitai_kddi_ezweb' => 'kddi',
|
||||
@@ -116,7 +119,7 @@ class Email
|
||||
* get the full check array
|
||||
* this will be deprected at some point
|
||||
*
|
||||
* @return array
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function getEmailRegexCheck(): array
|
||||
{
|
||||
@@ -132,9 +135,11 @@ class Email
|
||||
/**
|
||||
* guesses the email type (mostly for mobile) from the domain
|
||||
* if second is set to true, it will return short naming scheme (only provider)
|
||||
* @param string $email email string
|
||||
* @param bool $short default false, if true, returns only short type (pc instead of pc_html)
|
||||
* @return string|bool email type, eg "pc", "docomo", etc, false for invalid short type
|
||||
* @param string $email email string
|
||||
* @param bool $short default false, if true,
|
||||
* returns only short type (pc instead of pc_html)
|
||||
* @return string|bool email type, eg "pc", "docomo", etc,
|
||||
* false for invalid short type
|
||||
*/
|
||||
public static function getEmailType(string $email, bool $short = false)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,12 @@ class File
|
||||
is_readable($file)
|
||||
) {
|
||||
$f = fopen($file, 'rb');
|
||||
if (!is_resource($f)) {
|
||||
return 0;
|
||||
}
|
||||
$lines = 0;
|
||||
while (!feof($f)) {
|
||||
$lines += substr_count(fread($f, 8192), "\n");
|
||||
$lines += substr_count(fread($f, 8192) ?: '', "\n");
|
||||
}
|
||||
fclose($f);
|
||||
} else {
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace CoreLibs\Check;
|
||||
|
||||
class Jason
|
||||
{
|
||||
/** @var int */
|
||||
private static $json_last_error;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ class Jason
|
||||
* @param string|null $json a json string, or null data
|
||||
* @param bool $override if set to true, then on json error
|
||||
* set original value as array
|
||||
* @return array returns an array from the json values
|
||||
* @return array<mixed> returns an array from the json values
|
||||
*/
|
||||
public static function jsonConvertToArray(?string $json, bool $override = false): array
|
||||
{
|
||||
|
||||
@@ -35,8 +35,6 @@ class Password
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// in case something strange, return false on default
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,8 +49,6 @@ class Password
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// in case of strange, force re-hash
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,19 +35,15 @@ class PhpVersion
|
||||
}
|
||||
// set the php version id
|
||||
if (!defined('PHP_VERSION_ID')) {
|
||||
$version = explode('.', phpversion());
|
||||
$version = explode('.', phpversion() ?: '');
|
||||
// creates something like 50107
|
||||
define('PHP_VERSION_ID', (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2]);
|
||||
}
|
||||
// check if matching for version
|
||||
if ($min_version && !$max_version) {
|
||||
if (PHP_VERSION_ID >= $min_version) {
|
||||
return true;
|
||||
}
|
||||
} elseif ($min_version && $max_version) {
|
||||
if (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
|
||||
return true;
|
||||
}
|
||||
if (!$max_version && PHP_VERSION_ID >= $min_version) {
|
||||
return true;
|
||||
} elseif (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
|
||||
return true;
|
||||
}
|
||||
// if no previous return, fail
|
||||
return false;
|
||||
|
||||
@@ -13,11 +13,11 @@ class ArrayHandler
|
||||
/**
|
||||
* searches key = value in an array / array
|
||||
* only returns the first one found
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array $haystack haystack (search in)
|
||||
* @param string|null $key_lookin the key to look out for, default empty
|
||||
* @return array array with the elements where the needle can be
|
||||
* found in the haystack array
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array<mixed> $haystack haystack (search in)
|
||||
* @param string|null $key_lookin the key to look out for, default empty
|
||||
* @return array<mixed> array with the elements where the needle can be
|
||||
* found in the haystack array
|
||||
*/
|
||||
public static function arraySearchRecursive($needle, array $haystack, ?string $key_lookin = null): array
|
||||
{
|
||||
@@ -68,11 +68,11 @@ class ArrayHandler
|
||||
|
||||
/**
|
||||
* recursive array search function, which returns all found not only the first one
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array $haystack haystack (search in)
|
||||
* @param string|int $key the key to look for in
|
||||
* @param array|null $path recursive call for previous path
|
||||
* @return ?array all array elements paths where the element was found
|
||||
* @param string|int $needle needle (search for)
|
||||
* @param array<mixed> $haystack haystack (search in)
|
||||
* @param string|int $key the key to look for in
|
||||
* @param array<mixed>|null $path recursive call for previous path
|
||||
* @return array<mixed>|null all array elements paths where the element was found
|
||||
*/
|
||||
public static function arraySearchRecursiveAll($needle, array $haystack, $key, ?array $path = null): ?array
|
||||
{
|
||||
@@ -82,41 +82,40 @@ class ArrayHandler
|
||||
'level' => 0,
|
||||
'work' => []
|
||||
];
|
||||
}
|
||||
// init sub sets if not set
|
||||
if (!isset($path['level'])) {
|
||||
$path['level'] = 0;
|
||||
}
|
||||
if (!isset($path['work'])) {
|
||||
$path['work'] = [];
|
||||
} else {
|
||||
// init sub sets if not set
|
||||
if (!isset($path['level'])) {
|
||||
$path['level'] = 0;
|
||||
}
|
||||
if (!isset($path['work'])) {
|
||||
$path['work'] = [];
|
||||
}
|
||||
}
|
||||
// should not be needed because it would trigger a php mehtod error
|
||||
if (!is_array($haystack)) {
|
||||
$haystack = [];
|
||||
}
|
||||
|
||||
// @phan HACK
|
||||
$path['level'] = $path['level'] ?? 0;
|
||||
// go through the array,
|
||||
foreach ($haystack as $_key => $_value) {
|
||||
if (is_scalar($_value) && $_value == $needle && !$key) {
|
||||
// only value matches
|
||||
$path['work'][$path['level']] = $_key;
|
||||
$path['work'][$path['level'] ?? 0] = $_key;
|
||||
$path['found'][] = $path['work'];
|
||||
} elseif (is_scalar($_value) && $_value == $needle && $_key == $key) {
|
||||
// key and value matches
|
||||
$path['work'][$path['level']] = $_key;
|
||||
$path['work'][$path['level'] ?? 0] = $_key;
|
||||
$path['found'][] = $path['work'];
|
||||
} elseif (is_array($_value)) {
|
||||
// add position to working
|
||||
$path['work'][$path['level']] = $_key;
|
||||
$path['work'][$path['level'] ?? 0] = $_key;
|
||||
// we will up a level
|
||||
$path['level'] += 1;
|
||||
// call recursive
|
||||
$path = self::arraySearchRecursiveAll($needle, $_value, $key, $path);
|
||||
}
|
||||
}
|
||||
// @phan HACK
|
||||
// be 100% sure the array elements are set
|
||||
$path['level'] = $path['level'] ?? 0;
|
||||
$path['work'] = $path['work'] ?? [];
|
||||
// cut all that is >= level
|
||||
@@ -128,10 +127,10 @@ class ArrayHandler
|
||||
|
||||
/**
|
||||
* array search simple. looks for key, value combination, if found, returns true
|
||||
* @param array $array search in as array
|
||||
* @param string|int $key key (key to search in)
|
||||
* @param string|int $value value (what to find)
|
||||
* @return bool true on found, false on not found
|
||||
* @param array<mixed> $array search in as array
|
||||
* @param string|int $key key (key to search in)
|
||||
* @param string|int $value value (what to find)
|
||||
* @return bool true on found, false on not found
|
||||
*/
|
||||
public static function arraySearchSimple(array $array, $key, $value): bool
|
||||
{
|
||||
@@ -160,7 +159,7 @@ class ArrayHandler
|
||||
* ... etc
|
||||
* bool key flag: true: handle keys as string or int
|
||||
* default false: all keys are string
|
||||
* @return array|bool merged array
|
||||
* @return array<mixed>|bool merged array
|
||||
*/
|
||||
public static function arrayMergeRecursive()
|
||||
{
|
||||
@@ -215,9 +214,9 @@ class ArrayHandler
|
||||
* array_diff only checks elements from A that are not in B, but not the
|
||||
* other way around.
|
||||
* Note that like array_diff this only checks first level values not keys
|
||||
* @param array $a array to compare a
|
||||
* @param array $b array to compare b
|
||||
* @return array array with missing elements from a & b
|
||||
* @param array<mixed> $a array to compare a
|
||||
* @param array<mixed> $b array to compare b
|
||||
* @return array<mixed> array with missing elements from a & b
|
||||
*/
|
||||
public static function arrayDiff(array $a, array $b): array
|
||||
{
|
||||
@@ -228,9 +227,9 @@ class ArrayHandler
|
||||
/**
|
||||
* search for the needle array elements in haystack and return the ones found as an array,
|
||||
* is there nothing found, it returns FALSE (boolean)
|
||||
* @param array $needle elements to search for
|
||||
* @param array $haystack array where the $needle elements should be searched int
|
||||
* @return array|bool either the found elements or false for nothing found or error
|
||||
* @param array<mixed> $needle elements to search for
|
||||
* @param array<mixed> $haystack array where the $needle elements should be searched int
|
||||
* @return array<mixed>|bool either the found elements or false for nothing found or error
|
||||
*/
|
||||
public static function inArrayAny(array $needle, array $haystack)
|
||||
{
|
||||
@@ -255,11 +254,11 @@ class ArrayHandler
|
||||
|
||||
/**
|
||||
* creates out of a normal db_return array an assoc array
|
||||
* @param array $db_array return array from the database
|
||||
* @param array<mixed> $db_array return array from the database
|
||||
* @param string|int|bool $key key set, false for not set
|
||||
* @param string|int|bool $value value set, false for not set
|
||||
* @param bool $set_only flag to return all (default), or set only
|
||||
* @return array associative array
|
||||
* @return array<mixed> associative array
|
||||
*/
|
||||
public static function genAssocArray(array $db_array, $key, $value, bool $set_only = false): array
|
||||
{
|
||||
@@ -285,8 +284,8 @@ class ArrayHandler
|
||||
/**
|
||||
* converts multi dimensional array to a flat array
|
||||
* does NOT preserve keys
|
||||
* @param array $array ulti dimensionial array
|
||||
* @return array flattened array
|
||||
* @param array<mixed> $array ulti dimensionial array
|
||||
* @return array<mixed> flattened array
|
||||
*/
|
||||
public static function flattenArray(array $array): array
|
||||
{
|
||||
@@ -302,8 +301,8 @@ class ArrayHandler
|
||||
|
||||
/**
|
||||
* will loop through an array recursivly and write the array keys back
|
||||
* @param array $array multidemnsional array to flatten
|
||||
* @return array flattened keys array
|
||||
* @param array<mixed> $array multidemnsional array to flatten
|
||||
* @return array<mixed> flattened keys array
|
||||
*/
|
||||
public static function flattenArrayKey(array $array): array
|
||||
{
|
||||
@@ -320,9 +319,9 @@ class ArrayHandler
|
||||
/**
|
||||
* searches for key -> value in an array tree and writes the value one level up
|
||||
* this will remove this leaf will all other values
|
||||
* @param array $array nested array
|
||||
* @param string|int $search key to find that has no sub leaf and will be pushed up
|
||||
* @return array modified, flattened array
|
||||
* @param array<mixed> $array nested array
|
||||
* @param string|int $search key to find that has no sub leaf and will be pushed up
|
||||
* @return array<mixed> modified, flattened array
|
||||
*/
|
||||
public static function arrayFlatForKey(array $array, $search): array
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ class DateTime
|
||||
{
|
||||
// check if the timestamp has any h/m/s/ms inside, if yes skip
|
||||
if (!preg_match("/(h|m|s|ms)/", (string)$timestamp)) {
|
||||
list($timestamp, $ms) = array_pad(explode('.', (string)round($timestamp, 4)), 2, null);
|
||||
list($timestamp, $ms) = array_pad(explode('.', (string)round((float)$timestamp, 4)), 2, null);
|
||||
// if negative remember
|
||||
$negative = false;
|
||||
if ((int)$timestamp < 0) {
|
||||
@@ -65,11 +65,14 @@ class DateTime
|
||||
if ($ms !== null) {
|
||||
// if we have ms and it has leading zeros, remove them, but only if it is nut just 0
|
||||
$ms = preg_replace("/^0+(\d+)$/", '${1}', $ms);
|
||||
if (!is_string($ms) || empty($ms)) {
|
||||
$ms = '0';
|
||||
}
|
||||
// add ms if there
|
||||
if ($show_micro) {
|
||||
$time_string .= ' ' . (!$ms ? 0 : $ms) . 'ms';
|
||||
$time_string .= ' ' . $ms . 'ms';
|
||||
} elseif (!$time_string) {
|
||||
$time_string .= (!$ms ? 0 : $ms) . 'ms';
|
||||
$time_string .= $ms . 'ms';
|
||||
}
|
||||
}
|
||||
if ($negative) {
|
||||
@@ -78,7 +81,7 @@ class DateTime
|
||||
} else {
|
||||
$time_string = $timestamp;
|
||||
}
|
||||
return $time_string;
|
||||
return (string)$time_string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +93,8 @@ class DateTime
|
||||
public static function stringToTime($timestring)
|
||||
{
|
||||
$timestamp = 0;
|
||||
if (preg_match("/(d|h|m|s|ms)/", $timestring)) {
|
||||
if (preg_match("/(d|h|m|s|ms)/", (string)$timestring)) {
|
||||
$timestring = (string)$timestring;
|
||||
// pos for preg match read + multiply factor
|
||||
$timegroups = [2 => 86400, 4 => 3600, 6 => 60, 8 => 1];
|
||||
$matches = [];
|
||||
@@ -131,7 +135,11 @@ class DateTime
|
||||
if (!$date) {
|
||||
return false;
|
||||
}
|
||||
list ($year, $month, $day) = array_pad(preg_split("/[\/-]/", $date), 3, null);
|
||||
list ($year, $month, $day) = array_pad(
|
||||
preg_split("/[\/-]/", $date) ?: [],
|
||||
3,
|
||||
null
|
||||
);
|
||||
if (!$year || !$month || !$day) {
|
||||
return false;
|
||||
}
|
||||
@@ -146,12 +154,16 @@ class DateTime
|
||||
* @param string $datetime date (YYYY-MM-DD) + time (HH:MM:SS), SS can be dropped
|
||||
* @return bool true if valid date, false if date not valid
|
||||
*/
|
||||
public static function checkDateTime($datetime): bool
|
||||
public static function checkDateTime(string $datetime): bool
|
||||
{
|
||||
if (!$datetime) {
|
||||
return false;
|
||||
}
|
||||
list ($year, $month, $day, $hour, $min, $sec) = array_pad(preg_split("/[\/\- :]/", $datetime), 6, null);
|
||||
list ($year, $month, $day, $hour, $min, $sec) = array_pad(
|
||||
preg_split("/[\/\- :]/", $datetime) ?: [],
|
||||
6,
|
||||
null
|
||||
);
|
||||
if (!$year || !$month || !$day) {
|
||||
return false;
|
||||
}
|
||||
@@ -190,8 +202,16 @@ class DateTime
|
||||
}
|
||||
|
||||
// splits the data up with / or -
|
||||
list ($start_year, $start_month, $start_day) = array_pad(preg_split('/[\/-]/', $start_date), 3, null);
|
||||
list ($end_year, $end_month, $end_day) = array_pad(preg_split('/[\/-]/', $end_date), 3, null);
|
||||
list ($start_year, $start_month, $start_day) = array_pad(
|
||||
preg_split('/[\/-]/', $start_date) ?: [],
|
||||
3,
|
||||
null
|
||||
);
|
||||
list ($end_year, $end_month, $end_day) = array_pad(
|
||||
preg_split('/[\/-]/', $end_date) ?: [],
|
||||
3,
|
||||
null
|
||||
);
|
||||
// check that month & day are two digits and then combine
|
||||
foreach (['start', 'end'] as $prefix) {
|
||||
foreach (['month', 'day'] as $date_part) {
|
||||
@@ -214,6 +234,8 @@ class DateTime
|
||||
return 0;
|
||||
} elseif ($start_date > $end_date) {
|
||||
return 1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +264,8 @@ class DateTime
|
||||
return 0;
|
||||
} elseif ($start_timestamp > $end_timestamp) {
|
||||
return 1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +276,7 @@ class DateTime
|
||||
* @param string $start_date valid start date (y/m/d)
|
||||
* @param string $end_date valid end date (y/m/d)
|
||||
* @param bool $return_named return array type, false (default), true for named
|
||||
* @return array 0/overall, 1/weekday, 2/weekend
|
||||
* @return array<mixed> 0/overall, 1/weekday, 2/weekend
|
||||
*/
|
||||
public static function calcDaysInterval($start_date, $end_date, bool $return_named = false): array
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ class Byte
|
||||
// detects up to exo bytes
|
||||
preg_match(
|
||||
"/([\d.,]*)\s?(eib|pib|tib|gib|mib|kib|eb|pb|tb|gb|mb|kb|e|p|t|g|m|k|b)$/i",
|
||||
strtolower($number),
|
||||
strtolower((string)$number),
|
||||
$matches
|
||||
);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
@@ -136,7 +136,7 @@ class Byte
|
||||
// convert any mb/gb/etc to single m/b
|
||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $matches[2]);
|
||||
if ($unit) {
|
||||
$number = $number * pow($si ? 1000 : 1024, stripos($valid_units_, $unit[0]));
|
||||
$number = $number * pow($si ? 1000 : 1024, stripos($valid_units_, $unit[0]) ?: 0);
|
||||
}
|
||||
// convert to INT to avoid +E output
|
||||
$number = (int)round($number);
|
||||
|
||||
@@ -18,14 +18,18 @@ class Colors
|
||||
{
|
||||
/**
|
||||
* converts a hex RGB color to the int numbers
|
||||
* @param string $hexStr RGB hexstring
|
||||
* @param bool $returnAsString flag to return as string
|
||||
* @param string $seperator string seperator: default: ","
|
||||
* @return string|array|bool false on error or array with RGB or a string with the seperator
|
||||
* @param string $hexStr RGB hexstring
|
||||
* @param bool $returnAsString flag to return as string
|
||||
* @param string $seperator string seperator: default: ","
|
||||
* @return string|array<string,float|int>|bool false on error or array with RGB
|
||||
* or a string with the seperator
|
||||
*/
|
||||
public static function hex2rgb(string $hexStr, bool $returnAsString = false, string $seperator = ',')
|
||||
{
|
||||
$hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
|
||||
if (!is_string($hexStr)) {
|
||||
return false;
|
||||
}
|
||||
$rgbArray = [];
|
||||
if (strlen($hexStr) == 6) {
|
||||
// If a proper hex code, convert using bitwise operation. No overhead... faster
|
||||
@@ -76,10 +80,10 @@ class Colors
|
||||
* converts RGB to HSB/V values
|
||||
* returns:
|
||||
* array with hue (0-360), sat (0-100%), brightness/value (0-100%)
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array Hue, Sat, Brightness/Value
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array<int|float> Hue, Sat, Brightness/Value
|
||||
*/
|
||||
public static function rgb2hsb(int $red, int $green, int $blue): array
|
||||
{
|
||||
@@ -119,10 +123,10 @@ class Colors
|
||||
|
||||
/**
|
||||
* converts HSB/V to RGB values RGB is full INT
|
||||
* @param int $H hue 0-360
|
||||
* @param int $S saturation 0-100 (int)
|
||||
* @param int $V brightness/value 0-100 (int)
|
||||
* @return array 0 red/1 green/2 blue array as 0-255
|
||||
* @param int $H hue 0-360
|
||||
* @param int $S saturation 0-100 (int)
|
||||
* @param int $V brightness/value 0-100 (int)
|
||||
* @return array<int> 0 red/1 green/2 blue array as 0-255
|
||||
*/
|
||||
public static function hsb2rgb(int $H, int $S, int $V): array
|
||||
{
|
||||
@@ -199,10 +203,10 @@ class Colors
|
||||
* converts a RGB (0-255) to HSL
|
||||
* return:
|
||||
* array with hue (0-360), saturation (0-100%) and luminance (0-100%)
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array hue/sat/luminance
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array<float> hue/sat/luminance
|
||||
*/
|
||||
public static function rgb2hsl(int $red, int $green, int $blue): array
|
||||
{
|
||||
@@ -253,7 +257,7 @@ class Colors
|
||||
* @param int $hue hue: 0-360 (degrees)
|
||||
* @param float $sat saturation: 0-100
|
||||
* @param float $lum luminance: 0-100
|
||||
* @return array red/blue/green 0-255 each
|
||||
* @return array<int,float|int> red/blue/green 0-255 each
|
||||
*/
|
||||
public static function hsl2rgb(int $hue, float $sat, float $lum): array
|
||||
{
|
||||
|
||||
@@ -39,10 +39,10 @@ class Html
|
||||
* returns 'checked' or 'selected' if okay
|
||||
* $needle is a var, $haystack an array or a string
|
||||
* **** THE RETURN: VALUE WILL CHANGE TO A DEFAULT NULL IF NOT FOUND ****
|
||||
* @param array|string $haystack (search in) haystack can be an array or a string
|
||||
* @param string $needle needle (search for)
|
||||
* @param int $type type: 0: returns selected, 1, returns checked
|
||||
* @return ?string returns checked or selected, else returns null
|
||||
* @param array<mixed>|string $haystack (search in) haystack can be an array or a string
|
||||
* @param string $needle needle (search for)
|
||||
* @param int $type type: 0: returns selected, 1, returns checked
|
||||
* @return ?string returns checked or selected, else returns null
|
||||
*/
|
||||
public static function checked($haystack, $needle, int $type = 0): ?string
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CoreLibs\Convert;
|
||||
|
||||
class MimeAppName
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
private static $mime_apps = [];
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,9 @@ class Hash
|
||||
{
|
||||
/**
|
||||
* checks php version and if >=5.2.7 it will flip the string
|
||||
* can return empty string if none of string sets work
|
||||
* hash returns false
|
||||
* preg_replace fails for older php version
|
||||
* @param string $string string to crc
|
||||
* @return string crc32b hash (old type)
|
||||
*/
|
||||
@@ -24,6 +27,9 @@ class Hash
|
||||
// flip it back to old (two char groups)
|
||||
$string = preg_replace("/^([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})$/", "$4$3$2$1", $string);
|
||||
}
|
||||
if (!is_string($string)) {
|
||||
$string = '';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,13 @@ namespace CoreLibs\Create;
|
||||
class RandomKey
|
||||
{
|
||||
// key generation
|
||||
/** @var array<mixed> */
|
||||
private static $key_range = [];
|
||||
/** @var int */
|
||||
private static $one_key_length;
|
||||
/** @var int */
|
||||
private static $key_length = 4; // default key length
|
||||
/** @var int */
|
||||
private static $max_key_length = 256; // max allowed length
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,17 +38,21 @@ namespace CoreLibs\DB\Extended;
|
||||
class ArrayIO extends \CoreLibs\DB\IO
|
||||
{
|
||||
// main calss variables
|
||||
/** @var array<mixed> */
|
||||
public $table_array; // the array from the table to work on
|
||||
/** @var string */
|
||||
public $table_name; // the table_name
|
||||
/** @var string */
|
||||
public $pk_name; // the primary key from this table
|
||||
/** @var int|string|null */
|
||||
public $pk_id; // the PK id
|
||||
|
||||
/**
|
||||
* constructor for the array io class, set the
|
||||
* primary key name automatically (from array)
|
||||
* @param array $db_config db connection config
|
||||
* @param array $table_array table array config
|
||||
* @param string $table_name table name string
|
||||
* @param array<mixed> $db_config db connection config
|
||||
* @param array<mixed> $table_array table array config
|
||||
* @param string $table_name table name string
|
||||
*/
|
||||
public function __construct(array $db_config, array $table_array, string $table_name)
|
||||
{
|
||||
@@ -174,9 +178,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* deletes one dataset
|
||||
* @param array $table_array optional override for table array set
|
||||
* set this as new table array too
|
||||
* @return array returns the table array that was deleted
|
||||
* @param array<mixed> $table_array optional override for table array set
|
||||
* set this as new table array too
|
||||
* @return array<mixed> returns the table array that was deleted
|
||||
*/
|
||||
public function dbDelete($table_array = [])
|
||||
{
|
||||
@@ -234,9 +238,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* reads one row into the array
|
||||
* @param boolean $edit on true convert data, else as is
|
||||
* @param array $table_array optional table array, overwrites internal set array
|
||||
* @return array set table array with values
|
||||
* @param boolean $edit on true convert data, else as is
|
||||
* @param array<mixed> $table_array optional table array, overwrites internal set array
|
||||
* @return array<mixed> set table array with values
|
||||
*/
|
||||
public function dbRead($edit = false, $table_array = [])
|
||||
{
|
||||
@@ -276,7 +280,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
|
||||
// if query was executed okay, else set error
|
||||
if ($this->dbExec($q)) {
|
||||
if ($res = $this->dbFetchArray()) {
|
||||
if (is_array($res = $this->dbFetchArray())) {
|
||||
reset($this->table_array);
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
// wenn "edit" dann gib daten wie in DB zurück, ansonten aufbereiten fr ausgabe
|
||||
@@ -309,9 +313,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* writes one set into DB or updates one set (if PK exists)
|
||||
* @param boolean $addslashes old convert entities and set set escape
|
||||
* @param array $table_array optional table array, overwrites internal one
|
||||
* @return array table array or null
|
||||
* @param boolean $addslashes old convert entities and set set escape
|
||||
* @param array<mixed> $table_array optional table array, overwrites internal one
|
||||
* @return array<mixed> table array or null
|
||||
*/
|
||||
public function dbWrite($addslashes = false, $table_array = [])
|
||||
{
|
||||
@@ -499,11 +503,12 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
if (!$this->table_array[$this->pk_name]['value']) {
|
||||
// max id, falls INSERT
|
||||
$q = 'SELECT MAX(' . $this->pk_name . ') + 1 AS pk_id FROM ' . $this->table_name;
|
||||
$res = $this->dbReturnRow($q);
|
||||
if (!isset($res['pk_id'])) {
|
||||
$res['pk_id'] = 1;
|
||||
if (is_array($res = $this->dbReturnRow($q))) {
|
||||
$pk_id = $res['pkd_id'];
|
||||
} else {
|
||||
$pk_id = 1;
|
||||
}
|
||||
$this->table_array[$this->pk_name]['value'] = $res['pk_id'];
|
||||
$this->table_array[$this->pk_name]['value'] = $pk_id;
|
||||
}
|
||||
|
||||
if (!$insert) {
|
||||
@@ -533,8 +538,13 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
}
|
||||
// set primary key
|
||||
if ($insert) {
|
||||
$this->table_array[$this->pk_name]['value'] = $this->insert_id;
|
||||
$this->pk_id = $this->insert_id;
|
||||
// FIXME: this has to be fixes by fixing DB::IO clas
|
||||
$insert_id = $this->dbGetInsertPK();
|
||||
if (is_array($insert_id)) {
|
||||
$insert_id = 0;
|
||||
}
|
||||
$this->table_array[$this->pk_name]['value'] = $insert_id;
|
||||
$this->pk_id = $insert_id;
|
||||
}
|
||||
// return the table if needed
|
||||
return $this->table_array;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,9 @@ namespace CoreLibs\DB\SQL;
|
||||
|
||||
class PgSQL
|
||||
{
|
||||
/** @var string */
|
||||
private $last_error_query;
|
||||
/** @var resource|bool */
|
||||
private $dbh;
|
||||
|
||||
/**
|
||||
@@ -81,6 +83,9 @@ class PgSQL
|
||||
public function __dbQuery(string $query)
|
||||
{
|
||||
$this->last_error_query = '';
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
// read out the query status and save the query if needed
|
||||
$result = pg_query($this->dbh, $query);
|
||||
if (!$result) {
|
||||
@@ -96,7 +101,11 @@ class PgSQL
|
||||
*/
|
||||
public function __dbSendQuery(string $query): bool
|
||||
{
|
||||
return pg_send_query($this->dbh, $query);
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
$result = pg_send_query($this->dbh, $query);
|
||||
return $result ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +115,13 @@ class PgSQL
|
||||
public function __dbGetResult()
|
||||
{
|
||||
$this->last_error_query = '';
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
$result = pg_get_result($this->dbh);
|
||||
if (!is_resource($result)) {
|
||||
return false;
|
||||
}
|
||||
if ($error = pg_result_error($result)) {
|
||||
$this->last_error_query = $error;
|
||||
}
|
||||
@@ -119,10 +134,11 @@ class PgSQL
|
||||
*/
|
||||
public function __dbClose(): void
|
||||
{
|
||||
if (is_resource($this->dbh)) {
|
||||
if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) {
|
||||
pg_close($this->dbh);
|
||||
}
|
||||
if (!is_resource($this->dbh)) {
|
||||
return;
|
||||
}
|
||||
if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) {
|
||||
pg_close($this->dbh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +150,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbPrepare(string $name, string $query)
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
$result = pg_prepare($this->dbh, $name, $query);
|
||||
if (!$result) {
|
||||
$this->last_error_query = $query;
|
||||
@@ -144,11 +163,14 @@ class PgSQL
|
||||
/**
|
||||
* wrapper for pg_execute for running a prepared statement
|
||||
* @param string $name statement name
|
||||
* @param array $data data array
|
||||
* @param array<mixed> $data data array
|
||||
* @return resource|bool returns status or false for error
|
||||
*/
|
||||
public function __dbExecute(string $name, array $data)
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
$result = pg_execute($this->dbh, $name, $data);
|
||||
if (!$result) {
|
||||
$this->last_error_query = $name;
|
||||
@@ -192,7 +214,7 @@ class PgSQL
|
||||
* if through/true false, use __dbResultType(true)
|
||||
* @param resource $cursor cursor resource
|
||||
* @param int $result_type result type as int number
|
||||
* @return array|bool array result data or false on end/error
|
||||
* @return array<mixed>|bool array result data or false on end/error
|
||||
*/
|
||||
public function __dbFetchArray($cursor, int $result_type = PGSQL_BOTH)
|
||||
{
|
||||
@@ -217,7 +239,7 @@ class PgSQL
|
||||
/**
|
||||
* wrapper for pg_fetch_all
|
||||
* @param resource $cursor cursor resource
|
||||
* @return array|bool data array or false for end/error
|
||||
* @return array<mixed>|bool data array or false for end/error
|
||||
*/
|
||||
public function __dbFetchAll($cursor)
|
||||
{
|
||||
@@ -239,11 +261,11 @@ class PgSQL
|
||||
* if there is no pk_name tries to auto built it from the table name
|
||||
* this only works if db schema is after "no plural names. and pk name is table name + _id
|
||||
* detects schema prefix in table name
|
||||
* @param string $query query string
|
||||
* @param string $pk_name primary key name, if '' then auto detect
|
||||
* @return string|int primary key value
|
||||
* @param string $query query string
|
||||
* @param string|null $pk_name primary key name, if '' then auto detect
|
||||
* @return string|int|false primary key value
|
||||
*/
|
||||
public function __dbInsertId(string $query, string $pk_name)
|
||||
public function __dbInsertId(string $query, ?string $pk_name)
|
||||
{
|
||||
// only if an insert has been done
|
||||
if (preg_match("/^insert /i", $query)) {
|
||||
@@ -258,7 +280,7 @@ class PgSQL
|
||||
$table = $_table;
|
||||
}
|
||||
// no PK name given at all
|
||||
if (!$pk_name) {
|
||||
if (empty($pk_name)) {
|
||||
// if name is plurar, make it singular
|
||||
// if (preg_match("/.*s$/i", $table))
|
||||
// $table = substr($table, 0, -1);
|
||||
@@ -269,11 +291,18 @@ class PgSQL
|
||||
$q = "SELECT CURRVAL('$seq') AS insert_id";
|
||||
// I have to do manually or I overwrite the original insert internal vars ...
|
||||
if ($q = $this->__dbQuery($q)) {
|
||||
list($id) = $this->__dbFetchArray($q);
|
||||
// abort if this is not an resource
|
||||
if (!is_resource($q)) {
|
||||
return false;
|
||||
}
|
||||
list($id) = $this->__dbFetchArray($q) ?: [];
|
||||
} else {
|
||||
$id = [-1, $q];
|
||||
}
|
||||
return $id;
|
||||
} else {
|
||||
//if not insert, return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +320,14 @@ class PgSQL
|
||||
if ($schema) {
|
||||
$q = "SHOW search_path";
|
||||
$cursor = $this->__dbQuery($q);
|
||||
$search_path = $this->__dbFetchArray($cursor)['search_path'];
|
||||
if (!is_resource($cursor)) {
|
||||
return false;
|
||||
}
|
||||
$__db_fetch_array = $this->__dbFetchArray($cursor);
|
||||
if (!is_array($__db_fetch_array)) {
|
||||
return false;
|
||||
}
|
||||
$search_path = $__db_fetch_array['search_path'] ?? '';
|
||||
if ($search_path != $schema) {
|
||||
$table_prefix = $schema . '.';
|
||||
}
|
||||
@@ -316,8 +352,12 @@ class PgSQL
|
||||
. "pg_attribute.attnum = any(pg_index.indkey) "
|
||||
. "AND indisprimary";
|
||||
$cursor = $this->__dbQuery($q);
|
||||
if ($cursor) {
|
||||
return $this->__dbFetchArray($cursor)['column_name'] ?? false;
|
||||
if (is_resource($cursor)) {
|
||||
$__db_fetch_array = $this->__dbFetchArray($cursor);
|
||||
if (!is_array($__db_fetch_array)) {
|
||||
return false;
|
||||
}
|
||||
return $__db_fetch_array['column_name'] ?? false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -328,13 +368,13 @@ class PgSQL
|
||||
|
||||
/**
|
||||
* wrapper for pg_connect, writes out failure to screen if error occurs (hidden var)
|
||||
* @param string $db_host host name
|
||||
* @param string $db_user user name
|
||||
* @param string $db_pass password
|
||||
* @param string $db_name databse name
|
||||
* @param integer $db_port port (int, 5432 is default)
|
||||
* @param string $db_ssl SSL (allow is default)
|
||||
* @return ?resource db handler resource or null on error
|
||||
* @param string $db_host host name
|
||||
* @param string $db_user user name
|
||||
* @param string $db_pass password
|
||||
* @param string $db_name databse name
|
||||
* @param integer $db_port port (int, 5432 is default)
|
||||
* @param string $db_ssl SSL (allow is default)
|
||||
* @return resource|bool db handler resource or false on error
|
||||
*/
|
||||
public function __dbConnect(
|
||||
string $db_host,
|
||||
@@ -350,11 +390,9 @@ class PgSQL
|
||||
}
|
||||
$this->dbh = pg_connect("host=" . $db_host . " port=" . $db_port . " user="
|
||||
. $db_user . " password=" . $db_pass . " dbname=" . $db_name . " sslmode=" . $db_ssl);
|
||||
if (!$this->dbh) {
|
||||
die("<!-- Can't connect [host=" . $db_host . " port=" . $db_port . " user="
|
||||
. $db_user . " password=XXXX dbname=" . $db_name . " sslmode=" . $db_ssl . "] //-->");
|
||||
return null;
|
||||
}
|
||||
// if (!$this->dbh) {
|
||||
// die("<!-- Can't connect to database //-->");
|
||||
// }
|
||||
return $this->dbh;
|
||||
}
|
||||
|
||||
@@ -366,6 +404,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbPrintError($cursor = null): string
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return '';
|
||||
}
|
||||
// run the query again for the error result here
|
||||
if (!$cursor && $this->last_error_query) {
|
||||
pg_send_query($this->dbh, $this->last_error_query);
|
||||
@@ -381,12 +422,15 @@ class PgSQL
|
||||
|
||||
/**
|
||||
* wrapper for pg_meta_data
|
||||
* @param string $table table name
|
||||
* @param bool $extended show extended info (default false)
|
||||
* @return array|bool array data for the table info or false on error
|
||||
* @param string $table table name
|
||||
* @param bool $extended show extended info (default false)
|
||||
* @return array<mixed>|bool array data for the table info or false on error
|
||||
*/
|
||||
public function __dbMetaData(string $table, $extended = false)
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
// needs to prefixed with @ or it throws a warning on not existing table
|
||||
return @pg_meta_data($this->dbh, $table, $extended);
|
||||
}
|
||||
@@ -398,6 +442,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbEscapeString($string): string
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return '';
|
||||
}
|
||||
return pg_escape_string($this->dbh, (string)$string);
|
||||
}
|
||||
|
||||
@@ -410,6 +457,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbEscapeLiteral($string): string
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return '';
|
||||
}
|
||||
return pg_escape_string($this->dbh, (string)$string);
|
||||
}
|
||||
|
||||
@@ -420,6 +470,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbEscapeBytea($bytea): string
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return '';
|
||||
}
|
||||
return pg_escape_bytea($this->dbh, $bytea);
|
||||
}
|
||||
|
||||
@@ -429,6 +482,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbConnectionBusy(): bool
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return false;
|
||||
}
|
||||
return pg_connection_busy($this->dbh);
|
||||
}
|
||||
|
||||
@@ -440,6 +496,9 @@ class PgSQL
|
||||
*/
|
||||
public function __dbVersion(): string
|
||||
{
|
||||
if (!is_resource($this->dbh)) {
|
||||
return '';
|
||||
}
|
||||
// array has client, protocol, server
|
||||
// we just need the server
|
||||
$v = pg_version($this->dbh);
|
||||
@@ -448,11 +507,12 @@ class PgSQL
|
||||
|
||||
/**
|
||||
* postgresql array to php array
|
||||
* @param string $text array text from PostgreSQL
|
||||
* @param array $output (internal) recursive pass on for nested arrays
|
||||
* @param bool|int $limit (internal) max limit to not overshoot the end, start with false
|
||||
* @param integer $offset (internal) shift offset for {}
|
||||
* @return array|int converted PHP array, interal recusrive int position
|
||||
* @param string $text array text from PostgreSQL
|
||||
* @param array<mixed> $output (internal) recursive pass on for nested arrays
|
||||
* @param bool|int $limit (internal) max limit to not overshoot
|
||||
* the end, start with false
|
||||
* @param integer $offset (internal) shift offset for {}
|
||||
* @return array<mixed>|int converted PHP array, interal recusrive int position
|
||||
*/
|
||||
public function __dbArrayParse($text, &$output, $limit = false, $offset = 1)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CoreLibs\Debug;
|
||||
|
||||
class FileWriter
|
||||
{
|
||||
/** @var string */
|
||||
private static $debug_filename = 'debug_file.log'; // where to write output
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,38 +27,65 @@ namespace CoreLibs\Debug;
|
||||
class Logging
|
||||
{
|
||||
// page and host name
|
||||
/** @var string */
|
||||
private $page_name;
|
||||
/** @var string */
|
||||
private $host_name;
|
||||
/** @var int */
|
||||
private $host_port;
|
||||
// internal error reporting vars
|
||||
/** @var array<mixed> */
|
||||
private $error_msg = []; // the "connection" to the outside errors
|
||||
// debug output prefix
|
||||
/** @var string */
|
||||
private $error_msg_prefix = ''; // prefix to the error string (the class name)
|
||||
// debug flags
|
||||
/** @var array<mixed> */
|
||||
private $debug_output = []; // if this is true, show debug on desconstructor
|
||||
/** @var array<mixed> */
|
||||
private $debug_output_not = [];
|
||||
/** @var bool */
|
||||
private $debug_output_all = false;
|
||||
/** @var array<mixed> */
|
||||
private $echo_output = []; // errors: echo out, default is 1
|
||||
/** @var array<mixed> */
|
||||
private $echo_output_not = [];
|
||||
/** @var bool */
|
||||
private $echo_output_all = false;
|
||||
/** @var array<mixed> */
|
||||
private $print_output = []; // errors: print to file, default is 0
|
||||
/** @var array<mixed> */
|
||||
private $print_output_not = [];
|
||||
/** @var bool */
|
||||
private $print_output_all = false;
|
||||
// debug flags/settings
|
||||
/** @var string */
|
||||
private $running_uid = ''; // unique ID set on class init and used in logging as prefix
|
||||
// log file name
|
||||
/** @var string */
|
||||
private $log_folder = '';
|
||||
/** @var string */
|
||||
private $log_file_name_ext = 'log'; // use this for date rotate
|
||||
/** @var int */
|
||||
private $log_max_filesize = 0; // set in kilobytes
|
||||
/** @var string */
|
||||
private $log_print_file = 'error_msg##LOGID####LEVEL####CLASS####PAGENAME####DATE##';
|
||||
/** @var string */
|
||||
private $log_file_unique_id; // a unique ID set only once for call derived from this class
|
||||
/** @var bool */
|
||||
private $log_print_file_date = true; // if set add Y-m-d and do automatic daily rotation
|
||||
/** @var string */
|
||||
private $log_file_id = ''; // a alphanumeric name that has to be set as global definition
|
||||
/** @var bool */
|
||||
private $log_per_level = false; // set, it will split per level (first parameter in debug call)
|
||||
/** @var bool */
|
||||
private $log_per_class = false; // set, will split log per class
|
||||
/** @var bool */
|
||||
private $log_per_page = false; // set, will split log per called file
|
||||
/** @var bool */
|
||||
private $log_per_run = false; // create a new log file per run (time stamp + unique ID)
|
||||
// script running time
|
||||
/** @var float */
|
||||
private $script_starttime;
|
||||
|
||||
public function __construct()
|
||||
@@ -282,7 +309,8 @@ class Logging
|
||||
{
|
||||
// get the last class entry and wrie that
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) ?? [['class' => get_class($this)]];
|
||||
return end($backtrace)['class'];
|
||||
// make sure if false it is an array and then check if not class set return empty string
|
||||
return (end($backtrace) ?: [])['class'] ?? '';
|
||||
}
|
||||
|
||||
// *** PUBLIC ***
|
||||
@@ -341,7 +369,7 @@ class Logging
|
||||
*/
|
||||
public function debugFor(string $type, string $flag): void
|
||||
{
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal @phpstan-ignore-next-line */
|
||||
$this->setLogLevel(...[func_get_args()]);
|
||||
}
|
||||
|
||||
@@ -381,7 +409,7 @@ class Logging
|
||||
* @param string $flag on/off
|
||||
* @param string|null $level if not null then check if this array entry is set
|
||||
* else return false
|
||||
* @return bool|array if $level is null, return array, else boolean true/false
|
||||
* @return bool|array<mixed> if $level is null, return array, else boolean true/false
|
||||
*/
|
||||
public function getLogLevel(string $type, string $flag, ?string $level = null)
|
||||
{
|
||||
@@ -439,8 +467,8 @@ class Logging
|
||||
* It uses some special code sets so we can convert that to pre flags
|
||||
* for echo output {##HTMLPRE##} ... {##/HTMLPRE##}
|
||||
* Do not use this without using it in a string in debug function
|
||||
* @param array $a Array to format
|
||||
* @return string print_r formated
|
||||
* @param array<mixed> $a Array to format
|
||||
* @return string print_r formated
|
||||
*/
|
||||
public function prAr(array $a): string
|
||||
{
|
||||
@@ -486,9 +514,13 @@ class Logging
|
||||
($strip ?
|
||||
// find any <br> and replace them with \n
|
||||
// strip rest of html elements (base only)
|
||||
preg_replace("/(<\/?)(\w+)([^>]*>)/", '', str_replace('<br>', "\n", $prefix . $string)) :
|
||||
preg_replace(
|
||||
"/(<\/?)(\w+)([^>]*>)/",
|
||||
'',
|
||||
str_replace('<br>', "\n", $prefix . $string)
|
||||
) :
|
||||
$prefix . $string
|
||||
)
|
||||
) ?: ''
|
||||
)
|
||||
. "\n"
|
||||
);
|
||||
@@ -522,8 +554,8 @@ class Logging
|
||||
/**
|
||||
* merges the given error array with the one from this class
|
||||
* only merges visible ones
|
||||
* @param array $error_msg error array
|
||||
* @return void has no return
|
||||
* @param array<mixed> $error_msg error array
|
||||
* @return void has no return
|
||||
*/
|
||||
public function mergeErrors(array $error_msg = []): void
|
||||
{
|
||||
@@ -593,7 +625,7 @@ class Logging
|
||||
/**
|
||||
* Get current error message array
|
||||
*
|
||||
* @return array error messages collected
|
||||
* @return array<mixed> error messages collected
|
||||
*/
|
||||
public function getErrorMsg(): array
|
||||
{
|
||||
|
||||
@@ -11,12 +11,18 @@ namespace CoreLibs\Debug;
|
||||
class RunningTime
|
||||
{
|
||||
// hr
|
||||
/** @var float */
|
||||
private static $hr_starttime;
|
||||
/** @var float */
|
||||
private static $hr_runtime;
|
||||
/** @var float */
|
||||
private static $hr_endtime;
|
||||
// normal
|
||||
/** @var float */
|
||||
private static $starttime;
|
||||
/** @var float */
|
||||
private static $endtime;
|
||||
/** @var string */
|
||||
private static $runningtime_string;
|
||||
|
||||
/**
|
||||
@@ -77,8 +83,8 @@ class RunningTime
|
||||
* on second call it sends the end time and then also prints the running time
|
||||
* Sets the internal runningtime_string variable with Start/End/Run time string
|
||||
* NOTE: for pure running time check it is recommended to use hrRunningTime method
|
||||
* @param bool|boolean $simple if true prints HTML strings, default text only
|
||||
* @return float running time as float number
|
||||
* @param bool $simple if true prints HTML strings, default text only
|
||||
* @return float running time as float number
|
||||
*/
|
||||
public static function runningTime(bool $simple = false): float
|
||||
{
|
||||
|
||||
@@ -31,8 +31,8 @@ class Support
|
||||
|
||||
/**
|
||||
* prints a html formatted (pre) array
|
||||
* @param array $array any array
|
||||
* @return string formatted array for output with <pre> tag added
|
||||
* @param array<mixed> $array any array
|
||||
* @return string formatted array for output with <pre> tag added
|
||||
*/
|
||||
public static function printAr(array $array): string
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ class System
|
||||
|
||||
/**
|
||||
* get the host name without the port as given by the SELF var
|
||||
* @return array host name/port name
|
||||
* @return array<mixed> host name/port name
|
||||
*/
|
||||
public static function getHostName(): array
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class System
|
||||
/**
|
||||
* similar to getPageName, but it retuns the raw array
|
||||
*
|
||||
* @return array pathinfo array from PHP SELF
|
||||
* @return array<string> pathinfo array from PHP SELF
|
||||
*/
|
||||
public static function getPageNameArray(): array
|
||||
{
|
||||
|
||||
@@ -28,21 +28,27 @@ namespace CoreLibs\Language\Core;
|
||||
// over it (it assumes knowledge of StringReader internals)
|
||||
class CachedFileReader extends \CoreLibs\Language\Core\StringReader
|
||||
{
|
||||
/** @var int */
|
||||
public $error = 0;
|
||||
/** @var string */
|
||||
public $fd_str = '';
|
||||
|
||||
public function __construct($filename)
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
public function __construct(string $filename)
|
||||
{
|
||||
parent::__construct();
|
||||
if (file_exists($filename)) {
|
||||
$length = filesize($filename);
|
||||
$fd = fopen($filename, 'rb');
|
||||
|
||||
if (!$fd) {
|
||||
if (!is_resource($fd)) {
|
||||
$this->error = 3; // Cannot read file, probably permissions
|
||||
} else {
|
||||
$this->fd_str = fread($fd, filesize($filename) ?: 0) ?: '';
|
||||
fclose($fd);
|
||||
}
|
||||
$this->fd_str = fread($fd, $length);
|
||||
fclose($fd);
|
||||
} else {
|
||||
$this->error = 2; // File doesn't exist
|
||||
}
|
||||
|
||||
@@ -26,9 +26,13 @@ namespace CoreLibs\Language\Core;
|
||||
|
||||
class FileReader
|
||||
{
|
||||
/** @var int */
|
||||
public $fr_pos;
|
||||
/** @var resource|bool */
|
||||
public $fr_fd;
|
||||
/** @var int */
|
||||
public $fr_length;
|
||||
/** @var int */
|
||||
public $error = 0;
|
||||
|
||||
/**
|
||||
@@ -38,10 +42,10 @@ class FileReader
|
||||
public function __construct($filename)
|
||||
{
|
||||
if (file_exists($filename)) {
|
||||
$this->fr_length = filesize($filename);
|
||||
$this->fr_length = filesize($filename) ?: 0;
|
||||
$this->fr_pos = 0;
|
||||
$this->fr_fd = fopen($filename, 'rb');
|
||||
if (!$this->fr_fd) {
|
||||
if (!is_resource($this->fr_fd)) {
|
||||
$this->error = 3; // Cannot read file, probably permissions
|
||||
}
|
||||
} else {
|
||||
@@ -56,23 +60,25 @@ class FileReader
|
||||
*/
|
||||
public function read($bytes)
|
||||
{
|
||||
if ($bytes) {
|
||||
fseek($this->fr_fd, $this->fr_pos);
|
||||
|
||||
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
|
||||
// the discussions at PHP Bugs suggest it's the intended behaviour
|
||||
$data = '';
|
||||
while ($bytes > 0) {
|
||||
$chunk = fread($this->fr_fd, $bytes);
|
||||
$data .= $chunk;
|
||||
$bytes -= strlen($chunk);
|
||||
}
|
||||
$this->fr_pos = ftell($this->fr_fd);
|
||||
|
||||
return $data;
|
||||
} else {
|
||||
if (!$bytes || !is_resource($this->fr_fd)) {
|
||||
return '';
|
||||
}
|
||||
fseek($this->fr_fd, $this->fr_pos);
|
||||
|
||||
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
|
||||
// the discussions at PHP Bugs suggest it's the intended behaviour
|
||||
$data = '';
|
||||
while ($bytes > 0) {
|
||||
$chunk = fread($this->fr_fd, $bytes);
|
||||
if ($chunk === false) {
|
||||
break;
|
||||
}
|
||||
$data .= $chunk;
|
||||
$bytes -= strlen($chunk);
|
||||
}
|
||||
$this->fr_pos = ftell($this->fr_fd) ?: 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,8 +88,11 @@ class FileReader
|
||||
*/
|
||||
public function seekto($pos)
|
||||
{
|
||||
if (!is_resource($this->fr_fd)) {
|
||||
return 0;
|
||||
}
|
||||
fseek($this->fr_fd, $pos);
|
||||
$this->fr_pos = ftell($this->fr_fd);
|
||||
$this->fr_pos = ftell($this->fr_fd) ?: 0;
|
||||
return $this->fr_pos;
|
||||
}
|
||||
|
||||
@@ -111,7 +120,9 @@ class FileReader
|
||||
*/
|
||||
public function close(): void
|
||||
{
|
||||
fclose($this->fr_fd);
|
||||
if (is_resource($this->fr_fd)) {
|
||||
fclose($this->fr_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,19 +40,31 @@ namespace CoreLibs\Language\Core;
|
||||
class GetTextReader
|
||||
{
|
||||
// public:
|
||||
/** @var int */
|
||||
public $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 $STREAM = null;
|
||||
/** @var FileReader */
|
||||
private $STREAM;
|
||||
/** @var bool */
|
||||
private $short_circuit = false;
|
||||
/** @var bool */
|
||||
private $enable_cache = false;
|
||||
private $originals = null; // offset of original table
|
||||
private $translations = null; // offset of translation table
|
||||
private $pluralheader = null; // cache header field for plural forms
|
||||
/** @var int */
|
||||
private $originals = 0; // offset of original table
|
||||
/** @var int */
|
||||
private $translations = 0; // offset of translation table
|
||||
/** @var string */
|
||||
private $pluralheader = ''; // cache header field for plural forms
|
||||
/** @var int */
|
||||
private $total = 0; // total string count
|
||||
/** @var array<mixed>|null */
|
||||
private $table_originals = null; // table for original strings (offsets)
|
||||
/** @var array<mixed>|null */
|
||||
private $table_translations = null; // table for translated strings (offsets)
|
||||
/** @var array<mixed> */
|
||||
private $cache_translations = []; // original -> translation mapping
|
||||
|
||||
|
||||
@@ -69,13 +81,12 @@ class GetTextReader
|
||||
{
|
||||
if ($this->BYTEORDER == 0) {
|
||||
// low endian
|
||||
$input = unpack('V', $this->STREAM->read(4));
|
||||
return array_shift($input);
|
||||
$input = unpack('V', $this->STREAM->read(4)) ?: [];
|
||||
} else {
|
||||
// big endian
|
||||
$input = unpack('N', $this->STREAM->read(4));
|
||||
return array_shift($input);
|
||||
$input = unpack('N', $this->STREAM->read(4)) ?: [];
|
||||
}
|
||||
return array_shift($input);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,29 +103,34 @@ class GetTextReader
|
||||
* Reads an array of Integers from the Stream
|
||||
*
|
||||
* @param int $count How many elements should be read
|
||||
* @return array Array of Integers
|
||||
* @return array<mixed> Array of Integers
|
||||
*/
|
||||
public function readintarray($count)
|
||||
{
|
||||
if ($this->BYTEORDER == 0) {
|
||||
// low endian
|
||||
return unpack('V' . $count, $this->STREAM->read(4 * $count));
|
||||
return unpack('V' . $count, $this->STREAM->read(4 * $count)) ?: [];
|
||||
} else {
|
||||
// big endian
|
||||
return unpack('N' . $count, $this->STREAM->read(4 * $count));
|
||||
return unpack('N' . $count, $this->STREAM->read(4 * $count)) ?: [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $Reader the StreamReader object
|
||||
* @param bool $enable_cache Enable or disable caching of strings (default on)
|
||||
* @param FileReader|bool $Reader the StreamReader object
|
||||
* @param bool $enable_cache Enable or disable caching of strings (default on)
|
||||
*/
|
||||
public function __construct($Reader, $enable_cache = true)
|
||||
{
|
||||
// If there isn't a StreamReader, turn on short circuit mode.
|
||||
if (!$Reader || $Reader->error) {
|
||||
if ((!is_object($Reader) && !$Reader) || (is_object($Reader) && $Reader->error)) {
|
||||
$this->short_circuit = true;
|
||||
return;
|
||||
}
|
||||
// bail out for sure if this is not an objet here
|
||||
if (!is_object($Reader)) {
|
||||
$this->short_circuit = true;
|
||||
return;
|
||||
}
|
||||
@@ -149,8 +165,9 @@ class GetTextReader
|
||||
* to speed up translation lookups
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function load_tables()
|
||||
private function loadTables(): void
|
||||
{
|
||||
if (
|
||||
is_array($this->cache_translations) &&
|
||||
@@ -190,10 +207,10 @@ class GetTextReader
|
||||
* @param int $num Offset number of original string
|
||||
* @return string Requested string if found, otherwise ''
|
||||
*/
|
||||
private function get_original_string($num)
|
||||
private function getOriginalString($num)
|
||||
{
|
||||
$length = $this->table_originals[$num * 2 + 1];
|
||||
$offset = $this->table_originals[$num * 2 + 2];
|
||||
$length = $this->table_originals[$num * 2 + 1] ?? 0;
|
||||
$offset = $this->table_originals[$num * 2 + 2] ?? 0;
|
||||
if (!$length) {
|
||||
return '';
|
||||
}
|
||||
@@ -209,10 +226,10 @@ class GetTextReader
|
||||
* @param int $num Offset number of original string
|
||||
* @return string Requested string if found, otherwise ''
|
||||
*/
|
||||
private function get_translation_string($num)
|
||||
private function getTranslationString($num)
|
||||
{
|
||||
$length = $this->table_translations[$num * 2 + 1];
|
||||
$offset = $this->table_translations[$num * 2 + 2];
|
||||
$length = $this->table_translations[$num * 2 + 1] ?? 0;
|
||||
$offset = $this->table_translations[$num * 2 + 2] ?? 0;
|
||||
if (!$length) {
|
||||
return '';
|
||||
}
|
||||
@@ -228,18 +245,18 @@ class GetTextReader
|
||||
* @param string $string string to find
|
||||
* @param int $start (internally used in recursive function)
|
||||
* @param int $end (internally used in recursive function)
|
||||
* @return int|string|float (offset in originals table)
|
||||
* @return int (offset in originals table)
|
||||
*/
|
||||
private function find_string($string, $start = -1, $end = -1)
|
||||
private function findString($string, $start = -1, $end = -1)
|
||||
{
|
||||
if (($start == -1) or ($end == -1)) {
|
||||
// find_string is called with only one parameter, set start end end
|
||||
// findString is called with only one parameter, set start end end
|
||||
$start = 0;
|
||||
$end = $this->total;
|
||||
}
|
||||
if (abs($start - $end) <= 1) {
|
||||
// We're done, now we either found the string, or it doesn't exist
|
||||
$txt = $this->get_original_string($start);
|
||||
$txt = $this->getOriginalString($start);
|
||||
if ($string == $txt) {
|
||||
return $start;
|
||||
} else {
|
||||
@@ -247,20 +264,20 @@ class GetTextReader
|
||||
}
|
||||
} elseif ($start > $end) {
|
||||
// start > end -> turn around and start over
|
||||
return $this->find_string($string, $end, $start);
|
||||
return $this->findString($string, $end, $start);
|
||||
} else {
|
||||
// Divide table in two parts
|
||||
$half = (int)(($start + $end) / 2);
|
||||
$cmp = strcmp($string, $this->get_original_string($half));
|
||||
$cmp = strcmp($string, $this->getOriginalString($half));
|
||||
if ($cmp == 0) {
|
||||
// string is exactly in the middle => return it
|
||||
return $half;
|
||||
} elseif ($cmp < 0) {
|
||||
// The string is in the upper half
|
||||
return $this->find_string($string, $start, $half);
|
||||
return $this->findString($string, $start, $half);
|
||||
} else {
|
||||
// Translateshe string is in the lower half
|
||||
return $this->find_string($string, $half, $end);
|
||||
return $this->findString($string, $half, $end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +294,7 @@ class GetTextReader
|
||||
if ($this->short_circuit) {
|
||||
return $string;
|
||||
}
|
||||
$this->load_tables();
|
||||
$this->loadTables();
|
||||
|
||||
if ($this->enable_cache) {
|
||||
// Caching enabled, get translated string from cache
|
||||
@@ -288,11 +305,11 @@ class GetTextReader
|
||||
}
|
||||
} else {
|
||||
// Caching not enabled, try to find string
|
||||
$num = $this->find_string($string);
|
||||
$num = $this->findString($string);
|
||||
if ($num == -1) {
|
||||
return $string;
|
||||
} else {
|
||||
return $this->get_translation_string($num);
|
||||
return $this->getTranslationString($num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +321,7 @@ class GetTextReader
|
||||
* @param string $expr an expression to match
|
||||
* @return string sanitized plural form expression
|
||||
*/
|
||||
private function sanitize_plural_expression($expr)
|
||||
private function sanitizePluralExpression($expr)
|
||||
{
|
||||
// Get rid of disallowed characters.
|
||||
$expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
|
||||
@@ -341,7 +358,7 @@ class GetTextReader
|
||||
* @param string $header header search in plurals
|
||||
* @return string verbatim plural form header field
|
||||
*/
|
||||
private function extract_plural_forms_header_from_po_header($header)
|
||||
private function extractPluralFormsHeaderFromPoHeader($header)
|
||||
{
|
||||
if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) {
|
||||
$expr = $regs[2];
|
||||
@@ -351,27 +368,27 @@ class GetTextReader
|
||||
return $expr;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get possible plural forms from MO header
|
||||
*
|
||||
* @access private
|
||||
* @return string plural form header
|
||||
*/
|
||||
private function get_plural_forms()
|
||||
private function getPluralForms()
|
||||
{
|
||||
// lets assume message number 0 is header
|
||||
// this is true, right?
|
||||
$this->load_tables();
|
||||
$this->loadTables();
|
||||
|
||||
// cache header field for plural forms
|
||||
if (! is_string($this->pluralheader)) {
|
||||
if ($this->enable_cache) {
|
||||
$header = $this->cache_translations[''];
|
||||
} else {
|
||||
$header = $this->get_translation_string(0);
|
||||
$header = $this->getTranslationString(0);
|
||||
}
|
||||
$expr = $this->extract_plural_forms_header_from_po_header($header);
|
||||
$this->pluralheader = $this->sanitize_plural_expression($expr);
|
||||
$expr = $this->extractPluralFormsHeaderFromPoHeader($header);
|
||||
$this->pluralheader = $this->sanitizePluralExpression($expr);
|
||||
}
|
||||
return $this->pluralheader;
|
||||
}
|
||||
@@ -383,9 +400,9 @@ class GetTextReader
|
||||
* @param string $n count
|
||||
* @return int array index of the right plural form
|
||||
*/
|
||||
private function select_string($n)
|
||||
private function selectString($n)
|
||||
{
|
||||
$string = $this->get_plural_forms();
|
||||
$string = $this->getPluralForms();
|
||||
$string = str_replace('nplurals', "\$total", $string);
|
||||
$string = str_replace("n", $n, $string);
|
||||
$string = str_replace('plural', "\$plural", $string);
|
||||
@@ -394,6 +411,7 @@ class GetTextReader
|
||||
$plural = 0;
|
||||
|
||||
eval("$string");
|
||||
/** @phpstan-ignore-next-line */
|
||||
if ($plural >= $total) {
|
||||
$plural = $total - 1;
|
||||
}
|
||||
@@ -420,7 +438,7 @@ class GetTextReader
|
||||
}
|
||||
|
||||
// find out the appropriate form
|
||||
$select = $this->select_string($number);
|
||||
$select = $this->selectString($number);
|
||||
|
||||
// this should contains all strings separated by NULLs
|
||||
$key = $single . chr(0) . $plural;
|
||||
@@ -434,11 +452,11 @@ class GetTextReader
|
||||
return $list[$select];
|
||||
}
|
||||
} else {
|
||||
$num = $this->find_string($key);
|
||||
$num = $this->findString($key);
|
||||
if ($num == -1) {
|
||||
return ($number != 1) ? $plural : $single;
|
||||
} else {
|
||||
$result = $this->get_translation_string($num);
|
||||
$result = $this->getTranslationString($num);
|
||||
$list = explode(chr(0), $result);
|
||||
return $list[$select];
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace CoreLibs\Language\Core;
|
||||
|
||||
class StringReader
|
||||
{
|
||||
/** @var int */
|
||||
public $sr_pos;
|
||||
/** @var string */
|
||||
public $sr_str;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace CoreLibs\Language;
|
||||
|
||||
class Encoding
|
||||
{
|
||||
/** @var string */
|
||||
private static $mb_error_char = '';
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ class Encoding
|
||||
* @param string $string string to test
|
||||
* @param string $from_encoding encoding of string to test
|
||||
* @param string $to_encoding target encoding
|
||||
* @return bool|array false if no error or array with failed characters
|
||||
* @return bool|array<string> false if no error or array with failed characters
|
||||
*/
|
||||
public static function checkConvertEncoding(string $string, string $from_encoding, string $to_encoding)
|
||||
{
|
||||
|
||||
@@ -33,9 +33,13 @@ use CoreLibs\Language\Core\GetTextReader;
|
||||
|
||||
class L10n extends \CoreLibs\Basic
|
||||
{
|
||||
/** @var string */
|
||||
private $lang = '';
|
||||
/** @var string */
|
||||
private $mofile = '';
|
||||
/** @var FileReader|bool */
|
||||
private $input;
|
||||
/** @var GetTextReader */
|
||||
private $l10n;
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,10 @@ class Elements
|
||||
$hour = !$hour ? date('H', $timestamp) : $hour;
|
||||
$min = !$min ? date('i', $timestamp) : $min; // add to five min?
|
||||
// max days in selected month
|
||||
$days_in_month = date('t', strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $min . ':0'));
|
||||
$days_in_month = date(
|
||||
't',
|
||||
strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $min . ':0') ?: null
|
||||
);
|
||||
$string = '';
|
||||
// from now to ?
|
||||
if ($name_pos_back === false) {
|
||||
@@ -93,7 +96,7 @@ class Elements
|
||||
// set weekday text based on current month ($month) and year ($year)
|
||||
$string .= '<option value="' . ($i < 10 ? '0' . $i : $i) . '" '
|
||||
. ($day == $i ? 'selected' : '') . '>' . $i
|
||||
. ' (' . date('D', mktime(0, 0, 0, $month, $i, $year)) . ')</option>';
|
||||
. ' (' . date('D', mktime(0, 0, 0, (int)$month, $i, (int)$year) ?: null) . ')</option>';
|
||||
}
|
||||
$string .= '</select> ';
|
||||
if ($name_pos_back === true) {
|
||||
@@ -142,8 +145,8 @@ class Elements
|
||||
$protList = ["http", "https", "ftp", "news", "nntp"];
|
||||
|
||||
// find urls w/o protocol
|
||||
$output = preg_replace("/([^\/])www\.([\w\.-]+)\.([a-zA-Z]{2,4})/", "\\1http://www.\\2.\\3", $output);
|
||||
$output = preg_replace("/([^\/])ftp\.([\w\.-]+)\.([a-zA-Z]{2,4})/", "\\1ftp://ftp.\\2.\\3", $output);
|
||||
$output = preg_replace("/([^\/])www\.([\w\.-]+)\.([a-zA-Z]{2,4})/", "\\1http://www.\\2.\\3", $output) ?: '';
|
||||
$output = preg_replace("/([^\/])ftp\.([\w\.-]+)\.([a-zA-Z]{2,4})/", "\\1ftp://ftp.\\2.\\3", $output) ?: '';
|
||||
|
||||
// remove doubles, generate protocol-regex
|
||||
// DIRTY HACK
|
||||
@@ -181,7 +184,7 @@ class Elements
|
||||
);
|
||||
},
|
||||
$output
|
||||
);
|
||||
) ?: '';
|
||||
// find email-addresses, but not mailto prefix ones
|
||||
$output = preg_replace_callback(
|
||||
"/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/",
|
||||
@@ -197,7 +200,7 @@ class Elements
|
||||
);
|
||||
},
|
||||
$output
|
||||
);
|
||||
) ?: '';
|
||||
|
||||
// we have one slashes after the Protocol -> internal link no domain, strip out the proto
|
||||
// $output = preg_replace("/($protRegex)\/(.*)/e", "\\2", $ouput);
|
||||
@@ -270,6 +273,9 @@ class Elements
|
||||
return "mailto:" . $email;
|
||||
} elseif ($atag) {
|
||||
return $atag . $email;
|
||||
} else {
|
||||
// else just return email as is
|
||||
return $email;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,51 +222,82 @@ 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 = [];
|
||||
/** @var string */
|
||||
public $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]
|
||||
/** @var int */
|
||||
public $yes; // the yes flag that triggers the template to show ALL and not only new/load
|
||||
/** @var string */
|
||||
public $msg; // the error msg
|
||||
/** @var int */
|
||||
public $error; // the error flag set for printing red error msg
|
||||
/** @var int */
|
||||
public $warning; // warning flag, for information (saved, loaded, etc)
|
||||
/** @var string */
|
||||
public $archive_pk_name; // the pk name for the load select form
|
||||
/** @var string */
|
||||
private $int_pk_name; // primary key, only internal usage
|
||||
/** @var array<mixed> */
|
||||
public $reference_array = []; // reference arrays -> stored in $this->reference_array[$table_name] => [];
|
||||
/** @var array<mixed> */
|
||||
public $element_list; // element list for elements next to each other as a special sub group
|
||||
/** @var array<mixed> */
|
||||
public $table_array = [];
|
||||
/** @var string */
|
||||
public $my_page_name; // the name of the page without .php extension
|
||||
/** @var bool */
|
||||
public $mobile_phone = false;
|
||||
// buttons and checkboxes
|
||||
/** @var string */
|
||||
public $archive;
|
||||
/** @var string */
|
||||
public $new;
|
||||
/** @var string */
|
||||
public $really_new;
|
||||
/** @var string */
|
||||
public $delete;
|
||||
/** @var string */
|
||||
public $really_delete;
|
||||
/** @var string */
|
||||
public $save;
|
||||
/** @var string */
|
||||
public $remove_button;
|
||||
// security publics
|
||||
/** @var int */
|
||||
public $base_acl_level;
|
||||
/** @var array<mixed> */
|
||||
public $security_level;
|
||||
// layout publics
|
||||
/** @var int */
|
||||
public $table_width;
|
||||
// internal lang & encoding vars
|
||||
/** @var string */
|
||||
public $lang_dir = '';
|
||||
/** @var string */
|
||||
public $lang;
|
||||
/** @var string */
|
||||
public $lang_short;
|
||||
/** @var string */
|
||||
public $encoding;
|
||||
// language
|
||||
/** @var \CoreLibs\Language\L10n */
|
||||
public $l;
|
||||
|
||||
// now some default error msgs (english)
|
||||
/** @var array<mixed> */
|
||||
public $language_array = [];
|
||||
|
||||
/**
|
||||
* construct form generator
|
||||
* @param array $db_config db config array
|
||||
* @param int|integer $table_width table/div width (default 750)
|
||||
* @param array<mixed> $db_config db config array
|
||||
* @param int|integer $table_width table/div width (default 750)
|
||||
*/
|
||||
public function __construct(array $db_config, int $table_width = 750)
|
||||
{
|
||||
global $table_arrays;
|
||||
// replace any non valid variable names
|
||||
// TODO extracft only alphanumeric and _ after . to _ replacement
|
||||
$this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1));
|
||||
@@ -278,12 +309,15 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
// first check if we have a in page override as $table_arrays[page name]
|
||||
if (
|
||||
isset($_GLOBALS['table_arrays']) &&
|
||||
is_array($_GLOBALS['table_arrays']) &&
|
||||
isset($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
|
||||
is_array($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)])
|
||||
/* isset($GLOBALS['table_arrays']) &&
|
||||
is_array($GLOBALS['table_arrays']) &&
|
||||
isset($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
|
||||
is_array($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) */
|
||||
isset($table_arrays[\CoreLibs\Get\System::getPageName(1)]) &&
|
||||
is_array($table_arrays[\CoreLibs\Get\System::getPageName(1)])
|
||||
) {
|
||||
$config_array = $_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)];
|
||||
// $config_array = $GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)];
|
||||
$config_array = $table_arrays[\CoreLibs\Get\System::getPageName(1)];
|
||||
} else {
|
||||
// WARNING: auto spl load does not work with this as it is an array and not a function/object
|
||||
// check if this is the old path or the new path
|
||||
@@ -321,9 +355,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (isset($config_array['load_query']) && $config_array['load_query']) {
|
||||
$this->load_query = $config_array['load_query'];
|
||||
}
|
||||
$this->archive_pk_name = 'a_' . $this->pk_name;
|
||||
$this->col_name = str_replace('_id', '', $this->pk_name);
|
||||
$this->int_pk_name = $this->pk_name;
|
||||
$this->archive_pk_name = 'a_' . $this->pk_name ?? '';
|
||||
$this->col_name = str_replace('_id', '', $this->pk_name ?? '');
|
||||
$this->int_pk_name = $this->pk_name ?? '';
|
||||
// check if reference_arrays are given and proceed them
|
||||
if (isset($config_array['reference_arrays']) && is_array($config_array['reference_arrays'])) {
|
||||
foreach ($config_array['reference_arrays'] as $key => $value) {
|
||||
@@ -474,7 +508,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
* array of fields
|
||||
* @param string $want_key the key where you want the data from
|
||||
* @param string|null $key_value if set searches for special right value
|
||||
* @return array found key fields
|
||||
* @return array<mixed> found key fields
|
||||
*/
|
||||
public function formGetColNameArrayFromKey(string $want_key, ?string $key_value = null): array
|
||||
{
|
||||
@@ -496,7 +530,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* formated output for the error && warning msg
|
||||
* @return array error message with msg, width, clas
|
||||
* @return array<string,string|int> error message with msg, width, clas
|
||||
*/
|
||||
public function formPrintMsg(): array
|
||||
{
|
||||
@@ -601,9 +635,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* default delete procedure
|
||||
* @param array $element_list element array that should be removed
|
||||
* @param array $remove_name key names that should be removed
|
||||
* @return void has no return
|
||||
* @param array<mixed> $element_list element array that should be removed
|
||||
* @param array<mixed> $remove_name key names that should be removed
|
||||
* @return void has no return
|
||||
*/
|
||||
public function formProcedureDeleteFromElementList(array $element_list, array $remove_name): void
|
||||
{
|
||||
@@ -700,7 +734,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* create the load list and return it as an array
|
||||
* @return array load list array with primary key, name and selected entry
|
||||
* @return array<string,mixed> load list array with primary key, name and selected entry
|
||||
*/
|
||||
public function formCreateLoad(): array
|
||||
{
|
||||
@@ -717,7 +751,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
// load list data
|
||||
$this->dbExec($this->load_query);
|
||||
while ($res = $this->dbFetchArray()) {
|
||||
while (is_array($res = $this->dbFetchArray())) {
|
||||
$pk_ids[] = $res[$this->int_pk_name];
|
||||
if (
|
||||
isset($this->table_array[$this->int_pk_name]['value']) &&
|
||||
@@ -762,8 +796,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* Create new entry element for HTML output
|
||||
* @param bool $hide_new_checkbox show or hide the new checkbox, default is false
|
||||
* @return array return the new create array with name & checkbox show flag
|
||||
* @param bool $hide_new_checkbox show or hide the new checkbox, default is false
|
||||
* @return array<string,string|int> return the new create array with name & checkbox show flag
|
||||
*/
|
||||
public function formCreateNew($hide_new_checkbox = false): array
|
||||
{
|
||||
@@ -794,7 +828,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
* create the save and delete element html group data
|
||||
* @param bool $hide_delete hide the delete button (default false)
|
||||
* @param bool $hide_delete_checkbox hide the delete checkbox (default false)
|
||||
* @return array return the hide/show delete framework for html creation
|
||||
* @return array<string,mixed> return the hide/show delete framework
|
||||
* for html creation
|
||||
*/
|
||||
public function formCreateSaveDelete($hide_delete = false, $hide_delete_checkbox = false): array
|
||||
{
|
||||
@@ -810,7 +845,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
(isset($this->security_level['delete']) &&
|
||||
$this->base_acl_level >= $this->security_level['delete'])
|
||||
) {
|
||||
$old_school_hidden = 0;
|
||||
if ($this->base_acl_level >= $this->security_level['save']) {
|
||||
$seclevel_okay = 1;
|
||||
if (empty($this->table_array[$this->int_pk_name]['value'])) {
|
||||
@@ -819,7 +853,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$save = $this->l->__('Update');
|
||||
}
|
||||
// print the old_school hidden if requestet
|
||||
if ($old_school_hidden) {
|
||||
if ($old_school_hidden == 1) {
|
||||
$pk_name = $this->int_pk_name;
|
||||
$pk_value = $this->table_array[$this->int_pk_name]['value'];
|
||||
}
|
||||
@@ -850,8 +884,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
* @param string $element_name the name from the array, you want to have build
|
||||
* @param string|null $query can overrule internal query data,
|
||||
* for drop down, as data comes from a reference table
|
||||
* for drop_down_text it has to be an array with $key->$valu
|
||||
* @return array html settings array
|
||||
* for drop_down_text it has to be an
|
||||
* array with $key->$value
|
||||
* @return array<string,mixed> html settings array
|
||||
*/
|
||||
public function formCreateElement(string $element_name, ?string $query = null): array
|
||||
{
|
||||
@@ -990,7 +1025,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$data['name'] = $element_name;
|
||||
$data['value'][] = '';
|
||||
$data['output'][] = $this->l->__('Please choose .. . ');
|
||||
while ($res = $this->dbReturn($query)) {
|
||||
while (is_array($res = $this->dbReturn($query))) {
|
||||
$data['value'][] = $res[0];
|
||||
$data['output'][] = $res[1];
|
||||
if (
|
||||
@@ -1270,7 +1305,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// if mandatory && no input
|
||||
// $this->log->debug('form', 'A: ' . $this->table_array[$key]['type'] . ' -- '
|
||||
// . $this->table_array[$key]['input_value'] . ' -- ' . $this->table_array[$key]['value']);
|
||||
if (!$this->table_array[$key]['value'] && $this->table_array[$key]['type'] != 'binary') {
|
||||
if (
|
||||
empty($this->table_array[$key]['value']) &&
|
||||
$this->table_array[$key]['type'] != 'binary'
|
||||
) {
|
||||
$this->msg .= sprintf(
|
||||
$this->l->__('Please enter something into the <b>%s</b> field!<br>'),
|
||||
$this->table_array[$key]['output_name']
|
||||
@@ -1303,22 +1341,18 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
} // while
|
||||
// do check for reference tables
|
||||
if (is_array($this->reference_array)) {
|
||||
reset($this->reference_array);
|
||||
foreach ($this->reference_array as $key => $value) {
|
||||
if (
|
||||
isset($this->reference_array[$key]['mandatory']) &&
|
||||
$this->reference_array[$key]['mandatory'] &&
|
||||
!$this->reference_array[$key]['selected'][0]
|
||||
) {
|
||||
$this->msg .= sprintf(
|
||||
$this->l->__('Please select at least one Element from field <b>%s</b>!<br>'),
|
||||
$this->reference_array[$key]['output_name']
|
||||
);
|
||||
}
|
||||
reset($this->reference_array);
|
||||
foreach ($this->reference_array as $key => $value) {
|
||||
if (
|
||||
isset($this->reference_array[$key]['mandatory']) &&
|
||||
$this->reference_array[$key]['mandatory'] &&
|
||||
!$this->reference_array[$key]['selected'][0]
|
||||
) {
|
||||
$this->msg .= sprintf(
|
||||
$this->l->__('Please select at least one Element from field <b>%s</b>!<br>'),
|
||||
$this->reference_array[$key]['output_name']
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->reference_array = [];
|
||||
}
|
||||
// $this->log->debug('edit_error', 'QS: <pre>' . print_r($_POST, true) . '</pre>');
|
||||
if (is_array($this->element_list)) {
|
||||
@@ -1496,7 +1530,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* sets the order to the maximum, if order flag is set in array
|
||||
* @return array table array with set order number
|
||||
* @return array<mixed> table array with set order number
|
||||
*/
|
||||
public function formSetOrder(): array
|
||||
{
|
||||
@@ -1505,7 +1539,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($order_name) {
|
||||
// first check out of order ...
|
||||
|
||||
if (!$this->table_array[$order_name]['value']) {
|
||||
if (empty($this->table_array[$order_name]['value'])) {
|
||||
// set order (read max)
|
||||
$q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name;
|
||||
list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q);
|
||||
@@ -1513,7 +1547,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (!$this->table_array[$order_name]['value']) {
|
||||
$this->table_array[$order_name]['value'] = 1;
|
||||
}
|
||||
} elseif ($this->table_array[$this->int_pk_name]['value']) {
|
||||
} elseif (!empty($this->table_array[$this->int_pk_name]['value'])) {
|
||||
$q = 'SELECT ' . $order_name
|
||||
. ' FROM ' . $this->table_name
|
||||
. ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
|
||||
@@ -1587,7 +1621,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$q = 'SELECT ' . $this->reference_array[$key]['other_table_pk']
|
||||
. ' FROM ' . $this->reference_array[$key]['table_name']
|
||||
. ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$this->reference_array[$key]['selected'][] = $res[$this->reference_array[$key]['other_table_pk']];
|
||||
}
|
||||
}
|
||||
@@ -1640,14 +1674,14 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
. ' (' . $this->table_array[$key]['input_name'] . ') VALUES ('
|
||||
. "'" . $this->dbEscapeString($this->table_array[$key]['input_value']) . "')";
|
||||
$this->dbExec($q);
|
||||
if (!empty($this->table_array[$key]['where'])) {
|
||||
if (!empty($this->table_array[$key]['where']) && is_numeric($this->dbGetInsertPK())) {
|
||||
// make an update on the just inseted data with the where data als update values
|
||||
$q = 'UPDATE ' . $this->table_array[$key]['table_name'] . ' SET ';
|
||||
$q .= $this->table_array[$key]['where'] . ' ';
|
||||
$q .= 'WHERE ' . $this->table_array[$key]['pk_name'] . ' = ' . $this->insert_id;
|
||||
$q .= 'WHERE ' . $this->table_array[$key]['pk_name'] . ' = ' . $this->dbGetInsertPK();
|
||||
$this->dbExec($q);
|
||||
}
|
||||
$this->table_array[$key]['value'] = $this->insert_id;
|
||||
$this->table_array[$key]['value'] = $this->dbGetInsertPK();
|
||||
} // set value from DB through select or insert
|
||||
unset($this->table_array[$key]['input_value']);
|
||||
} // if it is certain field type && if there is something in the temp field
|
||||
@@ -2033,8 +2067,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* creates HTML hidden input fields out of an hash array
|
||||
* @param array $hidden_array The list of fields to be added as hidden
|
||||
* @return array key -> value list of hidden fileds data
|
||||
* @param array<mixed> $hidden_array The list of fields to be added as hidden
|
||||
* @return array<mixed> key -> value list of hidden fileds data
|
||||
*/
|
||||
public function formCreateHiddenFields(array $hidden_array = []): array
|
||||
{
|
||||
@@ -2066,8 +2100,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
/**
|
||||
* creates the multiple select part for a reference_table
|
||||
* @param string $table_name Table name for reference array lookup
|
||||
* @return array Reference table output array
|
||||
* @param string $table_name Table name for reference array lookup
|
||||
* @return array<string,mixed> Reference table output array
|
||||
*/
|
||||
public function formCreateElementReferenceTable(string $table_name): array
|
||||
{
|
||||
@@ -2081,7 +2115,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
$data['name'] = $this->reference_array[$table_name]['other_table_pk'];
|
||||
$data['size'] = $this->reference_array[$table_name]['select_size'];
|
||||
while ($res = $this->dbReturn($this->reference_array[$table_name]['query'])) {
|
||||
while (is_array($res = $this->dbReturn($this->reference_array[$table_name]['query']))) {
|
||||
$data['value'][] = $res[0];
|
||||
$data['output'][] = $res[1];
|
||||
$data['selected'][] = (\CoreLibs\Convert\Html::checked(
|
||||
@@ -2103,8 +2137,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
* this currently only works for a list that is filled from a sub table and creates
|
||||
* only a connection to this one new version will allow a sub list with free input
|
||||
* fields to directly fill a sub table to a master table
|
||||
* @param string $table_name which element entry to create
|
||||
* @return array element for html creation
|
||||
* @param string $table_name Which element entry to create
|
||||
* @return array<string,mixed> Element for html creation
|
||||
*/
|
||||
public function formCreateElementListTable(string $table_name): array
|
||||
{
|
||||
@@ -2183,7 +2217,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// only two elements are allowed: pos 0 is key, pso 1 is visible output name
|
||||
if (isset($data_array['type']) && $data_array['type'] == 'drop_down_db') {
|
||||
$md_q = md5($data_array['query']);
|
||||
while ($res = $this->dbReturn($data_array['query'])) {
|
||||
while (is_array($res = $this->dbReturn($data_array['query']))) {
|
||||
/** @phan-suppress-next-line PhanTypeInvalidDimOffset */
|
||||
$this->log->debug('edit', 'Q[' . $md_q . '] pos: ' . $this->cursor_ext[$md_q]['pos']
|
||||
. ' | want: ' . ($data_array['preset'] ?? '-')
|
||||
@@ -2326,7 +2360,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (isset($q)) {
|
||||
$pos = 0; // position in while for overwrite if needed
|
||||
// read out the list and add the selected data if needed
|
||||
while ($res = $this->dbReturn($q)) {
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$_data = [];
|
||||
$prfx = $data['prefix'] ?? ''; // short
|
||||
// go through each res
|
||||
@@ -2377,7 +2411,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->element_list[$table_name]['max_empty'] = 10;
|
||||
}
|
||||
// check if we need to fill fields
|
||||
$element_count = (isset($data['content']) && is_array($data['content'])) ? count($data['content']) : 0;
|
||||
$element_count = count($data['content'] ?? []);
|
||||
$missing_empty_count = $this->element_list[$table_name]['max_empty'] - $element_count;
|
||||
$this->log->debug('CFG MAX', 'Max empty: '
|
||||
. $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count
|
||||
|
||||
@@ -127,13 +127,13 @@ class Image
|
||||
$return_data = $thumb;
|
||||
// if we have a delete filename, delete here with glob
|
||||
if ($delete_filename) {
|
||||
array_map('unlink', glob($delete_filename . '*'));
|
||||
array_map('unlink', glob($delete_filename . '*') ?: []);
|
||||
}
|
||||
} else {
|
||||
if ($dummy && strstr($dummy, '/') === false) {
|
||||
if (!empty($dummy) && strstr($dummy, '/') === false) {
|
||||
// check if we have the "dummy" image flag set
|
||||
$filename = PICTURES . ICONS . strtoupper($dummy) . ".png";
|
||||
if ($dummy && file_exists($filename) && is_file($filename)) {
|
||||
if (!empty($dummy) && file_exists($filename) && is_file($filename)) {
|
||||
$return_data = $filename;
|
||||
} else {
|
||||
$return_data = false;
|
||||
@@ -255,11 +255,18 @@ class Image
|
||||
) {
|
||||
// image, copy source image, offset in image, source x/y, new size, source image size
|
||||
$thumb = imagecreatetruecolor($thumb_width_r, $thumb_height_r);
|
||||
if ($thumb === false) {
|
||||
return false;
|
||||
}
|
||||
if ($img_type == IMAGETYPE_PNG) {
|
||||
$imagecolorallocatealpha = imagecolorallocatealpha($thumb, 0, 0, 0, 127);
|
||||
if ($imagecolorallocatealpha === false) {
|
||||
return false;
|
||||
}
|
||||
// preservere transaprency
|
||||
imagecolortransparent(
|
||||
$thumb,
|
||||
imagecolorallocatealpha($thumb, 0, 0, 0, 127)
|
||||
$imagecolorallocatealpha
|
||||
);
|
||||
imagealphablending($thumb, false);
|
||||
imagesavealpha($thumb, true);
|
||||
@@ -274,7 +281,7 @@ class Image
|
||||
break;
|
||||
}
|
||||
// check that we have a source image resource
|
||||
if ($source !== null) {
|
||||
if ($source !== null && $source !== false) {
|
||||
// resize no shift
|
||||
if ($high_quality === true) {
|
||||
imagecopyresized(
|
||||
@@ -356,10 +363,16 @@ class Image
|
||||
$thumb_width = 250;
|
||||
}
|
||||
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
|
||||
if ($thumb === false) {
|
||||
return false;
|
||||
}
|
||||
// add outside border px = 5% (rounded up)
|
||||
// eg 50px -> 2.5px
|
||||
$gray = imagecolorallocate($thumb, 200, 200, 200);
|
||||
$white = imagecolorallocate($thumb, 255, 255, 255);
|
||||
if ($gray === false || $white === false) {
|
||||
return false;
|
||||
}
|
||||
// fill gray background
|
||||
imagefill($thumb, 0, 0, $gray);
|
||||
// now create rectangle
|
||||
@@ -407,55 +420,66 @@ class Image
|
||||
*/
|
||||
public static function correctImageOrientation($filename): void
|
||||
{
|
||||
if (function_exists('exif_read_data') && is_writeable($filename)) {
|
||||
list($inc_width, $inc_height, $img_type) = getimagesize($filename);
|
||||
// add @ to avoid "file not supported error"
|
||||
$exif = @exif_read_data($filename);
|
||||
$orientation = null;
|
||||
$img = null;
|
||||
if ($exif && isset($exif['Orientation'])) {
|
||||
$orientation = $exif['Orientation'];
|
||||
}
|
||||
if ($orientation != 1) {
|
||||
switch ($img_type) {
|
||||
case IMAGETYPE_JPEG:
|
||||
$img = imagecreatefromjpeg($filename);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
$img = imagecreatefrompng($filename);
|
||||
break;
|
||||
}
|
||||
$deg = 0;
|
||||
// 1 top, 6: left, 8: right, 3: bottom
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$deg = 180;
|
||||
break;
|
||||
case 6:
|
||||
$deg = -90;
|
||||
break;
|
||||
case 8:
|
||||
$deg = 90;
|
||||
break;
|
||||
}
|
||||
if ($img !== null) {
|
||||
if ($deg) {
|
||||
$img = imagerotate($img, $deg, 0);
|
||||
}
|
||||
// then rewrite the rotated image back to the disk as $filename
|
||||
switch ($img_type) {
|
||||
case IMAGETYPE_JPEG:
|
||||
imagejpeg($img, $filename);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
imagepng($img, $filename);
|
||||
break;
|
||||
}
|
||||
// clean up image if we have an image
|
||||
imagedestroy($img);
|
||||
}
|
||||
} // only if we need to rotate
|
||||
} // function exists & file is writeable, else do nothing
|
||||
// function exists & file is writeable, else do nothing
|
||||
if (!function_exists('exif_read_data') || !is_writeable($filename)) {
|
||||
return;
|
||||
}
|
||||
list($inc_width, $inc_height, $img_type) = getimagesize($filename);
|
||||
// add @ to avoid "file not supported error"
|
||||
$exif = @exif_read_data($filename);
|
||||
$orientation = null;
|
||||
$img = null;
|
||||
if ($exif && isset($exif['Orientation'])) {
|
||||
$orientation = $exif['Orientation'];
|
||||
}
|
||||
// only if we need to rotate, if 1 it is already upright
|
||||
if ($orientation === null || $orientation == 1) {
|
||||
return;
|
||||
}
|
||||
switch ($img_type) {
|
||||
case IMAGETYPE_JPEG:
|
||||
$img = imagecreatefromjpeg($filename);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
$img = imagecreatefrompng($filename);
|
||||
break;
|
||||
}
|
||||
// no image loaded (wrong type)
|
||||
if ($img === null || $img === false) {
|
||||
return;
|
||||
}
|
||||
$deg = 0;
|
||||
// 1 top, 6: left, 8: right, 3: bottom
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$deg = 180;
|
||||
break;
|
||||
case 6:
|
||||
$deg = -90;
|
||||
break;
|
||||
case 8:
|
||||
$deg = 90;
|
||||
break;
|
||||
}
|
||||
// rotate if needed
|
||||
if ($deg) {
|
||||
$img = imagerotate($img, $deg, 0);
|
||||
}
|
||||
// rotate failed
|
||||
if ($img === false) {
|
||||
return;
|
||||
}
|
||||
// then rewrite the rotated image back to the disk as $filename
|
||||
switch ($img_type) {
|
||||
case IMAGETYPE_JPEG:
|
||||
imagejpeg($img, $filename);
|
||||
break;
|
||||
case IMAGETYPE_PNG:
|
||||
imagepng($img, $filename);
|
||||
break;
|
||||
}
|
||||
// clean up image if we have an image
|
||||
imagedestroy($img);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,13 @@ class ProgressBar
|
||||
{
|
||||
// private vars
|
||||
|
||||
/** @var string */
|
||||
public $code; // unique code
|
||||
/** @var string */
|
||||
public $status = 'new'; // current status (new,show,hide)
|
||||
/** @var float|int */
|
||||
public $step = 0; // current step
|
||||
/** @var array<string,?int> */
|
||||
public $position = [ // current bar position
|
||||
'left' => null,
|
||||
'top' => null,
|
||||
@@ -32,27 +36,43 @@ class ProgressBar
|
||||
'height' => null,
|
||||
];
|
||||
|
||||
/** @var int */
|
||||
public $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 vars
|
||||
|
||||
/** @var int */
|
||||
public $min = 0; // minimal steps
|
||||
/** @var int */
|
||||
public $max = 100; // maximal steps
|
||||
|
||||
/** @var int */
|
||||
public $left = 5; // bar position from left
|
||||
/** @var int */
|
||||
public $top = 5; // bar position from top
|
||||
/** @var int */
|
||||
public $width = 300; // bar width
|
||||
/** @var int */
|
||||
public $height = 25; // bar height
|
||||
/** @var int */
|
||||
public $pedding = 0; // bar pedding
|
||||
/** @var string */
|
||||
public $color = '#0033ff'; // bar color
|
||||
/** @var string */
|
||||
public $bgr_color = '#c0c0c0'; // bar background color
|
||||
/** @var string */
|
||||
public $bgr_color_master = '#ffffff'; // master div background color
|
||||
/** @var int */
|
||||
public $border = 1; // bar border width
|
||||
/** @var string */
|
||||
public $brd_color = '#000000'; // bar border color
|
||||
|
||||
/** @var string */
|
||||
public $direction = 'right'; // direction of motion (right,left,up,down)
|
||||
|
||||
/** @var array<string,mixed> */
|
||||
public $frame = ['show' => false]; // ProgressBar Frame
|
||||
/* 'show' => false, # frame show (true/false)
|
||||
'left' => 200, # frame position from left
|
||||
@@ -64,6 +84,7 @@ class ProgressBar
|
||||
'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color
|
||||
*/
|
||||
|
||||
/** @var array<mixed> */
|
||||
public $label = []; // ProgressBar Labels
|
||||
/* 'name' => [ # label name
|
||||
'type' => 'text', # label type (text,button,step,percent,crossbar)
|
||||
@@ -81,6 +102,7 @@ class ProgressBar
|
||||
]
|
||||
*/
|
||||
|
||||
/** @var string */
|
||||
// output strings
|
||||
public $prefix_message = '';
|
||||
|
||||
@@ -141,8 +163,8 @@ class ProgressBar
|
||||
|
||||
/**
|
||||
* calculate position in bar step
|
||||
* @param float $step percent step to do
|
||||
* @return array bar position as array
|
||||
* @param float $step percent step to do
|
||||
* @return array<mixed> bar position as array
|
||||
*/
|
||||
private function __calculatePosition(float $step): array
|
||||
{
|
||||
@@ -201,8 +223,8 @@ class ProgressBar
|
||||
|
||||
/**
|
||||
* set the step
|
||||
* @param float $step percent step to do
|
||||
* @return void has no return
|
||||
* @param float $step percent step to do
|
||||
* @return void
|
||||
*/
|
||||
private function __setStep(float $step): void
|
||||
{
|
||||
@@ -220,7 +242,7 @@ class ProgressBar
|
||||
* set frame layout
|
||||
* @param integer $width bar width
|
||||
* @param integer $height bar height
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setFrame(int $width = 0, int $height = 0): void
|
||||
{
|
||||
@@ -249,7 +271,7 @@ class ProgressBar
|
||||
* @param string $type label type
|
||||
* @param string $name label name (internal)
|
||||
* @param string $value label output name (optional)
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function addLabel(string $type, string $name, string $value = ' '): void
|
||||
{
|
||||
@@ -355,7 +377,7 @@ class ProgressBar
|
||||
* @param string $value button text (output)
|
||||
* @param string $action button action (link)
|
||||
* @param string $target button action target (default self)
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function addButton(string $name, string $value, string $action, string $target = 'self'): void
|
||||
{
|
||||
@@ -372,7 +394,7 @@ class ProgressBar
|
||||
* @param int $width width px
|
||||
* @param int $height height px
|
||||
* @param string $align alignment (left/right/etc), default empty
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setLabelPosition(
|
||||
string $name,
|
||||
@@ -418,7 +440,7 @@ class ProgressBar
|
||||
* set label color
|
||||
* @param string $name label name to set
|
||||
* @param string $color color value in rgb html hex
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setLabelColor(string $name, string $color): void
|
||||
{
|
||||
@@ -434,7 +456,7 @@ class ProgressBar
|
||||
* set the label background color
|
||||
* @param string $name label name to set
|
||||
* @param string $color background color to set in rgb html hex
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setLabelBackground(string $name, string $color): void
|
||||
{
|
||||
@@ -452,7 +474,7 @@ class ProgressBar
|
||||
* @param int $size font size in px
|
||||
* @param string $family font family (default empty)
|
||||
* @param string $weight font weight (default empty)
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setLabelFont(string $name, int $size, string $family = '', string $weight = ''): void
|
||||
{
|
||||
@@ -501,7 +523,7 @@ class ProgressBar
|
||||
* set the label valeu
|
||||
* @param string $name label name to set
|
||||
* @param string $value label value (output)
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setLabelValue(string $name, string $value): void
|
||||
{
|
||||
@@ -517,7 +539,7 @@ class ProgressBar
|
||||
/**
|
||||
* set the bar color
|
||||
* @param string $color color for the progress bar in rgb html hex
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setBarColor(string $color): void
|
||||
{
|
||||
@@ -532,7 +554,7 @@ class ProgressBar
|
||||
/**
|
||||
* set the progress bar background color
|
||||
* @param string $color background color in rgb html hex
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setBarBackground(string $color): void
|
||||
{
|
||||
@@ -547,7 +569,7 @@ class ProgressBar
|
||||
/**
|
||||
* progress bar direct (left/right)
|
||||
* @param string $direction set direction as left/right
|
||||
* @return void has no return
|
||||
* @return void
|
||||
*/
|
||||
public function setBarDirection(string $direction): void
|
||||
{
|
||||
|
||||
@@ -361,6 +361,11 @@ class SmartyExtend extends SmartyBC
|
||||
$this->HEADER['ENCODING'] = $this->encoding;
|
||||
$this->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
|
||||
// form name
|
||||
$this->DATA['FORM_NAME'] = !$this->FORM_NAME ?
|
||||
str_replace('.php', '', $this->page_name) :
|
||||
$this->FORM_NAME;
|
||||
$this->DATA['FORM_ACTION'] = $this->FORM_ACTION;
|
||||
// special for admin
|
||||
if ($admin_call === true) {
|
||||
// set ACL extra show
|
||||
@@ -385,6 +390,7 @@ class SmartyExtend extends SmartyBC
|
||||
// the page name
|
||||
$this->DATA['page_name'] = $this->page_name;
|
||||
$this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH;
|
||||
$this->DATA['form_name'] = $this->DATA['FORM_NAME'];
|
||||
// for tinymce special
|
||||
$this->DATA['TINYMCE_LANG'] = $this->lang_short;
|
||||
// include flags
|
||||
@@ -404,11 +410,6 @@ class SmartyExtend extends SmartyBC
|
||||
|
||||
// LANG
|
||||
$this->DATA['LANG'] = $this->lang;
|
||||
// form name
|
||||
$this->DATA['FORM_NAME'] = !$this->FORM_NAME ?
|
||||
str_replace('.php', '', $this->page_name) :
|
||||
$this->FORM_NAME;
|
||||
$this->DATA['FORM_ACTION'] = $this->FORM_ACTION;
|
||||
// include flags
|
||||
$this->DATA['JS_DATEPICKR'] = $this->JS_DATEPICKR;
|
||||
$this->DATA['JS_FLATPICKR'] = $this->JS_FLATPICKR;
|
||||
|
||||
@@ -1,38 +1,33 @@
|
||||
<?php
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
/*********************************************************************
|
||||
* AUTHOR: Clemens Schwaighofer
|
||||
* CREATED: 2011/2/8
|
||||
* DESCRIPTION: pre function to collect all non critical errors into a log file if possible
|
||||
* include this file at the very beginning of the script to get the notices, strict, etc messages.
|
||||
* DESCRIPTION: pre function to collect all non critical errors
|
||||
* into a log file if possible
|
||||
* include this file at the very beginning of the script to get the notices,
|
||||
* strict, etc messages.
|
||||
* error etc will still be written to the log/display
|
||||
*********************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// define the base working directory outside because in the function it might return undefined
|
||||
// if we have config set BASE use this
|
||||
if (defined('BASE')) {
|
||||
DEFINE('CURRENT_WORKING_DIR', BASE);
|
||||
} else {
|
||||
// else we set. We fully assuem that Error.Handling is where it should be, in lib dir
|
||||
DEFINE('CURRENT_WORKING_DIR', str_replace('lib', '', __DIR__));
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* will catch any error except E_ERROR and try to write them to the log file
|
||||
* in log/php_error-<DAY>.log
|
||||
* if this fails, it will print the data to the window via echo
|
||||
* @param int $type the error code from PHP
|
||||
* @param string $message the error message from php
|
||||
* @param string $file in which file the error happend. this is the source file (eg include)
|
||||
* @param int $line in which line the error happened
|
||||
* @param array $context array with all the variable
|
||||
* @return bool true, so cought errors do not get processed by the PHP error engine
|
||||
* @param int $type the error code from PHP
|
||||
* @param string $message the error message from php
|
||||
* @param string $file in which file the error happend.
|
||||
* this is the source file (eg include)
|
||||
* @param int $line in which line the error happened
|
||||
* @param array<mixed> $context array with all the variable
|
||||
* @return bool True, so cought errors do not get processed
|
||||
* by the PHP error engine
|
||||
*/
|
||||
function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool
|
||||
{
|
||||
if (!(error_reporting() & $type) && !SHOW_ALL_ERRORS) {
|
||||
if (!(error_reporting() & $type) && empty(SHOW_ALL_ERRORS)) {
|
||||
// This error code is not included in error_reporting
|
||||
return false;
|
||||
}
|
||||
@@ -67,8 +62,15 @@ function MyErrorHandler(int $type, string $message, string $file, int $line, arr
|
||||
// : the php error message
|
||||
$output = '{' . array_pop($page_temp) . '} [' . $file . '] '
|
||||
. '<' . $line . '> [' . $error_level[$type] . '|' . $type . ']: ' . $message;
|
||||
# try to open file
|
||||
$ROOT = CURRENT_WORKING_DIR;
|
||||
// define the base working directory outside because in the function it might return undefined
|
||||
// if we have config set BASE use this
|
||||
$ROOT = '';
|
||||
if (defined('BASE')) {
|
||||
$ROOT = BASE;
|
||||
} else {
|
||||
// else we set. We fully assuem that Error.Handling is where it should be, in lib dir
|
||||
$ROOT = str_replace('lib', '', __DIR__);
|
||||
}
|
||||
$LOG = 'log' . DIRECTORY_SEPARATOR;
|
||||
// if the log folder is not found, try to create it
|
||||
if (!is_dir($ROOT . $LOG) && !is_file($ROOT . LOG)) {
|
||||
|
||||
32
www/lib/FileUpload/Core/qqUploadedFile.php
Normal file
32
www/lib/FileUpload/Core/qqUploadedFile.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace FileUpload\Core;
|
||||
|
||||
interface qqUploadedFile // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean TRUE on success
|
||||
*/
|
||||
public function save(string $path): bool;
|
||||
|
||||
/**
|
||||
* get qqfile name from _GET array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Get file size from _SERVERa array, throws an error if not possible
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSize(): int;
|
||||
}
|
||||
|
||||
// __END__
|
||||
@@ -5,26 +5,40 @@ namespace FileUpload\Core;
|
||||
/**
|
||||
* Handle file uploads via regular form post (uses the $_FILES array)
|
||||
*/
|
||||
class qqUploadedFileForm
|
||||
class qqUploadedFileForm implements qqUploadedFile // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean TRUE on success
|
||||
*/
|
||||
public function save($path)
|
||||
public function save(string $path): bool
|
||||
{
|
||||
if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function getName()
|
||||
|
||||
/**
|
||||
* get qqfile name from _FILES array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $_FILES['qqfile']['name'];
|
||||
return $_FILES['qqfile']['name'] ?? '';
|
||||
}
|
||||
public function getSize()
|
||||
|
||||
/**
|
||||
* get files size from _FILES array
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize(): int
|
||||
{
|
||||
return $_FILES['qqfile']['size'];
|
||||
return (int)$_FILES['qqfile']['size'] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,16 +5,22 @@ namespace FileUpload\Core;
|
||||
/**
|
||||
* Handle file uploads via XMLHttpRequest
|
||||
*/
|
||||
class qqUploadedFileXhr
|
||||
class qqUploadedFileXhr implements qqUploadedFile // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean TRUE on success
|
||||
*/
|
||||
public function save($path)
|
||||
public function save(string $path): bool
|
||||
{
|
||||
$input = fopen("php://input", "r");
|
||||
$temp = tmpfile();
|
||||
// abort if not resources
|
||||
if (!is_resource($input) || !is_resource($temp)) {
|
||||
return false;
|
||||
}
|
||||
$realSize = stream_copy_to_stream($input, $temp);
|
||||
fclose($input);
|
||||
|
||||
@@ -23,17 +29,34 @@ class qqUploadedFileXhr
|
||||
}
|
||||
|
||||
$target = fopen($path, "w");
|
||||
if (!is_resource($target)) {
|
||||
return false;
|
||||
}
|
||||
fseek($temp, 0, SEEK_SET);
|
||||
stream_copy_to_stream($temp, $target);
|
||||
fclose($target);
|
||||
|
||||
return true;
|
||||
}
|
||||
public function getName()
|
||||
|
||||
/**
|
||||
* get qqfile name from _GET array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $_GET['qqfile'];
|
||||
return $_GET['qqfile'] ?? '';
|
||||
}
|
||||
public function getSize()
|
||||
|
||||
/**
|
||||
* Get file size from _SERVERa array, throws an error if not possible
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSize(): int
|
||||
{
|
||||
if (isset($_SERVER['CONTENT_LENGTH'])) {
|
||||
return (int)$_SERVER['CONTENT_LENGTH'];
|
||||
|
||||
@@ -2,17 +2,29 @@
|
||||
|
||||
namespace FileUpload;
|
||||
|
||||
// use \FileUpload\Core;
|
||||
use FileUpload\Core;
|
||||
|
||||
class qqFileUploader
|
||||
// TODO: find all usages from qqFileUploader and name to Qq
|
||||
class qqFileUploader // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
{
|
||||
private $allowedExtensions = array();
|
||||
/** @var array<mixed> */
|
||||
private $allowedExtensions = [];
|
||||
/** @var int */
|
||||
private $sizeLimit = 10485760;
|
||||
/** @var null|Core\qqUploadedFileXhr|Core\qqUploadedFileForm */
|
||||
private $file;
|
||||
/** @var string */
|
||||
public $uploadFileName;
|
||||
/** @var string */
|
||||
public $uploadFileExt;
|
||||
|
||||
public function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760)
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array<mixed> $allowedExtensions
|
||||
* @param integer $sizeLimit
|
||||
*/
|
||||
public function __construct(array $allowedExtensions = [], int $sizeLimit = 10485760)
|
||||
{
|
||||
$allowedExtensions = array_map("strtolower", $allowedExtensions);
|
||||
|
||||
@@ -22,18 +34,23 @@ class qqFileUploader
|
||||
$this->checkServerSettings();
|
||||
|
||||
if (isset($_GET['qqfile'])) {
|
||||
$this->file = new \FileUpload\Core\qqUploadedFileXhr();
|
||||
$this->file = new Core\qqUploadedFileXhr();
|
||||
} elseif (isset($_FILES['qqfile'])) {
|
||||
$this->file = new \FileUpload\Core\qqUploadedFileForm();
|
||||
$this->file = new Core\qqUploadedFileForm();
|
||||
} else {
|
||||
$this->file = false;
|
||||
$this->file = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function checkServerSettings()
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function checkServerSettings(): void
|
||||
{
|
||||
$postSize = $this->toBytes(ini_get('post_max_size'));
|
||||
$uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
|
||||
$postSize = $this->toBytes(ini_get('post_max_size') ?: '');
|
||||
$uploadSize = $this->toBytes(ini_get('upload_max_filesize') ?: '');
|
||||
|
||||
if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit) {
|
||||
$size = max(1, $this->sizeLimit / 1024 / 1024) . 'M';
|
||||
@@ -41,10 +58,16 @@ class qqFileUploader
|
||||
}
|
||||
}
|
||||
|
||||
private function toBytes($str)
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $str
|
||||
* @return integer
|
||||
*/
|
||||
private function toBytes(string $str): int
|
||||
{
|
||||
$val = (int)trim($str);
|
||||
$last = strtolower($str[strlen($str)-1]);
|
||||
$last = strtolower($str[strlen($str) - 1]);
|
||||
switch ($last) {
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
@@ -59,36 +82,42 @@ class qqFileUploader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array('success'=>true) or array('error'=>'error message')
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $uploadDirectory
|
||||
* @param boolean $replaceOldFile
|
||||
* @return array<string,string|bool> Returns ['success'=>true] or
|
||||
* ['error'=>'error message']
|
||||
*/
|
||||
public function handleUpload($uploadDirectory, $replaceOldFile = false)
|
||||
public function handleUpload(string $uploadDirectory, bool $replaceOldFile = false): array
|
||||
{
|
||||
if (!is_writable($uploadDirectory)) {
|
||||
return array('error' => "Server error. Upload directory isn't writable.");
|
||||
return ['error' => "Server error. Upload directory isn't writable."];
|
||||
}
|
||||
|
||||
if (!$this->file) {
|
||||
return array('error' => 'No files were uploaded.');
|
||||
if (!is_object($this->file)) {
|
||||
return ['error' => 'No files were uploaded.'];
|
||||
}
|
||||
|
||||
$size = 0;
|
||||
$size = $this->file->getSize();
|
||||
|
||||
if ($size == 0) {
|
||||
return array('error' => 'File is empty');
|
||||
return ['error' => 'File is empty'];
|
||||
}
|
||||
|
||||
if ($size > $this->sizeLimit) {
|
||||
return array('error' => 'File is too large');
|
||||
return ['error' => 'File is too large'];
|
||||
}
|
||||
|
||||
$pathinfo = pathinfo($this->file->getName());
|
||||
$filename = $pathinfo['filename'];
|
||||
$filename = $pathinfo['filename'] ?? '';
|
||||
//$filename = md5(uniqid());
|
||||
$ext = $pathinfo['extension'] ?? '';
|
||||
|
||||
if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
|
||||
$these = implode(', ', $this->allowedExtensions);
|
||||
return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');
|
||||
return ['error' => 'File has an invalid extension, it should be one of ' . $these . '.'];
|
||||
}
|
||||
|
||||
if (!$replaceOldFile) {
|
||||
@@ -102,10 +131,12 @@ class qqFileUploader
|
||||
$this->uploadFileExt = $ext;
|
||||
|
||||
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) {
|
||||
return array('success' => true);
|
||||
return ['success' => true];
|
||||
} else {
|
||||
return array('error' => 'Could not save uploaded file.' .
|
||||
'The upload was cancelled, or server error encountered');
|
||||
return [
|
||||
'error' => 'Could not save uploaded file.' .
|
||||
'The upload was cancelled, or server error encountered'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
58
www/lib/Test/DB/TestDB.php
Normal file
58
www/lib/Test/DB/TestDB.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* TEST sets for DB::IO
|
||||
*/
|
||||
|
||||
namespace Test\DB;
|
||||
|
||||
use CoreLibs\DB\IO;
|
||||
|
||||
class TestDB
|
||||
{
|
||||
/** @var IO */
|
||||
private $db;
|
||||
/** @var array<mixed> */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = [
|
||||
'db_name' => $_ENV['DB_NAME_TEST'] ?? '',
|
||||
'db_user' => $_ENV['DB_USER_TEST'] ?? '',
|
||||
'db_pass' => $_ENV['DB_PASS_TEST'] ?? '',
|
||||
'db_host' => $_ENV['DB_HOST_TEST'] ?? '',
|
||||
'db_port' => 5432,
|
||||
'db_schema' => 'public',
|
||||
'db_type' => 'pgsql',
|
||||
'db_encoding' => '',
|
||||
'db_ssl' => 'allow'
|
||||
];
|
||||
$this->db = new IO($this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function testDBa(): void
|
||||
{
|
||||
$this->db->dbInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRunDB(): void
|
||||
{
|
||||
$this->testDBa();
|
||||
}
|
||||
}
|
||||
|
||||
// __ENB__
|
||||
78
www/lib/Test/Test.php
Normal file
78
www/lib/Test/Test.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* TEST sets only
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Test\DB;
|
||||
|
||||
class Test
|
||||
{
|
||||
/** @var DB\TestDB */
|
||||
private $test_db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// calls all tests
|
||||
$this->testPrivate();
|
||||
$this->testProtected();
|
||||
$this->testPublic();
|
||||
|
||||
// call intern
|
||||
$this->test_db = new DB\TestDB();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
// calls all close tests
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function testPrivate(): string
|
||||
{
|
||||
$string = 'TEST Private';
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function testProtected(): string
|
||||
{
|
||||
$string = 'TEST Protected';
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function testPublic(): string
|
||||
{
|
||||
$string = 'TEST Public';
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClasses(): void
|
||||
{
|
||||
$this->test_db->testRunDB();
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
@@ -10,21 +10,26 @@ if (class_exists('Autoload', false) === false) {
|
||||
// define the auto loader class
|
||||
class Autoload
|
||||
{
|
||||
// we do it simple here
|
||||
// passes on the class to load and we search here in namespace
|
||||
// to load that class
|
||||
public static function load($class)
|
||||
/**
|
||||
* we do it simple here
|
||||
* passes on the class to load and we search here in namespace
|
||||
* to load that class
|
||||
*
|
||||
* @param string $class Namespace + class to load
|
||||
* @return void
|
||||
*/
|
||||
public static function load(string $class)
|
||||
{
|
||||
// print "(1) Class: $class / DIR: ".__DIR__."<br>";
|
||||
// set directory seperator (we need to replace from namespace)
|
||||
$DS = defined('DS') ? DS : DIRECTORY_SEPARATOR;
|
||||
$DS = DIRECTORY_SEPARATOR;
|
||||
// base lib
|
||||
$LIB = defined('LIB') ? LIB : 'lib' . $DS;
|
||||
// if lib is in path at the end, do not add lib again
|
||||
// note that $LIB can have a directory seperator at the end
|
||||
// strip that out before we do a match
|
||||
$_LIB = rtrim($LIB, $DS);
|
||||
if (preg_match("|$_LIB$|", __DIR__) === false) {
|
||||
if (!preg_match("|$_LIB$|", __DIR__)) {
|
||||
$LIB .= $DS;
|
||||
} else {
|
||||
$LIB = '';
|
||||
@@ -50,9 +55,7 @@ if (class_exists('Autoload', false) === false) {
|
||||
// we should sub that
|
||||
// self::loadFile($path);
|
||||
include $path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// end class define
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@
|
||||
<projectFiles>
|
||||
<file name="admin/class_test.php" />
|
||||
<file name="admin/config.php" />
|
||||
<file name="admin/error_test.php" />
|
||||
<file name="admin/l10n_test.php" />
|
||||
<file name="admin/namespace_test.php" />
|
||||
<file name="admin/other_test.php" />
|
||||
<file name="admin/smarty_test.php" />
|
||||
<file name="admin/various_class_test.php" />
|
||||
<directory name="configs" />
|
||||
<directory name="frontend" />
|
||||
<directory name="includes" />
|
||||
@@ -58,7 +52,6 @@
|
||||
<MissingReturnType errorLevel="error" />
|
||||
<MissingPropertyType errorLevel="error" />
|
||||
<InvalidDocblock errorLevel="error" />
|
||||
<MisplacedRequiredParam errorLevel="error" />
|
||||
|
||||
<PropertyNotSetInConstructor errorLevel="error" />
|
||||
<MissingConstructor errorLevel="error" />
|
||||
|
||||
6
www/vendor/composer/ClassLoader.php
vendored
6
www/vendor/composer/ClassLoader.php
vendored
@@ -37,8 +37,8 @@ namespace Composer\Autoload;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
@@ -60,7 +60,7 @@ class ClassLoader
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
|
||||
1
www/vendor/composer/autoload_classmap.php
vendored
1
www/vendor/composer/autoload_classmap.php
vendored
@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
5
www/vendor/composer/autoload_real.php
vendored
5
www/vendor/composer/autoload_real.php
vendored
@@ -13,6 +13,9 @@ class ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
@@ -25,7 +28,7 @@ class ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::getInitializer($loader));
|
||||
} else {
|
||||
|
||||
5
www/vendor/composer/autoload_static.php
vendored
5
www/vendor/composer/autoload_static.php
vendored
@@ -6,9 +6,14 @@ namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
|
||||
{
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->classMap = ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
||||
6
www/vendor/composer/installed.json
vendored
6
www/vendor/composer/installed.json
vendored
@@ -1 +1,5 @@
|
||||
[]
|
||||
{
|
||||
"packages": [],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user