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


PHP validate_password函數代碼示例

本文整理匯總了PHP中validate_password函數的典型用法代碼示例。如果您正苦於以下問題:PHP validate_password函數的具體用法?PHP validate_password怎麽用?PHP validate_password使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了validate_password函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: login

function login($username, $passwd)
{
    global $db_link;
    // check if username is unique
    $result = wrap_db_query("SELECT user_id, passwd FROM " . BOOKING_USER_TABLE . " \r\n\t\t\t\t\t\tWHERE username = '" . wrap_db_escape_string($username) . "'");
    if (!$result) {
        return false;
    }
    $fields = wrap_db_fetch_array($result);
    # check to see if username was found
    # also to prevent username = "" sql default
    if (empty($fields)) {
        return false;
    }
    # check for admin login, passwd = NULL
    if ($passwd == "" && $result && $fields[1] == NULL) {
        $passwd = NULL;
    }
    //echo "username: $username<br />";
    //echo "password: $passwd<br />";
    //echo "db field: ".$fields['passwd']."<br />";
    if ($fields['passwd'] == NULL) {
        echo "NULL db passwd<br />";
    }
    if (validate_password($passwd, $fields['passwd'])) {
        return true;
    }
    return false;
}
開發者ID:dev-lav,項目名稱:htdocs,代碼行數:29,代碼來源:user_auth_fns.php

示例2: index

 public function index()
 {
     checkIE();
     if (IS_POST) {
         $username = I('username', null);
         $password = I('password', null);
         $code = I('code', null);
         $check_verify = $this->_check_verify($code);
         if ($check_verify) {
             $user = D('Member')->getUsersByUsername($username);
             $auth_success = false;
             if ($user) {
                 $auth_success = validate_password($password, $user[0]['salted_hash']);
             }
             if ($auth_success) {
                 $result['code'] = self::SUCCESS_CODE;
                 session('username', $user[0]['username']);
                 session('uid', $user[0]['uid']);
                 session('email', $user[0]['email']);
                 session('groupid', $user[0]['groupid']);
                 session('gender', $user[0]['gender']);
                 session('avatar', $user[0]['avatar']);
             } else {
                 $result['code'] = self::AUTH_FAILED_CODE;
                 $result['error'] = self::AUTH_FAILED_TIP;
             }
         } else {
             $result['code'] = self::VERIFY_FAILED_CODE;
             $result['error'] = self::VERIFY_FAILED_TIP;
         }
         $this->ajaxReturn($result);
     }
     $this->display();
 }
開發者ID:imdaqian,項目名稱:SCAP,代碼行數:34,代碼來源:LoginController.class.php

示例3: login

function login($dirty_email, $dirty_password)
{
    $email = escape($dirty_email);
    $password = escape($dirty_password);
    if (!validate_email($email)) {
        echo "login-invalid-email";
        return;
    }
    if (!validate_password($password)) {
        echo "login-invalid-password";
        return;
    }
    $account_id = account_id_from_email($email);
    if ($account_id == -1) {
        echo "DEBUG: email or password invalid";
        return;
    }
    if (correct_password($account_id, $password) == false) {
        echo "DEBUG: email or password invalid";
        return;
    }
    session_regenerate_id();
    fresh_logon($account_id);
    $username = username_from_account_id($account_id);
    setcookie('LOGGED_IN', $username, time() + 3600);
    echo "login-success";
}
開發者ID:andrewdownie,項目名稱:projectportfolio.io,代碼行數:27,代碼來源:auth.php

示例4: login

