Skip to content

Commit 0023b22

Browse files
committed
More php 8 fixes.
1 parent c382be2 commit 0023b22

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

interface/lib/classes/validate_datetime.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function _datetime_selected($field_value)
4242
{
4343
if (is_array($field_value) && count($field_value) >= 5)
4444
{
45-
$result = array_filter($field_value, create_function('$dt_unit', 'return ($dt_unit > 0);'));
45+
$result = array_filter($field_value, function($dt_unit) {return ($dt_unit > 0);});
4646
return count($result) !== 0;
4747
}
4848

@@ -86,7 +86,7 @@ function _get_timestamp_value($field_value)
8686
{
8787
if(!is_array($field_value)) return 0;
8888
$second = 0;
89-
$filtered_values = array_map(create_function('$item', 'return (int)$item;'), $field_value);
89+
$filtered_values = array_map(function($item) {return (int)$item;}, $field_value);
9090
extract($filtered_values, EXTR_OVERWRITE);
9191

9292
return mktime($hour, $minute, $second, $month, $day, $year);

interface/web/mailuser/mail_user_autoresponder_edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function onSubmit() {
6464

6565
//* if autoresponder checkbox not selected, do not save dates
6666
if (!isset($_POST['autoresponder']) && array_key_exists('autoresponder_start_date', $_POST)) {
67-
$this->dataRecord['autoresponder_start_date'] = array_map(create_function('$item', 'return 0;'), $this->dataRecord['autoresponder_start_date']);
68-
$this->dataRecord['autoresponder_end_date'] = array_map(create_function('$item', 'return 0;'), $this->dataRecord['autoresponder_end_date']);
67+
$this->dataRecord['autoresponder_start_date'] = array_map(function($item) { return 0;}), $this->dataRecord['autoresponder_start_date']);
68+
$this->dataRecord['autoresponder_end_date'] = array_map(function($item) { return 0;}), $this->dataRecord['autoresponder_end_date']);
6969

7070
/* To be used when we go to PHP 7.x as min PHP version
7171
$this->dataRecord['autoresponder_start_date'] = array_map( function ('$item') { 'return 0;' }, $this->dataRecord['autoresponder_start_date']);

server/lib/classes/cron.d/100-monitor_cpu.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function onRunJob() {
7878

7979
$part = preg_split('/:/', $line);
8080
$key = trim($part[0]);
81-
$value = trim($part[1]);
81+
$value = (isset($part[1]))?trim($part[1]):'';
8282
if ($key == 'processor')
8383
$processor = intval($value);
8484
if ($key != '')

server/lib/classes/cron.d/100-monitor_disk_usage.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function onRunJob() {
8383
* ignore the first line, process the rest
8484
*/
8585
for ($i = 1; $i <= sizeof($df); $i++) {
86-
if ($df[$i] != '') {
86+
if (isset($df[$i]) && $df[$i] != '') {
8787
/*
8888
* Make an array of the data
8989
*/

server/lib/classes/cron.d/100-monitor_hd_quota.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function onRunJob() {
7878

7979
//* ignore the first 5 lines, process the rest
8080
for ($i = 5; $i <= sizeof($df); $i++) {
81-
if ($df[$i] != '') {
81+
if (isset($df[$i]) && $df[$i] != '') {
8282
//* Make a array of the data
8383
$s = preg_split('/[\s]+/', $df[$i]);
8484
$username = $s[0];
@@ -106,7 +106,7 @@ public function onRunJob() {
106106

107107
//* ignore the first 5 lines, process the rest
108108
for ($i = 5; $i <= sizeof($df); $i++) {
109-
if ($df[$i] != '') {
109+
if (isset($df[$i]) && $df[$i] != '') {
110110
//* Make a array of the data
111111
$s = preg_split('/[\s]+/', $df[$i]);
112112
$groupname = $s[0];

server/lib/classes/cron.d/100-monitor_mail_queue.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function onRunJob() {
8989
$tmp = explode("\n", $data['output']);
9090
$more = $tmp[sizeof($tmp) - 1];
9191
$res = $this->_getIntArray($more);
92-
$data['bytes'] = $res[0];
93-
$data['requests'] = $res[1];
92+
$data['bytes'] = (isset($res[0]))?$res[0]:0;
93+
$data['requests'] = (isset($res[1]))?$res[1]:0;
9494

9595
/** The state of the mailq. */
9696
$state = 'ok';

server/lib/classes/cron.d/100-monitor_mem_usage.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function onRunJob() {
7878
$key = trim($part[0]);
7979
$tmp = explode(' ', trim($part[1]));
8080
$value = 0;
81-
if ($tmp[1] == 'kB')
81+
if (isset($tmp[1]) && $tmp[1] == 'kB')
8282
$value = $tmp[0] * 1024;
8383
$data[$key] = $value;
8484
}

server/lib/classes/libdatetime.inc.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static function to_timestamp($date) {
152152
* - onlytime: HH:MM
153153
* - rss: Rss time format for XML
154154
* - nice: if you prepend a nice: (like nice:long) you will get results like "today" or "yesterday" if applicable
155-
* - custom: you can give a strftime format like %d.%m.%Y %H:%M if you prepend custom: to it
155+
* - custom: you can give a php date function format like d.m.Y H:i if you prepend custom: to it
156156
* @param bool $time if true apped the time to the date string
157157
* @param bool $seconds if true append the seconds to the time
158158
* @return string date string
@@ -174,15 +174,15 @@ public static function to_string($date, $format = 'short', $time = false, $secon
174174
$fmt = '';
175175
$prepend = '';
176176
if(substr($format, 0, 5) == 'nice:') {
177-
if(strftime('%d.%m.%Y', $date) == strftime('%d.%m.%Y', $portal->getTime())) {
177+
if(date('d.m.Y', $date) == date('d.m.Y', $portal->getTime())) {
178178
if($time == true) $format = 'onlytime';
179179
else $format = '';
180180
$prepend = 'Heute';
181-
} elseif(strftime('%d.%m.%Y', $date) == strftime('%d.%m.%Y', $portal->getTime() - 86400)) {
181+
} elseif(date('d.m.Y', $date) == date('d.m.Y', $portal->getTime() - 86400)) {
182182
if($time == true) $format = 'onlytime';
183183
else $format = '';
184184
$prepend = 'Gestern';
185-
} elseif(strftime('%d.%m.%Y', $date) == strftime('%d.%m.%Y', $portal->getTime() + 86400)) {
185+
} elseif(date('d.m.Y', $date) == date('d.m.Y', $portal->getTime() + 86400)) {
186186
if($time == true) $format = 'onlytime';
187187
else $format = '';
188188
$prepend = 'Morgen';
@@ -195,21 +195,21 @@ public static function to_string($date, $format = 'short', $time = false, $secon
195195
$time = false;
196196
}
197197

198-
if($format == 'short') $fmt = '%d.%m.%y';
199-
elseif($format == 'veryshort') $fmt = '%d.%m.';
200-
elseif($format == 'medium') $fmt = '%d.%m.%Y';
201-
elseif($format == 'long') $fmt = '%d. %B %Y';
202-
elseif($format == 'extra') $fmt = '%A, %d. %B %Y';
203-
elseif($format == 'day') $fmt = '%d';
204-
elseif($format == 'monthnum') $fmt = '%m';
205-
elseif($format == 'shortmonth') $fmt = '%b';
206-
elseif($format == 'month') $fmt = '%B';
207-
elseif($format == 'shortyear') $fmt = '%y';
208-
elseif($format == 'year') $fmt = '%Y';
209-
elseif($format == 'onlydate') $fmt = '%d.%m.';
210-
elseif($format == 'onlydatelong') $fmt = '%d. %B';
198+
if($format == 'short') $fmt = 'd.m.y';
199+
elseif($format == 'veryshort') $fmt = 'd.m.';
200+
elseif($format == 'medium') $fmt = 'd.m.Y';
201+
elseif($format == 'long') $fmt = 'd. B Y';
202+
elseif($format == 'extra') $fmt = 'A, d. B Y';
203+
elseif($format == 'day') $fmt = 'd';
204+
elseif($format == 'monthnum') $fmt = 'm';
205+
elseif($format == 'shortmonth') $fmt = 'b';
206+
elseif($format == 'month') $fmt = 'B';
207+
elseif($format == 'shortyear') $fmt = 'y';
208+
elseif($format == 'year') $fmt = 'Y';
209+
elseif($format == 'onlydate') $fmt = 'd.m.';
210+
elseif($format == 'onlydatelong') $fmt = 'd. B';
211211
elseif($format == 'onlytime') {
212-
$fmt = '%H:%M';
212+
$fmt = 'H:i';
213213
$time = false;
214214
} elseif($format == 'rss') {
215215
$ret = date(DATE_RSS, $date);
@@ -220,9 +220,9 @@ public static function to_string($date, $format = 'short', $time = false, $secon
220220
if($prepend != '') $ret = $prepend . ' ' . $ret;
221221
return $ret;
222222
}
223-
if($time == true) $fmt .= ' %H:%M' . ($seconds == true ? ':%S' : '');
223+
if($time == true) $fmt .= ' H:i' . ($seconds == true ? ':s' : '');
224224

225-
if($fmt != '') $ret = strftime($fmt, $date);
225+
if($fmt != '') $ret = date($fmt, $date);
226226
else $ret = '';
227227

228228
if($prepend != '') $ret = trim($prepend . ' ' . $ret);
@@ -249,10 +249,10 @@ public static function to_string($date, $format = 'short', $time = false, $secon
249249
* @return mixed either int (months) or array of int (0 => years, 1 => months) or FALSE on invalid dates
250250
*/
251251
public static function months_between($date_from, $date_to, $return_years = false, $include_both = false) {
252-
$date_from = self::to_string($date_from, 'custom:%Y%m');
252+
$date_from = self::to_string($date_from, 'custom:Ym');
253253
if($date_from === false) return $date_from;
254254

255-
$date_to = self::to_string($date_to, 'custom:%Y%m');
255+
$date_to = self::to_string($date_to, 'custom:Ym');
256256
if($date_to === false) return $date_to;
257257

258258
$date_from = intval($date_from);
@@ -294,12 +294,12 @@ public static function months_between($date_from, $date_to, $return_years = fals
294294
* @return mixed either int (days) or FALSE on invalid dates
295295
*/
296296
public static function days_between($date_from, $date_to, $include_both = false) {
297-
$date_from = self::to_string($date_from, 'custom:%Y-%m-%d');
297+
$date_from = self::to_string($date_from, 'custom:Y-m-d');
298298
if($date_from === false) return $date_from;
299299
list($y, $m, $d) = explode('-', $date_from);
300300
$ts_from = mktime(0, 0, 0, $m, $d, $y);
301301

302-
$date_to = self::to_string($date_to, 'custom:%Y-%m-%d');
302+
$date_to = self::to_string($date_to, 'custom:Y-m-d');
303303
if($date_to === false) return $date_to;
304304
list($y, $m, $d) = explode('-', $date_to);
305305
$ts_to = mktime(0, 0, 0, $m, $d, $y);
@@ -364,7 +364,7 @@ public static function sql_date($date = false, $no_time = false) {
364364
if($date === false) $date = $portal->getTime(true);
365365

366366
if(is_numeric($date)) {
367-
return $no_time ? strftime('%Y-%m-%d', $date) : strftime('%Y-%m-%d %H:%M:%S', $date);
367+
return $no_time ? date('Y-m-d', $date) : date('Y-m-d H:i:s', $date);
368368
}
369369

370370
if(preg_match('/^(.*)(\d{1,2}:\d{1,2}(:\d{1,2})?)(\D|$)/', $date, $matches)) {
@@ -473,7 +473,7 @@ public static function calc_age($date) {
473473
if($date === false) return $date;
474474

475475
list($year, $month, $day) = explode('-', $date);
476-
list($curyear, $curmonth, $curday) = explode('-', strftime('%Y-%m-%d', $portal->getTime()));
476+
list($curyear, $curmonth, $curday) = explode('-', date('Y-m-d', $portal->getTime()));
477477

478478
$year_diff = $curyear - $year;
479479
$month_diff = $curmonth - $month;

0 commit comments

Comments
 (0)