diff --git a/NEWS b/NEWS index d790129..9e17cf7 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ * When number of sync servers equals zero, set sync result to success. Patch from arte42.ripe in issue #7. + * When there is only one KSM, use more portable code without async. + Patch from arte42.ripe in issue #7. + * Add files COPYING and AUTHORS. * Version 2.4 released 2010-03-16 diff --git a/ykval-common.php b/ykval-common.php index e794149..76073b9 100644 --- a/ykval-common.php +++ b/ykval-common.php @@ -195,10 +195,25 @@ function retrieveURLasync ($urls, $ans_req=1, $match="^OK", $returl=False) { return $str; } +function retrieveURLsimple ($url, $match="^OK") { + foreach (file($url) as $line) { + if (preg_match("/".$match."/", $line)) { + return $line; + } + } + return false; +} + // $otp: A yubikey OTP function KSMdecryptOTP($urls) { $ret = array(); - $response = retrieveURLasync ($urls); + if (!is_array($urls)) { + $response = retrieveURLsimple ($urls); + } elseif (count($urls) == 1) { + $response = retrieveURLsimple ($urls[0]); + } else { + $response = retrieveURLasync ($urls); + } if ($response) { debug("YK-KSM response: " . $response); }