本文整理汇总了PHP中PasswordHash::check_password方法的典型用法代码示例。如果您正苦于以下问题:PHP PasswordHash::check_password方法的具体用法?PHP PasswordHash::check_password怎么用?PHP PasswordHash::check_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PasswordHash
的用法示例。
在下文中一共展示了PasswordHash::check_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_login
/**
* Returns wether the user is logged in or not.
*
* @return boolean
* True if logged in, else false.
*/
public function check_login()
{
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$pw_hash = new PasswordHash();
if ($this->access_config->user_exists($_SERVER['PHP_AUTH_USER'])) {
$user = $this->access_config->user_get($_SERVER['PHP_AUTH_USER']);
if ($pw_hash->check_password($_SERVER['PHP_AUTH_PW'], $user['password'])) {
self::$session->set('username', $_SERVER['PHP_AUTH_USER']);
// This is for now the only position where we write, so we can close the session for write operations.
// This will speed up the performance.
self::$session->close_write();
$this->user = $this->get_config()->user_get(self::$session->get('username'));
return true;
}
}
}
if (self::$session->get('username') != 0) {
$this->user = $this->get_config()->user_get(self::$session->get('username'));
return true;
}
header('WWW-Authenticate: Basic realm="PHPMiner "');
header('HTTP/1.0 401 Unauthorized');
}
示例2: PasswordHash
/**
* New page
*
* New page description
*
* @access public
* @param none
* @return redirect
* @route n/a
*/
function verify_password($password, $user_id)
{
$query = $this->CI->db->where(array('user_id' => $user_id))->get($this->user_table);
if ($query->num_rows() > 0) {
$user_data = $query->row_array();
$hasher = new PasswordHash();
if ($hasher->check_password($password, $user_data['user_pass'])) {
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}