1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-08 03:54:20 +01:00

Refactor.

- $allowed is easier on the eyes.

- enabled in_array(, , TRUE) for strict comparision.
This commit is contained in:
Jean Paul Galea 2015-07-16 23:29:11 +02:00
parent 1d331555c5
commit dd4cb68b41

View File

@ -33,6 +33,7 @@ require_once 'ykval-synclib.php';
$apiKey = ''; $apiKey = '';
$ipaddr = $_SERVER['REMOTE_ADDR']; $ipaddr = $_SERVER['REMOTE_ADDR'];
$allowed = $baseParams['__YKVAL_ALLOWED_SYNC_POOL__'];
header('content-type: text/plain'); header('content-type: text/plain');
@ -58,11 +59,9 @@ if (! $sync->isConnected()) {
# #
$myLog->log(LOG_DEBUG, 'Received request from ' . $ipaddr); $myLog->log(LOG_DEBUG, 'Received request from ' . $ipaddr);
$allowed = in_array($ipaddr, $baseParams['__YKVAL_ALLOWED_SYNC_POOL__']); if (in_array($ipaddr, $allowed, TRUE) === FALSE) {
if (!$allowed) {
$myLog->log(LOG_NOTICE, 'Operation not allowed from IP ' . $ipaddr); $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); sendResp(S_OPERATION_NOT_ALLOWED, $myLog, $apiKey);
} }