Compare commits

...

8 Commits

Author SHA1 Message Date
Clemens Schwaighofer
736f822363 PHPstan check for level 5
Fix various issues for phpstan level 5

Start initial settings for level 6 (needs type declarations for all
vars)
2021-10-22 11:14:00 +09:00
Clemens Schwaighofer
ffd1a86dcc Force DB IO db_port to INT because it must be INT 2021-10-11 11:16:23 +09:00
Clemens Schwaighofer
b3d783bf63 Add .env reading flow in config.php
Will check if there is a read_env_file.php and then run it to load .env
file in /configs folder

This file can hold secrets that are not to be checked into git

Updated edit.js file to be eslint compatible
2021-10-11 09:40:01 +09:00
Clemens Schwaighofer
e0cc766cc7 Fix Flash constant calls 2021-08-30 11:28:06 +09:00
Clemens Schwaighofer
f151509bfe Update CoreLibs with remove of flash folder and add data folder 2021-08-30 11:25:19 +09:00
Clemens Schwaighofer
e252a76c4c Fix for test datetime, indet on test db, remove debug in test lang 2021-08-13 18:11:37 +09:00
Clemens Schwaighofer
7005e07f4c Composer core updates, Fix for Form/Generate 2021-08-12 16:49:36 +09:00
Clemens Schwaighofer
a86ae3efc3 DB IO updates for settings return, Smarty Extended update
Update core template main body with better position for overlib init,
pagename div id add, remove px from any size call (width)

DB IO adds return for config settings, fix db async check to always
return boolean only, add had error variable return method

Some minor fixes in Smarty Extended for some legacy admin page variables
needed.

Update Error reporting to be self containing with defines
2021-07-26 16:09:51 +09:00
44 changed files with 444 additions and 212 deletions

View File

@@ -147,4 +147,4 @@ BEGIN
RETURN NULL; RETURN NULL;
END END
$$ $$
LANGUAGE 'plpgsql' LANGUAGE 'plpgsql';

View File

@@ -33,3 +33,13 @@ last tested PHP 5.6 and PHP 7.0
### namespace ### namespace
The new namespace branch. This is the development area for the master branch 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

View File

@@ -3,5 +3,7 @@
// Boostrap file for PHPstand // Boostrap file for PHPstand
// sets the _SERVER['HTTP_HOST'] var so we can have DB detection // sets the _SERVER['HTTP_HOST'] var so we can have DB detection
$_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp'; $_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp';
// so www/includes/edit_base.php works
require_once('www/lib/Smarty/SmartyBC.class.php');
// __END__ // __END__

View File

@@ -2,7 +2,7 @@
parameters: parameters:
tmpDir: /tmp/phpstan-corelibs tmpDir: /tmp/phpstan-corelibs
level: 1 level: 5
paths: paths:
- %currentWorkingDirectory%/www - %currentWorkingDirectory%/www
bootstrapFiles: bootstrapFiles:
@@ -20,6 +20,8 @@ parameters:
# no check admin # no check admin
- www/admin/qq_file_upload_front.php - www/admin/qq_file_upload_front.php
- www/admin/qq_file_upload_ajax.php - www/admin/qq_file_upload_ajax.php
- www/admin/class_test*php
- www/admin/error_test.php
# admin synlink files # admin synlink files
- www/admin/edit_access.php - www/admin/edit_access.php
- www/admin/edit_groups.php - www/admin/edit_groups.php
@@ -50,7 +52,10 @@ parameters:
# ignore the smartyextend # ignore the smartyextend
- www/lib/CoreLibs/Template/SmartyExtend.php - www/lib/CoreLibs/Template/SmartyExtend.php
# ignore errores with # ignore errores with
# ignoreErrors: ignoreErrors:
# -
# message: '#Reflection error: [a-zA-Z0-9\\_]+ not found.#'
# path: www/includes/edit_base.php
#- 'error regex' #- 'error regex'
#- #-
# message: 'error regex' # message: 'error regex'

View File

@@ -33,7 +33,7 @@ use CoreLibs\Combined\ArrayHandler;
use CoreLibs\Debug\Support as DgS; use CoreLibs\Debug\Support as DgS;
$basic = new CoreLibs\Basic(); $basic = new CoreLibs\Basic();
// $_array= new CoreLibs\Combined\ArrayHandler(); // $_array = new CoreLibs\Combined\ArrayHandler();
// $array_class = 'CoreLibs\Combination\ArrayHandler'; // $array_class = 'CoreLibs\Combination\ArrayHandler';
print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>"; print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>";

View File

@@ -33,7 +33,7 @@ use CoreLibs\Combined\DateTime;
use CoreLibs\Debug\Support as DgS; use CoreLibs\Debug\Support as DgS;
$basic = new CoreLibs\Basic(); $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 "<html><head><title>TEST CLASS: DATE/TIME</title><head>";
print "<body>"; print "<body>";

View File

@@ -63,9 +63,9 @@ while ($res = $db->dbReturn("SELECT * FROM max_test")) {
print "<pre>"; print "<pre>";
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST " . time() . "') RETURNING test"); $status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST " . time() . "') RETURNING test");
print "DIRECT INSERT STATUS: $status | " print "DIRECT INSERT STATUS: $status | "
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>"; . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
// should throw deprecated error // should throw deprecated error
// $db->getReturningExt(); // $db->getReturningExt();
@@ -74,9 +74,9 @@ print "DIRECT INSERT PREVIOUS INSERTED: "
$db->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); $db->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
$status = $db->dbExecute("ins_foo", array('BAR TEST ' . time())); $status = $db->dbExecute("ins_foo", array('BAR TEST ' . time()));
print "PREPARE INSERT STATUS: $status | " print "PREPARE INSERT STATUS: $status | "
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
. "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>"; . "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "<br>";
print "PREPARE INSERT PREVIOUS INSERTED: " 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 foo_id, test FROM foo WHERE foo_id = " . $db->dbGetInsertPK()), true) . "<br>";
@@ -96,22 +96,22 @@ $status = $db->dbExec(
. "RETURNING foo_id, test" . "RETURNING foo_id, test"
); );
print "DIRECT MULTIPLE INSERT STATUS: $status | " print "DIRECT MULTIPLE INSERT STATUS: $status | "
. "PRIMARY KEYS: " . print_r($db->dbGetInsertPK(), true) . " | " . "PRIMARY KEYS: " . print_r($db->dbGetInsertPK(), true) . " | "
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>"; . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
// no returning, but not needed ; // no returning, but not needed ;
$status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST " . time() . "');"); $status = $db->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST " . time() . "');");
print "DIRECT INSERT STATUS: $status | " print "DIRECT INSERT STATUS: $status | "
. "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | "
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>"; . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
// UPDATE WITH RETURNING // UPDATE WITH RETURNING
$status = $db->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test"); $status = $db->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test");
print "UPDATE STATUS: $status | " print "UPDATE STATUS: $status | "
. "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | "
. "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>"; . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "<br>";
print "</pre>"; print "</pre>";
// REEAD PREPARE // REEAD PREPARE

View File

@@ -52,9 +52,6 @@ echo "LANGUAGE FILE: " . $l->__getMoFile() . "<br>";
echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>"; echo "INPUT TEST: " . $string . " => " . $l->__($string) . "<br>";
// TODO: run compare check input must match output // TODO: run compare check input must match output
// error message
print $basic->log->printErrorMsg();
print "</body></html>"; print "</body></html>";
// __END__ // __END__

View File

