phpan/phpstan clean up runs, minor update to DB\IO

DB\IO dbReturn method has a third parameter to set read only assoc and
not number data from the query

Install basic composer for trying out psalm

setting phpan/phpstan for basic static checking and do basic clean up on
all of the files
This commit is contained in:
Clemens Schwaighofer
2019-09-18 09:25:35 +09:00
parent 25941f4b49
commit 9ea8364aab
42 changed files with 1179 additions and 242 deletions

View File

@@ -25,48 +25,64 @@ use Phan\Config;
* '-d' flag.
*/
return [
// If true, missing properties will be created when
// they are first seen. If false, we'll report an
// error message.
"allow_missing_properties" => true,
// If true, missing properties will be created when
// they are first seen. If false, we'll report an
// error message.
"allow_missing_properties" => false,
// Allow null to be cast as any type and for any
// type to be cast to null.
"null_casts_as_any_type" => true,
// Allow null to be cast as any type and for any
// type to be cast to null.
"null_casts_as_any_type" => false,
// Backwards Compatibility Checking
'backward_compatibility_checks' => false,
// Backwards Compatibility Checking
'backward_compatibility_checks' => true,
// Run a quick version of checks that takes less
// time
"quick_mode" => false,
// Run a quick version of checks that takes less
// time
"quick_mode" => false,
// Only emit critical issues to start with
// (0 is low severity, 5 is normal severity, 10 is critical)
"minimum_severity" => 10,
// Only emit critical issues to start with
// (0 is low severity, 5 is normal severity, 10 is critical)
"minimum_severity" => 5,
// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// 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',
],
// default false for include path check
"enable_include_path_checks" => true,
"include_paths" => [
'.', '../configs/'
],
'ignore_undeclared_variables_in_global_scope' => true,
// A list of directories holding code that we want
// to parse, but not analyze
"exclude_analysis_directory_list" => [
'www/vendor',
"file_list" => [
"./www/configs/config.db.php",
"./www/configs/config.host.php",
"./www/configs/config.path.php",
"./www/configs/config.master.php",
"./www/includes/admin_header.php",
],
// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// 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',
],
// A list of directories holding code that we want
// to parse, but not analyze
"exclude_analysis_directory_list" => [
'www/vendor',
'www/lib/FileUpload',
'www/lib/pChart',
'www/lib/pChart2.1.4',
@@ -77,5 +93,30 @@ return [
'www/tmp',
'www/cache',
'www/media',
],
],
'exclude_file_list' => [
'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',
// ignore the old qq tests
'www/admin/qq_file_upload_front.php',
'www/admin/qq_file_upload_ajax.php',
],
// what not to show as problem
'suppress_issue_types' => [
// 'PhanUndeclaredMethod',
],
// Override to hardcode existence and types of (non-builtin) globals in the global scope.
// Class names should be prefixed with `\`.
//
// (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`)
'globals_type_map' => [],
];

View File

