diff --git a/install/lib/classes/tpl.inc.php b/install/lib/classes/tpl.inc.php index 342b4125f8b4626f59d26999b8d0995a9f7dd82d..2bea1e1fd5474a0dcdfcc53da56a67fcf9e031a7 100644 --- a/install/lib/classes/tpl.inc.php +++ b/install/lib/classes/tpl.inc.php @@ -931,17 +931,12 @@ if (!defined('vlibTemplateClassLoaded')) { { array_push($this->_namespace, $varname); $tempvar = count($this->_namespace) - 1; - $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < (isset(\$this->_arrvars"; + $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < \$this->_tpl_count(\$this->_arrvars"; for ($i=0; $i < count($this->_namespace); $i++) { $retstr .= "['".$this->_namespace[$i]."']"; if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; } - $retstr .= ") ? count(\$this->_arrvars"; - for ($i=0; $i < count($this->_namespace); $i++) { - $retstr .= "['".$this->_namespace[$i]."']"; - if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; - } - return $retstr.") : 0); \$_".$tempvar."++) {"; + return $retstr."); \$_".$tempvar."++) {"; } /** @@ -1040,7 +1035,7 @@ if (!defined('vlibTemplateClassLoaded')) { $wholetag = $args[0]; $openclose = $args[1]; $tag = strtolower($args[2]); - + if ($tag == 'else') return '<?php } else { ?>'; if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags @@ -1281,6 +1276,27 @@ if (!defined('vlibTemplateClassLoaded')) { return $return; } + /** + * Used during in evaled code to replace PHP count function for PHP 8 compatibility + * @var variable to be counted + */ + private function _tpl_count($var) + { + $retvar = 0; + if(isset($var)) { + if(is_array($var)) { + $retvar = count($var); + } elseif(is_null($var)) { + $retvar = 0; + } else { + $retvar = 1; + } + } else { + $retvar = 0; + } + return $retvar; + } + /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following functions have no use and are included just so that if the user is making use of vlibTemplateCache functions, this doesn't crash when changed to diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 1bfc9102b669077027a2226f3e512387aa1efc1d..78eee8c9971a7353cb0517889b16f7b2cba247ac 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -526,7 +526,7 @@ class db $sString = ''; } - $cur_encoding = mb_detect_encoding($sString); + $cur_encoding = mb_detect_encoding($sString, "auto"); if($cur_encoding != "UTF-8") { if($cur_encoding != 'ASCII') { if(is_object($app) && method_exists($app, 'log')) $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_DEBUG); diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 4b92daa73c2cba5cc8b7ec01ee170a452e20a3c8..1206e3668a88bc3cc7133ac194188e1c07caa277 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -80,7 +80,7 @@ class listform { private function getDatasourceData($field) { - global $app; + global $app, $api; $values = array(); if($field['datasource']['type'] == 'SQL') { @@ -97,7 +97,8 @@ class listform { $querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring); $querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring); $querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring); - $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); + //$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); + $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', function($matches) {global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;}, $querystring); //* Getting the records $tmp_records = $app->db->queryAllRecords($querystring); @@ -195,9 +196,9 @@ class listform { if(@is_array($this->listDef['item'])) { foreach($this->listDef['item'] as $i) { $field = $i['field']; - $table = $i['table']; + $table = (isset($i['table']))?$i['table']:''; - $searchval = $_SESSION['search'][$list_name][$search_prefix.$field]; + $searchval = (isset($_SESSION['search'][$list_name][$search_prefix.$field]))?$_SESSION['search'][$list_name][$search_prefix.$field]:''; // IDN if($searchval != ''){ if(is_array($i['filters'])) { @@ -325,7 +326,7 @@ class listform { if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; $sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page); - $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ??".($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where", $table); + $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ??".(isset($app->listform->listDef['additional_tables']) && $app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where", $table); $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php index 86eebd3d6465922cca3f236e2dd5123209674b80..45973cb470ec9abbd35ea254049617037d735ca8 100644 --- a/interface/lib/classes/listform_actions.inc.php +++ b/interface/lib/classes/listform_actions.inc.php @@ -135,7 +135,7 @@ class listform_actions { } } - if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true; + if(@$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true; // Getting Datasets from DB $records = $app->db->queryAllRecords($this->getQueryString($php_sort)); @@ -226,7 +226,7 @@ class listform_actions { } $sql_where = $app->listform->getSearchSQL($sql_where); - if($app->listform->listDef['join_sql']) $sql_where .= ' AND '.$app->listform->listDef['join_sql']; + if(isset($app->listform->listDef['join_sql'])) $sql_where .= ' AND '.$app->listform->listDef['join_sql']; $app->tpl->setVar($app->listform->searchValues); $order_by_sql = $this->SQLOrderBy; @@ -245,8 +245,9 @@ class listform_actions { $table_selects = array(); $table_selects[] = trim($app->listform->listDef['table']).'.*'; - $app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']); - if($app->listform->listDef['additional_tables'] != ''){ + + if(isset($app->listform->listDef['additional_tables']) && trim($app->listform->listDef['additional_tables']) != ''){ + $app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']); $additional_tables = explode(',', $app->listform->listDef['additional_tables']); foreach($additional_tables as $additional_table){ $table_selects[] = trim($additional_table).'.*'; @@ -254,7 +255,7 @@ class listform_actions { } $select = implode(', ', $table_selects); - $sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql"; + $sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].(isset($app->listform->listDef['additional_tables']) && $app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql"; if($no_limit == false) $sql .= " $limit_sql"; //echo $sql; return $sql; diff --git a/interface/lib/classes/simplepie.inc.php b/interface/lib/classes/simplepie.inc.php index a2b80ed25b71755c81e56722f453d85d95207630..64f4d946f9ae58e8a4d358ce0b246264ab7efd16 100644 --- a/interface/lib/classes/simplepie.inc.php +++ b/interface/lib/classes/simplepie.inc.php @@ -13186,8 +13186,8 @@ class SimplePie_Parse_Date */ function __construct() { - $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; - $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; + $this->day_pcre = '(' . implode('|', array_keys($this->day)) . ')'; + $this->month_pcre = '(' . implode('|', array_keys($this->month)) . ')'; static $cache; if (!isset($cache[get_class($this)])) @@ -13338,9 +13338,9 @@ class SimplePie_Parse_Date } // Convert the number of seconds to an integer, taking decimals into account - $second = @round($match[6] + $match[7] / @pow(10, strlen($match[7]))); + $second = @round((int)$match[6] + (int)$match[7] / @pow(10, strlen($match[7]))); - return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; + return gmmktime((int)$match[4], (int)$match[5], (int)$second, (int)$match[2], (int)$match[3], (int)$match[1]) - $timezone; } else { diff --git a/interface/lib/classes/system.inc.php b/interface/lib/classes/system.inc.php index 9cb171cae5d2f230ede4b117bc1b6900625f1d69..c33137d6c1791fc3b9a77344ffed0b0fb3a0e8fa 100644 --- a/interface/lib/classes/system.inc.php +++ b/interface/lib/classes/system.inc.php @@ -33,6 +33,7 @@ class system { var $client_service = null; private $_last_exec_out = null; private $_last_exec_retcode = null; + private $server_count = null; public function has_service($userid, $service) { global $app; diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index cfaf0958d5f5ed39f4d90147501fc871807bec9d..a4624d4af5a928dd57dc374b45bfe601c71371d2 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -276,7 +276,8 @@ class tform_base { unset($tmp_recordid); $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring); - $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); + //$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); + $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', function($matches) {global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;}, $querystring); // Getting the records $tmp_records = $app->db->queryAllRecords($querystring); diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php index 8c7f51b8c7d0dd144b9c384f24813b67ea964231..977ed0901d1d5c0573cc736208d2f05cc339cc00 100644 --- a/interface/lib/classes/tpl.inc.php +++ b/interface/lib/classes/tpl.inc.php @@ -233,7 +233,7 @@ if (!defined('vlibTemplateClassLoaded')) { public function setVar($k, $v = null, $encode = false) { global $app; - + if (is_array($k)) { foreach($k as $key => $value){ $key = ($this->OPTIONS['CASELESS']) ? strtolower(trim($key)) : trim($key); @@ -1079,12 +1079,12 @@ if (!defined('vlibTemplateClassLoaded')) { private function _parseHook ($name) { global $app; - + if(!$name) return false; - + $module = isset($_SESSION['s']['module']['name']) ? $_SESSION['s']['module']['name'] : ''; $form = isset($app->tform->formDef['name']) ? $app->tform->formDef['name'] : ''; - + $events = array(); if($module) { $events[] = $module . ':' . ($form ? $form : '') . ':' . $name; @@ -1093,9 +1093,9 @@ if (!defined('vlibTemplateClassLoaded')) { $events[] = $name; $events[] = 'on_template_content'; } - + $events = array_unique($events); - + for($e = 0; $e < count($events); $e++) { $tmpresult = $app->plugin->raiseEvent($events[$e], array( 'name' => $name, @@ -1104,10 +1104,10 @@ if (!defined('vlibTemplateClassLoaded')) { ), true); if(!$tmpresult) $tmpresult = ''; else $tmpresult = $this->_getData($tmpresult, false, true); - + $result .= $tmpresult; } - + return $result; } @@ -1121,17 +1121,12 @@ if (!defined('vlibTemplateClassLoaded')) { { array_push($this->_namespace, $varname); $tempvar = count($this->_namespace) - 1; - $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < (isset(\$this->_arrvars"; - for ($i=0; $i < count($this->_namespace); $i++) { - $retstr .= "['".$this->_namespace[$i]."']"; - if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; - } - $retstr .= ") ? count(\$this->_arrvars"; + $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < \$this->_tpl_count(\$this->_arrvars"; for ($i=0; $i < count($this->_namespace); $i++) { $retstr .= "['".$this->_namespace[$i]."']"; if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; } - return $retstr.") : 0); \$_".$tempvar."++) {"; + return $retstr."); \$_".$tempvar."++) {"; } /** @@ -1230,7 +1225,7 @@ if (!defined('vlibTemplateClassLoaded')) { $wholetag = $args[0]; $openclose = $args[1]; $tag = strtolower($args[2]); - + if ($tag == 'else') return '<?php } else { ?>'; if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags @@ -1308,10 +1303,10 @@ if (!defined('vlibTemplateClassLoaded')) { if ($this->OPTIONS['ENABLE_PHPINCLUDE']) { return '<?php include(\''.$file.'\'); ?>'; } - + case 'hook': return $this->_parseHook(@$var); - + case 'include': return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; @@ -1466,6 +1461,27 @@ if (!defined('vlibTemplateClassLoaded')) { return $return; } + /** + * Used during in evaled code to replace PHP count function for PHP 8 compatibility + * @var variable to be counted + */ + private function _tpl_count($var) + { + $retvar = 0; + if(isset($var)) { + if(is_array($var)) { + $retvar = count($var); + } elseif(is_null($var)) { + $retvar = 0; + } else { + $retvar = 1; + } + } else { + $retvar = 0; + } + return $retvar; + } + /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following functions have no use and are included just so that if the user is making use of vlibTemplateCache functions, this doesn't crash when changed to diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index a649fef0f7fdfe9a28a1244e257b0ec780732976..50bcad91222b13b1405cd0e85ae336051af1fb0c 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -169,13 +169,13 @@ class dashlet_limits } if ($value != 0 || $value == $wb['unlimited_txt']) { $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; - if ($limit['q_type']!='') { + if (isset($limit['q_type']) && $limit['q_type'] != '') { $usage = $this->_get_assigned_quota($limit) . " MB"; $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB"; } else { $usage = $this->_get_limit_usage($limit); } - $percentage = ($value == '-1' || $value == 0 ? -1 : round(100 * $usage / $value)); + $percentage = ($value == '-1' || intval($value) == 0 || trim($value) == '' ? -1 : round(100 * (int)$usage / (int)$value)); $progressbar = $percentage > 100 ? 100 : $percentage; $rows[] = array('field' => $field, 'field_txt' => $wb[$field.'_txt'], diff --git a/server/lib/classes/cron.inc.php b/server/lib/classes/cron.inc.php index 67be475fe37249d1df27d13c1d7408a72e9ba1e0..2c7f16170c32bb121e0b33280e15a9614712f488 100644 --- a/server/lib/classes/cron.inc.php +++ b/server/lib/classes/cron.inc.php @@ -246,7 +246,7 @@ class cron { $ts = mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear); //print strftime('%d.%m.%Y (%A) %H:%M', $ts) . "\n"; //var_dump($iCurMinute, $iCurHour, $iCurDay, $iCurMonth, $iCurWDay, '--', $iNextMinute, $iNextHour, $iNextDay, $iNextMonth, $iNextWDay); - if(ISPConfigDateTime::last_day($iMonth, $iYear) >= $iDay && in_array($app->functions->intval(strftime('%w', $ts)), $this->_aValidValues['weekday'], true) === true) { + if(ISPConfigDateTime::last_day($iMonth, $iYear) >= $iDay && in_array($app->functions->intval(date('w', $ts)), $this->_aValidValues['weekday'], true) === true) { $bValid = true; } else { if($iYear - $iStartYear > 5) { diff --git a/server/lib/classes/tpl.inc.php b/server/lib/classes/tpl.inc.php index 2af1bf141bfecf360b2bf2585e2f998eacf701d6..a4ba1602529663254b096a91e3151ed6c6d29aec 100644 --- a/server/lib/classes/tpl.inc.php +++ b/server/lib/classes/tpl.inc.php @@ -1074,10 +1074,10 @@ if (!defined('vlibTemplateClassLoaded')) { private function _parseHook ($name) { global $app; - + $namespace = ''; if(strpos($name, ':') !== false) list($namespace, $name) = explode(':', $name, 2); - + $result = $app->plugins->raiseAction('on_template_content_hook', array( 'name' => $name, 'namespace' => $namespace, @@ -1085,7 +1085,7 @@ if (!defined('vlibTemplateClassLoaded')) { ), true); if(!$result) $result = ''; else $result = $this->_getData($result, false, true); - + return $result; } @@ -1099,17 +1099,12 @@ if (!defined('vlibTemplateClassLoaded')) { { array_push($this->_namespace, $varname); $tempvar = count($this->_namespace) - 1; - $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < (isset(\$this->_arrvars"; + $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < \$this->_tpl_count(\$this->_arrvars"; for ($i=0; $i < count($this->_namespace); $i++) { $retstr .= "['".$this->_namespace[$i]."']"; if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; } - $retstr .= ") ? count(\$this->_arrvars"; - for ($i=0; $i < count($this->_namespace); $i++) { - $retstr .= "['".$this->_namespace[$i]."']"; - if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; - } - return $retstr.") : 0); \$_".$tempvar."++) {"; + return $retstr."); \$_".$tempvar."++) {"; } /** @@ -1208,7 +1203,7 @@ if (!defined('vlibTemplateClassLoaded')) { $wholetag = $args[0]; $openclose = $args[1]; $tag = strtolower($args[2]); - + if ($tag == 'else') return '<?php } else { ?>'; if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags @@ -1286,10 +1281,10 @@ if (!defined('vlibTemplateClassLoaded')) { if ($this->OPTIONS['ENABLE_PHPINCLUDE']) { return '<?php include(\''.$file.'\'); ?>'; } - + case 'hook': return $this->_parseHook(@$var); - + case 'include': return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; @@ -1444,6 +1439,27 @@ if (!defined('vlibTemplateClassLoaded')) { return $return; } + /** + * Used during in evaled code to replace PHP count function for PHP 8 compatibility + * @var variable to be counted + */ + private function _tpl_count($var) + { + $retvar = 0; + if(isset($var)) { + if(is_array($var)) { + $retvar = count($var); + } elseif(is_null($var)) { + $retvar = 0; + } else { + $retvar = 1; + } + } else { + $retvar = 0; + } + return $retvar; + } + /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following functions have no use and are included just so that if the user is making use of vlibTemplateCache functions, this doesn't crash when changed to