stripUsernameRegexp = $config->get('strip_username_regexp'); } /** * (PHP 5 >= 5.1.0)
* Count elements of an object * @link http://php.net/manual/en/countable.count.php * @return int The custom count as an integer. *

*

* The return value is cast to an integer. */ public function count() { return 1; } /** * Test whether the given user exists * * @param User $user * * @return bool */ public function hasUser(User $user) { if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['AUTH_TYPE']) && in_array($_SERVER['AUTH_TYPE'], array('Basic', 'Digest')) === true ) { $username = filter_var( $_SERVER['PHP_AUTH_USER'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH|FILTER_FLAG_ENCODE_LOW ); if ($username !== false) { if ($this->stripUsernameRegexp !== null) { $username = preg_replace($this->stripUsernameRegexp, '', $username); } return true; } } return false; } /** * Authenticate * * @param User $user * @param string $password * * @return bool */ public function authenticate(User $user, $password) { return $this->hasUser($user); } }