function login($username, $passwd)
{
    // check if username is unique
    $result = wrap_db_query("SELECT user_id, passwd FROM " . BOOKING_USER_TABLE . "\n\t\t\t\t\t\tWHERE username = '" . $username . "' AND login_enabled = '1'");
    if (!$result) {
        return false;
    }
    $fields = wrap_db_fetch_array($result);
    # check to see if username was found
    # also to prevent username = "" sql default
    if ($fields[0] == "") {
        return false;
    }
    # check for admin login, passwd = NULL
    if ($passwd == "" && $result && $fields[1] == NULL) {
        $passwd = NULL;
    }
    #echo "username: $username<br />";
    #echo "password: $passwd<br />";
    #echo "db field: $fields[1]<br />";
    #if ($fields[1] == NULL) { echo "NULL db passwd<br />"; }
    if (validate_password($passwd, $fields[1])) {
        return true;
    }
    return false;
}
開發者ID:haganbt,項目名稱:N27-Booking,代碼行數:26,代碼來源:user_auth_fns.php

示例5: authenticate

 public static function authenticate($ps_username, $ps_password = '', $pa_options = null)
 {
     $t_user = new ca_users();
     $t_user->load($ps_username);
     if ($t_user->getPrimaryKey() > 0) {
         $vs_hash = $t_user->get('password');
         if (preg_match('/^[a-f0-9]{32}$/', $vs_hash)) {
             // old-style md5 passwords
             //throw new CaUsersException(_t('The stored password for this user seems to be in legacy format. Please update the user account by resetting the password.'));
             if (md5($ps_password) == $vs_hash) {
                 // if the md5 hash matches, authenticate successfully and move the user over to pbkdf2 key
                 $t_user->setMode(ACCESS_WRITE);
                 // ca_users::update takes care of the hashing by calling AuthenticationManager::updatePassword()
                 $t_user->set('password', $ps_password);
                 $t_user->update();
                 return true;
             } else {
                 return false;
             }
         }
         return validate_password($ps_password, $vs_hash);
     } else {
         return false;
     }
 }
開發者ID:kai-iak,項目名稱:pawtucket2,代碼行數:25,代碼來源:CaUsers.php

示例6: checkUser

function checkUser($userName, $password)
{
    if (!isset($userName) && !isset($password)) {
        return false;
    }
    include '../../includes/database.php';
    // Retrieve username and password from database according to user's input
    $stmt = $db->prepare("SELECT * FROM " . "users" . " WHERE (`Email` = :Email)");
    $resul = $stmt->execute(array(':Email' => $userName));
    $result = $stmt->fetch();
    $num_rows = $stmt->rowCount();
    // Check username and password match
    //echo $num_rows > 0 &&validate_password($password,$result['password'])?"pasword is real...\n":"not the right pass?\n";
    if ($num_rows > 0 && validate_password($password, $result['password'])) {
        // Set username session variable
        $_SESSION['Email'] = $userName;
        $_SESSION['loggedin'] = true;
        $_SESSION['FName'] = $result['FName'];
        $_SESSION['LName'] = $result['LName'];
        $_SESSION['Index'] = $result['Index'];
        $_SESSION['verified'] = @$result['verified'];
        return true;
    } else {
        return false;
    }
}
開發者ID:nperez0111,項目名稱:Pizza,代碼行數:26,代碼來源:login.php

示例7: elgg_set_user_password

/**
 * Set a user's password
 * 
 * @return bool
 * @since 1.8.0
 * @access private
 */
