您好,欢迎访问一九零五行业门户网

用户口令检查(/etc/passwd)_PHP教程

/*
* etc.passwd.inc v1.0
*
* syntax:
* verifypasswd(string username, string password)
*
* the function will return one of three values:
* -2 if there was a file reading error
* -1 if the password is incorrect
* 0 if the username doesn't exist
* 1 if the password is correct
*/
function verifypasswd ($username, $password) {
$fd = fopen( /etc/passwd, r);
$contents = fread($fd, filesize( /etc/passwd));
fclose($fd);
if (!$contents) return -2;
$lines = split( n, $contents);
$passwd = array();
for($count=0;$countlist ($user,$pass) = split( :,$lines[$count]);
if ($user == $username) {
break;
}
}
if (!$user) return 0;
$cryptedpass = $pass;
$salt = substr($cryptedpass,0,2);
$pass = crypt($password,$salt);
if ($pass == $cryptedpass) {
return 1;
} else {
return -1;
}
}
?>
http://www.bkjia.com/phpjc/629775.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/629775.htmltecharticle? /* * etc.passwd.inc v1.0 * * syntax: * verifypasswd(string username, string password) * * the function will return one of three values: * -2 if there was a file reading error * -...
其它类似信息

推荐信息