当前位置: 首页>>代码示例>>PHP>>正文


PHP PasswordHash类代码示例

本文整理汇总了PHP中PasswordHash的典型用法代码示例。如果您正苦于以下问题:PHP PasswordHash类的具体用法?PHP PasswordHash怎么用?PHP PasswordHash使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PasswordHash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: is_password_protected

 static function is_password_protected()
 {
     global $post;
     $private_post = array('allowed' => false, 'error' => '');
     if (isset($_POST['submit_password'])) {
         // when we have a submision check the password and its submision
         if (isset($_POST['submit_password_nonce']) && wp_verify_nonce($_POST['submit_password_nonce'], 'password_protection')) {
             if (isset($_POST['post_password']) && !empty($_POST['post_password'])) {
                 // some simple checks on password
                 // finally test if the password submitted is correct
                 if ($post->post_password === $_POST['post_password']) {
                     $private_post['allowed'] = true;
                     // ok if we have a correct password we should inform wordpress too
                     // otherwise the mad dog will put the password form again in the_content() and other filters
                     global $wp_hasher;
                     if (empty($wp_hasher)) {
                         require_once ABSPATH . 'wp-includes/class-phpass.php';
                         $wp_hasher = new PasswordHash(8, true);
                     }
                     setcookie('wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword(stripslashes($_POST['post_password'])), 0, COOKIEPATH);
                 } else {
                     $private_post['error'] = '<h4 class="text--error">Wrong Password</h4>';
                 }
             }
         }
     }
     if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && get_permalink() == wp_get_referer()) {
         $private_post['error'] = '<h4 class="text--error">Wrong Password</h4>';
     }
     return $private_post;
 }
开发者ID:qhuit,项目名称:Tournesol,代码行数:31,代码来源:rosa.php