function elgg_set_user_password()
{
    $current_password = get_input('current_password', null, false);
    $password = get_input('password', null, false);
    $password2 = get_input('password2', null, false);
    $user_guid = get_input('guid');
    if (!$user_guid) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_guid);
    }
    if ($user && $password) {
        // let admin user change anyone's password without knowing it except his own.
        if (!elgg_is_admin_logged_in() || elgg_is_admin_logged_in() && $user->guid == elgg_get_logged_in_user_guid()) {
            $credentials = array('username' => $user->username, 'password' => $current_password);
            try {
                pam_auth_userpass($credentials);
            } catch (LoginException $e) {
                register_error(elgg_echo('LoginException:ChangePasswordFailure'));
                return false;
            }
        }
        try {
            $result = validate_password($password);
        } catch (RegistrationException $e) {
            register_error($e->getMessage());
            return false;
        }
        if ($result) {
            if ($password == $password2) {
                $user->salt = _elgg_generate_password_salt();
                $user->password = generate_user_password($user, $password);
                $user->code = '';
                if ($user->guid == elgg_get_logged_in_user_guid() && !empty($_COOKIE['elggperm'])) {
                    // regenerate remember me code so no other user could
                    // use it to authenticate later
                    $code = _elgg_generate_remember_me_token();
                    $_SESSION['code'] = $code;
                    $user->code = md5($code);
                    setcookie("elggperm", $code, time() + 86400 * 30, "/");
                }
                if ($user->save()) {
                    system_message(elgg_echo('user:password:success'));
                    return true;
                } else {
                    register_error(elgg_echo('user:password:fail'));
                }
            } else {
                register_error(elgg_echo('user:password:fail:notsame'));
            }
        } else {
            register_error(elgg_echo('user:password:fail:tooshort'));
        }
    } else {
        // no change
        return null;
    }
    return false;
}
開發者ID:elainenaomi,項目名稱:labxp2014,代碼行數:66,代碼來源:user_settings.php

示例8: validate

/** Tarkasta sisaankirjautumislomake
 * @param $email string
 * @param $password string
 * @return boolean
 */
function validate($email, $password)
{
    if (validate_email($email) && validate_password($password)) {
        return true;
    } else {
        return false;
    }
}
開發者ID:vilsu,項目名稱:codes,代碼行數:13,代碼來源:receive_login_form.php

示例9: getCredentials

 /**
  *
  * @param string $username
  * @param string $password
  * @return Users 
  */
 public function getCredentials($username, $password)
 {
     $query = Doctrine_Query::create()->from('SystemUser')->where('user_name = ?', $username)->andWhere('deleted = 0');
     $user = $query->fetchOne();
     if (validate_password($password, $user->get('user_password'))) {
         return $user;
     }
     return null;
 }
開發者ID:THM068,項目名稱:orangehrm,代碼行數:15,代碼來源:AuthenticationDao.php

示例10: login

 public function login($username, $password)
 {
     $stmt = $this->dbh->prepare('SELECT * FROM accounts WHERE username = ?');
     $stmt->bindParam(1, $username);
     $stmt->execute();
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     if (validate_password($password, $row['password'])) {
         return $row;
     }
     return '';
 }
開發者ID:x86asm,項目名稱:ws1,代碼行數:11,代碼來源:DB.php

示例11: validate_credentials

function validate_credentials($form)
{
    $errors = [];
    $userNameValid = validate_username($form);
    if (!$userNameValid) {
        $errors["validation.userName"] = "User name is required and should be an email address";
    }
    $passwordValid = validate_password($form);
    if (!$passwordValid) {
        $errors["validation.password"] = "Password is required and should have at least 4 characters";
    }
    return $errors;
}
開發者ID:lihaoxiang1989,項目名稱:Marlabs-notes,代碼行數:13,代碼來源:auth_service.php

示例12: verifyPassword

/**
 * check if password entered matches DB
 * @param string $url 
 * @param string $pwd 
 * @return boolean true, if password matches
 * @return error message if exception catched during PDO
 */
function verifyPassword($url, $password, $pdo)
{
    try {
        require 'password_hash.php';
        $stmt = $pdo->prepare("SELECT pwdView from note where id = :url");
        $stmt->bindValue(':url', $url, PDO::PARAM_STR);
        $stmt->execute();
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        return validate_password($password, $result['pwdView']);
    } catch (PDOException $e) {
        throw $e;
    }
}
開發者ID:gmolveau,項目名稱:minote,代碼行數:20,代碼來源:model_note_view.php

