Re: PHP & HTACCESS

From: Date: Thu, 08 Feb 2001 10:15:45 +0000
Subject: Re: PHP & HTACCESS
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38695@lists.php.net to get a copy of this message
> Does anybody know or have some PHP code to read the htaccess file. Off the top of my head: <?php $valid = 0; $path = "/path/to/.htpasswd"; $file = file($path) or die("Could not read $path"); while (list(,$line) = each($file)){ list($username, $password) = explode($line); if ($username == $user && crypt($pass) == $password){ $valid = 1; } } if (!$valid){ header("Location: index.htm"); exit; } ?> You may need to use mcrypt(), and the encryption used by your OS may or may not be available, and your OS may or may not have been configured at some point to use a different encryption, so the passwords in a single .htpasswd might actually be in two different formats... -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#38695) next »