本文整理匯總了PHP中AuthManager::getHashingAlgorithm方法的典型用法代碼示例。如果您正苦於以下問題:PHP AuthManager::getHashingAlgorithm方法的具體用法?PHP AuthManager::getHashingAlgorithm怎麽用?PHP AuthManager::getHashingAlgorithm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AuthManager
的用法示例。
在下文中一共展示了AuthManager::getHashingAlgorithm方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkLogin
public function checkLogin($username, $password)
{
$USER_ID = AuthManager::getIdFromUsername($username);
if (!is_null($USER_ID)) {
// if the user exists
$hash = hash(AuthManager::getHashingAlgorithm($USER_ID), $password . AuthManager::getSalt($USER_ID));
$sql = <<<EOD
\tSELECT
\t\t`user_type`
\tFROM
\t\tusers
\tWHERE
\t\tusername='{$username}'
\t\t\tAND
\t\tpassword='{$hash}'
\t\t\tAND
\t\tUSER_ID='{$USER_ID}'
EOD;
// compare the password has against whats in the database
$result = mysql_query($sql);
$count = mysql_num_rows($result);
// If there is only 1 user found
if ($count == 1) {
$row = mysql_fetch_array($result);
// return the user details
return array('count' => $count, 'USER_ID' => $USER_ID, 'user_type' => $row['user_type']);
} else {
// password incorrect or multiple accounts found
return array('count' => 0);
}
} else {
// username not found
return array('count' => 0);
}
}