示例13: index

 public function index()
 {
     $this->load->helper('pbkdf2_helper');
     $pass = create_hash('usr#6379');
     echo $pass;
     echo "<p>" . strlen($pass) . "</p>";
     echo "<p>result:</p>";
     if (validate_password('usr#6379', $pass) == true) {
         echo "validation passed";
     } else {
         echo "didn't pass!";
     }
 }
開發者ID:emnik,項目名稱:tuitioninfo,代碼行數:13,代碼來源:test.php

示例14: elgg_set_user_password

/**
 * Set a user's password
 * 
 * @return bool
 * @since 1.8.0
 * @access private
 */
function elgg_set_user_password()
{
    $current_password = get_input('current_password');
    $password = get_input('password');
    $password2 = get_input('password2');
    $user_guid = get_input('guid');
    if (!$user_guid) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_guid);
    }
    if ($user && $password) {
        // let admin user change anyone's password without knowing it except his own.
        if (!elgg_is_admin_logged_in() || elgg_is_admin_logged_in() && $user->guid == elgg_get_logged_in_user_guid()) {
            $credentials = array('username' => $user->username, 'password' => $current_password);
            try {
                pam_auth_userpass($credentials);
            } catch (LoginException $e) {
                register_error(elgg_echo('LoginException:ChangePasswordFailure'));
                return false;
            }
        }
        try {
            $result = validate_password($password);
        } catch (RegistrationException $e) {
            register_error($e->getMessage());
            return false;
        }
        if ($result) {
            if ($password == $password2) {
                $user->salt = generate_random_cleartext_password();
                // Reset the salt
                $user->password = generate_user_password($user, $password);
                if ($user->save()) {
                    system_message(elgg_echo('user:password:success'));
                    return true;
                } else {
                    register_error(elgg_echo('user:password:fail'));
                }
            } else {
                register_error(elgg_echo('user:password:fail:notsame'));
            }
        } else {
            register_error(elgg_echo('user:password:fail:tooshort'));
        }
    } else {
        // no change
        return null;
    }
    return false;
}
開發者ID:nachopavon,項目名稱:Elgg,代碼行數:58,代碼來源:user_settings.php

示例15: verify_account

function verify_account($dirty_username, $dirty_password, $dirty_activation_code)
{
    $username = escape($dirty_username);
    $password = escape($dirty_password);
    $code = escape($dirty_activation_code);
    $validateUsrMsg = validate_username($username);
    if ($validateUsrMsg != "valid-username") {
        return;
    }
    $validatePwdMsg = validate_password($password);
    if ($validatePwdMsg != "valid-password") {
        return;
    }
    $account_id = account_id_from_code($code);
    $sql1 = "SELECT * FROM account_signup WHERE code='{$code}'";
    $result = query($sql1);
    if (mysqli_num_rows($result) == 1) {
        $row = mysqli_fetch_assoc($result);
        $date_requested = $row["date_requested"];
        $expires = $date_requested + 86400;
        if (time() > $expires) {
            echo "validation-expired";
            return;
        }
        $encrypted_password = encrypt_password($password);
        $sql2 = "UPDATE account_head SET status='logged-out' WHERE account={$account_id};";
        query($sql2);
        if (user_has_status($account_id, 'logged-out') == false) {
            echo 'verify-error';
            return;
        }
        $sql3 = "INSERT INTO account_credentials (account, username, password)";
        $sql3 .= " VALUES ({$account_id}, '{$username}', '{$encrypted_password}');";
        query($sql3);
        if (user_has_credentials($account_id, $username, $encrypted_password) == false) {
            echo 'verify-error';
            return;
        }
        $sql4 = "DELETE FROM account_signup WHERE account={$account_id};";
        query($sql4);
        if (user_has_signup_pending($account_id)) {
            echo 'verify-error';
            return;
        }
        echo "verify-success";
        return;
    }
    echo 'verify-error';
}
開發者ID:andrewdownie,項目名稱:projectportfolio.io,代碼行數:49,代碼來源:verify_account.php


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