當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PasswordHash::check_password方法代碼示例

本文整理匯總了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');
 }
開發者ID:javascriptit,項目名稱:phpminer,代碼行數:29,代碼來源:AccessControl.class.php

示例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;
     }
 }
開發者ID:kershan,項目名稱:Crysandrea,代碼行數:25,代碼來源:authentication.php


注:本文中的PasswordHash::check_password方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。