diff --git a/Adapter/AbstractAdapter.php b/Adapter/AbstractAdapter.php index 571e2fb..9db6b2a 100644 --- a/Adapter/AbstractAdapter.php +++ b/Adapter/AbstractAdapter.php @@ -83,7 +83,7 @@ public static function factory($type = 'socket', $proxyConfig = null, $customNam { $obj = null; // Ensure the custom namespace ends with a \ - $customNamespace = rtrim($customNamespace, '\\') .'\\'; + $customNamespace = rtrim($customNamespace ?? '', '\\') .'\\'; if ((strpos($type, '\\') !== false) && class_exists($type)) { $obj = new $type($proxyConfig); } elseif ((strlen($customNamespace) > 1) && class_exists($customNamespace . ucfirst($type))) { diff --git a/Adapter/Socket.php b/Adapter/Socket.php index 02af658..0f49481 100644 --- a/Adapter/Socket.php +++ b/Adapter/Socket.php @@ -238,7 +238,7 @@ private function connectToProxy(array $proxyConfig, array $config) */ private function getProxyList() { - if (!strlen($this->proxyConfig)) { + if (!strlen($this->proxyConfig ?? '')) { return false; } diff --git a/Config/Config.php b/Config/Config.php index 20cdbf4..857cff7 100644 --- a/Config/Config.php +++ b/Config/Config.php @@ -73,7 +73,7 @@ public function __construct($specialWhois = array(), $customIni = null) { if (empty($this->config)) { $this->config = parse_ini_file('whois.ini'); - if (strlen($customIni)) { + if (strlen($customIni ?? '')) { $this->customConfig = parse_ini_file($customIni); } } diff --git a/Parser.php b/Parser.php index cef8ac8..629f145 100644 --- a/Parser.php +++ b/Parser.php @@ -118,7 +118,7 @@ class Parser * @var string * @access protected */ - protected $dateformat = '%Y-%m-%d %H:%M:%S'; + protected $dateformat = 'Y-m-d H:i:s'; /** * Activate cache @@ -272,7 +272,7 @@ private function prepare($query) if ($this->cachePath !== null) { $Parser->setCachePath($this->cachePath); } - $this->Query = $Parser->parse(filter_var($query, FILTER_SANITIZE_STRING)); + $this->Query = $Parser->parse(filter_var($query, FILTER_UNSAFE_RAW)); } } @@ -287,7 +287,7 @@ private function prepare($query) public function call($query = '') { if ($query != '') { - $this->Query = filter_var($query, FILTER_SANITIZE_STRING); + $this->Query = filter_var($query, FILTER_UNSAFE_RAW); } $Config = $this->Config->getCurrent(); @@ -471,7 +471,7 @@ public function getQuery() */ public function setFormat($format = 'object') { - $this->format = filter_var($format, FILTER_SANITIZE_STRING); + $this->format = filter_var($format, FILTER_UNSAFE_RAW); } /** @@ -483,7 +483,7 @@ public function setFormat($format = 'object') * @param string $dateformat * @return void */ - public function setDateFormat($dateformat = '%Y-%m-%d %H:%M:%S') + public function setDateFormat($dateformat = 'Y-m-d H:i:s') { $this->dateformat = $dateformat; } diff --git a/Result/Result.php b/Result/Result.php index a91ec7b..603b3cc 100644 --- a/Result/Result.php +++ b/Result/Result.php @@ -174,7 +174,7 @@ class Result extends AbstractResult /** * Name of the actual template * - * @var string + * @var string[] * @access protected */ public $template; @@ -533,7 +533,7 @@ public function cleanUp($config, $dateformat) /** * Format given dates by date format * - * @param string $dateformat + * @param string $dateformat * @param string $date * @return string */ @@ -548,6 +548,12 @@ private function formatDate($dateformat, $date) $timestamp = strtotime(str_replace('/', '.', $date)); } - return (strlen($timestamp) ? strftime($dateformat, $timestamp) : $date); + if ($timestamp !== false) { + $dt = new \DateTime(); + $dt->setTimestamp($timestamp); + return $dt->format($dateformat); + } + + return $date; } } diff --git a/Templates/Type/AbstractTemplate.php b/Templates/Type/AbstractTemplate.php index 7f53172..491a6b7 100644 --- a/Templates/Type/AbstractTemplate.php +++ b/Templates/Type/AbstractTemplate.php @@ -106,7 +106,7 @@ public static function factory($template, $customNamespace = null) $obj = null; // Ensure the custom namespace ends with a \ - $customNamespace = rtrim($customNamespace, '\\') .'\\'; + $customNamespace = rtrim($customNamespace ?? '', '\\') .'\\'; if ((strpos($template, '\\') !== false) && class_exists($template, $customNamespace)) { $class = $template; $obj = new $class(); diff --git a/composer.json b/composer.json index c76d1e5..9903b02 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ , "author": "Novutec Inc." , "license": "Apache-2.0" , "require": { + "php": ">=7.4.0", "novutec/domainparser": ">=2.0.3" } , "autoload": {