From 170714f03311c1fb59ca43b2ff02a4bf41d315dd Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 3 Nov 2019 18:21:02 +0100 Subject: [PATCH] Fix Long2IP issue with PHP7.1 Since PHP7.1, as long2ip expects an int, due to the strict_mode, PHP throws an error. Signed-off-by: Hugues Peccatte --- .../Abs/LongToIPv4TransformationsPlugin.php | 6 +++--- libraries/classes/Util.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libraries/classes/Plugins/Transformations/Abs/LongToIPv4TransformationsPlugin.php b/libraries/classes/Plugins/Transformations/Abs/LongToIPv4TransformationsPlugin.php index 8498d1b7b4..217c46b005 100644 --- a/libraries/classes/Plugins/Transformations/Abs/LongToIPv4TransformationsPlugin.php +++ b/libraries/classes/Plugins/Transformations/Abs/LongToIPv4TransformationsPlugin.php @@ -9,6 +9,7 @@ namespace PhpMyAdmin\Plugins\Transformations\Abs; use PhpMyAdmin\Plugins\TransformationsPlugin; +use PhpMyAdmin\Util; /** * Provides common methods for all of the long to IPv4 transformations plugins. @@ -41,14 +42,13 @@ abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin */ public function applyTransformation($buffer, array $options = array(), $meta = '') { - if ($buffer < 0 || $buffer > 4294967295) { + if (! Util::isInteger($buffer) || $buffer < 0 || $buffer > 4294967295) { return htmlspecialchars($buffer); } - return long2ip($buffer); + return long2ip((int) $buffer); } - /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ /** diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 6461c61812..41f27c9362 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -4741,4 +4741,16 @@ class Util return self::linkOrButton($url, $title . $orderImg, $orderLinkParams); } + + /** + * Check that input is an int or an int in a string + * + * @param mixed $input + * + * @return bool + */ + public static function isInteger($input) + { + return (ctype_digit((string) $input)); + } }