当前位置: 首页>>代码示例>>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;未经允许,请勿转载。