|
|
|
<?
if( !($passwd = @fopen( "passwords", "r" )))
{ echo "Cannot open password file.";
exit;
}
if( !$PHP_AUTH_USER )
{ Header( "WWW-authenticate: basic realm=\"Realm\"" );
Header( "HTTP/1.0 401 Unauthorized" );
echo "Text to see if user hits 'Cancel'";
exit;
}
// file format => username:passwd{\n}
while( $pwent = fgets( $passwd, 100 ))
{ $part = split( ":", ereg_replace( "\n", "", $pwent ));
if( $part[0] != $PHP_AUTH_USER )
continue;
// Username was found - verify passwd
if( $part[1] !=
// The crypt salt is stored as chars 1&2 of passwd
crypt( $PHP_AUTH_PW, substr( $part[1], 0, 2 )))
break;
echo "Hello $PHP_AUTH_USER.<p>\n";
}
// This only has effect of no text was output previously, so
// it is ignored in all cases except authentication error.
@Header( "HTTP/1.0 401 Unauthorized" );
?> |
|
| Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate. Categories : Authentication, PHP | | | Function to remember password Categories : PHP, Authentication, Personalization and Membership | | | PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | Authorize Me! An authentication script. Categories : MySQL, Databases, Authentication, PHP | | | Authentication script to authenticate users in Active Directory through LDAP. Categories : LDAP, Authentication, Cookies, PHP | | | MD5 secured login Categories : PHP, Java Script, Authentication, Security | | | Import the yahoo address book. Categories : PHP, CURL, Authentication | | | Simple and fast user authentication Categories : PHP, PHP Classes, Authentication | | | Is there some possibility to link a database to an htaccess file, so that instead of having a passwd file you would have a database with DES-crypted password and username fields? Categories : Authentication, PHP, General SQL, Databases | | | Authentication HTTP protocol POST Categories : Authentication, HTTP, PHP | | | Full membership authentication system. Categories : Authentication, MySQL, PHP, Databases | | | A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page. Categories : PHP, Sessions, Security, Authentication | | | Implementing a "Members ONLY" area Categories : PHP, MySQL, Databases, Authentication | | | AUTH (.htaccess style) - a login system that uses PostgreSQL. Categories : PHP, Authentication, Databases, PostgreSQL | | | Form Security - Match A Value For Success Categories : PHP, Authentication, HTML and PHP, Sessions, Security | |
|
|
|