@@ -1,7 +1,90 @@
-- 2019/9/10 update edit_page with reference
-- 2019/9/10 update edit_page with reference and additional ACLs, update core functions
-- page content reference settings
-- * random_string function
-- * add cuid column in edit_generic
-- * update generic trigger function
-- * edit_page_content table/trigger
-- * edit_* additional_acl entries
-- * edit_page content alias link
-- * update any missing cuid entries
-- create random string with length X
CREATE FUNCTION random_string(randomLength int)
RETURNS text AS $$
SELECT array_to_string(
ARRAY(
SELECT substring(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
trunc(random() * 62)::int + 1,
1
)
FROM generate_series(1, randomLength) AS gs(x)
),
''
)
$$ LANGUAGE SQL
RETURNS NULL ON NULL INPUT
VOLATILE;
-- edit_gneric update
ALTER TABLE edit_generic ADD cuid VARCHAR;
-- adds the created or updated date tags
CREATE OR REPLACE FUNCTION set_edit_generic() RETURNS TRIGGER AS '
DECLARE
random_length INT = 12; -- that should be long enough
BEGIN
IF TG_OP = ''INSERT'' THEN
NEW.date_created := ''now'';
NEW.cuid := random_string(random_length);
ELSIF TG_OP = ''UPDATE'' THEN
NEW.date_updated := ''now'';
END IF;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
-- DROP TABLE edit_page_content;
CREATE TABLE edit_page_content (
edit_page_content_id SERIAL PRIMARY KEY,
edit_page_id INT NOT NULL,
edit_access_right_id INT NOT NULL,
name VARCHAR,
uid VARCHAR UNIQUE,
order_number INT NOT NULL,
online SMALLINT NOT NULL DEFAULT 0,
FOREIGN KEY (edit_access_right_id) REFERENCES edit_access_right (edit_access_right_id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (edit_page_id) REFERENCES edit_page (edit_page_id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE
) INHERITS (edit_generic) WITHOUT OIDS;
DROP TRIGGER trg_edit_page_content ON edit_page_content;
CREATE TRIGGER trg_edit_page_content
BEFORE INSERT OR UPDATE ON edit_page_content
FOR EACH ROW EXECUTE PROCEDURE set_edit_generic();
-- INSERT new list entry
INSERT INTO edit_access_right (name, level, type) VALUES ('List', 10, 'list');
-- UPDATE
ALTER TABLE edit_user ADD additional_acl JSONB;
ALTER TABLE edit_group ADD additional_acl JSONB;
ALTER TABLE edit_access ADD additional_acl JSONB;
-- page content reference settings
ALTER TABLE edit_page ADD content_alias_edit_page_id INT;
ALTER TABLE edit_page ADD CONSTRAINT edit_page_content_alias_edit_page_id_fkey FOREIGN KEY (content_alias_edit_page_id) REFERENCES edit_page (edit_page_id) MATCH FULL ON DELETE RESTRICT ON UPDATE CASCADE;
-- 2019/9/10 UPDATE missing cuid in edit_* tables
UPDATE edit_access SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_access_data SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_access_right SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_access_user SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_group SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_language SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_log SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_menu_group SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_page SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_page_access SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_page_content SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_query_string SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_scheme SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_user SET cuid = random_string(12) WHERE cuid IS NULL;
UPDATE edit_visible_group SET cuid = random_string(12) WHERE cuid IS NULL;

7
phpstan-bootstrap.php Executable file
View File

@@ -0,0 +1,7 @@
<?php
// Boostrap file for PHPstand
// sets the _SERVER['HTTP_HOST'] var so we can have DB detection
$_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp';
// __END__

37
phpstan.neon Normal file
View File

@@ -0,0 +1,37 @@
# PHP Stan Config
parameters:
level: 1
paths:
- %currentWorkingDirectory%/www
#bootstrap: %currentWorkingDirectory%/phpstan-bootstrap.php
#bootstrap: phpstan-bootstrap.php
autoload_directories:
autoload_files:
- %currentWorkingDirectory%/phpstan-bootstrap.php
- www/configs/config.master.php
- www/lib/autoloader.php
excludes_analyse:
- www/includes/admin_header.php # ignore the admin include stuff
- www/includes/admin_footer.php # ignore the admin include stuff
- www/includes/admin_set_paths.php # ignore the admin include stuff
- www/includes/admin_smarty.php # ignore the admin include stuff
- www/templates_c
- www/cache
- www/log
- www/media
- www/tmp
- www/lib/pChart
- www/lib/pChart2.1.4
- www/lib/Smarty/
- www/lib/smarty-3.1.30/
- 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/vendor

3
static_checkers.txt Normal file
View File

@@ -0,0 +1,3 @@
phan --progress-bar -C -o analysis.txt
phpstan analyse -c phpstan.neon --memory-limit=4G -l 0 www
www/: psalm (this needs the composer autoloader defined)

View File

@@ -17,18 +17,21 @@ define('USE_DATABASE', true);
require 'config.php';
// set session name
if (!defined('SET_SESSION_NAME')) {
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
}
// define log file id
DEFINE('LOG_FILE_ID', 'classTest');
define('LOG_FILE_ID', 'classTest');
// set language for l10n
$lang = 'en_utf8';
// init login & backend class
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
$basic = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
$login = new CoreLibs\ACL\Login(DB_CONFIG, $lang);
$basic = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
$basic->dbInfo(1);
ob_end_flush();
echo "DB_CONFIG_SET constant: <pre>".print_r(DB_CONFIG, true)."</pre><br>";
$basic->hrRunningTime();
$basic->runningTime();
echo "RANDOM KEY [50]: ".$basic->randomKeyGen(50)."<br>";
@@ -40,7 +43,7 @@ echo "TIMED: ".$basic->hrRunningTime()."<br>";
// set + check edit access id
$edit_access_id = 3;
if (isset($login) && is_object($login) && isset($login->acl['unit'])) {
if (is_object($login) && isset($login->acl['unit'])) {
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), true)."<br>";
print "ACCESS CHECK: ".$login->loginCheckEditAccess($edit_access_id)."<br>";
if ($login->loginCheckEditAccess($edit_access_id)) {
@@ -76,7 +79,7 @@ print "CALLER BACKTRACE: ".$basic->getCallerMethod()."<br>";
$basic->debug('SOME MARK', 'Some error output');
print "EDIT ACCESS ID: ".$basic->edit_access_id."<br>";
if (isset($login)) {
if (is_object($login)) {
// print "ACL: <br>".$basic->print_ar($login->acl)."<br>";
$basic->debug('ACL', "ACL: ".$basic->printAr($login->acl));
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
@@ -90,9 +93,13 @@ if (isset($login)) {
// DB client encoding
print "DB Client encoding: ".$basic->dbGetEncoding()."<br>";
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
while ($res = $basic->dbReturn("SELECT * FROM max_test", 0, true)) {
print "TIME: ".$res['time']."<br>";
}
print "CACHED DATA: <pre>".print_r($basic->cursor_ext, true)."</pre><br>";
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
print "[CACHED] TIME: ".$res['time']."<br>";
}
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, true)."<br>";

View File

@@ -10,12 +10,12 @@ ob_start();
// admin class tests
require 'config.php';
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
$SET_SESSION_NAME = EDIT_SESSION_NAME;
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
$lang = 'ja_utf8';
$base = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
$base = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
ob_end_flush();
print "Start time: ".$base->runningTime()."<br>";

View File

@@ -21,3 +21,14 @@ class FooBar
echo "B: $wrong<br>";
}
}
$foo = $bar ?? 'EMPTY';
echo "BAR: ".$foo."<br>";
// define('DS', DIRECTORY_SEPARATOR);
$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR;
$du = DS ?? DIRECTORY_SEPARATOR;
echo "DS is: ".$ds."<br>";
echo "SERVER HOST: ".$_SERVER['HTTP_HOST']."<br>";
// __END__

View File

@@ -1,5 +1,7 @@
<?php
namespace CoreLibs;
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1;
$PRINT_ALL = 1;
@@ -7,14 +9,14 @@ $DB_DEBUG = 1;
// admin class tests
require 'config.php';
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
$base = new CoreLibs\Basic();
$SET_SESSION_NAME = EDIT_SESSION_NAME;
$base = new Basic();
print "THIS HOST: ".HOST_NAME.", with PROTOCOL: ".HOST_PROTOCOL." is running SSL: ".HOST_SSL."<br>";
print "DIR: ".DIR."<br>";
print "BASE: ".BASE."<br>";
print "ROOT: ".ROOT."<br>";
print "HOST: ".$HOST_NAME." => DB HOST: ".$DB_HOST[$HOST_NAME]." => ".MAIN_DB."<br>";
print "HOST: ".HOST_NAME." => DB HOST: ".DB_CONFIG_NAME." => ".DB_SCHEMA." => ".print_r(DB_CONFIG, true)."<br>";
$text = 'I am some text
with some

12
www/composer.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "gullevek/www",
"description": "CoreLibs",
"type": "library",
"authors": [
{
"name": "Clemens Schwaighofer",
"email": "clemens.schwaighofer@egplusww.com"
}
],
"require": {}
}

View File

@@ -105,6 +105,7 @@ DEFINE('DEFAULT_ACL_ADMIN', 100); */
DEFINE('LOGOUT_TARGET', '');
// password change allowed
DEFINE('PASSWORD_CHANGE', false);
DEFINE('PASSWORD_FORGOT', false);
// min/max password length
DEFINE('PASSWORD_MIN_LENGTH', 8);
DEFINE('PASSWORD_MAX_LENGTH', 255);
@@ -130,7 +131,7 @@ DEFINE('EDIT_SESSION_NAME', 'ADMIN_SESSION_NAME'.SERVER_NAME_HASH);
// frontend
DEFINE('SESSION_NAME', 'SESSION_NAME'.SERVER_NAME_HASH);
// SET_SESSION_NAME should be set in the header if a special session name is needed
// DEFINE('SET_SESSION_NAME', SESSION_NAME);
DEFINE('SET_SESSION_NAME', SESSION_NAME);
/************* CACHE/COMPILE IDS *************/
DEFINE('CACHE_ID', 'CACHE_'.SERVER_NAME_HASH);
@@ -166,13 +167,31 @@ DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public');
DEFINE('LIVE_SCHEMA', 'public');
/************* CORE HOST SETTINGS *****************/
if (file_exists(BASE.CONFIGS.'config.host.php')) {
require BASE.CONFIGS.'config.host.php';
}
if (!isset($DB_HOST)) {
$DB_HOST = array ();
}
if (!isset($DB_PATH)) {
$DB_PATH = array ();
}
if (!isset($LOCATION)) {
$LOCATION = array ();
}
if (!isset($DEBUG_FLAG)) {
$DEBUG_FLAG = array ();
}
if (!isset($SITE_LANG)) {
$SITE_LANG = array ();
}
/************* DB ACCESS *****************/
if (file_exists(BASE.CONFIGS.'config.db.php')) {
require BASE.CONFIGS.'config.db.php';
}
/************* CORE HOST SETTINGS *****************/
if (file_exists(BASE.CONFIGS.'config.host.php')) {
require BASE.CONFIGS.'config.host.php';
if (!isset($DB_CONFIG)) {
$DB_CONFIG = array ();
}
/************* OTHER PATHS *****************/
if (file_exists(BASE.CONFIGS.'config.path.php')) {
@@ -201,9 +220,9 @@ if ((array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) && $_SERVE
DEFINE('HOST_SSL', false);
DEFINE('HOST_PROTOCOL', 'http://');
}
// define the static names
DEFINE('LOGIN_DB', $DB_HOST[$HOST_NAME]);
DEFINE('MAIN_DB', $DB_HOST[$HOST_NAME]);
// define the db config set name, the db config and the db schema
DEFINE('DB_CONFIG_NAME', $DB_HOST[$HOST_NAME]);
DEFINE('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME]);
DEFINE('DB_SCHEMA', $DB_PATH[$HOST_NAME]);
// DEFINE('TARGET_DB', $DB_TARGET_HOST[$HOST_NAME]);
// DEFINE('URL_REDIRECT_DB', $DB_URL_REDIRECT_HOST[$HOST_NAME]);
@@ -252,17 +271,19 @@ foreach ($paths as $path) {
// turn off debug if debug flag is OFF
if (defined('DEBUG') && DEBUG == false) {
$ECHO_ALL = 0;
$DEBUG_ALL = 0;
$PRINT_ALL = 0;
$DB_DEBUG = 0;
$ENABLE_ERROR_HANDLING = 0;
$ECHO_ALL = false;
$DEBUG_ALL = false;
$PRINT_ALL = false;
$DB_DEBUG = false;
$ENABLE_ERROR_HANDLING = false;
$DEBUG_ALL_OVERRIDE = false;
} else {
$ECHO_ALL = 0;
$DEBUG_ALL = 1;
$PRINT_ALL = 1;
$DB_DEBUG = 1;
$ENABLE_ERROR_HANDLING = 0;
$ECHO_ALL = false;
$DEBUG_ALL = true;
$PRINT_ALL = true;
$DB_DEBUG = true;
$ENABLE_ERROR_HANDLING = false;
$DEBUG_ALL_OVERRIDE = false;
}
// read auto loader

View File

@@ -23,7 +23,7 @@ extract($_POST, EXTR_SKIP);
// set output to quiet for load of classes & session settings
ob_start();
// set the session name
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
$SET_SESSION_NAME = EDIT_SESSION_NAME;
//------------------------------ library include end
//------------------------------ basic variable settings start
@@ -48,7 +48,7 @@ if (isset($AJAX_PAGE) && isset($ZIP_STREAM) && $AJAX_PAGE && !$ZIP_STREAM) {
//------------------------------ class init start
// login & page access check
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
$login = new CoreLibs\ACL\Login(DB_CONFIG, $lang);
// post login lang check
if ($_SESSION['DEFAULT_LANG']) {
$lang = $_SESSION['DEFAULT_LANG'];
@@ -56,7 +56,7 @@ if ($_SESSION['DEFAULT_LANG']) {
// create smarty object
$smarty = new CoreLibs\Template\SmartyExtend($lang);
// create new DB class
$cms = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
$cms = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
// the menu show flag (what menu to show)
$cms->menu_show_flag = 'main';
// db nfo

View File

@@ -24,14 +24,10 @@ $DB_DEBUG = 1;
// TODO: only extract _POST data that is needed
extract($_POST, EXTR_SKIP);
$table_width = '100%';
// this is for certain CMS modules that set a relative path
define('REL_PATH', '');
ob_start();
require 'config.php';
// set session name here
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
$SET_SESSION_NAME = EDIT_SESSION_NAME;
// overrride debug flags
if (!DEBUG) {
$DEBUG_ALL = 0;
@@ -47,10 +43,10 @@ if (!isset($lang)) {
// should be utf8
header("Content-type: text/html; charset=".DEFAULT_ENCODING);
ob_end_flush();
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
$login = new CoreLibs\ACL\Login(DB_CONFIG, $lang);
// create form class
$form = new CoreLibs\Output\Form\Generate($DB_CONFIG[MAIN_DB], $lang);
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $lang);
if ($form->mobile_phone) {
echo "I am sorry, but this page cannot be viewed by a mobile phone";
exit;
@@ -70,6 +66,8 @@ if (TARGET == 'live' || TARGET == 'remote') {
$form->echo_output_all = 0;
$form->print_output_all = DEBUG ? 1 : 0;
}
// space for setting special debug flags
$login->debug_output_all = 1;
// set the template dir
// WARNING: this has a special check for the mailing tool layout (old layout)
if (defined('LAYOUT')) {
@@ -81,32 +79,8 @@ if (defined('LAYOUT')) {
$DATA['css'] = CSS;
$DATA['js'] = JS;
}
// space for setting special debug flags
$login->debug_output_all = 1;
// define edit logging function. should be in a special edit interface class later
// METHOD: EditLog()
// PARAMS: event -> any kind of event description, data -> any kind of data related to that event
// RETURN: none
// DESC: writes all action vars plus other info into edit_log table
function EditLog($event = '', $data = '')
{
$q = "INSERT INTO edit_log ";
$q .= "(euid, event_date, ip, event, data, page) ";
$q .= "VALUES (".$_SESSION['EUID'].", NOW(), '".$_SERVER["REMOTE_ADDR"]."', '".$GLOBALS['form']->dbEscapeString($event)."', '".$GLOBALS['form']->dbEscapeString($data)."', '".$GLOBALS['form']->getPageName()."')";
}
// log backend data
// data part creation
$data = array (
'_SESSION' => $_SESSION,
'_GET' => $_GET,
'_POST' => $_POST,
'_FILES' => $_FILES
);
// log action
EditLog('Edit Submit', serialize($data));
// set table width
$table_width = '100%';
// define all needed smarty stuff for the general HTML/page building
$HEADER['CSS'] = CSS;
@@ -128,12 +102,14 @@ if ($form->my_page_name == 'edit_order') {
if (!isset($position)) {
$position = array ();
}
$row_data_id = $_POST['row_data_id'];
$original_id = $row_data_id;
if (count($position)) {
$original_id = $row_data_id;
$row_data_order = $_POST['row_data_order'];
// FIRST u have to put right sort, then read again ...
// hast to be >0 or the first one is selected and then there is no move
if (isset($up) && $position[0] > 0) {
if (isset($up) && isset($position[0]) && $position[0] > 0) {
for ($i = 0; $i < count($position); $i++) {
// change position order
// this gets temp, id before that, gets actual (moves one "down")
@@ -141,8 +117,8 @@ if ($form->my_page_name == 'edit_order') {
// is done for every element in row
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
$temp_id = $row_data_id[$position[$i]];
$row_data_id[$position[$i]] = $row_data_id[$position[$i]-1];
$row_data_id[$position[$i]-1] = $temp_id;
$row_data_id[$position[$i]] = $row_data_id[$position[$i] - 1];
$row_data_id[$position[$i] - 1] = $temp_id;
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
} // for
} // if up
@@ -191,6 +167,9 @@ if ($form->my_page_name == 'edit_order') {
$messages = array ();
// error msg
if (isset($error)) {
if (!isset($msg)) {
$msg = array ();
}
$messages[] = array ('msg' => $msg, 'class' => 'error', 'width' => '100%');
}
$DATA['form_error_msg'] = $messages;
@@ -199,7 +178,7 @@ if ($form->my_page_name == 'edit_order') {
$options_id = array ();
$options_name = array ();
$options_selected = array ();
if (!is_array($row_data)) {
if (!isset($row_data) || !is_array($row_data)) {
$row_data = array ();
}
for ($i = 0; $i < count($row_data); $i ++) {
@@ -270,6 +249,7 @@ if ($form->my_page_name == 'edit_order') {
if (!isset($PAGES) || !is_array($PAGES)) {
$PAGES = array ();
}
$menuarray = array ();
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
if ($PAGE_DATA['menu'] && $PAGE_DATA['online']) {
$menuarray[] = $PAGE_DATA;
@@ -288,6 +268,7 @@ if ($form->my_page_name == 'edit_order') {
}
$position = 0;
$menu_data = array ();
for ($i = 1; $i <= count($menuarray); $i ++) {
// do that for new array
$j = $i - 1;
@@ -338,7 +319,7 @@ if ($form->my_page_name == 'edit_order') {
$DATA['form_my_page_name'] = $form->my_page_name;
$DATA['filename_exist'] = 0;
$DATA['drop_down_input'] = 0;
$elements = array ();
// depending on the "getPageName()" I show different stuff
switch ($form->my_page_name) {
case 'edit_users':

View File

@@ -120,7 +120,8 @@ class Login extends \CoreLibs\DB\IO
$this->log_per_class = 1;
// create db connection and init base class
if (!parent::__construct($db_config, $set_control_flag)) {
parent::__construct($db_config, $set_control_flag);
if ($this->db_init_error === false) {
echo 'Could not connect to DB<br>';
// if I can't connect to the DB to auth exit hard. No access allowed
exit;
@@ -365,7 +366,7 @@ class Login extends \CoreLibs\DB\IO
$q .= "(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 (!$this->cursor_ext[md5($q)]['num_rows']) {
$this->login_error = 1010;
} else {
// if login errors is half of max errors and the last login error was less than 10s ago, forbid any new login try
@@ -422,8 +423,9 @@ class Login extends \CoreLibs\DB\IO
$q .= "WHERE edit_user_id = ".$res['edit_user_id'];
$this->dbExec($q);
}
$pages = array();
$edit_page_ids = array();
$pages = array();
$pages_acl = array ();
// set pages access
$q = "SELECT ep.edit_page_id, ep.cuid, epca.cuid AS content_alias_uid, ep.filename, ep.name AS edit_page_name, ep.order_number AS edit_page_order, ep.menu, ";
$q .= "ep.popup, ep.popup_x, ep.popup_y, ep.online, ear.level, ear.type ";
@@ -804,8 +806,12 @@ class Login extends \CoreLibs\DB\IO
{
if ($this->change_password) {
$event = 'Password Change';
$data = '';
// check that given username is NOT in the deny list, else silent skip (with error log)
if (!in_array($this->pw_username, $this->pw_change_deny_users)) {
// init the edit user id variable
$edit_user_id = '';
// cehck if either username or old password is not set
if (!$this->pw_username || !$this->pw_old_password) {
$this->login_error = 200;
$data = 'Missing username or old password.';
@@ -852,7 +858,7 @@ class Login extends \CoreLibs\DB\IO
}
}
// no error change this users password
if (!$this->login_error) {
if (!$this->login_error && $edit_user_id) {
// update the user (edit_user_id) with the new password
$q = "UPDATE edit_user SET password = '".$this->dbEscapeString($this->passwordSet($this->pw_new_password))."' WHERE edit_user_id = ".$edit_user_id;
$this->dbExec($q);
@@ -883,7 +889,7 @@ class Login extends \CoreLibs\DB\IO
if ($AJAX_PAGE === true) {
$data = array (
'status' => 'error',
'error_code' => $this->loging_error,
'error_code' => $this->login_error,
'msg' => array (
'level' => 'error',
'str' => $this->l->__('Login necessary')

View File

@@ -67,7 +67,7 @@ class Backend extends \CoreLibs\DB\IO
public $COMPILE_ID;
public $includes;
public $template_path;
public $lang_dir;
public $lang_dir = '';
public $javascript;
public $css;
public $pictures;
@@ -124,6 +124,7 @@ class Backend extends \CoreLibs\DB\IO
// DESC : writes all action vars plus other info into edit_log table
public function adbEditLog(string $event = '', $data = '', string $write_type = 'STRING')
{
$data_binary = '';
if ($write_type == 'BINARY') {
$data_binary = $this->dbEscapeBytea(bzcompress(serialize($data)));
$data = 'see bzip compressed data_binary field';
@@ -140,7 +141,7 @@ class Backend extends \CoreLibs\DB\IO
$q .= "VALUES ";
$q .= "(".$this->dbEscapeString(isset($_SESSION['EUID']) ? $_SESSION['EUID'] : '').", ";
$q .= "NOW(), ";
$q .= "'".$this->dbEscapeString($event)."', '".$data."', '".$data_binary."', '".$this->dbEscapeString($this->page_name)."', ";
$q .= "'".$this->dbEscapeString((string)$event)."', '".$data."', '".$data_binary."', '".$this->dbEscapeString($this->page_name)."', ";
$q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->dbEscapeString(@$_SERVER['HTTP_USER_AGENT'])."', ";
$q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')."', ";
$q .= "'".$this->dbEscapeString(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '')."', ";
@@ -177,6 +178,7 @@ class Backend extends \CoreLibs\DB\IO
if (!isset($PAGES) || !is_array($PAGES)) {
$PAGES = array ();
}
$pages = array ();
foreach ($PAGES as $PAGE_CUID => $PAGE_DATA) {
$pages[] = $PAGE_DATA;
}
@@ -209,7 +211,7 @@ class Backend extends \CoreLibs\DB\IO
$pages[$i]['popup'] = 0;
}
$query_string = '';
if (count($pages[$i]['query'])) {
if (isset($pages[$i]['query']) && count($pages[$i]['query'])) {
for ($j = 0, $jMax = count($pages[$i]['query']); $j < $jMax; $j ++) {
if (strlen($query_string)) {
$query_string .= '&';
@@ -318,7 +320,7 @@ class Backend extends \CoreLibs\DB\IO
$level = "info";
}
$this->messages[] = array (
'msg' => sprintf($this->l->__($msg), $vars),
'msg' => vsprintf($this->l->__($msg), $vars),
'class' => $level
);
switch ($level) {

View File

@@ -111,9 +111,9 @@ class Basic
public $host_name;
public $host_port;
// internal error reporting vars
private $error_id; // error ID for errors in classes
private $error_string; // error strings in classes (for error_id)
private $error_msg = array (); // the "connection" to the outside errors
protected $error_id; // error ID for errors in classes
protected $error_msg = array (); // the "connection" to the outside errors
// debug output prefix
public $error_msg_prefix = ''; // prefix to the error string (the class name)
// debug flags
public $debug_output; // if this is true, show debug on desconstructor
@@ -126,7 +126,7 @@ class Basic
public $print_output_not;
public $print_output_all;
// debug flags/settings
public $debug_fp = ''; // filepointer for writing to file
public $debug_fp; // filepointer for writing to file
public $debug_filename = 'debug_file.log'; // where to write output
public $hash_algo = 'crc32b'; // the hash algo used for the internal debug uid
public $running_uid = ''; // unique ID set on class init and used in logging as prefix
@@ -137,10 +137,10 @@ class Basic
private $log_file_unique_id; // a unique ID set only once for call derived from this class
public $log_print_file_date = 1; // if set add Y-m-d and do automatic daily rotation
private $log_file_id = ''; // a alphanumeric name that has to be set as global definition
public $log_per_level = 0; // set, it will split per level (first parameter in debug call)
public $log_per_class = 0; // set, will split log per class
public $log_per_page = 0; // set, will split log per called file
public $log_per_run = 0; // create a new log file per run (time stamp + unique ID)
public $log_per_level = false; // set, it will split per level (first parameter in debug call)
public $log_per_class = false; // set, will split log per class
public $log_per_page = false; // set, will split log per called file
public $log_per_run = false; // create a new log file per run (time stamp + unique ID)
// run time messurements
private $starttime; // start time if time debug is used
private $endtime; // end time if time debug is used
@@ -200,7 +200,7 @@ class Basic
'UPLOADS', 'CSV', 'JS', 'CSS', 'TABLE_ARRAYS', 'SMARTY', 'LANG', 'CACHE', 'TMP', 'LOG', 'TEMPLATES', 'TEMPLATES_C',
'DEFAULT_LANG', 'DEFAULT_ENCODING', 'DEFAULT_HASH',
'DEFAULT_ACL_LEVEL', 'LOGOUT_TARGET', 'PASSWORD_CHANGE', 'AJAX_REQUEST_TYPE', 'USE_PROTOTYPE', 'USE_SCRIPTACULOUS', 'USE_JQUERY',
'PAGE_WIDTH', 'MASTER_TEMPLATE_NAME', 'PUBLIC_SCHEMA', 'TEST_SCHEMA', 'DEV_SCHEMA', 'LIVE_SCHEMA', 'LOGIN_DB', 'MAIN_DB', 'DB_SCHEMA',
'PAGE_WIDTH', 'MASTER_TEMPLATE_NAME', 'PUBLIC_SCHEMA', 'TEST_SCHEMA', 'DEV_SCHEMA', 'LIVE_SCHEMA', 'DB_CONFIG_NAME', 'DB_CONFIG', 'DB_SCHEMA',
'LOGIN_DB_SCHEMA', 'GLOBAL_DB_SCHEMA', 'TARGET', 'DEBUG', 'SHOW_ALL_ERRORS'
) as $constant) {
if (!defined($constant)) {
@@ -237,27 +237,27 @@ class Basic
// if given via parameters, only for all
$this->debug_output_all = false;
$this->echo_output_all = true;
$this->echo_output_all = false;
$this->print_output_all = false;
// globals overrule given settings, for one (array), eg $ECHO['db'] = 1;
if (isset($GLOBALS['DEBUG'])) {
if (isset($GLOBALS['DEBUG']) && is_array($GLOBALS['DEBUG'])) {
$this->debug_output = $GLOBALS['DEBUG'];
}
if (isset($GLOBALS['ECHO'])) {
if (isset($GLOBALS['ECHO']) && is_array($GLOBALS['ECHO'])) {
$this->echo_output = $GLOBALS['ECHO'];
}
if (isset($GLOBALS['PRINT'])) {
if (isset($GLOBALS['PRINT']) && is_array($GLOBALS['PRINT'])) {
$this->print_output = $GLOBALS['PRINT'];
}
// exclude these ones from output
if (isset($GLOBALS['DEBUG_NOT'])) {
if (isset($GLOBALS['DEBUG_NOT']) && is_array($GLOBALS['DEBUG_NOT'])) {
$this->debug_output_not = $GLOBALS['DEBUG_NOT'];
}
if (isset($GLOBALS['ECHO_NOT'])) {
if (isset($GLOBALS['ECHO_NOT']) && is_array($GLOBALS['ECHO_NOT'])) {
$this->echo_output_not = $GLOBALS['ECHO_NOT'];
}
if (isset($GLOBALS['PRINT_NOT'])) {
if (isset($GLOBALS['PRINT_NOT']) && is_array($GLOBALS['PRINT_NOT'])) {
$this->print_output_not = $GLOBALS['PRINT_NOT'];
}
@@ -374,6 +374,11 @@ class Basic
// set the session name for possible later check
$this->session_name = SET_SESSION_NAME;
}
// override with global if set
if (isset($GLOBALS['SET_SESSION_NAME'])) {
$this->session_name = $GLOBALS['SET_SESSION_NAME'];
}
// if set, set special session name
if ($this->session_name) {
session_name($this->session_name);
}
@@ -484,13 +489,10 @@ class Basic
// must be alphanumeric only (\w)
public function basicSetLogId(string $string): string
{
if (!isset($log_file_id)) {
$log_file_id = '';
}
if (isset($string) && preg_match("/^\w+$/", $string)) {
if (preg_match("/^\w+$/", $string)) {
$this->log_file_id = $string;
}
return $log_file_id;
return $this->log_file_id;
}
// ****** DEBUG/ERROR FUNCTIONS ******
@@ -595,7 +597,7 @@ class Basic
$string .= substr($microtime, 1);
} elseif ($set_microtime >= 1) {
// in round case we run this through number format to always get the same amount of digits
$string .= substr(number_format(round($microtime, $set_microtime), $set_microtime), 1);
$string .= substr(number_format(round((float)$microtime, $set_microtime), $set_microtime), 1);
}
return $string;
}
@@ -888,8 +890,7 @@ class Basic
// DESC : validates they key length
private function validateRandomKeyLenght(int $key_length): bool
{
if (isset($key_length) &&
is_numeric($key_length) &&
if (is_numeric($key_length) &&
$key_length > 0 &&
$key_length <= $this->max_key_length
) {
@@ -1146,11 +1147,15 @@ class Basic
// only returns the first one found
public static function arraySearchRecursive($needle, array $haystack, $key_lookin = ''): ?array
{
$path = null;
$path = array ();
if (!is_array($haystack)) {
$haystack = array();
}
if (!is_array($key_lookin) && !empty($key_lookin) && array_key_exists($key_lookin, $haystack) && $needle === $haystack[$key_lookin]) {
if (!is_array($key_lookin) &&
!empty($key_lookin) &&
array_key_exists($key_lookin, $haystack) &&
$needle === $haystack[$key_lookin]
) {
$path[] = $key_lookin;
} else {
foreach ($haystack as $key => $val) {
@@ -1184,7 +1189,7 @@ class Basic
if (!isset($path['work'])) {
$path['work'] = array ();
}
if (!isset($haystack)) {
if (!is_array($haystack)) {
$haystack = array ();
}
@@ -1461,7 +1466,7 @@ class Basic
// labels in order of size
$labels = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
// calc file size, round down too two digits, add label based max change
return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).($space ? ' ' : '').(isset($labels[$i]) ? $labels[$i] : '>EB');
return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).($space ? ' ' : '').(isset($labels[(int)$i]) ? $labels[(int)$i] : '>EB');
}
return (string)$number;
}
@@ -1527,7 +1532,7 @@ class Basic
public static function dateStringFormat($timestamp, bool $show_micro = true): string
{
list ($timestamp, $ms) = explode('.', (string)round($timestamp, 4));
$string = date("Y-m-d H:i:s", $timestamp);
$string = date("Y-m-d H:i:s", (int)$timestamp);
if ($show_micro) {
$string .= ' '.$ms.'ms';
}
@@ -1549,8 +1554,8 @@ class Basic
$labels = array ('d', 'h', 'm', 's');
$time_string = '';
for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i ++) {
$output = floor($timestamp / $timegroups[$i]);
$timestamp = $timestamp % $timegroups[$i];
$output = floor((float)$timestamp / $timegroups[$i]);
$timestamp = (float)$timestamp % $timegroups[$i];
// output has days|hours|min|sec
if ($output || $time_string) {
$time_string .= $output.$labels[$i].(($i + 1) != count($timegroups) ? ' ' : '');
@@ -1589,7 +1594,7 @@ class Basic
// multiply the returned matches and sum them up. the last one (ms) is added with .
foreach ($timegroups as $i => $time_multiply) {
if (is_numeric($matches[$i])) {
$timestamp += $matches[$i] * $time_multiply;
$timestamp += (float)$matches[$i] * $time_multiply;
}
}
if (is_numeric($matches[10])) {
@@ -1612,7 +1617,7 @@ class Basic
if (!$year || !$month || !$day) {
return false;
}
if (!checkdate($month, $day, $year)) {
if (!checkdate((int)$month, (int)$day, (int)$year)) {
return false;
}
return true;
@@ -1629,15 +1634,15 @@ class Basic
if (!$year || !$month || !$day) {
return false;
}
if (!checkdate($month, $day, $year)) {
if (!checkdate((int)$month, (int)$day, (int)$year)) {
return false;
}
if (!$hour || !$min) {
if (!is_numeric($hour) || !is_numeric($min)) {
return false;
}
if (($hour < 0 || $hour > 24) ||
($min < 0 || $min > 60) ||
($sec && ($sec < 0 || $sec > 60))
(is_numeric($sec) && ($sec < 0 || $sec > 60))
) {
return false;
}
@@ -1726,6 +1731,8 @@ class Basic
$end->setTime(0, 0, 1);
$days[0] = $end->diff($start)->days;
$days[1] = 0;
$days[2] = 0;
$period = new \DatePeriod($start, new \DateInterval('P1D'), $end);
@@ -1767,7 +1774,7 @@ class Basic
2 => 'jpg',
3 => 'png'
);
$return_data = false;
if (!empty($cache_source)) {
$tmp_src = $cache_source;
} else {
@@ -1790,6 +1797,7 @@ class Basic
list($width, $height, $type) = getimagesize($filename);
$convert_prefix = '';
$create_file = false;
$delete_filename = '';
// check if we can skip the PDF creation: if we have size, if do not have type, we assume type png
if (!$type && is_numeric($size_x) && is_numeric($size_y)) {
$check_thumb = $tmp_src.'thumb_'.$pic.'_'.$size_x.'x'.$size_y.'.'.$image_types[3];
@@ -1887,6 +1895,7 @@ class Basic
$compare = mb_convert_encoding($temp, $from_encoding, $to_encoding);
// if string does not match anymore we have a convert problem
if ($string != $compare) {
$failed = array ();
// go through each character and find the ones that do not match
for ($i = 0, $iMax = mb_strlen($string, $from_encoding); $i < $iMax; $i ++) {
$char = mb_substr($string, $i, 1, $from_encoding);
@@ -1989,10 +1998,10 @@ class Basic
}
// split up the version strings to calc the compare number
$version = explode('.', $min_version);
$min_version = $version[0] * 10000 + $version[1] * 100 + $version[2];
$min_version = (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2];
if ($max_version) {
$version = explode('.', $max_version);
$max_version = $version[0] * 10000 + $version[1] * 100 + $version[2];
$max_version = (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2];
// drop out if min is bigger max, equal size is okay, that would be only THIS
if ($min_version > $max_version) {
return false;
@@ -2002,7 +2011,7 @@ class Basic
if (!defined('PHP_VERSION_ID')) {
$version = explode('.', phpversion());
// creates something like 50107
define('PHP_VERSION_ID', $version[0] * 10000 + $version[1] * 100 + $version[2]);
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) {
@@ -2242,6 +2251,7 @@ class Basic
$MAX = max($r, $g, $b);
$MIN = min($r, $g, $b);
$HUE = 0;
if ($MAX == $MIN) {
return array(0, 0, round($MAX * 100));
@@ -2292,41 +2302,41 @@ class Basic
switch ($Hi) {
case 0:
$red = $V;
$gre = $t;
$blu = $p;
$green = $t;
$blue = $p;
break;
case 1:
$red = $q;
$gre = $V;
$blu = $p;
$green = $V;
$blue = $p;
break;
case 2:
$red = $p;
$gre = $V;
$blu = $t;
$green = $V;
$blue = $t;
break;
case 3:
$red = $p;
$gre = $q;
$blu = $V;
$green = $q;
$blue = $V;
break;
case 4:
$red = $t;
$gre = $p;
$blu = $V;
$green = $p;
$blue = $V;
break;
case 5:
$red = $V;
$gre = $p;
$blu = $q;
$green = $p;
$blue = $q;
break;
default:
$red = 0;
$gre = 0;
$green = 0;
$blue = 0;
}
return array(round($red * 255), round($gre * 255), round($blu * 255));
return array(round($red * 255), round($green * 255), round($blue * 255));
}
// METHOD: rgb2hsl
@@ -2345,6 +2355,7 @@ class Basic
$MIN = min($r, $g, $b);
$MAX = max($r, $g, $b);
$HUE = 0;
// luminance
$L = round((($MAX + $MIN) / 2) * 100);
@@ -2497,7 +2508,7 @@ class Basic
$timestamp = time() + 3600; // in seconds
// the max year is this year + 1;
$max_year = date("Y", $timestamp) + 1;
$max_year = (int)date("Y", $timestamp) + 1;
// preset year, month, ...
$year = (!$year) ? date("Y", $timestamp) : $year;
@@ -2507,7 +2518,7 @@ class Basic
$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"));
$string = '';
// from now to ?
if ($name_pos_back === false) {
$string = 'Year ';
@@ -2630,7 +2641,7 @@ class Basic
public function setFormToken(string $name = 'form_token'): string
{
// current hard set to sha256
$token = uniqid(hash('sha256', rand()));
$token = uniqid(hash('sha256', (string)rand()));
$_SESSION[$name] = $token;
return $token;
}
@@ -2683,14 +2694,14 @@ class Basic
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->fdebugFP($flag);
$this->fdebugFP($flag);
}
public function debug_for($type, $flag)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->debugFor($type, $flag);
$this->debugFor($type, $flag);
}
public function get_caller_method($level = 2)
@@ -2704,7 +2715,7 @@ class Basic
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->mergeErrors($error_msg);
$this->mergeErrors($error_msg);
}
public function print_error_msg($string = '')
@@ -2718,14 +2729,14 @@ class Basic
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->writeErrorMsg($level, $error_string);
$this->writeErrorMsg($level, $error_string);
}
public function reset_error_msg($level = '')
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->resetErrorMsg($level);
$this->resetErrorMsg($level);
}
public static function print_ar($array)

View File

@@ -411,7 +411,9 @@ class ArrayIO extends \CoreLibs\DB\IO
}
// integer is different
if (isset($this->table_array[$column]['int']) || isset($this->table_array[$column]['int_null'])) {
$this->debug('write_check', '['.$column.']['.$this->table_array[$column]['value'].']['.$this->table_array[$column]['type'].'] VALUE SET: '.isset($this->table_array[$column]['value']).' | INT NULL: '.isset($this->table_array[$column]['int_null']));
$this->debug('write_check', '['.$column.']['.$this->table_array[$column]['value'].']['.$this->table_array[$column]['type'].'] '.
'VALUE SET: '.(string)isset($this->table_array[$column]['value']).
' | INT NULL: '.(string)isset($this->table_array[$column]['int_null']));
if (isset($this->table_array[$column]['value']) &&
!$this->table_array[$column]['value'] &&
isset($this->table_array[$column]['int_null'])
@@ -436,6 +438,9 @@ class ArrayIO extends \CoreLibs\DB\IO
$_value = 'NULL';
} elseif (isset($this->table_array[$column]['value'])) {
$_value = $this->table_array[$column]['value'];
} else {
// fallback
$_value = 'NULL';
}
$q_data .= $_value;
} else {
@@ -514,7 +519,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// set primary key
if ($insert) {
$this->table_array[$this->pk_name]['value'] = $this->insert_id;
$this->ok = $this->insert_id;
$this->pk_id = $this->insert_id;
}
// return the table if needed
return $this->table_array;

View File

@@ -277,9 +277,12 @@ class IO extends \CoreLibs\Basic
// other vars
private $nbsp = ''; // used by print_array recursion function
// error & warning id
private $error_id;
// not error_id is defined in \CoreLibs\Basic
private $had_error;
private $warning_id;
private $had_warning;
// error thrown on class init if we cannot connect to db
protected $db_init_error = false;
// sub include with the database functions
private $db_functions;
@@ -305,6 +308,11 @@ class IO extends \CoreLibs\Basic
// set_control_flag -> flags for core class get/set variable error handling
// RETURN nothing
// DESC constructor for db_clss
/**
* main DB concstructor with auto connection to DB and failure set on failed connection
* @param array $db_config DB configuration array
* @param int|integer $set_control_flag Class set control flag
*/
public function __construct(array $db_config, int $set_control_flag = 0)
{
// start basic class
@@ -373,18 +381,18 @@ class IO extends \CoreLibs\Basic
// abort error
$this->error_id = 10;
$this->__dbError();
return false;
$this->db_init_error = false;
}
// connect to DB
if (!$this->__connectToDB()) {
$this->error_id = 16;
$this->__dbError();
return false;
$this->db_init_error = false;
}
// so we can check that we have a successful DB connection created
return true;
$this->db_init_error = true;
}
// METHOD: __destruct
@@ -980,7 +988,7 @@ class IO extends \CoreLibs\Basic
}
$string = '';
if (is_array($array)) {
$this->nbps = '';
$this->nbsp = '';
$string .= $this->__printArray($array);
$this->__dbDebug('db', $string, 'dbDumpData');
}
@@ -991,15 +999,22 @@ class IO extends \CoreLibs\Basic
// WAS : db_return
// PARAMS: query -> the query ...
// reset -> if set to 1, at the end of the query (last row returned), the stored array will be deleted ...
// if set to 2, the data will be read new and cached (wheres 1 reads new AND destroys at end of read)
// if set to 2, the data will be read new and cached (wheres 1 reads cache AND destroys at end of read)
// -> if set to 3, after EACH row, the data will be reset, no caching is done except for basic (count, etc)
// RETURN: res mixed (array/hash)
// RETURN: res mixed (array/bool)
// DESC : single running function, if called creates md5 from
// query string and so can itself call exec/return calls
// caches data, so next time called with IDENTICAL (!!!!)
// [this means 1:1 bit to bit identical query] returns cached
// data, or with reset flag set calls data from DB again
public function dbReturn($query, $reset = 0)
/**
* returned array is database number/fieldname -> value element
* @param string $query Query string
* @param integer $reset reset status: 1: read cache, clean at the end, 2: read new, clean at end, 3: never cache
* @param bool $assoc_only true to only returned the named and not index position ones
* @return array|boolean return array data or false on error/end
*/
public function dbReturn($query, $reset = 0, bool $assoc_only = false)
{
if (!$query) {
$this->error_id = 11;
@@ -1028,7 +1043,8 @@ class IO extends \CoreLibs\Basic
$this->__dbError('', $this->cursor_ext[$md5]['query']);
return false;
}
// init return als false
$return = false;
// if it is a call with reset in it we reset the cursor, so we get an uncached return
// but only for the FIRST call (pos == 0)
if ($reset && !$this->cursor_ext[$md5]['pos']) {
@@ -1092,9 +1108,14 @@ class IO extends \CoreLibs\Basic
}
// read data for further work ... but only if necessarry
if ($this->cursor_ext[$md5]['read_rows'] == $this->cursor_ext[$md5]['num_rows']) {
$return = 0;
$return = false;
} else {
$return = $this->__dbConvertEncoding($this->db_functions->__dbFetchArray($this->cursor_ext[$md5]['cursor']));
$return = $this->__dbConvertEncoding(
$this->db_functions->__dbFetchArray(
$this->cursor_ext[$md5]['cursor'],
$this->db_functions->__dbResultType($assoc_only)
)
);
}
// check if cached call or reset call ...
if (!$return && !$reset) {
@@ -1103,15 +1124,22 @@ class IO extends \CoreLibs\Basic
$this->cursor_ext[$md5]['pos'] = 0;
# if not reset given, set the cursor to true, so in a cached call on a different page we don't get problems from DB connection (as those will be LOST)
$this->cursor_ext[$md5]['cursor'] = 1;
$return = 0;
$return = false;
} else {
// unset return value ...
unset($return);
$return = array ();
for ($i = 0; $i < $this->cursor_ext[$md5]['num_fields']; $i ++) {
// create mixed return array
$field_value = $this->cursor_ext[$md5][$this->cursor_ext[$md5]['pos']][$this->cursor_ext[$md5]['field_names'][$i]];
$return[$i] = $field_value;
$return[$this->cursor_ext[$md5]['field_names'][$i]] = $field_value;
if ($assoc_only === false && isset($this->cursor_ext[$md5]['data'][$this->cursor_ext[$md5]['pos']][$i])) {
$return[$i] = $this->cursor_ext[$md5]['data'][$this->cursor_ext[$md5]['pos']][$i];
}
// named part
if (isset($this->cursor_ext[$md5]['data'][$this->cursor_ext[$md5]['pos']][$i])) {
$return[$this->cursor_ext[$md5]['field_names'][$i]] = $this->cursor_ext[$md5]['data'][$this->cursor_ext[$md5]['pos']][$i];
} else {
// throws PhanTypeMismatchDimFetch error
$return[$this->cursor_ext[$md5]['field_names'][$i]] = $this->cursor_ext[$md5]['data'][$this->cursor_ext[$md5]['pos']][$this->cursor_ext[$md5]['field_names'][$i]];
}
}
$this->cursor_ext[$md5]['pos'] ++;
}
@@ -1125,7 +1153,7 @@ class IO extends \CoreLibs\Basic
// at end of read reset pos & set cursor to 1 (so it does not get lost in session transfer)
$this->cursor_ext[$md5]['pos'] = 0;
$this->cursor_ext[$md5]['cursor'] = 1;
$return = 0;
$return = false;
}
// if something found, write data into hash array
if ($return) {
@@ -1134,10 +1162,11 @@ class IO extends \CoreLibs\Basic
$this->cursor_ext[$md5]['read_rows'] ++;
// if reset is <3 caching is done, else no
if ($reset < 3) {
$temp = array ();
foreach ($return as $field_name => $data) {
$temp[$field_name] = $data;
}
$this->cursor_ext[$md5][] = $temp;
$this->cursor_ext[$md5]['data'][] = $temp;
}
} // cached data if
} // cached or not if
@@ -1325,7 +1354,9 @@ class IO extends \CoreLibs\Basic
return false;
}
$cursor = $this->dbExec($query);
$rows = array ();
while ($res = $this->dbFetchArray($cursor, $assoc_only)) {
$data = array ();
for ($i = 0; $i < $this->num_fields; $i ++) {
$data[$this->field_names[$i]] = $res[$this->field_names[$i]];
}
@@ -1746,7 +1777,7 @@ class IO extends \CoreLibs\Basic
$has_default = $table_data[$field]['has default'];
$not_null = $table_data[$field]['not null'];
// if not null and string => '', if not null and int or numeric => 0, if bool => skip, all others skip
if ($not_null && !isset($_data)) {
if ($not_null && $_data == null) {
if (strstr($table_data[$field]['type'], 'int') || strstr($table_data[$field]['type'], 'numeric')) {
$_data = 0;
} else {
@@ -1756,7 +1787,12 @@ class IO extends \CoreLibs\Basic
// we detect bool, so we can force a write on "false"
$is_bool = $table_data[$field]['type'] == 'bool' ? true : false;
// write if the field has to be not null, or if there is no data and the field has no default values or if there is data or if this is an update and there is no data (set null)
if (($not_null && isset($_data)) || (!$has_default && !isset($_data)) || (is_numeric($_data) && isset($_data)) || ($primary_key['value'] && !isset($_data)) || isset($_data)) {
if (($not_null && $_data) ||
(!$has_default && !$_data) ||
(is_numeric($_data) && $_data) ||
($primary_key['value'] && !$_data) ||
$_data
) {
if ($q_sub_value && !$primary_key['value']) {
$q_sub_value .= ', ';
}
@@ -1774,7 +1810,7 @@ class IO extends \CoreLibs\Basic
}
// write data into sql string
if (strstr($table_data[$field]['type'], 'int')) {
$q_sub_data .= (is_numeric($_data) && isset($_data)) ? $_data : 'NULL';
$q_sub_data .= (is_numeric($_data)) ? $_data : 'NULL';
} else {
// if bool -> set bool, else write data
$q_sub_data .= isset($_data) ? "'".($is_bool ? $this->dbBoolean($_data, true) : $this->dbEscapeString($_data))."'" : 'NULL';
@@ -1886,7 +1922,7 @@ class IO extends \CoreLibs\Basic
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->__closeDB();
$this->__closeDB();
}
private function _check_query_for_select($query)
@@ -1914,14 +1950,14 @@ class IO extends \CoreLibs\Basic
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->__dbDebug($debug_id, $error_string, $id, $type);
$this->__dbDebug($debug_id, $error_string, $id, $type);
}
public function _db_error($cursor = '', $msg = '')
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED);
return $this->__dbError($cursor, $msg);
$this->__dbError($cursor, $msg);
}
private function _db_convert_encoding($row)

View File

@@ -423,7 +423,7 @@ class PgSQL
{
if (false === $limit) {
$limit = strlen($text) - 1;
$output = array();
$output = array ();
}
if ('{}' != $text) {
do {
@@ -435,7 +435,7 @@ class PgSQL
return $offset;
}
} else {
$offset = $this->__dbArrayParse($text, $output[], $limit, $offset + 1);
$offset = $this->__dbArrayParse($text, $output, $limit, $offset + 1);
}
} while ($limit > $offset);
}

View File

@@ -26,21 +26,23 @@ namespace CoreLibs\Language\Core;
// over it (it assumes knowledge of StringReader internals)
class CachedFileReader extends \CoreLibs\Language\Core\StringReader
{
public $error = 0;
public $_str = '';
public function __construct($filename)
{
parent::__construct();
if (file_exists($filename)) {
$length = filesize($filename);
$fd = fopen($filename, 'rb');
if (!$fd) {
$this->error = 3; // Cannot read file, probably permissions
return false;
}
$this->_str = fread($fd, $length);
fclose($fd);
} else {
$this->error = 2; // File doesn't exist
return false;
}
}
}

View File

@@ -27,6 +27,7 @@ class FileReader
public $fr_pos;
public $fr_fd;
public $fr_length;
public $error = 0;
public function __construct($filename)
{
@@ -36,11 +37,9 @@ class FileReader
$this->fr_fd = fopen($filename, 'rb');
if (!$this->fr_fd) {
$this->error = 3; // Cannot read file, probably permissions
return false;
}
} else {
$this->error = 2; // File doesn't exist
return false;
}
}

View File

@@ -39,7 +39,7 @@ class GetTextReader
// public:
public $error = 0; // public variable that holds error code (0 if no error)
//private:
// private:
private $BYTEORDER = 0; // 0: low endian, 1: big endian
private $STREAM = null;
private $short_circuit = false;
@@ -125,7 +125,6 @@ class GetTextReader
$this->BYTEORDER = 0;
} else {
$this->error = 1; // not MO file
return false;
}
// FIXME: Do we care about revision? We should.
@@ -396,7 +395,7 @@ class GetTextReader
* @param string single
* @param string plural
* @param string number
* @return translated plural form
* @return string plural form
*/
public function ngettext($single, $plural, $number)
{

View File

@@ -26,6 +26,10 @@ namespace CoreLibs\Language\Core;
// seek is essential, and it should be byte stream
class StreamReader
{
public function __construct()
{
// empty
}
// should return a string [FIXME: perhaps return array of bytes?]
public function read($bytes)
{

View File

@@ -35,8 +35,9 @@ class L10n extends \CoreLibs\Basic
private $input;
private $l10n;
public function __construct(string $lang = '', string $path = '')
public function __construct(string $lang = '', string $path = '', int $set_control_flag = 0)
{
parent::__construct($set_control_flag);
if (!$lang) {
$this->lang = 'en';
} else {

View File

@@ -226,6 +226,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
private $int_pk_name; // primary key, only internal usage
public $reference_array = array (); // reference arrays -> stored in $this->reference_array[$table_name]=>array();
public $element_list; // element list for elements next to each other as a special sub group
public $table_array = array ();
public $my_page_name; // the name of the page without .php extension
public $mobile_phone = false;
// buttons and checkboxes
@@ -241,6 +242,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
public $security_level;
// layout publics
public $table_width;
// language
public $l;
// now some default error msgs (english)
public $language_array = array ();
@@ -501,7 +504,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
public function formProcedureDeleteFromElementList($element_list, $remove_name)
{
$this->debug('REMOVE ELEMENT', 'Remove REF ELEMENT: '.$this->base_acl_level.' >= '.$this->security_level['delete']);
$this->debug('REMOVE ELEMENT', 'Protected Value set: '.isset($this->table_array['protected']['value']));
$this->debug('REMOVE ELEMENT', 'Protected Value set: '.(string)isset($this->table_array['protected']['value']));
$this->debug('REMOVE ELEMENT', 'Error: '.$this->error);
// only do if the user is allowed to delete
if ($this->base_acl_level >= $this->security_level['delete'] &&
@@ -517,9 +520,11 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// if prefix, set it
$prfx = ($this->element_list[$element_list[$i]]['prefix']) ? $this->element_list[$element_list[$i]]['prefix'].'_' : '';
// get the primary key
$pk_name = '';
foreach ($this->element_list[$element_list[$i]]['elements'] as $el_name => $data) {
if (isset($data['pk_id'])) {
$pk_name = $el_name;
break;
}
}
// which key should be deleted
@@ -726,13 +731,13 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$data['value'][] = $i;
$data['output'][] = $this->table_array[$element_name]['element_list'][$i];
$data['name'] = $element_name;
if ((isset($i) && isset($this->table_array[$element_name]['value'])) ||
(!isset($i) && !isset($this->table_array[$element_name]['value']))
if (($i && isset($this->table_array[$element_name]['value'])) ||
(!$i && !isset($this->table_array[$element_name]['value']))
) {
$data['checked'] = $this->table_array[$element_name]['value'];
}
if (isset($i)) {
if ($i) {
$data['separator'] = '';
}
}
@@ -923,7 +928,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
break;
case 'date': // YYYY-MM-DD
if (!$this->checkDate($this->table_array[$key]['value'], 1)) {
if (!$this->checkDate($this->table_array[$key]['value'])) {
$this->msg .= sprintf($this->l->__('Please enter a vailid date (YYYY-MM-DD) for the <b>%s</b> Field!<br>'), $this->table_array[$key]['output_name']);
}
break;
@@ -937,7 +942,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
break;
case 'intervalshort': // ony interval n [Y/M/D] only
if (preg_match("/^\d{1,3}\ ?[YMDymd]{1}$/", $this->table_array[$key]['value'])) {
$this->msg .= sprintf($this->l->__('Please enter a valid time interval in the format <length> Y|M|D for the <b>%s</b> Field!<br>'), $this->table[$key]['output_name']);
$this->msg .= sprintf($this->l->__('Please enter a valid time interval in the format <length> Y|M|D for the <b>%s</b> Field!<br>'), $this->table_array[$key]['output_name']);
}
break;
case 'email':
@@ -1037,24 +1042,28 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
}
} // while
// do check for reference tables
if (is_array($this->reference_array)) {
// do check for reference tables
if (!is_array($this->reference_array)) {
$this->reference_array = array ();
}
reset($this->reference_array);
foreach ($this->reference_array as $key => $value) {
if ($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 = array ();
}
// $this->debug('edit_error', 'QS: <pre>'.print_r($_POST, true).'</pre>');
if (is_array($this->element_list)) {
// check the mandatory stuff
// if mandatory, check that at least on pk exists or if at least the mandatory field is filled
foreach ($this->element_list as $table_name => $reference_array) {
if (!is_array($reference_array)) {
$reference_array = array ();
}
// set pk/fk id for this
$_pk_name = '';
$_fk_name = '';
foreach ($reference_array['elements'] as $_name => $_data) {
if (isset($_data['pk_id'])) {
$_pk_name = $_name;
@@ -1081,6 +1090,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
$this->debug('POST ARRAY', $this->printAr($_POST));
$mand_okay = 0;
$mand_name = '';
# check each row
for ($i = 0; $i < $max; $i ++) {
// either one of the post pks is set, or the mandatory
@@ -1125,8 +1135,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if ($this->table_array[$this->int_pk_name]['value']) {
$q .= ' AND '.$this->int_pk_name.' <> '.$this->table_array[$this->int_pk_name]['value'];
}
list($$key) = $this->dbReturnRow($q);
if ($$key) {
list($key) = $this->dbReturnRow($q);
if ($key) {
$this->msg .= sprintf($this->l->__('The field <b>%s</b> in row <b>%s</b> can be used only once!<br>'), $reference_array['output_name'], $i);
}
break;
@@ -1142,7 +1152,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
// main mandatory is met -> error msg
if (!isset($mand_okay) && isset($reference_array['mandatory'])) {
if (!$mand_okay && isset($reference_array['mandatory'])) {
$this->msg .= sprintf($this->l->__('You need to enter at least one data set for field <b>%s</b>!<Br>'), $reference_array['output_name']);
}
for ($i = 0; $i < $max; $i ++) {
@@ -1269,7 +1279,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
{
// for drop_down_db_input check if text field is filled and if, if not yet in db ...
// and upload files
if (!isset($this->table_array)) {
if (!is_array($this->table_array)) {
$this->table_array = array ();
}
reset($this->table_array);
@@ -1345,7 +1355,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
}
if (move_uploaded_file($GLOBALS['_FILES'][$key.'_file']['tmp_name'], $this->table_array[$key]['save_dir'].$GLOBALS['_FILES'][$key.'_file']['name'])) {
// make it unique with a unique number at the beginning
$this->table_array[$key]['value'] = uniqid(rand(), 1).'_'.$GLOBALS['_FILES'][$key.'_file']['name'];
$this->table_array[$key]['value'] = uniqid((string)rand(), true).'_'.$GLOBALS['_FILES'][$key.'_file']['name'];
} else {
$this->msg .= $this->l->__('File could not be copied to target directory! Perhaps wrong directory permissions.');
$this->error = 1;
@@ -1400,6 +1410,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
reset($this->element_list);
foreach ($this->element_list as $table_name => $reference_array) {
// init arrays
$q_begin = array ();
$q_middle = array ();
$q_end = array ();
$q_names = array ();
$q_data = array ();
$q_values = array ();
@@ -1702,6 +1715,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
reset($this->element_list[$table_name]['elements']);
// generic data read in (counts for all rows)
// visible list data output
$q_select = array ();
$proto = array ();
foreach ($this->element_list[$table_name]['elements'] as $el_name => $data_array) {
// $this->debug('CFG', 'El: '.$el_name.' -> '.$this->printAr($data_array));
// if the element name matches the read array, then set the table as a name prefix
@@ -1765,6 +1780,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if (isset($this->element_list[$table_name]['read_data'])) {
// we need a second one for the query build only
// prefix all elements with the $table name
$_q_select = array ();
foreach ($q_select as $_pos => $element) {
$_q_select[$_pos] = $table_name.'.'.$element;
}

View File

@@ -115,6 +115,7 @@ class ProgressBar
private function __calculatePosition($step)
{
$bar = 0;
switch ($this->direction) {
case 'right':
case 'left':
@@ -137,6 +138,7 @@ class ProgressBar
$pixel = $bar - ($this->pedding * 2);
}
$position = array ();
switch ($this->direction) {
case 'right':
$position['left'] = $this->pedding;
@@ -438,6 +440,7 @@ class ProgressBar
$this->__setStep($this->step);
$this->position = $this->__calculatePosition($this->step);
$style_master = '';
if ($this->top || $this->left) {
$style_master = 'position:relative;top:'.$this->top.'px;left:'.$this->left.'px;width:'.($this->width + 10).'px;';
}
@@ -459,6 +462,7 @@ class ProgressBar
}
if ($this->frame['show'] == true) {
$border = '';
if ($this->frame['border'] > 0) {
$border = 'border:'.$this->frame['border'].'px solid;border-color:'.$this->frame['brd_color'].';margin-top:2px;-webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;';
}

View File

@@ -22,7 +22,7 @@ class SmartyExtend extends SmartyBC
// constructor class, just sets the language stuff
public function __construct(string $lang)
{
SmartyBC::__construct();
parent::__construct();
$this->l10n = new \CoreLibs\Language\L10n($lang);
// variable variable register
// $this->register_modifier('getvar', array(&$this, 'get_template_vars'));

View File

@@ -60,7 +60,7 @@ function MyErrorHandler($type, $message, $file, $line, $context)
// <> the line number in this file
// [|] error name and error number
// : the php error message
$output = '['.date("Y-m-d H:i:s").'] {'.array_pop($page_temp).'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message;
$output = '{'.array_pop($page_temp).'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message;
# try to open file
$ROOT = CURRENT_WORKING_DIR;
$LOG = 'log/';
@@ -76,7 +76,7 @@ function MyErrorHandler($type, $message, $file, $line, $context)
$fp = @fopen($fn, 'a');
// write if we have a file pointer, else set error flag
if ($fp) {
fwrite($fp, $output."\n");
fwrite($fp, '['.date("Y-m-d H:i:s").'] '.$output."\n");
fclose($fp);
} else {
$error = 1;
@@ -92,13 +92,13 @@ function MyErrorHandler($type, $message, $file, $line, $context)
if (ini_get("display_errors")) {
echo "<div style='border: 1px dotted red; background-color: #ffffe5; color: #000000; padding: 5px; margin-bottom: 2px;'>";
echo "<div style='color: orange; font-weight: bold;'>".$error_level[$type].":</div>";
echo "<b>$message</b> on line <b>$line</b> in <b>$file</b>";
echo "<b>".$message."</b> on line <b>".$line."</b> in <b>".$file."</b>";
echo "</div>";
}
// if write to log is on
// simplified, remove datetime for log file
if (ini_get('log_errors')) {
error_log('{'.$page_temp.'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message);
error_log($output);
}
}
// return true, to avoid that php calls its own error stuff

View File

@@ -38,7 +38,7 @@ class qqUploadedFileXhr
if (isset($_SERVER["CONTENT_LENGTH"])) {
return (int)$_SERVER["CONTENT_LENGTH"];
} else {
throw new Exception('Getting content length is not supported.');
throw new \Exception('Getting content length is not supported.');
}
}
}

View File

@@ -9,6 +9,8 @@ class qqFileUploader
private $allowedExtensions = array();
private $sizeLimit = 10485760;
private $file;
public $uploadFileName;
public $uploadFileExt;
public function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760)
{
@@ -41,7 +43,7 @@ class qqFileUploader
private function toBytes($str)
{
$val = trim($str);
$val = (int)trim($str);
$last = strtolower($str[strlen($str)-1]);
switch ($last) {
case 'g':

View File

@@ -15,12 +15,12 @@ if (class_exists('Autoload', false) === false) {
{
// print "(1) Class: $class / DIR: ".__DIR__."<br>";
// set directory seperator (we need to replace from namespace)
$ds = DS ?? DIRECTORY_SEPARATOR;
$ds = defined('DS') ? DS : DIRECTORY_SEPARATOR;
// base lib
$LIB = LIB ?? 'lib';
$LIB = defined('LIB') ? LIB : 'lib';
// if lib is in path, do not add lib again
if (strpos(__DIR__, $LIB) !== false) {
$LIB .= DS;
$LIB .= $ds;
} else {
$LIB = '';
}

77
www/psalm.xml Normal file
View File

@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
autoloader="lib/autoloader.php"
>
<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" />
<directory name="lib" />
<directory name="layout" />
<ignoreFiles>
<directory name="vendor" />
<directory name="templates_c" />
<directory name="cache" />
<directory name="tmp" />
<directory name="log" />
<directory name="media" />
<directory name="lib/pChart" />
<directory name="lib/pChart2.1.4" />
<directory name="lib/Smarty" />
<directory name="lib/smarty-3.1.30" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<LessSpecificReturnType errorLevel="error" />
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
<DeprecatedMethod errorLevel="error" />
<DeprecatedProperty errorLevel="error" />
<DeprecatedClass errorLevel="error" />
<DeprecatedConstant errorLevel="error" />
<DeprecatedFunction errorLevel="error" />
<DeprecatedInterface errorLevel="error" />
<DeprecatedTrait errorLevel="error" />
<InternalMethod errorLevel="error" />
<InternalProperty errorLevel="error" />
<InternalClass errorLevel="error" />
<MissingClosureReturnType errorLevel="error" />
<MissingReturnType errorLevel="error" />
<MissingPropertyType errorLevel="error" />
<InvalidDocblock errorLevel="error" />
<MisplacedRequiredParam errorLevel="error" />
<PropertyNotSetInConstructor errorLevel="error" />
<MissingConstructor errorLevel="error" />
<MissingClosureParamType errorLevel="error" />
<MissingParamType errorLevel="error" />
<RedundantCondition errorLevel="error" />
<DocblockTypeContradiction errorLevel="error" />
<RedundantConditionGivenDocblockType errorLevel="error" />
<UnresolvableInclude errorLevel="error" />
<RawObjectIteration errorLevel="error" />
<InvalidStringClass errorLevel="error" />
</issueHandlers>
</psalm>

7
www/vendor/autoload.php vendored Normal file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9::getLoader();

445
www/vendor/composer/ClassLoader.php vendored Normal file
View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @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/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

21
www/vendor/composer/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

9
www/vendor/composer/autoload_psr4.php vendored Normal file
View File

@@ -0,0 +1,9 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

52
www/vendor/composer/autoload_real.php vendored Normal file
View File

@@ -0,0 +1,52 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9', 'loadClassLoader'));
$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';
call_user_func(\Composer\Autoload\ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

15
www/vendor/composer/autoload_static.php vendored Normal file
View File

@@ -0,0 +1,15 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
{
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
}, null, ClassLoader::class);
}
}

1
www/vendor/composer/installed.json vendored Normal file
View File

@@ -0,0 +1 @@
[]