@@ -32,6 +32,7 @@ $LOG_FILE_ID = 'classTest-form';
ob_end_flush(); ob_end_flush();
// define an array for page use // define an array for page use
$table_arrays = [];
$table_arrays[\CoreLibs\Get\System::getPageName(1)] = [ $table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
// form fields mtaching up with db fields // form fields mtaching up with db fields
'table_array' => [ 'table_array' => [

View File

@@ -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.lang.php">Class Test: LANG/L10n</a></div>';
print '<div><a href="class_test.smarty.php">Class Test: SMARTY</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 // set + check edit access id
$edit_access_id = 3; $edit_access_id = 3;
if (is_object($login) && isset($login->acl['unit'])) { if (is_object($login) && isset($login->acl['unit'])) {

View File

@@ -84,6 +84,7 @@ $options = [
]; ];
$smarty->DATA['drop_down_test'] = $options; $smarty->DATA['drop_down_test'] = $options;
$smarty->DATA['drop_down_test_selected'] = '';
$smarty->DATA['loop_start'] = 2; $smarty->DATA['loop_start'] = 2;
// require BASE.INCLUDES.'admin_smarty.php'; // require BASE.INCLUDES.'admin_smarty.php';
$smarty->setSmartyVarsAdmin(); $smarty->setSmartyVarsAdmin();

8
www/configs/.env.example Normal file
View 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=

View File

@@ -13,15 +13,15 @@ declare(strict_types=1);
// please be VERY carefull only to change the right side // please be VERY carefull only to change the right side
$DB_CONFIG = [ $DB_CONFIG = [
'test' => [ 'test' => [
'db_name' => 'clemens', 'db_name' => $_ENV['DB_NAME_TEST'] ?? '',
'db_user' => 'clemens', 'db_user' => $_ENV['DB_USER_TEST'] ?? '',
'db_pass' => 'clemens', 'db_pass' => $_ENV['DB_PASS_TEST'] ?? '',
'db_host' => 'db.tokyo.tequila.jp', 'db_host' => $_ENV['DB_HOST_TEST'] ?? '',
'db_port' => 5432, 'db_port' => 5432,
'db_schema' => 'public', 'db_schema' => 'public',
'db_type' => 'pgsql', 'db_type' => 'pgsql',
'db_encoding' => '', 'db_encoding' => '',
'db_ssl' => 'disable' // allow, disable, require, prefer 'db_ssl' => 'allow' // allow, disable, require, prefer
], ],
]; ];

View File

@@ -41,8 +41,6 @@ define('IMAGES', 'images' . DS);
define('ICONS', 'icons' . DS); define('ICONS', 'icons' . DS);
// media (accessable from outside) // media (accessable from outside)
define('MEDIA', 'media' . DS); define('MEDIA', 'media' . DS);
// flash-root (below media or data)
define('FLASH', 'flash' . DS);
// uploads (anything to keep or data) // uploads (anything to keep or data)
define('UPLOADS', 'uploads' . DS); define('UPLOADS', 'uploads' . DS);
// files (binaries) (below media or data) // files (binaries) (below media or data)
@@ -86,7 +84,7 @@ define('DEFAULT_HASH', 'sha256');
// default acl level // default acl level
define('DEFAULT_ACL_LEVEL', 80); define('DEFAULT_ACL_LEVEL', 80);
// SSL host name // SSL host name
// define('SSL_HOST', 'ssl.host.name'); // define('SSL_HOST', $_ENV['SSL_HOST'] ?? '');
// error page strictness, Default is 3 // 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 // 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 // 2: if template not found, do not search, show error template
@@ -133,15 +131,16 @@ define('USE_SCRIPTACULOUS', false);
define('USE_JQUERY', true); define('USE_JQUERY', true);
/************* LAYOUT WIDTHS *************/ /************* LAYOUT WIDTHS *************/
define('PAGE_WIDTH', 800); define('PAGE_WIDTH', '100%');
define('CONTENT_WIDTH', 800); define('CONTENT_WIDTH', '100%');
// the default template name // the default template name
define('MASTER_TEMPLATE_NAME', 'main_body.tpl'); define('MASTER_TEMPLATE_NAME', 'main_body.tpl');
/************* OVERALL CONTROL NAMES *************/ /************* OVERALL CONTROL NAMES *************/
// BELOW has HAS to be changed // BELOW has HAS to be changed
// base name for all session and log names // 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 *************/ /************* SESSION NAMES *************/
// server name HASH // server name HASH
@@ -268,7 +267,7 @@ define('LOGIN_ENABLED', $SITE_CONFIG[HOST_NAME]['login_enabled']);
define('SHOW_ALL_ERRORS', true); define('SHOW_ALL_ERRORS', true);
/************* GENERAL PAGE TITLE ********/ /************* GENERAL PAGE TITLE ********/
define('G_TITLE', '<OVERALL FALLBACK PAGE TITLE>'); define('G_TITLE', $_ENV['G_TITLE'] ?? '');
/************ STYLE SHEETS / JS **********/ /************ STYLE SHEETS / JS **********/
define('ADMIN_STYLESHEET', 'edit.css'); define('ADMIN_STYLESHEET', 'edit.css');

View File

@@ -10,7 +10,7 @@
declare(strict_types=1); declare(strict_types=1);
// DEFINE('SOME_ID', <SOME VALUE>); // define('SOME_ID', <SOME VALUE>);
/************* CONVERT *******************/ /************* CONVERT *******************/
// this only needed if the external thumbnail create is used // this only needed if the external thumbnail create is used

View File

@@ -16,6 +16,13 @@ $CONFIG_PATH_PREFIX = '';
for ($dir_pos = 0, $dir_max = count(explode(DIRECTORY_SEPARATOR, __DIR__)); $dir_pos <= $dir_max; $dir_pos++) { for ($dir_pos = 0, $dir_max = count(explode(DIRECTORY_SEPARATOR, __DIR__)); $dir_pos <= $dir_max; $dir_pos++) {
$CONFIG_PATH_PREFIX .= '..' . DIRECTORY_SEPARATOR; $CONFIG_PATH_PREFIX .= '..' . DIRECTORY_SEPARATOR;
if (file_exists($CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php')) { 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'; require $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php';
break; break;
} }

View 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__

View File

@@ -100,10 +100,10 @@
</script> </script>
<!-- /TinyMCE --> <!-- /TinyMCE -->
{/if} {/if}
{popup_init src="`$js`/overlib/overlib.js"}
</head> </head>
<body> <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: relative; height: 20px;" class="menu">
<div style="position: absolute; width: 200px;">{t 1=$USER_NAME|upper}Hello %1{/t}</div> <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;"> <div style="position: absolute; text-align: right; right: 0px; width: 120px;">
@@ -127,13 +127,13 @@
{/if} {/if}
{/foreach} {/foreach}
</div> </div>
<div class="pagename"> <div id="pagename" class="pagename">
{$page_name} {$page_name}
</div> </div>
</div> </div>
{* error/warning *} {* error/warning *}
{if $messages} {if $messages}
<div style="margin: 2px; width: {$table_width}px;"> <div style="margin: 2px; width: {$table_width};">
{foreach from=$messages item=item key=key} {foreach from=$messages item=item key=key}
<div class="{$item.class}">{$item.msg}</div> <div class="{$item.class}">{$item.msg}</div>
{/foreach} {/foreach}
@@ -143,7 +143,7 @@
{* debug info *} {* debug info *}
{if $DEBUG} {if $DEBUG}
<div style="width:{$table_width}px;" class="debug_message"> <div style="width:{$table_width};" class="debug_message">
{$Id}<br> {$Id}<br>
<b>{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}</b><br> <b>{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}</b><br>
{$debug_error_msg} {$debug_error_msg}

View File

@@ -3,6 +3,8 @@
/* jshint esversion: 6 */ /* jshint esversion: 6 */
/* global i18n */
// debug set // debug set
/*var FRONTEND_DEBUG = false; /*var FRONTEND_DEBUG = false;
var DEBUG = true; var DEBUG = true;
@@ -22,7 +24,8 @@ var GL_OB_BASE = 30;
* @param {String} winName window name * @param {String} winName window name
* @param {Object} features popup features * @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 = window.open(theURL, winName, features);
winName.focus(); winName.focus();
} }
@@ -31,7 +34,8 @@ function pop(theURL, winName, features) {
* automatically resize a text area based on the amount of lines in it * automatically resize a text area based on the amount of lines in it
* @param {[string} ta_id element id * @param {[string} ta_id element id
*/ */
function expandTA(ta_id) { function expandTA(ta_id) // eslint-disable-line no-unused-vars
{
var ta; var ta;
// if a string comes, its a get by id, else use it as an element pass on // if a string comes, its a get by id, else use it as an element pass on
if (!ta_id.length) { if (!ta_id.length) {
@@ -40,7 +44,7 @@ function expandTA(ta_id) {
ta = document.getElementById(ta_id); ta = document.getElementById(ta_id);
} }
var maxChars = ta.cols; var maxChars = ta.cols;
var theRows = ta.value.split("\n"); var theRows = ta.value.split('\n');
var numNewRows = 0; var numNewRows = 0;
for ( var i = 0; i < theRows.length; i++ ) { 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 {Number} [duration=500] animation time, default 500ms
* @param {String} [base='body,html'] base element for offset scroll * @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 { try {
if ($('#' + element).length) { if ($('#' + element).length) {
@@ -190,7 +194,7 @@ if (Number.prototype.round) {
* @param {Number} x number to be formated * @param {Number} x number to be formated
* @return {String} formatted with , in thousands * @return {String} formatted with , in thousands
*/ */
function numberWithCommas(x) function numberWithCommas(x) // eslint-disable-line no-unused-vars
{ {
var parts = x.toString().split('.'); var parts = x.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
@@ -202,7 +206,7 @@ function numberWithCommas(x)
* @param {String} string any string * @param {String} string any string
* @return {String} string with <br> * @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>'); return string.replace(/(?:\r\n|\r|\n)/g, '<br>');
} }
@@ -214,14 +218,14 @@ function convertLBtoBR(string)
*/ */
if (!String.prototype.escapeHTML) { if (!String.prototype.escapeHTML) {
String.prototype.escapeHTML = function() { String.prototype.escapeHTML = function() {
return this.replace(/[&<>"'\/]/g, function (s) { return this.replace(/[&<>"'/]/g, function (s) {
var entityMap = { var entityMap = {
"&": "&amp;", '&': '&amp;',
"<": "&lt;", '<': '&lt;',
">": "&gt;", '>': '&gt;',
'"': '&quot;', '"': '&quot;',
"'": '&#39;', '\'': '&#39;',
"/": '&#x2F;' '/': '&#x2F;'
}; };
return entityMap[s]; return entityMap[s];
@@ -238,12 +242,12 @@ if (!String.prototype.unescapeHTML) {
String.prototype.unescapeHTML = function() { String.prototype.unescapeHTML = function() {
return this.replace(/&[#\w]+;/g, function (s) { return this.replace(/&[#\w]+;/g, function (s) {
var entityMap = { var entityMap = {
"&amp;": "&", '&amp;': '&',
"&lt;": "<", '&lt;': '<',
"&gt;": ">", '&gt;': '>',
'&quot;': '"', '&quot;': '"',
'&#39;': "'", '&#39;': '\'',
'&#x2F;': "/" '&#x2F;': '/'
}; };
return entityMap[s]; return entityMap[s];
@@ -255,7 +259,7 @@ if (!String.prototype.unescapeHTML) {
* returns current timestamp (unix timestamp) * returns current timestamp (unix timestamp)
* @return {Number} timestamp (in milliseconds) * @return {Number} timestamp (in milliseconds)
*/ */
function getTimestamp() function getTimestamp() // eslint-disable-line no-unused-vars
{ {
var date = new Date(); var date = new Date();
return date.getTime(); return date.getTime();
@@ -278,7 +282,7 @@ function dec2hex(dec)
* @param {Number} len length of unique id string * @param {Number} len length of unique id string
* @return {String} random string in length of len * @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); var arr = new Uint8Array((len || 40) / 2);
(window.crypto || window.msCrypto).getRandomValues(arr); (window.crypto || window.msCrypto).getRandomValues(arr);
@@ -291,7 +295,7 @@ function generateId(len)
* after many runs it will create duplicates * after many runs it will create duplicates
* @return {String} not true random string * @return {String} not true random string
*/ */
function randomIdF() function randomIdF() // eslint-disable-line no-unused-vars
{ {
return Math.random().toString(36).substring(2); return Math.random().toString(36).substring(2);
} }
@@ -301,7 +305,7 @@ function randomIdF()
* @param {string} name Name of function to check if exists * @param {string} name Name of function to check if exists
* @return {Boolean} true/false * @return {Boolean} true/false
*/ */
function isFunction(name) function isFunction(name) // eslint-disable-line no-unused-vars
{ {
if (typeof window[name] !== 'undefined' && if (typeof window[name] !== 'undefined' &&
typeof window[name] === 'function') { typeof window[name] === 'function') {
@@ -320,7 +324,7 @@ function isFunction(name)
* hidden next are all the arguments * hidden next are all the arguments
* @return {mixed} Return values from functon * @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 args = Array.prototype.slice.call(arguments, 2);
var namespaces = functionName.split('.'); var namespaces = functionName.split('.');
@@ -362,7 +366,7 @@ function getObjectCount(object)
*/ */
function keyInObject(key, 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) * @param {Mixed} value any value (String, Number, etc)
* @return {String} the key found for the first matching value * @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(key => object[key] === value);
// return Object.keys(object).find(function (key) { // return Object.keys(object).find(function (key) {
@@ -385,9 +389,9 @@ function getKeyByValue(object, value)
* @param {Mixed} value any value (String, Number, etc) * @param {Mixed} value any value (String, Number, etc)
* @return {Boolean} true on value found, false on not found * @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.keys(object).find(function (key) {
// return object[key] === value; // return object[key] === value;
// }) ? true : false; // }) ? true : false;
@@ -403,7 +407,7 @@ function valueInObject(object, value)
function deepCopyFunction(inObject) function deepCopyFunction(inObject)
{ {
var outObject, value, key; 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 return inObject; // Return the value if inObject is not an object
} }
// Create an array or object to hold the values // Create an array or object to hold the values
@@ -434,14 +438,15 @@ function exists(id)
* @param {Number} bytes bytes in int * @param {Number} bytes bytes in int
* @return {String} string in GB/MB/KB * @return {String} string in GB/MB/KB
*/ */
function formatBytes(bytes) function formatBytes(bytes) // eslint-disable-line no-unused-vars
{ {
var i = -1; var i = -1;
do { do {
bytes = bytes / 1024; bytes = bytes / 1024;
i++; i++;
} while (bytes > 99); } 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 * @param {Number} bytes bytes in int
* @return {String} string in GB/MB/KB * @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 i = Math.floor(Math.log(bytes) / Math.log(1024));
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 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 * @param {String|Number} bytes Any string with B/K/M/etc
* @return {String|Number} A byte number, or original string as is * @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 anything not string return
if (!(typeof bytes === 'string' || bytes instanceof String)) { if (!(typeof bytes === 'string' || bytes instanceof String)) {
@@ -536,7 +541,7 @@ function errorCatch(err)
* default empty. for console.log * default empty. for console.log
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block * @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')) { if ($('#indicator').is(':visible')) {
actionIndicatorHide(loc, overlay); actionIndicatorHide(loc, overlay);
@@ -613,7 +618,7 @@ function overlayBoxHide()
/** /**
* position the overlay block box and shows it * position the overlay block box and shows it
*/ */
function setOverlayBox() function setOverlayBox() // eslint-disable-line no-unused-vars
{ {
if (!$('#overlayBox').is(':visible')) { if (!$('#overlayBox').is(':visible')) {
$('#overlayBox').show(); $('#overlayBox').show();
@@ -623,7 +628,7 @@ function setOverlayBox()
/** /**
* opposite of set, always hides overlay box * opposite of set, always hides overlay box
*/ */
function hideOverlayBox() function hideOverlayBox() // eslint-disable-line no-unused-vars
{ {
if ($('#overlayBox').is(':visible')) { if ($('#overlayBox').is(':visible')) {
$('#overlayBox').hide(); $('#overlayBox').hide();
@@ -633,7 +638,7 @@ function hideOverlayBox()
/** /**
* the abort call, clears the action box and hides it and the overlay box * 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').html('');
$('#actionBox').hide(); $('#actionBox').hide();
@@ -654,7 +659,7 @@ function ClearCall()
* - indicator is page centered * - indicator is page centered
* @param {String} loc ID string, only used for console log * @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); // console.log('Indicator: SHOW [%s]', loc);
// check if indicator element exists // check if indicator element exists
@@ -692,7 +697,7 @@ function showActionIndicator(loc)
* is set to this value * is set to this value
* @param {String} loc ID string, only used for console log * @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); // console.log('Indicator: HIDE [%s]', loc);
// check if indicator is visible // check if indicator is visible
@@ -732,7 +737,7 @@ function checkOverlayExists()
* if visible, add +1 to the GL_OB_S variable and * if visible, add +1 to the GL_OB_S variable and
* up zIndex by this value * 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); // console.log('SHOW overlaybox: %s', GL_OB_S);
// if overlay box is not visible show and set zIndex to 0 // 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 * only for single action box
*/ */
function clearCallActionBox() function clearCallActionBox() // eslint-disable-line no-unused-vars
{ {
$('#actionBox').html(''); $('#actionBox').html('');
$('#actionBox').hide(); $('#actionBox').hide();
@@ -872,7 +877,7 @@ function aelx(base, ...attach)
* @param {Array} attach array of objects to attach * @param {Array} attach array of objects to attach
* @return {Object} "none", technically there is no return needed, global 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 ++) { for (var i = 0; i < attach.length; i ++) {
// base.sub.push(Object.assign({}, attach[i])); // base.sub.push(Object.assign({}, attach[i]));
@@ -886,7 +891,7 @@ function aelxar(base, attach)
* @param {Object} base cel created element * @param {Object} base cel created element
* @return {Object} returns reset base element * @return {Object} returns reset base element
*/ */
function rel(base) function rel(base) // eslint-disable-line no-unused-vars
{ {
base.sub = []; base.sub = [];
return base; return base;
@@ -930,7 +935,7 @@ function acssel(_element, css)
* @param {String} acss style to add (name) * @param {String} acss style to add (name)
* @return {Object} returns full element * @return {Object} returns full element
*/ */
function scssel(_element, rcss, acss) function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
{ {
rcssel(_element, rcss); rcssel(_element, rcss);
acssel(_element, acss); acssel(_element, acss);
@@ -1008,7 +1013,7 @@ function phfo(tree)
* @param {Array} list Array of cel created objects * @param {Array} list Array of cel created objects
* @return {String} HTML String * @return {String} HTML String
*/ */
function phfa(list) function phfa(list) // eslint-disable-line no-unused-vars
{ {
var content = []; var content = [];
for (var i = 0; i < list.length; i ++) { for (var i = 0; i < list.length; i ++) {
@@ -1034,7 +1039,7 @@ function phfa(list)
* 'values' all others are ignored * 'values' all others are ignored
* @return {String} html with build options block * @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 // wrapper to new call
return html_options_block(name, data, selected, false, options_only, return_string, sort); 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 element_option;
var data_list = []; // for sorted output var data_list = []; // for sorted output
var value; var value;
var options = {};
// var option; // var option;
if (multiple > 0) { if (multiple > 0) {
select_options.multiple = ''; 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' * @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
* all others are ignored * 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 element_option;
var option_selected; var option_selected;
@@ -1186,21 +1192,26 @@ function html_options_refill(name, data, sort = '')
* or empty for none * or empty for none
* @return {Object|String} parameter entry list * @return {Object|String} parameter entry list
*/ */
function parseQueryString(query = '', return_key = '') { function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
{
if (!query) { if (!query) {
query = window.location.search.substring(1); query = window.location.search.substring(1);
} }
var vars = query.split("&"); var vars = query.split('&');
var query_string = {}; var query_string = {};
for (var i = 0; i < vars.length; i++) { for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("="); var pair = vars[i].split('=');
var key = decodeURIComponent(pair[0]); var key = decodeURIComponent(pair[0]);
var value = decodeURIComponent(pair[1]); var value = decodeURIComponent(pair[1]);
// skip over run if there is nothing
if (!key || value === 'undefined') {
continue;
}
// If first entry with this name // If first entry with this name
if (typeof query_string[key] === "undefined") { if (typeof query_string[key] === 'undefined') {
query_string[key] = decodeURIComponent(value); query_string[key] = decodeURIComponent(value);
// If second entry with this name // 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)]; var arr = [query_string[key], decodeURIComponent(value)];
query_string[key] = arr; query_string[key] = arr;
// If third or later entry with this name // If third or later entry with this name
@@ -1220,26 +1231,59 @@ function parseQueryString(query = '', return_key = '') {
} }
/** /**
* searchs the current url for a parameter * searches query parameters for entry and returns data either as string or array
* @param {String} key uid key to get data for * if no search is given the whole parameters are returned as an object
* @return {String} value for the key or '' for not found * 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); if (!query) {
var param = url.searchParams.get(key); query = window.location.href;
if (param) {
return param;
} else {
return '';
} }
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 // *** MASTER logout call
/** /**
* submits basic data for form logout * submits basic data for form logout
*/ */
function loginLogout() function loginLogout() // eslint-disable-line no-unused-vars
{ {
const form = document.createElement('form'); const form = document.createElement('form');
form.method = 'post'; form.method = 'post';
@@ -1259,7 +1303,7 @@ function loginLogout()
* if not set mainHeader is assumed * if not set mainHeader is assumed
* this is the target div for the "loginRow" * 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 header does not exist, we do nothing
if (exists(header_id)) { if (exists(header_id)) {
@@ -1293,7 +1337,8 @@ function createLoginRow(login_string, header_id = 'mainHeader')
* if not set mainHeader is assumed * if not set mainHeader is assumed
* this is the target div for the "menuRow" * 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 // must be an object
if (isObject(nav_menu) && getObjectCount(nav_menu) > 1) { if (isObject(nav_menu) && getObjectCount(nav_menu) > 1) {
// do we have more than one entry, if not, do not show (single page) // do we have more than one entry, if not, do not show (single page)

View File

@@ -176,7 +176,7 @@ class Login extends \CoreLibs\DB\IO
// check what schema to use. if there is a login schema use this, else check // 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 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 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; $SCHEMA = LOGIN_DB_SCHEMA;
} elseif (isset($db_config['db_schema']) && $db_config['db_schema']) { } elseif (isset($db_config['db_schema']) && $db_config['db_schema']) {
$SCHEMA = $db_config['db_schema']; $SCHEMA = $db_config['db_schema'];

View File

@@ -178,7 +178,7 @@ class Backend extends \CoreLibs\DB\IO
} }
// check schema // check schema
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) { if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) {
$SCHEMA = LOGIN_DB_SCHEMA; $SCHEMA = LOGIN_DB_SCHEMA;
} elseif ($this->dbGetSchema()) { } elseif ($this->dbGetSchema()) {
$SCHEMA = $this->dbGetSchema(); $SCHEMA = $this->dbGetSchema();
@@ -475,7 +475,7 @@ class Backend extends \CoreLibs\DB\IO
string $associate = null, string $associate = null,
string $file = null string $file = null
): void { ): void {
if (defined('GLOBAL_DB_SCHEMA') && GLOBAL_DB_SCHEMA) { if (defined('GLOBAL_DB_SCHEMA') && !empty(GLOBAL_DB_SCHEMA)) {
$SCHEMA = GLOBAL_DB_SCHEMA; $SCHEMA = GLOBAL_DB_SCHEMA;
} elseif ($this->dbGetSchema()) { } elseif ($this->dbGetSchema()) {
$SCHEMA = $this->dbGetSchema(); $SCHEMA = $this->dbGetSchema();

View File

@@ -87,7 +87,7 @@ class Basic
$abort = false; $abort = false;
foreach ( 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', 'VIDEOS', 'DOCUMENTS', 'PDFS', 'BINARIES', 'ICONS', 'UPLOADS', 'CSV', 'JS',
'CSS', 'TABLE_ARRAYS', 'SMARTY', 'LANG', 'CACHE', 'TMP', 'LOG', 'TEMPLATES', 'CSS', 'TABLE_ARRAYS', 'SMARTY', 'LANG', 'CACHE', 'TMP', 'LOG', 'TEMPLATES',
'TEMPLATES_C', 'DEFAULT_LANG', 'DEFAULT_ENCODING', 'DEFAULT_HASH', 'TEMPLATES_C', 'DEFAULT_LANG', 'DEFAULT_ENCODING', 'DEFAULT_HASH',
@@ -115,7 +115,7 @@ class Basic
// set the paths matching to the valid file types // set the paths matching to the valid file types
$this->data_path = [ $this->data_path = [
'P' => PICTURES, 'P' => PICTURES,
'F' => FLASH, 'F' => DATA,
'V' => VIDEOS, 'V' => VIDEOS,
'D' => DOCUMENTS, 'D' => DOCUMENTS,
'A' => PDFS, 'A' => PDFS,

View File

@@ -35,8 +35,6 @@ class Password
} else { } else {
return false; return false;
} }
// in case something strange, return false on default
return false;
} }
/** /**
@@ -51,8 +49,6 @@ class Password
} else { } else {
return false; return false;
} }
// in case of strange, force re-hash
return true;
} }
} }

View File

@@ -40,14 +40,10 @@ class PhpVersion
define('PHP_VERSION_ID', (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2]); define('PHP_VERSION_ID', (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2]);
} }
// check if matching for version // check if matching for version
if ($min_version && !$max_version) { if (!$max_version && PHP_VERSION_ID >= $min_version) {
if (PHP_VERSION_ID >= $min_version) { return true;
return true; } elseif (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
} return true;
} elseif ($min_version && $max_version) {
if (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
return true;
}
} }
// if no previous return, fail // if no previous return, fail
return false; return false;

View File

@@ -214,6 +214,8 @@ class DateTime
return 0; return 0;
} elseif ($start_date > $end_date) { } elseif ($start_date > $end_date) {
return 1; return 1;
} else {
return false;
} }
} }
@@ -242,6 +244,8 @@ class DateTime
return 0; return 0;
} elseif ($start_timestamp > $end_timestamp) { } elseif ($start_timestamp > $end_timestamp) {
return 1; return 1;
} else {
return false;
} }
} }

View File

@@ -288,7 +288,7 @@ class IO extends \CoreLibs\Basic
private $nbsp = ''; // used by print_array recursion function private $nbsp = ''; // used by print_array recursion function
// error & warning id // error & warning id
protected $error_id; protected $error_id;
private $had_error; private $had_error = 0;
private $warning_id; private $warning_id;
private $had_warning; private $had_warning;
// error thrown on class init if we cannot connect to db // error thrown on class init if we cannot connect to db
@@ -332,7 +332,7 @@ class IO extends \CoreLibs\Basic
$this->db_user = $db_config['db_user'] ?? ''; $this->db_user = $db_config['db_user'] ?? '';
$this->db_pwd = $db_config['db_pass'] ?? ''; $this->db_pwd = $db_config['db_pass'] ?? '';
$this->db_host = $db_config['db_host'] ?? ''; $this->db_host = $db_config['db_host'] ?? '';
$this->db_port = !empty($db_config['db_port']) ? $db_config['db_port'] : 5432; $this->db_port = !empty($db_config['db_port']) ? (int)$db_config['db_port'] : 5432;
// do not set to 'public' if not set, because the default is already public // do not set to 'public' if not set, because the default is already public
$this->db_schema = !empty($db_config['db_schema']) ? $db_config['db_schema'] : ''; $this->db_schema = !empty($db_config['db_schema']) ? $db_config['db_schema'] : '';
$this->db_encoding = !empty($db_config['db_encoding']) ? $db_config['db_encoding'] : ''; $this->db_encoding = !empty($db_config['db_encoding']) ? $db_config['db_encoding'] : '';
@@ -722,7 +722,8 @@ class IO extends \CoreLibs\Basic
$this->__dbError(); $this->__dbError();
return false; return false;
} }
// if we do have an insert, check if there is no RETURNING pk_id, add it if I can get the PK id // if we do have an insert, check if there is no RETURNING pk_id,
// add it if I can get the PK id
if ($this->__checkQueryForInsert($this->query, true)) { if ($this->__checkQueryForInsert($this->query, true)) {
$this->pk_name = $pk_name; $this->pk_name = $pk_name;
if ($this->pk_name != 'NULL') { if ($this->pk_name != 'NULL') {
@@ -909,7 +910,7 @@ class IO extends \CoreLibs\Basic
$this->db_debug = 0; $this->db_debug = 0;
} elseif ($this->db_debug) { } elseif ($this->db_debug) {
$this->db_debug = 0; $this->db_debug = 0;
} elseif (!$this->db_debug) { } else {
$this->db_debug = 1; $this->db_debug = 1;
} }
return $this->db_debug; return $this->db_debug;
@@ -1097,6 +1098,25 @@ class IO extends \CoreLibs\Basic
case 'user': case 'user':
$setting = $this->db_user; $setting = $this->db_user;
break; break;
case 'encoding':
$setting = $this->db_encoding;
break;
case 'schema':
$setting = $this->db_schema;
break;
case 'host':
$setting = $this->db_host;
break;
case 'port':
$setting = $this->db_port;
break;
case 'ssl':
$setting = $this->db_ssl;
break;
// we return *** and never the actual password
case 'password':
$setting = '***';
break;
default: default:
$setting = false; $setting = false;
break; break;
@@ -1439,9 +1459,10 @@ class IO extends \CoreLibs\Basic
/** /**
* checks a previous async query and returns data if finished * checks a previous async query and returns data if finished
* NEEDS : dbExecAsync * NEEDS : dbExecAsync
* @return bool true if the query is still running, false if an error occured or cursor of that query * @return bool|resource cursor resource if the query is still running,
* false if an error occured or cursor of that query
*/ */
public function dbCheckAsync(): bool public function dbCheckAsync()
{ {
// if there is actually a async query there // if there is actually a async query there
if ($this->async_running) { if ($this->async_running) {
@@ -1768,7 +1789,7 @@ class IO extends \CoreLibs\Basic
); );
$this->insert_id_ext = $this->insert_id; $this->insert_id_ext = $this->insert_id;
$this->insert_id_arr[] = $this->insert_id; $this->insert_id_arr[] = $this->insert_id;
} elseif ($result) { } elseif (!empty($result)) {
$this->insert_id = []; $this->insert_id = [];
$this->insert_id_ext = []; $this->insert_id_ext = [];
$this->insert_id_arr = []; $this->insert_id_arr = [];
@@ -1967,8 +1988,6 @@ class IO extends \CoreLibs\Basic
return 'f'; return 'f';
} }
} }
// if neither, just return data as is
return $string;
} }
// ** REMARK ** // ** REMARK **
@@ -1997,9 +2016,6 @@ class IO extends \CoreLibs\Basic
if (!is_array($not_write_array)) { if (!is_array($not_write_array)) {
$not_write_array = []; $not_write_array = [];
} }
if (is_array($table)) {
return false;
}
$not_write_update_array = []; $not_write_update_array = [];
return $this->dbWriteDataExt( return $this->dbWriteDataExt(
$write_array, $write_array,
@@ -2056,8 +2072,8 @@ class IO extends \CoreLibs\Basic
// loop through the write array and each field to build the query // loop through the write array and each field to build the query
foreach ($write_array as $field) { foreach ($write_array as $field) {
if ( if (
(!$primary_key['value'] || (empty($primary_key['value']) ||
($primary_key['value'] && (!empty($primary_key['value']) &&
!in_array($field, $not_write_update_array)) !in_array($field, $not_write_update_array))
) && ) &&
!in_array($field, $not_write_array) !in_array($field, $not_write_array)
@@ -2376,6 +2392,17 @@ class IO extends \CoreLibs\Basic
trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetNumRows()', E_USER_DEPRECATED); trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetNumRows()', E_USER_DEPRECATED);
return $this->dbGetNumRows(); return $this->dbGetNumRows();
} }
/**
* Sets error number that was last
* So we always have the last error number stored even if a new one is created
*
* @return int last error number
*/
public function getHadError()
{
return $this->had_error;
}
// end if db class // end if db class
} }

View File

@@ -239,9 +239,9 @@ class PgSQL
* if there is no pk_name tries to auto built it from the table name * 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 * this only works if db schema is after "no plural names. and pk name is table name + _id
* detects schema prefix in table name * detects schema prefix in table name
* @param string $query query string * @param string $query query string
* @param string $pk_name primary key name, if '' then auto detect * @param string $pk_name primary key name, if '' then auto detect
* @return string|int primary key value * @return string|int|false primary key value
*/ */
public function __dbInsertId(string $query, string $pk_name) public function __dbInsertId(string $query, string $pk_name)
{ {
@@ -274,6 +274,9 @@ class PgSQL
$id = [-1, $q]; $id = [-1, $q];
} }
return $id; return $id;
} else {
//if not insert, return false
return false;
} }
} }
@@ -351,9 +354,7 @@ class PgSQL
$this->dbh = pg_connect("host=" . $db_host . " port=" . $db_port . " user=" $this->dbh = pg_connect("host=" . $db_host . " port=" . $db_port . " user="
. $db_user . " password=" . $db_pass . " dbname=" . $db_name . " sslmode=" . $db_ssl); . $db_user . " password=" . $db_pass . " dbname=" . $db_name . " sslmode=" . $db_ssl);
if (!$this->dbh) { if (!$this->dbh) {
die("<!-- Can't connect [host=" . $db_host . " port=" . $db_port . " user=" die("<!-- Can't connect to database //-->");
. $db_user . " password=XXXX dbname=" . $db_name . " sslmode=" . $db_ssl . "] //-->");
return null;
} }
return $this->dbh; return $this->dbh;
} }

View File

@@ -11,6 +11,7 @@ namespace CoreLibs\Debug;
class FileWriter class FileWriter
{ {
/** @var string */
private static $debug_filename = 'debug_file.log'; // where to write output private static $debug_filename = 'debug_file.log'; // where to write output
/** /**

View File

@@ -341,7 +341,7 @@ class Logging
*/ */
public function debugFor(string $type, string $flag): void 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()]); $this->setLogLevel(...[func_get_args()]);
} }

View File

@@ -108,13 +108,13 @@ class GetTextReader
/** /**
* Constructor * Constructor
* *
* @param object $Reader the StreamReader object * @param object|bool $Reader the StreamReader object
* @param bool $enable_cache Enable or disable caching of strings (default on) * @param bool $enable_cache Enable or disable caching of strings (default on)
*/ */
public function __construct($Reader, $enable_cache = true) public function __construct($Reader, $enable_cache = true)
{ {
// If there isn't a StreamReader, turn on short circuit mode. // 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; $this->short_circuit = true;
return; return;
} }
@@ -125,7 +125,7 @@ class GetTextReader
$MAGIC1 = "\x95\x04\x12\xde"; $MAGIC1 = "\x95\x04\x12\xde";
$MAGIC2 = "\xde\x12\x04\x95"; $MAGIC2 = "\xde\x12\x04\x95";
$this->STREAM = $Reader; $this->STREAM = (object)$Reader;
$magic = $this->read(4); $magic = $this->read(4);
if ($magic == $MAGIC1) { if ($magic == $MAGIC1) {
$this->BYTEORDER = 1; $this->BYTEORDER = 1;
@@ -351,7 +351,7 @@ class GetTextReader
return $expr; return $expr;
} }
/** /**
* Get possible plural forms from MO header * Get possible plural forms from MO header
* *
* @access private * @access private
@@ -394,6 +394,7 @@ class GetTextReader
$plural = 0; $plural = 0;
eval("$string"); eval("$string");
/** @phpstan-ignore-next-line */
if ($plural >= $total) { if ($plural >= $total) {
$plural = $total - 1; $plural = $total - 1;
} }

View File

@@ -270,6 +270,9 @@ class Elements
return "mailto:" . $email; return "mailto:" . $email;
} elseif ($atag) { } elseif ($atag) {
return $atag . $email; return $atag . $email;
} else {
// else just return email as is
return $email;
} }
} }
} }

View File

@@ -267,6 +267,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
*/ */
public function __construct(array $db_config, int $table_width = 750) public function __construct(array $db_config, int $table_width = 750)
{ {
global $table_arrays;
// replace any non valid variable names // replace any non valid variable names
// TODO extracft only alphanumeric and _ after . to _ replacement // TODO extracft only alphanumeric and _ after . to _ replacement
$this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1)); $this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1));
@@ -278,12 +279,15 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// first check if we have a in page override as $table_arrays[page name] // first check if we have a in page override as $table_arrays[page name]
if ( if (
isset($_GLOBALS['table_arrays']) && /* isset($GLOBALS['table_arrays']) &&
is_array($_GLOBALS['table_arrays']) && is_array($GLOBALS['table_arrays']) &&
isset($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) && isset($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
is_array($_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 { } else {
// WARNING: auto spl load does not work with this as it is an array and not a function/object // 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 // check if this is the old path or the new path
@@ -321,9 +325,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if (isset($config_array['load_query']) && $config_array['load_query']) { if (isset($config_array['load_query']) && $config_array['load_query']) {
$this->load_query = $config_array['load_query']; $this->load_query = $config_array['load_query'];
} }
$this->archive_pk_name = 'a_' . $this->pk_name; $this->archive_pk_name = 'a_' . $this->pk_name ?? '';
$this->col_name = str_replace('_id', '', $this->pk_name); $this->col_name = str_replace('_id', '', $this->pk_name ?? '');
$this->int_pk_name = $this->pk_name; $this->int_pk_name = $this->pk_name ?? '';
// check if reference_arrays are given and proceed them // check if reference_arrays are given and proceed them
if (isset($config_array['reference_arrays']) && is_array($config_array['reference_arrays'])) { if (isset($config_array['reference_arrays']) && is_array($config_array['reference_arrays'])) {
foreach ($config_array['reference_arrays'] as $key => $value) { foreach ($config_array['reference_arrays'] as $key => $value) {
@@ -810,7 +814,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
(isset($this->security_level['delete']) && (isset($this->security_level['delete']) &&
$this->base_acl_level >= $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']) { if ($this->base_acl_level >= $this->security_level['save']) {
$seclevel_okay = 1; $seclevel_okay = 1;
if (empty($this->table_array[$this->int_pk_name]['value'])) { if (empty($this->table_array[$this->int_pk_name]['value'])) {
@@ -819,7 +822,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$save = $this->l->__('Update'); $save = $this->l->__('Update');
} }
// print the old_school hidden if requestet // print the old_school hidden if requestet
if ($old_school_hidden) { if ($old_school_hidden == 1) {
$pk_name = $this->int_pk_name; $pk_name = $this->int_pk_name;
$pk_value = $this->table_array[$this->int_pk_name]['value']; $pk_value = $this->table_array[$this->int_pk_name]['value'];
} }
@@ -1270,7 +1273,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// if mandatory && no input // if mandatory && no input
// $this->log->debug('form', 'A: ' . $this->table_array[$key]['type'] . ' -- ' // $this->log->debug('form', 'A: ' . $this->table_array[$key]['type'] . ' -- '
// . $this->table_array[$key]['input_value'] . ' -- ' . $this->table_array[$key]['value']); // . $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->msg .= sprintf(
$this->l->__('Please enter something into the <b>%s</b> field!<br>'), $this->l->__('Please enter something into the <b>%s</b> field!<br>'),
$this->table_array[$key]['output_name'] $this->table_array[$key]['output_name']
@@ -1505,7 +1511,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if ($order_name) { if ($order_name) {
// first check out of order ... // first check out of order ...
if (!$this->table_array[$order_name]['value']) { if (empty($this->table_array[$order_name]['value'])) {
// set order (read max) // set order (read max)
$q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name; $q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name;
list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q); list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q);
@@ -1513,7 +1519,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if (!$this->table_array[$order_name]['value']) { if (!$this->table_array[$order_name]['value']) {
$this->table_array[$order_name]['value'] = 1; $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 $q = 'SELECT ' . $order_name
. ' FROM ' . $this->table_name . ' FROM ' . $this->table_name
. ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value']; . ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
@@ -2377,7 +2383,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$this->element_list[$table_name]['max_empty'] = 10; $this->element_list[$table_name]['max_empty'] = 10;
} }
// check if we need to fill fields // 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; $missing_empty_count = $this->element_list[$table_name]['max_empty'] - $element_count;
$this->log->debug('CFG MAX', 'Max empty: ' $this->log->debug('CFG MAX', 'Max empty: '
. $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count . $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count

View File

@@ -130,10 +130,10 @@ class Image
array_map('unlink', glob($delete_filename . '*')); array_map('unlink', glob($delete_filename . '*'));
} }
} else { } else {
if ($dummy && strstr($dummy, '/') === false) { if (!empty($dummy) && strstr($dummy, '/') === false) {
// check if we have the "dummy" image flag set // check if we have the "dummy" image flag set
$filename = PICTURES . ICONS . strtoupper($dummy) . ".png"; $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; $return_data = $filename;
} else { } else {
$return_data = false; $return_data = false;

View File

@@ -22,9 +22,13 @@ class ProgressBar
{ {
// private vars // private vars
/** @var string */
public $code; // unique code public $code; // unique code
/** @var string */
public $status = 'new'; // current status (new,show,hide) public $status = 'new'; // current status (new,show,hide)
/** @var int */
public $step = 0; // current step public $step = 0; // current step
/** @var array<string,?int> */
public $position = [ // current bar position public $position = [ // current bar position
'left' => null, 'left' => null,
'top' => null, 'top' => null,
@@ -32,27 +36,43 @@ class ProgressBar
'height' => null, 'height' => null,
]; ];
/** @var int */
public $clear_buffer_size = 1; // we need to send this before the lfush to get browser output 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 $clear_buffer_size_init = 1024 * 1024; // if I don't send that junk, it won't send anything
// public vars // public vars
/** @var int */
public $min = 0; // minimal steps public $min = 0; // minimal steps
/** @var int */
public $max = 100; // maximal steps public $max = 100; // maximal steps
/** @var int */
public $left = 5; // bar position from left public $left = 5; // bar position from left
/** @var int */
public $top = 5; // bar position from top public $top = 5; // bar position from top
/** @var int */
public $width = 300; // bar width public $width = 300; // bar width
/** @var int */
public $height = 25; // bar height public $height = 25; // bar height
/** @var int */
public $pedding = 0; // bar pedding public $pedding = 0; // bar pedding
/** @var string */
public $color = '#0033ff'; // bar color public $color = '#0033ff'; // bar color
/** @var string */
public $bgr_color = '#c0c0c0'; // bar background color public $bgr_color = '#c0c0c0'; // bar background color
/** @var string */
public $bgr_color_master = '#ffffff'; // master div background color public $bgr_color_master = '#ffffff'; // master div background color
/** @var int */
public $border = 1; // bar border width public $border = 1; // bar border width
/** @var string */
public $brd_color = '#000000'; // bar border color public $brd_color = '#000000'; // bar border color
/** @var string */
public $direction = 'right'; // direction of motion (right,left,up,down) public $direction = 'right'; // direction of motion (right,left,up,down)
/** @var array<string,mixed> */
public $frame = ['show' => false]; // ProgressBar Frame public $frame = ['show' => false]; // ProgressBar Frame
/* 'show' => false, # frame show (true/false) /* 'show' => false, # frame show (true/false)
'left' => 200, # frame position from left 'left' => 200, # frame position from left
@@ -64,6 +84,7 @@ class ProgressBar
'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color
*/ */
/** @var array<mixed> */
public $label = []; // ProgressBar Labels public $label = []; // ProgressBar Labels
/* 'name' => [ # label name /* 'name' => [ # label name
'type' => 'text', # label type (text,button,step,percent,crossbar) 'type' => 'text', # label type (text,button,step,percent,crossbar)
@@ -81,6 +102,7 @@ class ProgressBar
] ]
*/ */
/** @var string */
// output strings // output strings
public $prefix_message = ''; public $prefix_message = '';
@@ -141,8 +163,8 @@ class ProgressBar
/** /**
* calculate position in bar step * calculate position in bar step
* @param float $step percent step to do * @param float $step percent step to do
* @return array bar position as array * @return array<mixed> bar position as array
*/ */
private function __calculatePosition(float $step): array private function __calculatePosition(float $step): array
{ {

View File

@@ -361,6 +361,11 @@ class SmartyExtend extends SmartyBC
$this->HEADER['ENCODING'] = $this->encoding; $this->HEADER['ENCODING'] = $this->encoding;
$this->HEADER['DEFAULT_ENCODING'] = DEFAULT_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 // special for admin
if ($admin_call === true) { if ($admin_call === true) {
// set ACL extra show // set ACL extra show
@@ -385,6 +390,7 @@ class SmartyExtend extends SmartyBC
// the page name // the page name
$this->DATA['page_name'] = $this->page_name; $this->DATA['page_name'] = $this->page_name;
$this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH; $this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH;
$this->DATA['form_name'] = $this->DATA['FORM_NAME'];
// for tinymce special // for tinymce special
$this->DATA['TINYMCE_LANG'] = $this->lang_short; $this->DATA['TINYMCE_LANG'] = $this->lang_short;
// include flags // include flags
@@ -404,11 +410,6 @@ class SmartyExtend extends SmartyBC
// LANG // LANG
$this->DATA['LANG'] = $this->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 // include flags
$this->DATA['JS_DATEPICKR'] = $this->JS_DATEPICKR; $this->DATA['JS_DATEPICKR'] = $this->JS_DATEPICKR;
$this->DATA['JS_FLATPICKR'] = $this->JS_FLATPICKR; $this->DATA['JS_FLATPICKR'] = $this->JS_FLATPICKR;

View File

@@ -1,38 +1,33 @@
<?php <?php // phpcs:ignore PSR1.Files.SideEffects
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2011/2/8 * CREATED: 2011/2/8
* DESCRIPTION: pre function to collect all non critical errors into a log file if possible * DESCRIPTION: pre function to collect all non critical errors
* include this file at the very beginning of the script to get the notices, strict, etc messages. * 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 * error etc will still be written to the log/display
*********************************************************************/ *********************************************************************/
declare(strict_types=1); 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__));
}
/** /**
* will catch any error except E_ERROR and try to write them to the log file * will catch any error except E_ERROR and try to write them to the log file
* in log/php_error-<DAY>.log * in log/php_error-<DAY>.log
* if this fails, it will print the data to the window via echo * if this fails, it will print the data to the window via echo
* @param int $type the error code from PHP * @param int $type the error code from PHP
* @param string $message the error message 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 string $file in which file the error happend.
* @param int $line in which line the error happened * this is the source file (eg include)
* @param array $context array with all the variable * @param int $line in which line the error happened
* @return bool true, so cought errors do not get processed by the PHP error engine * @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 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 // This error code is not included in error_reporting
return false; return false;
} }
@@ -67,8 +62,15 @@ function MyErrorHandler(int $type, string $message, string $file, int $line, arr
// : the php error message // : the php error message
$output = '{' . array_pop($page_temp) . '} [' . $file . '] ' $output = '{' . array_pop($page_temp) . '} [' . $file . '] '
. '<' . $line . '> [' . $error_level[$type] . '|' . $type . ']: ' . $message; . '<' . $line . '> [' . $error_level[$type] . '|' . $type . ']: ' . $message;
# try to open file // define the base working directory outside because in the function it might return undefined
$ROOT = CURRENT_WORKING_DIR; // 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; $LOG = 'log' . DIRECTORY_SEPARATOR;
// if the log folder is not found, try to create it // if the log folder is not found, try to create it
if (!is_dir($ROOT . $LOG) && !is_file($ROOT . LOG)) { if (!is_dir($ROOT . $LOG) && !is_file($ROOT . LOG)) {

View File

@@ -1,4 +1,4 @@
<?php <?php // phpcs:ignore PSR1.Files.SideEffects
declare(strict_types=1); declare(strict_types=1);
@@ -10,21 +10,26 @@ if (class_exists('Autoload', false) === false) {
// define the auto loader class // define the auto loader class
class Autoload class Autoload
{ {
// we do it simple here /**
// passes on the class to load and we search here in namespace * we do it simple here
// to load that class * passes on the class to load and we search here in namespace
public static function load($class) * 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>"; // print "(1) Class: $class / DIR: ".__DIR__."<br>";
// set directory seperator (we need to replace from namespace) // set directory seperator (we need to replace from namespace)
$DS = defined('DS') ? DS : DIRECTORY_SEPARATOR; $DS = DIRECTORY_SEPARATOR;
// base lib // base lib
$LIB = defined('LIB') ? LIB : 'lib' . $DS; $LIB = defined('LIB') ? LIB : 'lib' . $DS;
// if lib is in path at the end, do not add lib again // if lib is in path at the end, do not add lib again
// note that $LIB can have a directory seperator at the end // note that $LIB can have a directory seperator at the end
// strip that out before we do a match // strip that out before we do a match
$_LIB = rtrim($LIB, $DS); $_LIB = rtrim($LIB, $DS);
if (preg_match("|$_LIB$|", __DIR__) === false) { if (!preg_match("|$_LIB$|", __DIR__)) {
$LIB .= $DS; $LIB .= $DS;
} else { } else {
$LIB = ''; $LIB = '';
@@ -50,9 +55,7 @@ if (class_exists('Autoload', false) === false) {
// we should sub that // we should sub that
// self::loadFile($path); // self::loadFile($path);
include $path; include $path;
return true;
} }
return false;
} }
// end class define // end class define
} }

View File

@@ -11,12 +11,6 @@
<projectFiles> <projectFiles>
<file name="admin/class_test.php" /> <file name="admin/class_test.php" />
<file name="admin/config.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="configs" />
<directory name="frontend" /> <directory name="frontend" />
<directory name="includes" /> <directory name="includes" />
@@ -58,7 +52,6 @@
<MissingReturnType errorLevel="error" /> <MissingReturnType errorLevel="error" />
<MissingPropertyType errorLevel="error" /> <MissingPropertyType errorLevel="error" />
<InvalidDocblock errorLevel="error" /> <InvalidDocblock errorLevel="error" />
<MisplacedRequiredParam errorLevel="error" />
<PropertyNotSetInConstructor errorLevel="error" /> <PropertyNotSetInConstructor errorLevel="error" />
<MissingConstructor errorLevel="error" /> <MissingConstructor errorLevel="error" />

View File

@@ -37,8 +37,8 @@ namespace Composer\Autoload;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/ * @see https://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/ * @see https://www.php-fig.org/psr/psr-4/
*/ */
class ClassLoader class ClassLoader
{ {
@@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes() public function getPrefixes()
{ {
if (!empty($this->prefixesPsr0)) { 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(); return array();

View File

@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
); );

View File

@@ -13,6 +13,9 @@ class ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9
} }
} }
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader() public static function getLoader()
{ {
if (null !== self::$loader) { 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()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::getInitializer($loader));
} else { } else {

View File

@@ -6,9 +6,14 @@ namespace Composer\Autoload;
class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
{ {
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@@ -1 +1,5 @@
[] {
"packages": [],
"dev": true,
"dev-package-names": []
}