smart Posted March 1, 2005 Share Posted March 1, 2005 Hi I have uploaded Quick osCommerce administration authentication f files. When I enter user and password does not let me in? I will post code below............ <? class BasicAuthenticator { var $realm = "<private>"; var $message; var $authenticated = -1; var $users; function BasicAuthenticator($realm, $message = "Access Denied") { $this->realm = $realm; $this->message = $message; } function authenticate() { if ($this->isAuthenticated() == 0) { Header("HTTP/1.0 401 Unauthorized"); Header("WWW-Authenticate: Basic realm=\"$this->realm\""); echo $this->message; exit(); } else { Header("HTTP/1.0 200 OK"); } } function addUser($user, $passwd) { $this->users[$user] = $passwd; } function isAuthenticated() { global $PHP_AUTH_USER; global $PHP_AUTH_PW; if ($this->authenticated < 0) { if(isset($PHP_AUTH_USER)) { $this->authenticated = $this->validate($PHP_AUTH_USER, $PHP_AUTH_PW); } else { $this->authenticated = 0; } } return $this->authenticated; } function validate($user, $passwd) { if (strlen(trim($user)) > 0 && strlen(trim($passwd)) > 0) { // Both $user and $password are non-zero length if (isset($this->users[$user]) && $this->users[$user] == $passwd) { return 1; } } return 0; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.