From dd4cb68b41396d84f61e04dc6e8d7aa7bb5af942 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Thu, 16 Jul 2015 23:29:11 +0200 Subject: [PATCH] Refactor. - $allowed is easier on the eyes. - enabled in_array(, , TRUE) for strict comparision. --- ykval-sync.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ykval-sync.php b/ykval-sync.php index c9f2f2f..060f79d 100644 --- a/ykval-sync.php +++ b/ykval-sync.php @@ -33,6 +33,7 @@ require_once 'ykval-synclib.php'; $apiKey = ''; $ipaddr = $_SERVER['REMOTE_ADDR']; +$allowed = $baseParams['__YKVAL_ALLOWED_SYNC_POOL__']; header('content-type: text/plain'); @@ -58,11 +59,9 @@ if (! $sync->isConnected()) { # $myLog->log(LOG_DEBUG, 'Received request from ' . $ipaddr); -$allowed = in_array($ipaddr, $baseParams['__YKVAL_ALLOWED_SYNC_POOL__']); - -if (!$allowed) { +if (in_array($ipaddr, $allowed, TRUE) === FALSE) { $myLog->log(LOG_NOTICE, 'Operation not allowed from IP ' . $ipaddr); - $myLog->log(LOG_DEBUG, 'Remote IP ' . $ipaddr . ' not listed in allowed sync pool : ' . implode(', ', $baseParams['__YKVAL_ALLOWED_SYNC_POOL__'])); + $myLog->log(LOG_DEBUG, 'Remote IP ' . $ipaddr . ' not listed in allowed sync pool : ' . implode(', ', $allowed)); sendResp(S_OPERATION_NOT_ALLOWED, $myLog, $apiKey); }