From 733b206664d9d921ff9537fe2dbcdee962a97ac5 Mon Sep 17 00:00:00 2001 From: fusionate Date: Fri, 12 May 2023 00:45:09 +0000 Subject: [PATCH] Functions: Updates for PHP 8.1 --- resources/functions.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index bfcec7e1e3..a26fe476cb 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1218,6 +1218,7 @@ function number_pad($number,$n) { //return adjusted color in format received if (isset($hash) && $hash == '#') { //hex + $hex = ''; for ($i = 0; $i <= 2; $i++) { $hex_color = dechex($color[$i]); if (strlen($hex_color) == 1) { $hex_color = '0'.$hex_color; } @@ -2042,16 +2043,21 @@ function number_pad($number,$n) { //validate and format limit and offset clause of select statement if (!function_exists('limit_offset')) { - function limit_offset($limit, $offset = 0) { + function limit_offset($limit = null, $offset = 0) { $regex = '#[^0-9]#'; - $limit = preg_replace($regex, '', $limit); - $offset = preg_replace($regex, '', $offset ?? ''); - if (is_numeric($limit) && $limit > 0) { - $clause = ' limit '.$limit; - $offset = is_numeric($offset) ? $offset : 0; - $clause .= ' offset '.$offset; + if (!empty($limit)) { + $limit = preg_replace($regex, '', $limit); + $offset = preg_replace($regex, '', $offset ?? ''); + if (is_numeric($limit) && $limit > 0) { + $clause = ' limit '.$limit; + $offset = is_numeric($offset) ? $offset : 0; + $clause .= ' offset '.$offset; + } + return $clause.' '; + } + else { + return ''; } - return $clause.' '; } }