mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Functions: Updates for PHP 8.1
This commit is contained in:
@@ -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.' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user