示例2: checkPassword

	/**
	 * Check that the supplied password or key is valid for this user.
	 *
	 * @param string $password The password to verify
	 * @return boolean
	 */
	public function checkPassword($password){
		$hasher = new \PasswordHash(datastore::HASH_ITERATIONS);
		// The password for datastores are stored in the datastore.
		$currentpass = $this->_usermodel->get('password');

		return $hasher->checkPassword($password, $currentpass);
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:13,代码来源:gpg.php

示例3: run

 public function run()
 {
     $tpl = new template();
     $id = (int) $_GET['id'];
     $users = new users();
     $clients = new clients();
     if ($id && $id > 0) {
         $lead = $this->getLead($id);
         $contact = $this->getLeadContact($id);
         $values = array('user' => $contact['email'], 'password' => '', 'firstname' => '', 'lastname' => '', 'phone' => $contact['phone'], 'role' => 3, 'clientId' => $lead['clientId']);
         if (isset($_POST['save'])) {
             if (isset($_POST['user']) && isset($_POST['firstname']) && isset($_POST['lastname'])) {
                 $hasher = new PasswordHash(8, TRUE);
                 $values = array('user' => $_POST['user'], 'password' => $hasher->HashPassword($_POST['password']), 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'phone' => $_POST['phone'], 'role' => $_POST['role'], 'clientId' => $_POST['clientId']);
                 if ($users->usernameExist($values['user']) !== true) {
                     $users->addUser($values);
                     $tpl->setNotification('USER_CREATED', 'success');
                 } else {
                     $tpl->setNotification('USERNAME_EXISTS', 'error');
                 }
             } else {
                 $tpl->setNotification('MISSING_FIELDS', 'error');
             }
         }
         $tpl->assign('values', $values);
         $tpl->assign('clients', $clients->getAll());
         $tpl->assign('roles', $users->getRoles());
         $tpl->display('leads.convertToUser');
     } else {
         $tpl->display('general.error');
     }
 }
开发者ID:DevelopIdeas,项目名称:leantime,代码行数:32,代码来源:class.convertToUser.php

示例4: phpass_check

 function phpass_check($user, $auth)
 {
     $CI =& get_instance();
     $CI->load->library('PasswordHash');
     $hasher = new PasswordHash(HASH_COST_LOG2, HASH_PORTABLE);
     return $hasher->CheckPassword($auth['password'], $user['password']);
 }
开发者ID:kyxer,项目名称:barrioos,代码行数:7,代码来源:password_helper.php

示例5: onAuthenticate

 function onAuthenticate($credentials, $options = null)
 {
     // Check Login
     //------------------------------------------------------------------------------
     $data = ext_find_user($credentials['username'], null);
     // Username not existing
     if ($data === NULL) {
         return false;
     }
     require_once _EXT_PATH . '/libraries/PasswordHash.php';
     $hasher = new PasswordHash(8, FALSE);
     $result = $hasher->CheckPassword($credentials['password'], $data[1]);
     if (!$result) {
         $data = ext_find_user($credentials['username'], $credentials['password']);
         if ($data == NULL) {
             return false;
         }
     }
     // 	Set Login
     $_SESSION['credentials_extplorer']['username'] = $data[0];
     $_SESSION['credentials_extplorer']['password'] = $data[1];
     $_SESSION['file_mode'] = 'extplorer';
     $GLOBALS["home_dir"] = str_replace('\\', '/', $data[2]);
     $GLOBALS["home_url"] = $data[3];
     $GLOBALS["show_hidden"] = $data[4];
     $GLOBALS["no_access"] = $data[5];
     $GLOBALS["permissions"] = $data[6];
     return true;
 }
开发者ID:jramsey08,项目名称:Coldwebs-V2.0,代码行数:29,代码来源:extplorer.php

示例6: _authenticate

 private function _authenticate($queryWhereCondition, $loginStr, $password)
 {
     // query user in Joomla table
     $result = $this->_db->querySelect('user_login,user_email,user_pass', $this->_websoccer->getConfig('wordpresslogin_tableprefix') . 'users', 'user_status = 0 AND ' . $queryWhereCondition, $loginStr);
     $wpUser = $result->fetch_array();
     $result->free();
     // user does not exist
     if (!$wpUser) {
         return FALSE;
     }
     // check password.
     require BASE_FOLDER . '/classes/phpass/PasswordHash.php';
     $hasher = new PasswordHash(8, TRUE);
     if (!$hasher->CheckPassword($password, $wpUser['user_pass'])) {
         return FALSE;
     }
     // valid user, check if he exists
     $userEmail = strtolower($wpUser['user_email']);
     $userId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, $userEmail);
     if ($userId > 0) {
         return $userId;
     }
     // create new user
     return UsersDataService::createLocalUser($this->_websoccer, $this->_db, $wpUser['user_login'], $userEmail);
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:25,代码来源:WordpressUserLoginMethod.class.php

示例7: setHash

 public static function setHash($uid, $password)
 {
     $partHash = self::getPreHash($uid, $password);
     $tHasher = new PasswordHash(self::PASSWORD_HASH_ITERATION_COUNT, FALSE);
     $hash = $tHasher->HashPassword($partHash);
     return $hash;
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:7,代码来源:Credential.php

示例8: authenticate

 public function authenticate()
 {
     $passwordHasher = new PasswordHash(Yii::app()->params['phpass']['iteration_count_log2'], Yii::app()->params['phpass']['portable_hashes']);
     if (null === $this->_user) {
         $this->errorCode = self::ERROR_NOT_FOUND;
     } else {
         if (User::DISABLED === $this->_user->status) {
             $this->errorCode = self::ERROR_DISABLED;
         } else {
             if (null === $this->_user->password_hash) {
                 $this->errorCode = self::ERROR_PASSWORD_NOT_SET;
             } else {
                 if ($passwordHasher->CheckPassword($this->_user->password_hash, $this->_password)) {
                     $this->errorCode = self::ERROR_PASSWORD_INVALID;
                 } else {
                     $this->errorCode = self::ERROR_NONE;
                 }
             }
         }
     }
     if (self::ERROR_NONE !== $this->errorCode) {
         return $this->errorCode;
     }
     $this->setState('isAdmin', $this->_user->is_admin);
     return self::ERROR_NONE;
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:26,代码来源:EmailUserIdentity.php

示例9: install

 function install()
 {
     if ($this->config->is_loaded) {
         die("Oops, there's already a config.php file. You'll need to remove it to run this installer.");
     }
     $password_min_length = 5;
     $password_max_length = 72;
     $form = new \Leeflets\Form($this->config, $this->router, $this->settings, 'install-form', array('elements' => array('credentials' => array('type' => 'fieldset', 'elements' => array('username' => array('type' => 'email', 'placeholder' => 'Email Address', 'class' => 'input-block-level', 'required' => true), 'password1' => array('type' => 'password', 'placeholder' => 'Password', 'class' => 'input-block-level', 'required' => true, 'validation' => array(array('callback' => 'min_length', 'msg' => 'Sorry, your password must be at least ' . $password_min_length . ' characters in length.', 'args' => array($password_min_length)), array('callback' => 'max_length', 'msg' => 'Sorry, your password can be no longer than ' . $password_max_length . ' characters in length.', 'args' => array($password_max_length)))), 'password2' => array('type' => 'password', 'placeholder' => 'Confirm Password', 'class' => 'input-block-level', 'required' => true, 'validation' => array(array('callback' => array($this, 'matching_passwords'), 'msg' => 'Your passwords do not match. Please enter matching passwords.', 'args' => array($_POST['password2'])))))))));
     if (!$this->filesystem->have_direct_access()) {
         $elements['warning'] = array('type' => 'html', 'value' => $this->view->get_partial('ftp-warning'));
         $elements['connection'] = $this->filesystem->get_connection_fields(array($this, '_check_connection'), true);
     }
     $elements['buttons'] = array('type' => 'fieldset', 'elements' => array('submit' => array('type' => 'button', 'button-type' => 'submit', 'class' => 'btn btn-primary', 'value' => 'Install Leeflets')));
     $form->add_elements($elements);
     if ($form->validate()) {
         $hasher = new \PasswordHash(8, false);
         $data = array('username' => $_POST['credentials']['username'], 'password' => $hasher->HashPassword($_POST['credentials']['password1']));
         $this->config->write($this->filesystem, $data);
         $htaccess = new \Leeflets\Htaccess($this->filesystem, $this->router, $this->config);
         $htaccess->write();
         if (isset($_POST['connection']['type'])) {
             $this->settings->save_connection_info($_POST, $this->filesystem);
         }
         \Leeflets\Router::redirect($this->router->admin_url('/user/login/'));
         exit;
     }
     $args = compact('form');
     $args['page-title'] = 'Install';
     $args['layout'] = 'logged-out';
     return $args;
 }
开发者ID:pcbrsites,项目名称:leeflets,代码行数:31,代码来源:setup.php

示例10: register

function register($email, $password, $first, $last)
{
    global $db;
    $db->Prepare('SELECT id FROM `users` WHERE email=\'$0\'');
    $db->Execute($email);
    if ($db->RowCount() > 0) {
        return -1;
    }
    $hasher = new PasswordHash(8, false);
    $password = $hasher->HashPassword($password);
    $firstname = ucfirst($first);
    $lastname = ucfirst($last);
    $db->Prepare("INSERT INTO users (email, password, first_name, last_name, activated) VALUES ('\$0', '\$1', '\$2', '\$3', '\$4')");
    $db->Execute(trim($email), $password, trim($firstname), trim($lastname), 0);
    $db->Prepare("SELECT LAST_INSERT_ID()");
    $db->Execute();
    $id = $db->Fetch();
    $id = implode($id, "");
    $db->Prepare("SELECT UUID()");
    $db->Execute();
    $uuid = $db->Fetch();
    $uuid = str_replace("-", "", implode($uuid, ""));
    $uuid = substr($uuid, 0, 16);
    $db->Prepare("INSERT INTO activation_keys (`key`, user_id) VALUES ('\$0', '\$1')");
    $db->Execute($uuid, $id);
    return $uuid;
}
开发者ID:raphaelchang,项目名称:studybuddy,代码行数:27,代码来源:functions.php

示例11: newFund

function newFund($username, $password, $xml_url, $user_email, $fundName, $numMembers, $stateLaw, $fundAddressCareOf, $fundAddressLevel, $fundAddressStreet, $fundAddressSuburb, $fundAddressState, $fundAddressPostcode, $teeMtgAddressLevel, $teeMtgAddressStreet, $teeMtgAddressSuburb, $teeMtgAddressState, $teeMtgAddressPostcode, $m1MemberNamePrefix, $m1MemberGivenNames, $m1MemberFamilyName, $m1MemberDOB, $m1MemberTFN, $m1AddressLevel, $m1AddressStreet, $m1AddressSuburb, $m1AddressState, $m1AddressPostcode, $m2MemberNamePrefix, $m2MemberGivenNames, $m2MemberFamilyName, $m2MemberDOB, $m2MemberTFN, $m2AddressLevel, $m2AddressStreet, $m2AddressSuburb, $m2AddressState, $m2AddressPostcode, $m3MemberNamePrefix, $m3MemberGivenNames, $m3MemberFamilyName, $m3MemberDOB, $m3MemberTFN, $m3AddressLevel, $m3AddressStreet, $m3AddressSuburb, $m3AddressState, $m3AddressPostcode, $m4MemberNamePrefix, $m4MemberGivenNames, $m4MemberFamilyName, $m4MemberDOB, $m4MemberTFN, $m4AddressLevel, $m4AddressStreet, $m4AddressSuburb, $m4AddressState, $m4AddressPostcode, $t2NonMemberNamePrefix, $t2NonMemberGivenNames, $t2NonMemberFamilyName, $t2NonMemberAddressLevel, $t2NonMemberAddressStreet, $t2NonMemberAddressSuburb, $t2NonMemberAddressState, $t2NonMemberAddressPostcode, $corpTeeName, $corpTeeACN, $corpTeeAddressCareOf, $corpTeeAddressLevel, $corpTeeAddressStreet, $corpTeeAddressSuburb, $corpTeeAddressState, $corpTeeAddressPostcode, $d2NonMemberNamePrefix, $d2NonMemberGivenNames, $d2NonMemberFamilyName, $d2NonMemberAddressLevel, $d2NonMemberAddressStreet, $d2NonMemberAddressSuburb, $d2NonMemberAddressState, $d2NonMemberAddressPostcode, $chairmanTrustee)
{
    $ch = curl_init();
    $timeout = 3600;
    curl_setopt($ch, CURLOPT_URL, $xml_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    //    $response  = curl_getinfo($ch);
    curl_close($ch);
    $xml = simplexml_load_string($data);
    if (!simplexml_load_string($data) && !$xml) {
        global $wpdb;
        $wp_hasher = new PasswordHash(8, TRUE);
        $sql = "SELECT * FROM wp_users  WHERE user_login = '{$username}' ";
        $resultuser = $wpdb->get_results($sql);
        if ($resultuser) {
            foreach ($resultuser as $results) {
                if ($wp_hasher->CheckPassword($password, $results->user_pass)) {
                    $unique = trim(com_create_guid(), '{}');
                    $result = $wpdb->insert('service_nsf', array('unique_code' => $unique, 'user_email' => $user_email, 'fundName' => $fundName, 'numMembers' => $numMembers, 'stateLaw' => $stateLaw, 'fundAddressCareOf' => $fundAddressCareOf, 'fundAddressLevel' => $fundAddressLevel, 'fundAddressStreet' => $fundAddressStreet, 'fundAddressSuburb' => $fundAddressSuburb, 'fundAddressState' => $fundAddressState, 'fundAddressPostcode' => $fundAddressPostcode, 'teeMtgAddressLevel' => $teeMtgAddressLevel, 'teeMtgAddressStreet' => $teeMtgAddressStreet, 'teeMtgAddressSuburb' => $teeMtgAddressSuburb, 'teeMtgAddressState' => $teeMtgAddressState, 'teeMtgAddressPostcode' => $teeMtgAddressPostcode, 'm1MemberNamePrefix' => $m1MemberNamePrefix, 'm1MemberGivenNames' => $m1MemberGivenNames, 'm1MemberFamilyName' => $m1MemberFamilyName, 'm1MemberDOB' => $m1MemberDOB, 'm1MemberTFN' => $m1MemberTFN, 'm1AddressLevel' => $m1AddressLevel, 'm1AddressStreet' => $m1AddressStreet, 'm1AddressSuburb' => $m1AddressSuburb, 'm1AddressState' => $m1AddressState, 'm1AddressPostcode' => $m1AddressPostcode, 'm2MemberNamePrefix' => $m2MemberNamePrefix, 'm2MemberGivenNames' => $m2MemberGivenNames, 'm2MemberFamilyName' => $m2MemberFamilyName, 'm2MemberDOB' => $m2MemberDOB, 'm2MemberTFN' => $m2MemberTFN, 'm2AddressLevel' => $m2AddressLevel, 'm2AddressStreet' => $m2AddressStreet, 'm2AddressSuburb' => $m2AddressSuburb, 'm2AddressState' => $m2AddressState, 'm2AddressPostcode' => $m2AddressPostcode, 'm3MemberNamePrefix' => $m3MemberNamePrefix, 'm3MemberGivenNames' => $m3MemberGivenNames, 'm3MemberFamilyName' => $m3MemberFamilyName, 'm3MemberDOB' => $m3MemberDOB, 'm3MemberTFN' => $m3MemberTFN, 'm3AddressLevel' => $m3AddressLevel, 'm3AddressStreet' => $m3AddressStreet, 'm3AddressSuburb' => $m3AddressSuburb, 'm3AddressState' => $m3AddressState, 'm3AddressPostcode' => $m3AddressPostcode, 'm4MemberNamePrefix' => $m4MemberNamePrefix, 'm4MemberGivenNames' => $m4MemberGivenNames, 'm4MemberFamilyName' => $m4MemberFamilyName, 'm4MemberDOB' => $m4MemberDOB, 'm4MemberTFN' => $m4MemberTFN, 'm4AddressLevel' => $m4AddressLevel, 'm4AddressStreet' => $m4AddressStreet, 'm4AddressSuburb' => $m4AddressSuburb, 'm4AddressState' => $m4AddressState, 'm4AddressPostcode' => $m4AddressPostcode, 't2NonMemberNamePrefix' => $t2NonMemberNamePrefix, 't2NonMemberGivenNames' => $t2NonMemberGivenNames, 't2NonMemberFamilyName' => $t2NonMemberFamilyName, 't2NonMemberAddressLevel' => $t2NonMemberAddressLevel, 't2NonMemberAddressStreet' => $t2NonMemberAddressStreet, 't2NonMemberAddressSuburb' => $t2NonMemberAddressSuburb, 't2NonMemberAddressState' => $t2NonMemberAddressState, 't2NonMemberAddressPostcode' => $t2NonMemberAddressPostcode, 'corpTeeName' => $corpTeeName, 'corpTeeACN' => $corpTeeACN, 'corpTeeAddressCareOf' => $corpTeeAddressCareOf, 'corpTeeAddressLevel' => $corpTeeAddressLevel, 'corpTeeAddressStreet' => $corpTeeAddressStreet, 'corpTeeAddressSuburb' => $corpTeeAddressSuburb, 'corpTeeAddressState' => $corpTeeAddressState, 'corpTeeAddressPostcode' => $corpTeeAddressPostcode, 'd2NonMemberNamePrefix' => $d2NonMemberNamePrefix, 'd2NonMemberGivenNames' => $d2NonMemberGivenNames, 'd2NonMemberFamilyName' => $d2NonMemberFamilyName, 'd2NonMemberAddressLevel' => $d2NonMemberAddressLevel, 'd2NonMemberAddressStreet' => $d2NonMemberAddressStreet, 'd2NonMemberAddressSuburb' => $d2NonMemberAddressSuburb, 'd2NonMemberAddressState' => $d2NonMemberAddressState, 'd2NonMemberAddressPostcode' => $d2NonMemberAddressPostcode, 'chairmanTrustee' => $chairmanTrustee), array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'));
                    return array('unique_code' => $unique);
                } else {
                    return array('username' => 'Invalid username or password1');
                }
            }
        } else {
            return array('username' => 'Invalid username or password2' . $result);
        }
    } else {
        return @nsf_parser($username, $password, $xml_url);
    }
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:34,代码来源:service_nsf.php

示例12: authenticate

 public function authenticate()
 {
     error_log("authenticating", 0);
     $is_authenticated = 0;
     $associatedUserId = -1;
     if (isset($_POST["mac"])) {
         error_log("mac address auth:" . $_POST["mac"], 0);
         $mac = $_POST["mac"];
         $this->load->model("usermodel");
         $associatedUserId = $this->usermodel->getUserIdFromMACAddress($mac);
     }
     if ($associatedUserId > 0) {
         $is_authenticated = 1;
     } else {
         if (isset($_POST['u']) && isset($_POST['p'])) {
             $password = $_POST['p'];
             $this->db->where('user_login', $_POST['u']);
             $query = $this->db->get('wpmember_users');
             $results = $query->result();
             if (count($results) > 0) {
                 $hash = $results[0]->user_pass;
                 require_once MEMBERINCLUDEPATH . '/wp-includes/class-phpass.php';
                 $wp_hasher = new PasswordHash(8, TRUE);
                 $check = $wp_hasher->CheckPassword($password, $hash);
                 $is_authenticated = $check;
                 error_log("authentication" . $check, 0);
             }
         }
     }
     echo $is_authenticated;
 }
开发者ID:ashray-velapanur,项目名称:grind-members,代码行数:31,代码来源:usermanagement.php

示例13: check_login

function check_login($user_id, $password)
{
    session_destroy();
    session_start();
    $wp_host = "127.0.0.1";
    $wp_port = "3306";
    $wp_user = "root";
    $wp_pass = "root";
    $wp_db = "jol";
    $wp_conn = mysql_connect($wp_host . ":" . $wp_port, $wp_user, $wp_pass);
    //$password=HashPassword($password);
    $ret = false;
    $wp_pre = "wp_";
    $sql = "select * from " . $wp_pre . "users where user_login='" . mysql_real_escape_string($user_id) . "'";
    if ($wp_conn) {
        mysql_select_db($wp_db, $wp_conn);
        $result = mysql_query($sql, $wp_conn);
        $row = mysql_fetch_array($result);
        if ($row) {
            $wp_hasher = new PasswordHash(8, TRUE);
            if ($wp_hasher->CheckPassword($password, $row['user_pass'])) {
                $ret = $user_id;
                $sql = "insert into users(user_id,ip,nick,school) values('" . mysql_real_escape_string($user_id) . "','','','') on DUPLICATE KEY UPDATE nick='" . mysql_real_escape_string($user_id) . "'";
                mysql_query($sql);
            }
        }
    }
    return $ret;
}
开发者ID:riverstore,项目名称:hustoj,代码行数:29,代码来源:login-wp.php

示例14: LoginUser

 /**
  * Logs in a user. Returns boolean indicating the result.
  *
  * @param string $userName Username of the person logging in.
  * @param string $password Password in plain text of the person logging in.
  **/
 function LoginUser($userName, $password)
 {
     if ($stmt = $this->dbConnect->prepare("SELECT password FROM usersinfo WHERE username=?")) {
         $stmt->bind_param("s", $userName);
         $stmt->execute();
         $stmt->bind_result($hashedPassword);
         $stmt->fetch();
         $stmt->close();
         $pwdHasher = new PasswordHash(8, FALSE);
         $hashString = $pwdHasher->HashPassword($password);
         // Tests to determine if hashing is the issue with the login problem.
         /*
         	$hashString = $pwdHasher->HashPassword($password);
         	echo "The password entered is " . $password . "<br />";
         	echo "The hashed string is " . $hashString . "<br />";
         	echo "The hashed password to compare against is " . $hashedPassword;
         */
         //if($pwdHasher->CheckPassword($password, $hashedPassword))
         if ($pwdHasher->CheckPassword($hashString, $hashedPassword)) {
         }
         echo $userName;
         $_SESSION['username'] = $userName;
         return true;
     }
     return false;
 }
开发者ID:RandomlyKnighted,项目名称:discourse-analysis,代码行数:32,代码来源:UserModule.php

示例15: login

 public function login($user, $password)
 {
     $userslug = makeSlug($user);
     $tablename = $this->prefix . "users";
     // for once we don't use getUser(), because we need the password.
     $user = $this->db->fetchAssoc("SELECT * FROM {$tablename} WHERE username='{$userslug}'");
     if (empty($user)) {
         $this->session->setFlash('error', 'Username or password not correct. Please check your input.');
         return false;
     }
     require_once __DIR__ . "/phpass/PasswordHash.php";
     $hasher = new PasswordHash(8, TRUE);
     if ($hasher->CheckPassword($password, $user['password'])) {
         if (!$user['enabled']) {
             $this->session->setFlash('error', 'Your account is disabled. Sorry about that.');
             return false;
         }
         $update = array('lastseen' => date('Y-m-d H:i:s'), 'lastip' => $_SERVER['REMOTE_ADDR']);
         $this->db->update($tablename, $update, array('id' => $user['id']));
         $user = $this->getUser($user['id']);
         $this->session->start();
         $this->session->set('user', $user);
         $this->session->setFlash('success', "You've been logged on successfully.");
         return true;
     } else {
         $this->session->setFlash('error', 'Username or password not correct. Please check your input.');
         return false;
     }
 }
开发者ID:LeonB,项目名称:site,代码行数:29,代码来源:users.php


注:本文中的PasswordHash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。