');
/************ STYLE SHEETS / JS **********/
-DEFINE('ADMIN_STYLESHEET', 'edit.css');
-DEFINE('ADMIN_JAVASCRIPT', 'edit.js');
-DEFINE('STYLESHEET', 'frontend.css');
-DEFINE('JAVASCRIPT', 'frontend.js');
+define('ADMIN_STYLESHEET', 'edit.css');
+define('ADMIN_JAVASCRIPT', 'edit.js');
+define('STYLESHEET', 'frontend.css');
+define('JAVASCRIPT', 'frontend.js');
// anything optional
/************* INTERNAL ******************/
diff --git a/www/layout/admin/javascript/firebug.js b/www/layout/admin/javascript/firebug.js
index 27a5ca27..17249070 100644
--- a/www/layout/admin/javascript/firebug.js
+++ b/www/layout/admin/javascript/firebug.js
@@ -3,8 +3,9 @@
* firebug 1.2+ and the webkit console */
var ConsoleSetup = function() {
- if (!window.console)
+ if (!window.console) {
window.console = {};
+ }
var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];
diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php
index bdb61e03..03932fee 100644
--- a/www/lib/CoreLibs/ACL/Login.php
+++ b/www/lib/CoreLibs/ACL/Login.php
@@ -345,7 +345,7 @@ class Login extends \CoreLibs\DB\IO
* if user pressed login button this script is called, but only if there is no preview euid set]
* @return void has not return
*/
- private function loginLoginUser()
+ private function loginLoginUser(): void
{
// have to get the global stuff here for setting it later
if (!$this->euid && $this->login) {
@@ -587,7 +587,7 @@ class Login extends \CoreLibs\DB\IO
* for every page the user access this script checks if he is allowed to do so
* @return bool permission okay as true/false
*/
- public function loginCheckPermissions()
+ public function loginCheckPermissions(): bool
{
if ($this->euid && $this->login_error != 103) {
$q = "SELECT filename ";
@@ -613,7 +613,7 @@ class Login extends \CoreLibs\DB\IO
* if a user pressed on logout, destroyes session and unsets all global vars
* @return void has no return
*/
- public function loginLogoutUser()
+ public function loginLogoutUser(): void
{
if ($this->logout || $this->login_error) {
// unregister and destroy session vars
@@ -673,7 +673,7 @@ class Login extends \CoreLibs\DB\IO
* set all base ACL levels as a list keyword -> ACL number
* @return void has no return
*/
- private function loginSetAcl()
+ private function loginSetAcl(): void
{
// only set acl if we have permission okay
if ($this->permission_okay) {
@@ -766,8 +766,8 @@ class Login extends \CoreLibs\DB\IO
/**
* checks if this edit access id is valid
- * @param int $edit_access_id access id pk to check
- * @return bool true/false: if the edit access is not in the valid list: false
+ * @param int|null $edit_access_id access id pk to check
+ * @return bool true/false: if the edit access is not in the valid list: false
*/
public function loginCheckEditAccess($edit_access_id): bool
{
@@ -783,7 +783,7 @@ class Login extends \CoreLibs\DB\IO
* @param string $password the new password
* @return bool true or false if valid password or not
*/
- private function loginPasswordChangeValidPassword($password)
+ private function loginPasswordChangeValidPassword($password): bool
{
$is_valid_password = true;
// check for valid in regex arrays in list
@@ -805,7 +805,7 @@ class Login extends \CoreLibs\DB\IO
* dummy declare for password forget
* @return void has no return
*/
- private function loginPasswordForgot()
+ private function loginPasswordForgot(): void
{
// will do some password recovert, eg send email
}
@@ -831,7 +831,7 @@ class Login extends \CoreLibs\DB\IO
* changes a user password
* @return void has no return
*/
- private function loginPasswordChange()
+ private function loginPasswordChange(): void
{
if ($this->change_password) {
$event = 'Password Change';
@@ -1013,7 +1013,7 @@ class Login extends \CoreLibs\DB\IO
* checks if there are external templates, if not uses internal fallback ones
* @return void has no return
*/
- private function loginSetTemplates()
+ private function loginSetTemplates(): void
{
$strings = array(
'HTML_TITLE' => $this->l->__('LOGIN'),
@@ -1172,7 +1172,7 @@ EOM;
* @param string $username login user username
* @return void has no return
*/
- private function writeLog(string $event, string $data, $error = '', string $username = '')
+ private function writeLog(string $event, string $data, $error = '', string $username = ''): void
{
if ($this->login) {
$this->action = 'Login';
@@ -1217,28 +1217,33 @@ EOM;
}
/**
- *checks that the given edit access id is valid for this user
- * @param int $edit_access_id edit access id to check
- * @return int same edit access id if ok, or the default edit access id if given one is not valid
+ * checks that the given edit access id is valid for this user
+ * @param int|null $edit_access_id edit access id to check
+ * @return int|null same edit access id if ok
+ * or the default edit access id if given one is not valid
*/
- public function loginCheckEditAccessId(int $edit_access_id)
+ public function loginCheckEditAccessId(?int $edit_access_id): ?int
{
- if (!array_key_exists($edit_access_id, $_SESSION["UNIT"])) {
- return $_SESSION["UNIT_DEFAULT"];
+ if (isset($_SESSION['UNIT']) &&
+ is_array($_SESSION['UNIT']) &&
+ !array_key_exists($edit_access_id, $_SESSION['UNIT'])
+ ) {
+ return $_SESSION['UNIT_DEFAULT'];
} else {
return $edit_access_id;
}
}
/**
- * [loginSetEditAccessData description]
+ * retunrn a set entry from the UNIT session for an edit access_id
+ * if not found return false
* @param int $edit_access_id edit access id
* @param string|int $data_key key value to search for
* @return bool|string false for not found or string for found data
*/
public function loginSetEditAccessData(int $edit_access_id, $data_key)
{
- if (!$_SESSION['UNIT'][$edit_access_id]['data'][$data_key]) {
+ if (!isset($_SESSION['UNIT'][$edit_access_id]['data'][$data_key])) {
return false;
} else {
return $_SESSION['UNIT'][$edit_access_id]['data'][$data_key];
diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php
index c658bd08..047154a1 100644
--- a/www/lib/CoreLibs/Basic.php
+++ b/www/lib/CoreLibs/Basic.php
@@ -1562,6 +1562,31 @@ class Basic
return $array;
}
+ /**
+ * get lines in a file
+ * @param string $file file for line count read
+ * @return int number of lines or -1 for non readable file
+ */
+ public static function getLinesFromFile(string $file): int
+ {
+ if (is_file($file) &&
+ file_exists($file) &&
+ is_readable($file)
+ ) {
+ $f = fopen($file, 'rb');
+ $lines = 0;
+ while (!feof($f)) {
+ $lines += substr_count(fread($f, 8192), "\n");
+ }
+ fclose($f);
+ } else {
+ // if file does not exist or is not readable, return -1
+ $lines = -1;
+ }
+ // return lines in file
+ return $lines;
+ }
+
/**
* wrapper function for mb mime convert, for correct conversion with long strings
* @param string $string string to encode
@@ -1793,26 +1818,33 @@ class Basic
{
// check if the timestamp has any h/m/s/ms inside, if yes skip
if (!preg_match("/(h|m|s|ms)/", (string)$timestamp)) {
- $ms = 0;
- list ($timestamp, $ms) = explode('.', (string)round($timestamp, 4));
+ list ($timestamp, $ms) = array_pad(explode('.', (string)round($timestamp, 4)), 2, null);
$timegroups = array(86400, 3600, 60, 1);
$labels = array('d', 'h', 'm', 's');
$time_string = '';
- for ($i = 0, $iMax = count($timegroups); $i < $iMax; $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) ? ' ' : '');
+ // if timestamp is zero, return zero string
+ if ($timestamp == 0) {
+ $time_string = '0s';
+ } else {
+ for ($i = 0, $iMax = count($timegroups); $i < $iMax; $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) ? ' ' : '');
+ }
}
}
- // if we have ms and it has leading zeros, remove them
- $ms = preg_replace("/^0+/", '', $ms);
- // add ms if there
- if ($show_micro) {
- $time_string .= ' '.(!$ms ? 0 : $ms).'ms';
- } elseif (!$time_string) {
- $time_string .= (!$ms ? 0 : $ms).'ms';
+ // only add ms if we have an ms value
+ if ($ms !== null) {
+ // if we have ms and it has leading zeros, remove them, but only if it is nut just 0
+ $ms = preg_replace("/^0+(\d+)$/", '${1}', $ms);
+ // add ms if there
+ if ($show_micro) {
+ $time_string .= ' '.(!$ms ? 0 : $ms).'ms';
+ } elseif (!$time_string) {
+ $time_string .= (!$ms ? 0 : $ms).'ms';
+ }
}
} else {
$time_string = $timestamp;
@@ -1881,7 +1913,7 @@ class Basic
if (!$datetime) {
return false;
}
- list ($year, $month, $day, $hour, $min, $sec) = preg_split("/[\/\- :]/", $datetime);
+ list ($year, $month, $day, $hour, $min, $sec) = array_pad(preg_split("/[\/\- :]/", $datetime), 6, null);
if (!$year || !$month || !$day) {
return false;
}
@@ -2921,7 +2953,11 @@ class Basic
$HUE += 360;
}
- return array(round($HUE), round((($MAX - $MIN) / $MAX) * 100), round($MAX * 100));
+ return array(
+ (int)round($HUE),
+ (int)round((($MAX - $MIN) / $MAX) * 100),
+ (int)round($MAX * 100)
+ );
}
/**
@@ -2992,7 +3028,11 @@ class Basic
$blue = 0;
}
- return array(round($red * 255), round($green * 255), round($blue * 255));
+ return array(
+ (int)round($red * 255),
+ (int)round($green * 255),
+ (int)round($blue * 255)
+ );
}
/**
@@ -3039,7 +3079,11 @@ class Basic
// H, S, L
// S= L <= 0.5 ? C/2L : C/2 - 2L
- return array(round($HUE), round((($MAX - $MIN) / (($L <= 0.5) ? ($MAX + $MIN) : (2 - $MAX - $MIN))) * 100), $L);
+ return array(
+ (int)round($HUE),
+ (int)round((($MAX - $MIN) / (($L <= 0.5) ? ($MAX + $MIN) : (2 - $MAX - $MIN))) * 100),
+ (int)$L
+ );
}
}
@@ -3077,7 +3121,11 @@ class Basic
return $m1;
};
- return array(round(255 * $hue($h + (1 / 3))), round(255 * $hue($h)), round(255 * $hue($h - (1 / 3))));
+ return array(
+ (int)round(255 * $hue($h + (1 / 3))),
+ (int)round(255 * $hue($h)),
+ (int)round(255 * $hue($h - (1 / 3)))
+ );
}
}
@@ -3232,10 +3280,10 @@ class Basic
/**
* full wrapper for html entities
- * @param string $string string to html encode
- * @return mixed if string, encoded, else as is
+ * @param mixed $string string to html encode
+ * @return mixed if string, encoded, else as is (eg null)
*/
- public function htmlent(string $string)
+ public function htmlent($string)
{
if (is_string($string)) {
return htmlentities($string, ENT_COMPAT|ENT_HTML401, 'UTF-8', false);
diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php
index c06d559a..0202b435 100644
--- a/www/lib/CoreLibs/DB/IO.php
+++ b/www/lib/CoreLibs/DB/IO.php
@@ -957,6 +957,28 @@ class IO extends \CoreLibs\Basic
return $this->dbReturnRow('SHOW client_encoding')['client_encoding'];
}
+ /**
+ * get certain settings like username, db name
+ * @param string $name what setting to query
+ * @return mixed setting value, if not allowed name return false
+ */
+ public function dbGetSetting(string $name)
+ {
+ $setting = '';
+ switch ($name) {
+ case 'name':
+ $setting = $this->db_name;
+ break;
+ case 'user':
+ $setting = $this->db_user;
+ break;
+ default:
+ $setting = false;
+ break;
+ }
+ return $setting;
+ }
+
/**
* prints out status info from the connected DB (might be usefull for debug stuff)
* @param bool|boolean $show show db connection info, default true
@@ -1462,7 +1484,7 @@ class IO extends \CoreLibs\Basic
if (!$pk_name) {
// read the primary key from the table, if we do not have one, we get nothing in return
list($schema, $table) = $this->__dbReturnTable($query);
- if (!$this->pk_name_table[$table]) {
+ if (empty($this->pk_name_table[$table])) {
$this->pk_name_table[$table] = $this->db_functions->__dbPrimaryKey($table, $schema);
}
$pk_name = $this->pk_name_table[$table];
diff --git a/www/lib/CoreLibs/Output/Progressbar.php b/www/lib/CoreLibs/Output/Progressbar.php
index 496199b1..53a41441 100644
--- a/www/lib/CoreLibs/Output/Progressbar.php
+++ b/www/lib/CoreLibs/Output/Progressbar.php
@@ -110,7 +110,8 @@ class ProgressBar
$clear_buffer_size = $this->clear_buffer_size;
}
echo str_repeat(' ', $clear_buffer_size);
- ob_flush();
+ // a small hack to avoid warnings about no buffer to flush
+ @ob_flush();
flush();
}
@@ -541,6 +542,7 @@ class ProgressBar
$html = '';
$js = '';
$html_button = '';
+ $html_percent = '';
$this->__setStep($this->step);
$this->position = $this->__calculatePosition($this->step);
@@ -636,7 +638,7 @@ class ProgressBar
case 'percent':
// only one inner percent
// print "STYLE[$name]: ".$style_lbl."
";
- if (!isset($html_percent)) {
+ if (empty($html_percent)) {
$html_percent = ''.$this->__calculatePercent($this->step).'%
'."\n";
}
break;
diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php
index e3900642..20b15010 100644
--- a/www/lib/CoreLibs/Template/SmartyExtend.php
+++ b/www/lib/CoreLibs/Template/SmartyExtend.php
@@ -46,6 +46,7 @@ class SmartyExtend extends SmartyBC
public $USE_TINY_MCE = false;
public $JS_DATEPICKR = false;
public $JS_FLATPICKR = false;
+ public $JS_FILE_UPLOADER = false;
public $DEBUG_TMPL = false;
public $USE_INCLUDE_TEMPLATE = false;
// cache & compile
@@ -383,6 +384,7 @@ class SmartyExtend extends SmartyBC
// include flags
$this->DATA['JS_DATEPICKR'] = $this->JS_DATEPICKR;
$this->DATA['JS_FLATPICKR'] = $this->JS_FLATPICKR;
+ $this->DATA['JS_FILE_UPLOADER'] = $this->JS_FILE_UPLOADER;
// user name
$this->DATA['USER_NAME'] = !empty($_SESSION['USER_NAME']) ? $_SESSION['USER_NAME'] : '';
// the template part to include into the body
diff --git a/www/lib/FileUpload/Core/qqUploadedFileXhr.php b/www/lib/FileUpload/Core/qqUploadedFileXhr.php
index 15b2200a..3fbcb2cb 100755
--- a/www/lib/FileUpload/Core/qqUploadedFileXhr.php
+++ b/www/lib/FileUpload/Core/qqUploadedFileXhr.php
@@ -35,8 +35,8 @@ class qqUploadedFileXhr
}
public function getSize()
{
- if (isset($_SERVER["CONTENT_LENGTH"])) {
- return (int)$_SERVER["CONTENT_LENGTH"];
+ if (isset($_SERVER['CONTENT_LENGTH'])) {
+ return (int)$_SERVER['CONTENT_LENGTH'];
} else {
throw new \Exception('Getting content length is not supported.');
}