Updates for phpstan 1.0 level 8, fix spaces in config.master.php, add phpunit tets for math, email; update email class with more check methods
This commit is contained in:
@@ -98,7 +98,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
/** @var bool */
|
||||
private $password_forgot = false;
|
||||
/** @var bool */
|
||||
private $password_forgot_ok = false; // password forgot mail send ok
|
||||
// private $password_forgot_ok = false; // password forgot mail send ok
|
||||
/** @var string */
|
||||
private $change_password;
|
||||
/** @var string */
|
||||
@@ -196,7 +196,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
$this->login_is_ajax_page = isset($GLOBALS['AJAX_PAGE']) && $GLOBALS['AJAX_PAGE'] ? true : false;
|
||||
// set the default lang
|
||||
$lang = 'en_utf8';
|
||||
if (session_id() && isset($_SESSION['DEFAULT_LANG']) && $_SESSION['DEFAULT_LANG']) {
|
||||
if (session_id() !== false && !empty($_SESSION['DEFAULT_LANG'])) {
|
||||
$lang = $_SESSION['DEFAULT_LANG'];
|
||||
} else {
|
||||
$lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||
@@ -922,8 +922,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
. "FROM edit_user "
|
||||
. "WHERE enabled = 1 "
|
||||
. "AND username = '" . $this->dbEscapeString($this->pw_username) . "'";
|
||||
list ($edit_user_id) = $this->dbReturnRow($q);
|
||||
if (!$edit_user_id) {
|
||||
$res = $this->dbReturnRow($q);
|
||||
if (
|
||||
!is_array($res) ||
|
||||
(is_array($res) && empty($res['edit_user_id']))
|
||||
) {
|
||||
// username wrong
|
||||
$this->login_error = 201;
|
||||
$data = 'User could not be found';
|
||||
@@ -935,8 +938,17 @@ class Login extends \CoreLibs\DB\IO
|
||||
. "FROM edit_user "
|
||||
. "WHERE enabled = 1 "
|
||||
. "AND username = '" . $this->dbEscapeString($this->pw_username) . "'";
|
||||
list ($edit_user_id, $old_password_hash) = $this->dbReturnRow($q);
|
||||
if (!$edit_user_id || !$this->loginPasswordCheck($old_password_hash, $this->pw_old_password)) {
|
||||
$edit_user_id = '';
|
||||
$res = $this->dbReturnRow($q);
|
||||
if (is_array($res)) {
|
||||
$edit_user_id = $res['edit_user_id'];
|
||||
}
|
||||
if (
|
||||
!is_array($res) ||
|
||||
(is_array($res) &&
|
||||
(empty($res['edit_user_id']) ||
|
||||
!$this->loginPasswordCheck($res['old_password_hash'], $this->pw_old_password)))
|
||||
) {
|
||||
// old password wrong
|
||||
$this->login_error = 202;
|
||||
$data = 'The old password does not match';
|
||||
@@ -1096,7 +1108,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
// write to LOG table ...
|
||||
if ($this->login_error || $this->login || $this->logout) {
|
||||
$username = '';
|
||||
$password = '';
|
||||
// $password = '';
|
||||
// set event
|
||||
if ($this->login) {
|
||||
$event = 'Login';
|
||||
@@ -1109,7 +1121,10 @@ class Login extends \CoreLibs\DB\IO
|
||||
if ($this->euid) {
|
||||
// get user from user table
|
||||
$q = "SELECT username FROM edit_user WHERE edit_user_id = " . $this->euid;
|
||||
list($username) = $this->dbReturnRow($q);
|
||||
$username = '';
|
||||
if (is_array($res = $this->dbReturnRow($q))) {
|
||||
$username = $res['username'];
|
||||
}
|
||||
} // if euid is set, get username (or try)
|
||||
$this->writeLog($event, '', $this->login_error, $username);
|
||||
} // write log under certain settings
|
||||
|
||||
@@ -81,7 +81,7 @@ class Basic
|
||||
/** @var string */
|
||||
private $session_name = '';
|
||||
/** @var string */
|
||||
private $session_id = '';
|
||||
private $session_id = ''; /** @phpstan-ignore-line */
|
||||
|
||||
// ajax flag
|
||||
/** @var bool */
|
||||
@@ -164,7 +164,7 @@ class Basic
|
||||
// start session
|
||||
session_start();
|
||||
// set internal session id, we can use that later for protection check
|
||||
$this->session_id = session_id() ?: '';
|
||||
$this->session_id = (string)session_id();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,24 +1173,6 @@ class Basic
|
||||
|
||||
// *** UIDS END
|
||||
|
||||
// *** BETTER PASSWORD OPTIONS, must be used ***
|
||||
// [!!! DEPRECATED !!!]
|
||||
// moved to \CoreLibs\Check\Password
|
||||
/**
|
||||
* inits the password options set
|
||||
* currently this is et empty, and the default options are used
|
||||
* @return void has no reutrn
|
||||
* @deprecated use This function has been removed
|
||||
*/
|
||||
private function passwordInit(): void
|
||||
{
|
||||
trigger_error('Method ' . __METHOD__ . ' has been removed', E_USER_DEPRECATED);
|
||||
/* // set default password cost: use default set automatically
|
||||
$this->password_options = [
|
||||
// 'cost' => PASSWORD_BCRYPT_DEFAULT_COST
|
||||
]; */
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the password hash
|
||||
* @param string $password password
|
||||
|
||||
@@ -12,13 +12,25 @@ class Email
|
||||
0 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@"
|
||||
. "[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*\.([a-zA-Z]{2,}){1}$", // MASTER
|
||||
1 => "@(.*)@(.*)", // double @
|
||||
2 => "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@", // wrong part before @
|
||||
2 => "^[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+\-\/=?^_`{|}~\.]{0,63}@", // wrong part before @
|
||||
3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @
|
||||
4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part
|
||||
5 => "\.([a-zA-Z]{2,6}){1}$", // wrong top level part
|
||||
6 => "@(.*)\.{2,}", // double .. in domain name part
|
||||
7 => "@.*\.$" // ends with a dot, top level, domain missing
|
||||
];
|
||||
// for above position, description string below
|
||||
/** @var array<int,string> */
|
||||
private static $email_regex_check_message = [
|
||||
0 => 'Invalid email address',
|
||||
1 => 'Double @ mark in email address',
|
||||
2 => 'Invalid email part before @ sign',
|
||||
3 => 'Invalid domain part after @ sign',
|
||||
4 => 'Invalid domain name part',
|
||||
5 => 'Wrong domain top level part',
|
||||
6 => 'Double consecutive dots in domain name (..)',
|
||||
7 => 'Domain ends with a dot or is missing top level part'
|
||||
];
|
||||
// the array with the mobile types that are valid
|
||||
/** @var array<string,string> */
|
||||
private static $mobile_email_type = [
|
||||
@@ -100,7 +112,7 @@ class Email
|
||||
];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* get one position from the regex check list
|
||||
*
|
||||
* @param int $type Which position in the regex list to get
|
||||
* if not set or not valid get default pos 0
|
||||
@@ -116,8 +128,10 @@ class Email
|
||||
}
|
||||
|
||||
/**
|
||||
* get the full check array
|
||||
* this will be deprected at some point
|
||||
* get the full check array, except position 0, but preserve keys
|
||||
* Currently used to add per error level type from
|
||||
* getEmailRegex to error reporting
|
||||
* Might be deprecated at some point
|
||||
*
|
||||
* @return array<mixed>
|
||||
*/
|
||||
@@ -132,6 +146,22 @@ class Email
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns error message for email ergex error, or empty string if not set
|
||||
*
|
||||
* @param int $error
|
||||
* @return array<string,string|int> Error message and regex
|
||||
*/
|
||||
public static function getEmailRegexErrorMessage(int $error): array
|
||||
{
|
||||
// return error message and regex
|
||||
return [
|
||||
'error' => $error,
|
||||
'message' => self::$email_regex_check_message[$error] ?? '',
|
||||
'regex' => self::$email_regex_check[$error] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* guesses the email type (mostly for mobile) from the domain
|
||||
* if second is set to true, it will return short naming scheme (only provider)
|
||||
@@ -180,6 +210,54 @@ class Email
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* simple email check with the basic email eregex
|
||||
*
|
||||
* @param string $email Email address, will be checkd as lower
|
||||
* @return bool True if email is ok, or false if regex failed
|
||||
*/
|
||||
public static function checkEmail(string $email): bool
|
||||
{
|
||||
$email_regex = self::getEmailRegex();
|
||||
if (!preg_match("/$email_regex/", strtolower($email))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $email Email address, will be checkd as lower
|
||||
* @param bool $error_code_only If this is set to true it will only return
|
||||
* the error pos, instead of detailed array
|
||||
* @return array<mixed> Errors as array with message and regex
|
||||
*/
|
||||
public static function checkEmailFull(string $email, bool $error_code_only = false): array
|
||||
{
|
||||
$errors = [];
|
||||
foreach (self::$email_regex_check as $pos => $email_regex) {
|
||||
$match = preg_match("/$email_regex/", strtolower($email));
|
||||
// if the first does not fail, quit as ok
|
||||
if ($pos == 0 && $match) {
|
||||
break;
|
||||
}
|
||||
// else do error storage
|
||||
// not that for 1, 6, 7 the regex is matching
|
||||
if (
|
||||
(!$match && in_array($pos, [0, 2, 3, 4, 5])) ||
|
||||
($match && in_array($pos, [1, 6, 7]))
|
||||
) {
|
||||
if ($error_code_only === true) {
|
||||
$errors[] = $pos;
|
||||
} else {
|
||||
$errors[] = self::getEmailRegexErrorMessage($pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -27,7 +27,6 @@ class ArrayHandler
|
||||
}
|
||||
if (
|
||||
$key_lookin != null &&
|
||||
!empty($key_lookin) &&
|
||||
array_key_exists($key_lookin, $haystack) &&
|
||||
$needle === $haystack[$key_lookin]
|
||||
) {
|
||||
|
||||
@@ -302,8 +302,6 @@ class IO extends \CoreLibs\Basic
|
||||
private $insert_id_arr; // always return as array, even if only one
|
||||
/** @var string */
|
||||
private $insert_id_pk_name; // primary key name for insert recovery from insert_id_arr
|
||||
/** @var string */
|
||||
private $temp_sql;
|
||||
// other vars
|
||||
/** @var string */
|
||||
private $nbsp = ''; // used by print_array recursion function
|
||||
@@ -932,10 +930,7 @@ class IO extends \CoreLibs\Basic
|
||||
$this->warning_id = 31;
|
||||
$this->__dbError($cursor, '[dbExec]');
|
||||
}
|
||||
} elseif (
|
||||
$stm_name === null ||
|
||||
($stm_name !== null && !empty($cursor))
|
||||
) {
|
||||
} else { // was stm_name null or not null and cursor
|
||||
// we have returning, now we need to check if we get one or many returned
|
||||
// we'll need to loop this, if we have multiple insert_id returns
|
||||
while (
|
||||
@@ -2202,14 +2197,12 @@ class IO extends \CoreLibs\Basic
|
||||
$q = 'UPDATE ' . $table . ' SET ';
|
||||
$q .= $q_sub_data . ' ';
|
||||
$q .= 'WHERE ' . $primary_key['row'] . ' = ' . $primary_key['value'];
|
||||
$this->temp_sql = $q_sub_data;
|
||||
} else {
|
||||
$q = 'INSERT INTO ' . $table . ' (';
|
||||
$q .= $q_sub_value;
|
||||
$q .= ') VALUES (';
|
||||
$q .= $q_sub_data;
|
||||
$q .= ')';
|
||||
$this->temp_sql = $q;
|
||||
}
|
||||
if (!$this->dbExec($q)) {
|
||||
return false;
|
||||
@@ -2426,7 +2419,7 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
public function dbGetNumRows()
|
||||
{
|
||||
return $this->num_rows ?? null;
|
||||
return $this->num_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2440,6 +2433,17 @@ class IO extends \CoreLibs\Basic
|
||||
return $this->had_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets warning number that was last
|
||||
* So we always have the last warning number stored even if a new one is created
|
||||
*
|
||||
* @return int last error number
|
||||
*/
|
||||
public function getHadWarning()
|
||||
{
|
||||
return $this->had_warning;
|
||||
}
|
||||
|
||||
// DEPEREACTED CALLS
|
||||
|
||||
/**
|
||||
|
||||
@@ -295,7 +295,11 @@ class PgSQL
|
||||
if (!is_resource($q)) {
|
||||
return false;
|
||||
}
|
||||
list($id) = $this->__dbFetchArray($q) ?: [];
|
||||
if (is_array($res = $this->__dbFetchArray($q))) {
|
||||
list($id) = $res;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$id = [-1, $q];
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class Logging
|
||||
private function getCallerClass(): string
|
||||
{
|
||||
// get the last class entry and wrie that
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) ?? [['class' => get_class($this)]];
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
// make sure if false it is an array and then check if not class set return empty string
|
||||
return (end($backtrace) ?: [])['class'] ?? '';
|
||||
}
|
||||
|
||||
@@ -60,25 +60,30 @@ class Support
|
||||
|
||||
/**
|
||||
* Get the current class where this function is called
|
||||
* Is mostly used in debug log statements to get the class where the debug was called
|
||||
* Is mostly used in debug log statements to get the class where the debug
|
||||
* was called
|
||||
* gets top level class
|
||||
* loops over the debug backtrace until if finds the first class (from the end)
|
||||
* @return string Class name with namespace
|
||||
*/
|
||||
public static function getCallerClass(): string
|
||||
{
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) ?? [['class' => get_called_class()]];
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
// ?? [['class' => get_called_class()]];
|
||||
// TODO make sure that this doesn't loop forver
|
||||
$class = null;
|
||||
while ($class === null) {
|
||||
while ($class === null && count($backtrace) > 0) {
|
||||
// if current is
|
||||
// [function] => debug
|
||||
// [class] => CoreLibs\Debug\Logging
|
||||
// then return
|
||||
// (OUTSIDE) because it was not called from a class method
|
||||
// or return file name
|
||||
$class = array_pop($backtrace)['class'] ?? null;
|
||||
$get_class = array_pop($backtrace);
|
||||
$class = $get_class['class'] ?? null;
|
||||
}
|
||||
return $class ?? '';
|
||||
// on null or empty return empty string
|
||||
return empty($class) ? '' : $class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -355,9 +355,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (isset($config_array['load_query']) && $config_array['load_query']) {
|
||||
$this->load_query = $config_array['load_query'];
|
||||
}
|
||||
$this->archive_pk_name = 'a_' . $this->pk_name ?? '';
|
||||
$this->col_name = str_replace('_id', '', $this->pk_name ?? '');
|
||||
$this->int_pk_name = $this->pk_name ?? '';
|
||||
$this->archive_pk_name = 'a_' . $this->pk_name;
|
||||
$this->col_name = str_replace('_id', '', $this->pk_name);
|
||||
$this->int_pk_name = $this->pk_name;
|
||||
// check if reference_arrays are given and proceed them
|
||||
if (isset($config_array['reference_arrays']) && is_array($config_array['reference_arrays'])) {
|
||||
foreach ($config_array['reference_arrays'] as $key => $value) {
|
||||
@@ -1197,16 +1197,18 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
break;
|
||||
// check unique, check if field in table is not yet exist
|
||||
case 'unique':
|
||||
$q = 'SELECT ' . $key
|
||||
. ' FROM ' . $this->table_name
|
||||
. ' WHERE ' . $key . ' = '
|
||||
$q = 'SELECT ' . $key . ' AS unique_row '
|
||||
. 'FROM ' . $this->table_name . ' '
|
||||
. 'WHERE ' . $key . ' = '
|
||||
. "'" . $this->dbEscapeString($this->table_array[$key]['value']) . "'";
|
||||
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) {
|
||||
if (
|
||||
is_array($s_res = $this->dbReturnRow($q)) &&
|
||||
!empty($s_res['unique_row'])
|
||||
) {
|
||||
$this->msg .= sprintf(
|
||||
$this->l->__('The field <b>%s</b> can be used only once!<br>'),
|
||||
$this->table_array[$key]['output_name']
|
||||
@@ -1538,20 +1540,30 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$order_name = $this->formGetColNameFromKey('order');
|
||||
if ($order_name) {
|
||||
// first check out of order ...
|
||||
|
||||
if (empty($this->table_array[$order_name]['value'])) {
|
||||
// set order (read max)
|
||||
$q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name;
|
||||
list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q);
|
||||
$q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order '
|
||||
. 'FROM ' . $this->table_name;
|
||||
if (
|
||||
is_array($res = $this->dbReturnRow($q)) &&
|
||||
!empty($res['max_page_order'])
|
||||
) {
|
||||
$this->table_array[$order_name]['value'] = $res['max_page_order'];
|
||||
}
|
||||
// frist element is 0 because NULL gets returned, set to 1
|
||||
if (!$this->table_array[$order_name]['value']) {
|
||||
$this->table_array[$order_name]['value'] = 1;
|
||||
}
|
||||
} elseif (!empty($this->table_array[$this->int_pk_name]['value'])) {
|
||||
$q = 'SELECT ' . $order_name
|
||||
. ' FROM ' . $this->table_name
|
||||
. ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
|
||||
list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q);
|
||||
$q = 'SELECT ' . $order_name . ' AS order_name '
|
||||
. 'FROM ' . $this->table_name . ' '
|
||||
. 'WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
|
||||
if (
|
||||
is_array($res = $this->dbReturnRow($q)) &&
|
||||
!empty($res['order_name'])
|
||||
) {
|
||||
$this->table_array[$order_name]['value'] = $res['order_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->table_array;
|
||||
@@ -1656,7 +1668,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
) {
|
||||
// $this->log->debug('form', 'HERE');
|
||||
// check if this text name already exists (lowercase compare)
|
||||
$q = 'SELECT ' . $this->table_array[$key]['pk_name']
|
||||
$q = 'SELECT ' . $this->table_array[$key]['pk_name'] . ' AS pk_name '
|
||||
. ' FROM ' . $this->table_array[$key]['table_name']
|
||||
. ' WHERE LCASE(' . $this->table_array[$key]['input_name'] . ') = '
|
||||
. "'" . $this->dbEscapeString(strtolower($this->table_array[$key]['input_value'])) . "'";
|
||||
@@ -1664,9 +1676,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$key]['where']) {
|
||||
$q .= ' AND ' . $this->table_array[$key]['where'];
|
||||
}
|
||||
list($pk_name_temp) = $this->dbReturnRow($q);
|
||||
if ($this->num_rows >= 1) {
|
||||
$this->table_array[$key]['value'] = $pk_name_temp;
|
||||
if (
|
||||
is_array($s_res = $this->dbReturnRow($q)) &&
|
||||
!empty($s_res['pk_name'])
|
||||
) {
|
||||
// $this->table_array[$key]['value'] = $pk_name_temp;
|
||||
$this->table_array[$key]['value'] = $s_res['pk_name'];
|
||||
} else {
|
||||
// if a where was given, set this key also [dangerous!]
|
||||
// postgreSQL compatible insert
|
||||
@@ -1694,7 +1709,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// if drop down & input are different
|
||||
if ($this->table_array[$key]['input_value'] != $this->table_array[$key]['value']) {
|
||||
// check if 'right input' is in DB
|
||||
$q = 'SELECT ' . $this->table_array[$key]['input_name']
|
||||
$q = 'SELECT ' . $this->table_array[$key]['input_name'] . ' AS temp '
|
||||
. ' FROM ' . $this->table_array[$key]['table_name']
|
||||
. ' WHERE LCASE(' . $this->table_array[$key]['input_name'] . ') = '
|
||||
. "'" . strtolower($this->dbEscapeString($this->table_array[$key]['input_value'])) . "'";
|
||||
@@ -1702,9 +1717,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$key]['where']) {
|
||||
$q .= ' AND ' . $this->table_array[$key]['where'];
|
||||
}
|
||||
list($temp) = $this->dbReturnRow($q);
|
||||
// nothing found in table, use new inserted key
|
||||
if (!$temp) {
|
||||
if (
|
||||
is_array($s_res = $this->dbReturnRow($q)) &&
|
||||
empty($s_res['temp'])
|
||||
) {
|
||||
$this->table_array[$key]['value'] = $this->table_array[$key]['input_value'];
|
||||
} else {
|
||||
// found in DB
|
||||
@@ -1800,7 +1816,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
} // foreach reference arrays
|
||||
} // if reference arrays
|
||||
// write element list
|
||||
if (isset($this->element_list) && is_array($this->element_list)) {
|
||||
if (is_array($this->element_list)) {
|
||||
$type = [];
|
||||
reset($this->element_list);
|
||||
foreach ($this->element_list as $table_name => $reference_array) {
|
||||
@@ -2294,7 +2310,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
}
|
||||
// @phan HACK
|
||||
$data['prefix'] = $data['prefix'] ?? '';
|
||||
$data['prefix'] = $data['prefix'];
|
||||
// set the rest of the data so we can print something out
|
||||
/** @phan-suppress-next-line PhanTypeArraySuspiciousNullable */
|
||||
$data['type'][$data['prefix'] . $this->element_list[$table_name]['read_data']['name']] = 'string';
|
||||
@@ -2362,7 +2378,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// read out the list and add the selected data if needed
|
||||
while (is_array($res = $this->dbReturn($q))) {
|
||||
$_data = [];
|
||||
$prfx = $data['prefix'] ?? ''; // short
|
||||
$prfx = $data['prefix']; // short
|
||||
// go through each res
|
||||
for ($i = 0, $i_max = count($q_select); $i < $i_max; $i++) {
|
||||
// query select part, set to the element name
|
||||
@@ -2411,7 +2427,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->element_list[$table_name]['max_empty'] = 10;
|
||||
}
|
||||
// check if we need to fill fields
|
||||
$element_count = count($data['content'] ?? []);
|
||||
$element_count = count($data['content']);
|
||||
$missing_empty_count = $this->element_list[$table_name]['max_empty'] - $element_count;
|
||||
$this->log->debug('CFG MAX', 'Max empty: '
|
||||
. $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count
|
||||
@@ -2428,22 +2444,18 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$pos++
|
||||
) {
|
||||
$_data = [];
|
||||
// just in case
|
||||
if (!isset($data['type'])) {
|
||||
$data['type'] = [];
|
||||
}
|
||||
// the fields that need to be filled are in data->type array:
|
||||
// pk fields are unfilled
|
||||
// fk fields are filled with the fk_id 'int_pk_name' value
|
||||
foreach ($data['type'] as $el_name => $type) {
|
||||
$_data[$el_name] = '';
|
||||
if (
|
||||
isset($data['pk_name']) &&
|
||||
!empty($data['pk_name']) &&
|
||||
$el_name == $data['pk_name']
|
||||
) {
|
||||
// do nothing for pk name
|
||||
} elseif (
|
||||
isset($data['fk_name']) &&
|
||||
!empty($data['fk_name']) &&
|
||||
$el_name == $data['fk_name'] &&
|
||||
isset($this->table_array[$this->int_pk_name]['value'])
|
||||
) {
|
||||
@@ -2466,7 +2478,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$data['content'][] = $proto;
|
||||
// we also need the pos add or we through an error in smarty
|
||||
$data['pos'][] = [
|
||||
0 => isset($data['pos']) ? count($data['pos']) : 0
|
||||
0 => count($data['pos'])
|
||||
];
|
||||
}
|
||||
// $this->log->debug('CFG ELEMENT LIST FILL', 'Data array: ' . $this->log->prAr($data));
|
||||
|
||||
@@ -65,7 +65,7 @@ class Image
|
||||
}
|
||||
// does this picture exist and is it a picture
|
||||
if (file_exists($filename) && is_file($filename)) {
|
||||
list($width, $height, $type) = getimagesize($filename);
|
||||
[$width, $height, $type] = getimagesize($filename) ?: [];
|
||||
$convert_prefix = '';
|
||||
$create_file = false;
|
||||
$delete_filename = '';
|
||||
@@ -94,7 +94,7 @@ class Image
|
||||
if (!is_file($filename)) {
|
||||
$filename .= '-0';
|
||||
}
|
||||
list($width, $height, $type) = getimagesize($filename);
|
||||
[$width, $height, $type] = getimagesize($filename) ?: [];
|
||||
}
|
||||
// if no size given, set size to original
|
||||
if (!$size_x || $size_x < 1 || !is_numeric($size_x)) {
|
||||
@@ -113,7 +113,7 @@ class Image
|
||||
$status = exec($convert_string, $output, $return);
|
||||
// get the size of the converted data, if converted
|
||||
if (is_file($thumbnail)) {
|
||||
list ($width, $height, $type) = getimagesize($thumbnail);
|
||||
[$width, $height, $type] = getimagesize($thumbnail) ?: [];
|
||||
}
|
||||
}
|
||||
if ($height > $size_y) {
|
||||
@@ -133,6 +133,7 @@ class Image
|
||||
if (!empty($dummy) && strstr($dummy, '/') === false) {
|
||||
// check if we have the "dummy" image flag set
|
||||
$filename = PICTURES . ICONS . strtoupper($dummy) . ".png";
|
||||
/** @phpstan-ignore-next-line */
|
||||
if (!empty($dummy) && file_exists($filename) && is_file($filename)) {
|
||||
$return_data = $filename;
|
||||
} else {
|
||||
@@ -187,7 +188,7 @@ class Image
|
||||
is_writable(BASE . LAYOUT . CONTENT_PATH . CACHE)
|
||||
) {
|
||||
// $this->debug('IMAGE PREPARE', "FILENAME OK, THUMB WIDTH/HEIGHT OK");
|
||||
list($inc_width, $inc_height, $img_type) = getimagesize($filename);
|
||||
[$inc_width, $inc_height, $img_type] = getimagesize($filename) ?: [];
|
||||
$thumbnail_write_path = null;
|
||||
$thumbnail_web_path = null;
|
||||
// path set first
|
||||
@@ -424,7 +425,7 @@ class Image
|
||||
if (!function_exists('exif_read_data') || !is_writeable($filename)) {
|
||||
return;
|
||||
}
|
||||
list($inc_width, $inc_height, $img_type) = getimagesize($filename);
|
||||
[$inc_width, $inc_height, $img_type] = getimagesize($filename) ?: [];
|
||||
// add @ to avoid "file not supported error"
|
||||
$exif = @exif_read_data($filename);
|
||||
$orientation = null;
|
||||
|
||||
@@ -280,12 +280,12 @@ class SmartyExtend extends SmartyBC
|
||||
public function setSmartyPaths(): void
|
||||
{
|
||||
// master template
|
||||
if (!isset($this->MASTER_TEMPLATE_NAME)) {
|
||||
if (empty($this->MASTER_TEMPLATE_NAME)) {
|
||||
$this->MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME;
|
||||
}
|
||||
|
||||
// set include & template names
|
||||
if (!isset($this->CONTENT_INCLUDE)) {
|
||||
if (empty($this->CONTENT_INCLUDE)) {
|
||||
$this->CONTENT_INCLUDE = str_replace('.php', '', $this->page_name) . '.tpl';
|
||||
}
|
||||
// strip tpl and replace it with php
|
||||
@@ -435,10 +435,10 @@ class SmartyExtend extends SmartyBC
|
||||
$this->DATA['show_ea_extra'] = $cms->acl['show_ea_extra'] ?? false;
|
||||
$this->DATA['ADMIN'] = $cms->acl['admin'] ?? 0;
|
||||
// top menu
|
||||
$this->DATA['nav_menu'] = $cms->adbTopMenu() ?? [];
|
||||
$this->DATA['nav_menu'] = $cms->adbTopMenu();
|
||||
$this->DATA['nav_menu_count'] = is_array($this->DATA['nav_menu']) ? count($this->DATA['nav_menu']) : 0;
|
||||
// messages = ['msg' =>, 'class' => 'error/warning/...']
|
||||
$this->DATA['messages'] = $cms->messages ?? [];
|
||||
$this->DATA['messages'] = $cms->messages;
|
||||
} else { /** @phpstan-ignore-line Because I assume object for phpstan */
|
||||
$this->DATA['show_ea_extra'] = false;
|
||||
$this->DATA['ADMIN'] = 0;
|
||||
@@ -451,7 +451,7 @@ class SmartyExtend extends SmartyBC
|
||||
$this->HEADER['JAVASCRIPT'] = $this->ADMIN_JAVASCRIPT ? $this->ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT;
|
||||
// the page name
|
||||
$this->DATA['page_name'] = $this->page_name;
|
||||
$this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH;
|
||||
$this->DATA['table_width'] = empty($this->PAGE_WIDTH) ?: PAGE_WIDTH;
|
||||
$this->DATA['form_name'] = $this->DATA['FORM_NAME'];
|
||||
// for tinymce special
|
||||
$this->DATA['TINYMCE_LANG'] = $this->lang_short;
|
||||
|
||||
@@ -27,7 +27,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool
|
||||
{
|
||||
if (!(error_reporting() & $type) && empty(SHOW_ALL_ERRORS)) {
|
||||
if (!(error_reporting() & $type) && SHOW_ALL_ERRORS == false) {
|
||||
// This error code is not included in error_reporting
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class qqUploadedFileForm implements qqUploadedFile // phpcs:ignore Squiz.Classes
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $_FILES['qqfile']['name'] ?? '';
|
||||
return (string)$_FILES['qqfile']['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ class qqUploadedFileForm implements qqUploadedFile // phpcs:ignore Squiz.Classes
|
||||
*/
|
||||
public function getSize(): int
|
||||
{
|
||||
return (int)$_FILES['qqfile']['size'] ?? 0;
|
||||
return (int)$_FILES['qqfile']['size'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class qqFileUploader // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
}
|
||||
|
||||
$pathinfo = pathinfo($this->file->getName());
|
||||
$filename = $pathinfo['filename'] ?? '';
|
||||
$filename = $pathinfo['filename'];
|
||||
//$filename = md5(uniqid());
|
||||
$ext = $pathinfo['extension'] ?? '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user