本文整理汇总了PHP中password_check函数的典型用法代码示例。如果您正苦于以下问题:PHP password_check函数的具体用法?PHP password_check怎么用?PHP password_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了password_check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ok_f
public function ok_f()
{
$_back = $this->get("_back");
if (!$_back) {
$_back = $this->url;
$error_url = $this->url('login');
} else {
$error_url = $this->url('login', '', '_back=' . rawurlencode($_back));
}
if ($_SESSION["user_id"]) {
error(P_Lang('您已是本站会员,不需要再次登录'), $_back);
}
if ($this->config['is_vcode'] && function_exists('imagecreate')) {
$code = $this->get('_chkcode');
if (!$code) {
error(P_Lang('验证码不能为空'), $error_url, 'error');
}
$code = md5(strtolower($code));
if ($code != $_SESSION['vcode']) {
error(P_Lang('验证码填写不正确'), $error_url, 'error');
}
unset($_SESSION['vcode']);
}
//获取登录信息
$user = $this->get("user");
if (!$user) {
error(P_Lang('账号不能为空'), $error_url, 'error');
}
$pass = $this->get("pass");
if (!$pass) {
error(P_Lang('会员密码不能为空'), $error_url, 'error');
}
//多种登录方式
$user_rs = $this->model('user')->get_one($user, 'user');
if (!$user_rs) {
$user_rs = $this->model('user')->get_one($user, 'email');
if (!$user_rs) {
$user_rs = $this->model('user')->get_one($user, 'mobile');
if (!$user_rs) {
error(P_Lang('会员信息不存在'), $error_url, 'error');
}
}
}
if (!$user_rs['status']) {
error(P_Lang('会员审核中,暂时不能登录'), $error_url, 'error');
}
if ($user_rs['status'] == '2') {
error(P_Lang('会员被管理员锁定,请联系管理员解锁'), $error_url, 'error');
}
if (!password_check($pass, $user_rs["pass"])) {
error(P_Lang('登录密码不正确'), $error_url, 'error');
}
$_SESSION["user_id"] = $user_rs['id'];
$_SESSION["user_gid"] = $user_rs['group_id'];
$_SESSION["user_name"] = $user_rs["user"];
error(P_Lang('会员登录成功'), $_back, 'ok');
}
示例2: check_f
function check_f()
{
if ($_SESSION['admin_id']) {
$this->json(P_Lang('您已成功登录,无需再次验证'));
}
$user = $this->get('user');
if (!$user) {
$this->json(P_Lang('管理员账号不能为空'));
}
$pass = $this->get('pass');
if (!$pass) {
$this->json(P_Lang('密码不能为空'));
}
//验证码检测
if ($this->config['is_vcode'] && function_exists('imagecreate')) {
$code = $this->get("_code");
if (!$code) {
$this->json(P_Lang('验证码不能为空'));
}
$code = md5(strtolower($code));
if ($code != $_SESSION['vcode_admin']) {
$this->json(P_Lang('验证码填写不正确'));
}
}
$rs = $this->model('admin')->get_one_from_name($user);
if (!$rs) {
$this->json(P_Lang('管理员信息不存在'));
}
if (!password_check($pass, $rs["pass"])) {
$this->json(P_Lang('管理员密码输入不正确'));
}
if (!$rs["status"]) {
$this->json(P_Lang("管理员账号已被锁定,请联系超管!"));
}
//获取管理员的权限
if (!$rs["if_system"]) {
$popedom_list = $this->model('admin')->get_popedom_list($rs["id"]);
if (!$popedom_list) {
$this->json(P_Lang('你的管理权限未设置好,请联系超级管理员进行设置'));
}
$_SESSION["admin_popedom"] = $popedom_list;
//非系统管理员,判断都有哪些站点权限
$site_id = $this->model('popedom')->get_site_id($popedom_list);
if (!$site_id) {
$this->json(P_Lang('你的管理权限未设置好,请联系超级管理员进行设置'));
}
$_SESSION["admin_site_id"] = $site_id;
} else {
$_SESSION["admin_site_id"] = $this->site['id'];
}
$_SESSION["admin_id"] = $rs["id"];
$_SESSION["admin_account"] = $rs["account"];
$_SESSION["admin_rs"] = $rs;
unset($_SESSION['vcode_admin']);
$this->json(true);
}
示例3: save_f
public function save_f()
{
if ($_SESSION['user_id']) {
$this->json(P_Lang('您已是本站会员,不需要再次登录'));
}
if ($this->config['is_vcode'] && function_exists('imagecreate')) {
$code = $this->get('_chkcode');
if (!$code) {
$this->json(P_Lang('验证码不能为空'));
}
$code = md5(strtolower($code));
if ($code != $_SESSION['vcode']) {
$this->json(P_Lang('验证码填写不正确'));
}
unset($_SESSION['vcode']);
}
$user = $this->get("user");
if (!$user) {
$this->json(P_Lang('账号不能为空'));
}
$pass = $this->get("pass");
if (!$pass) {
$this->json(P_Lang('会员密码不能为空'));
}
//多种登录方式
$user_rs = $this->model('user')->get_one($user, 'user');
if (!$user_rs) {
$user_rs = $this->model('user')->get_one($user, 'email');
if (!$user_rs) {
$user_rs = $this->model('user')->get_one($user, 'mobile');
if (!$user_rs) {
$this->json(P_Lang('会员信息不存在'));
}
}
}
if (!$user_rs['status']) {
$this->json(P_Lang('会员审核中,暂时不能登录'));
}
if ($user_rs['status'] == '2') {
$this->json(P_Lang('会员被管理员锁定,请联系管理员解锁'));
}
if (!password_check($pass, $user_rs["pass"])) {
$this->json(P_Lang('登录密码不正确'));
}
$_SESSION["user_id"] = $user_rs['id'];
$_SESSION["user_gid"] = $user_rs['group_id'];
$_SESSION["user_name"] = $user_rs["user"];
$this->json(true);
}
示例4: attempt_login
function attempt_login($username, $password)
{
$find_user = find_user_by_username($username);
$user = $find_user[0];
if (isset($user)) {
if (password_check($password, $user['password'])) {
// password matches
return $user;
} else {
// password does not match
return false;
}
} else {
// user not found
return false;
}
}
示例5: attempt_login
function attempt_login($username, $hashed_password)
{
$admin = find_admin_by_username($username);
if ($admin_set) {
// found admin, now check password
if (password_check($hashed_password, $admin_set["hashed_password"])) {
// password matches
return $admin_set;
} else {
// password does not match
return false;
}
} else {
// admin not found
return false;
}
}
示例6: submit_f
function submit_f()
{
$oldpass = $this->get("oldpass");
if (!$oldpass) {
error(P_Lang('管理员密码验证不能为空'), $this->url("me", "setting"), "error");
}
$rs = $this->model('admin')->get_one($_SESSION["admin_id"]);
if (!password_check($oldpass, $rs["pass"])) {
error(P_Lang("管理员密码不正确"), $this->url("me", "setting"), "error");
}
$name = $this->get('name');
$array = array('email' => $this->get('email'));
$update_login = false;
$admin = $this->model('admin')->get_one($_SESSION['admin_id'], 'id');
$tip = P_Lang('信息修改成功');
if ($name && $name != $admin['account']) {
//修改管理员账号
$check = $this->model('admin')->check_account($name, $_SESSION['admin_id']);
if ($check) {
error(P_Lang('管理员账号已经存在,请重新设置'), $this->url('me', 'setting'), 'error');
}
$array['account'] = $name;
$update_login = true;
$tip = P_Lang('管理员账号信息变更成功,请重新登录');
}
$newpass = $this->get("newpass");
if ($newpass) {
$chkpass = $this->get("chkpass");
if ($newpass != $chkpass) {
error(P_Lang("两次输入的新密码不一致"), $this->url("me", "setting"), "error");
}
$array['pass'] = password_create($newpass);
$tip = P_Lang('密码修改成功,请下次登录后使用新密码登录!');
}
$array['fullname'] = $this->get('fullname');
$array['close_tip'] = $this->get('close_tip');
$this->model('admin')->save($array, $_SESSION['admin_id']);
if ($update_login) {
error($tip, $this->url('logout'), 'ok');
} else {
$info = $this->model('admin')->get_one($_SESSION['admin_id'], 'id');
$_SESSION['admin_rs'] = $info;
$html = '<input type="button" value=" ' . P_Lang('确定') . ' " class="submit" onclick="$.dialog.close();" />';
error_open($tip, "ok", $html);
}
}
示例7: attempt_login
function attempt_login($username, $password)
{
$admin = find_user_by_username($username);
if ($admin) {
if (password_check($password, $admin)) {
return $admin;
} else {
echo "<div id=\"error\">";
echo " password does not match";
echo "</div>";
return false;
}
} else {
// user not found
return false;
}
}
示例8: validate_user
function validate_user($username, $password)
{
global $connection;
$safe_username = mysql_prep($username);
$query = "SELECT password FROM user_auth WHERE user_id = '{$username}' LIMIT 1";
$password_set = mysqli_query($connection, $query);
$fetched_password = mysqli_fetch_assoc($password_set);
if (isset($fetched_password)) {
if (password_check($password, $fetched_password['password'])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例9: authenticate
public static function authenticate($username = "", $password = "")
{
global $database;
if ($result_set = self::find_by_field("username", $username)) {
$user = array_shift($result_set);
} else {
$user = false;
}
$password = $database->escape_value($password);
if ($user) {
if (password_check($password, $user->password)) {
return $user;
} else {
return false;
}
} else {
return false;
}
}
示例10: user_authenticate
function user_authenticate($Username, $Password)
{
lib('Passwords');
global $pdo;
$stmt = $pdo->prepare('
SELECT `password`
FROM `users`
WHERE `username` = :username
');
$stmt->bindValue(':username', $Username);
$stmt->execute();
if (!($row = $stmt->fetch())) {
return false;
}
if (password_check($Password, $row['password'])) {
$GLOBALS['user'] = new User($Username);
return true;
} else {
return false;
}
}
示例11: attempt_login
function attempt_login($username, $pword)
{
//echo 'attempt_login ' . $password . ' — ' . $username . '<br/>';
//var_dump($password);
//hash password
$password = crypt($pword, CRYPT_BLOWFISH);
$find_user = find_user_by_username($username);
$user = $find_user[0];
//echo '<br/><br/>$user: ' . $user;
if (isset($user)) {
// found user, now check password
// echo '<br/>password_check called';
if (password_check($password, $user['password'])) {
// password matches
return $user;
} else {
// password does not match
return false;
}
} else {
// user not found
return false;
}
}
示例12: attempt_login_user
function attempt_login_user($username, $password)
{
$user = find_user_by_username($username);
if ($user) {
if (password_check($password, $user["hashed_password"])) {
return $user;
} else {
return false;
}
} else {
return false;
}
}
示例13: printf
printf('<input type="hidden" name="attr" value="%s" />', $request['attribute']);
echo '<table class="forminput" width="100%" border="0">';
echo '<tr>';
printf('<td class="heading">%s</td>', _('Compare'));
printf('<td><input type="%s" name="hash" id="hash" value="%s" /></td>', obfuscate_password_display($request['enc_type']) ? 'password' : 'text', htmlspecialchars($request['hash']));
echo '</tr>';
echo '<tr>';
printf('<td class="heading">%s</td>', _('To'));
printf('<td><input type="password" name="check_password" value="%s" /></td>', htmlspecialchars($request['password']));
echo '</tr>';
echo '<tr>';
echo '<td> </td>';
echo '<td><input type="submit" value="Compare" />';
if ($request['action'] == 'compare') {
echo ' <b>';
if (password_check($request['hash'], $request['password'], $request['attribute'])) {
printf('<span class="good">%s</span>', _('Passwords match!'));
} else {
printf('<span class="bad">%s</span>', _('Passwords do not match!'));
}
echo '</b>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</form>';
# Pull our password from the form that opened this window.
if ($request['componentid']) {
echo '<script type="text/javascript">';
printf('var c = window.opener.document.getElementById("%s");', $request['componentid']);
printf('var h = document.getElementById("%s");', 'hash');
示例14: var_dump
var_dump(get_container("dc=com"));
echo "<br>\n";
echo "Should be null: ";
var_dump(get_container("Fred"));
echo "<br>\n";
}
// tests pla_explode_dn()
if (false) {
var_dump(pla_explode_dn("cn=<stuff>,dc=example,dc=<com>"));
}
if (false) {
$password = 'asdf@sadf';
foreach (array('md5', 'md5crypt', 'sha', 'ssha', 'smd5', 'crypt', 'clear') as $enc_type) {
$crypted_password = password_hash($password, $enc_type);
print "[" . $enc_type . "] " . $crypted_password . "<br />";
print " Test: " . (password_check($crypted_password, $password) ? "passed" : "failed");
print "\n";
//unset($crypted_password);
flush();
}
}
if (true) {
$secret = "foobar";
$passwords = array('fun!244A', 'asdf', 'dc=stuff,ou=things', 'y()ikes');
$passwords_encrypted = array();
foreach ($passwords as $password) {
$passwords_encrypted[] = pla_blowfish_encrypt($password, $secret);
}
$passwords_decrypted = array();
foreach ($passwords_encrypted as $password) {
$passwords_decrypted[] = pla_blowfish_decrypt($password, $secret);
示例15: attempt_login
function attempt_login($username, $password)
{
$user = find_user($username);
if ($user) {
/* user found, now verify password */
if (password_check($password, $user["user_pass"])) {
/* password matches */
return $user;
} else {
/* password does not match */
return false;
}
} else {
/* user not verified */
return false;
}
}