function getValidServerNonces($specific = false) { $tmp = array(); $timestamp = time(); $timestamp = $timestamp - $timestamp % NONCE_CHANGE; for ($i = 0; $i < (int) NONCE_LIFE; $i += NONCE_CHANGE) { $tmp[$timestamp] = getServerNonce($timestamp); if ($specific !== false && $specific == $tmp[$timestamp]) { return true; break; } $timestamp -= NONCE_CHANGE; } unset($timestamp); return $tmp; }
function getValidServerNonces($specific = false) { $tmp = array(); $timestamp = time(); // count backwards and check each interval for ($i = 0; $i < NONCE_LIFE; $i += NONCE_CHANGE) { $tmp[$timestamp] = getServerNonce($timestamp); if ($specific !== false && hash_equals($tmp[$timestamp], $specific)) { return true; } $timestamp -= NONCE_CHANGE; } unset($timestamp); // return false if asked to validate a specific server nonce if ($specific !== false) { return false; } return $tmp; }