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


PHP UserModel::checkUser方法代碼示例

本文整理匯總了PHP中UserModel::checkUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserModel::checkUser方法的具體用法?PHP UserModel::checkUser怎麽用?PHP UserModel::checkUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserModel的用法示例。


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

示例1: validateUser

 private static function validateUser($username, $password)
 {
     if (Session::get('failed_login_count') >= 3 and Session::get('last_failed_login') > time() - 30) {
         Session::add(Message::get('LOGIN_FAILED'), Message::get('LOGIN_3_ATTEMPTS'));
         return false;
     }
     $result = UserModel::checkUser($username);
     if ($result) {
         Session::set('failed_login_count', 0);
         Session::set('last_failed_login', '');
     } else {
         Session::set('failed_login_count', Session::get('failed_login_count') + 1);
         Session::set('last_failed_login', time());
         Session::add('feedback_negative', Message::get('LOGIN_3_ATTEMPTS'));
         return false;
     }
     if ($result['failed_login_count'] >= 3 and $result['last_failed_login'] > time() - 30) {
         Session::add(Message::get('LOGIN_FAILED'), Message::get('LOGIN_3_ATTEMPTS'));
         return false;
     }
     /*if ($result['active_user'] != 1) {
           Session::add(Message::get('LOGIN_FAILED'), Message::get('ACCOUNT_NOT_ACTIVATED'));
           return false;
       }*/
     if (!password_verify($password, $result['password'])) {
         self::incrementLoginFail($result['username']);
         Session::add(Message::get('LOGIN_FAILED'), Message::get('WRONG_PASSWORD'));
         return false;
     }
     return $result;
 }
開發者ID:heyjohnnyfunt,項目名稱:sendashare,代碼行數:31,代碼來源:LoginModel.php

示例2: loginAction

 /**
  * user login
  */
 public function loginAction()
 {
     parent::render('signin');
     if (isset($_POST['login'])) {
         $_SESSION['user'] = $_POST['user_id'];
         $user = new UserModel();
         if ($user->checkUser() === true) {
             parent::redirect("user", "userPage");
         } else {
             return $user->afterUnsuccessfulLogin();
         }
     }
 }
開發者ID:kapsi44,項目名稱:Gangouts,代碼行數:16,代碼來源:UserController.php

示例3: UserModel

	$name = $_POST['username'];
	$passwd = $_POST['passwd'];

	/*
	echo '<pre>';
	print_r($_POST);
	echo '</pre>';
	exit;
	*/

	//合法性檢測...

	$user = new UserModel();

	//核對用戶名,密碼
	$row = $user->checkUser($name, $passwd);

	if(empty($row)){
		$msg = '用戶名密碼不匹配!';
	}else{
		$msg = '登陸成功!';	
		//session_start();
		$_SESSION = $row; //登陸成功設置session

		//記住用戶名
		//remember
		if(isset($_POST['remember'])){
			setcookie('remuser', $name, time() + 14 * 24 * 3600); //保存2周
		}else{
			setcookie('remuser', '', 0);
		}
開發者ID:xiaoxiaoJun,項目名稱:phpper,代碼行數:31,代碼來源:login.php

示例4: doLogAction

 /**
  * 登錄處理
  */
 public function doLogAction()
 {
     $account = safe::filterPost('account');
     $password = $_POST['password'];
     $captcha = safe::filterPost('captcha', '/^[a-zA-Z]{4}$/');
     $data = array('errorCode' => 0);
     $captchaObj = new captcha();
     if ($account == '') {
         $data['errorCode'] = 1;
     } else {
         if ($password == '') {
             $data['errorCode'] = 2;
         } else {
             if ($captcha == '') {
                 $data['errorCode'] = 3;
             } else {
                 if (!$captchaObj->check($captcha)) {
                     //驗證碼是否正確
                     $data['errorCode'] = 4;
                 } else {
                     $userModel = new UserModel();
                     $userData = $userModel->checkUser($account, $password);
                     if (empty($userData)) {
                         //賬戶密碼錯誤
                         $data['errorCode'] = 5;
                     } else {
                         //登錄成功
                         $checkRight = new checkRight();
                         $checkRight->loginAfter($userData);
                     }
                 }
             }
         }
     }
     $data['returnUrl'] = isset($_POST['callback']) && $_POST['callback'] != '' ? trim($_POST['callback']) : url::createUrl('/');
     echo JSON::encode($data);
     return false;
 }
開發者ID:weipinglee,項目名稱:nn2,代碼行數:41,代碼來源:Index.php

示例5: UserModel

$user = new UserModel();
/*
調用自動檢驗功能
檢驗用戶名4-16字符之內
email檢測
passwd不能為空
*/
if (!$user->_validate($_POST)) {
    // 自動檢驗
    $msg = implode('<br />', $user->getErr());
    $url = 'login.php?pass=reg';
    Header("Location: {$url}");
    exit;
}
// 檢驗用戶名是否已存在
if ($user->checkUser($_POST['username'])) {
    $url = 'login.php?pass=reg';
    Header("Location: {$url}");
    exit;
}
/*檢驗驗證碼*/
if ($_SESSION['rand'] != $_POST['code']) {
    $url = 'login.php?pass=reg';
    Header("Location: {$url}");
    exit;
}
$data = $user->_autoFill($_POST);
// 自動填充
$data = $user->_facade($data);
// 自動過濾
$data['nickname'] = '野人';
開發者ID:hsian,項目名稱:sinsea,代碼行數:31,代碼來源:regAct.php

示例6: UserModel

<?php

/***
用戶登陸頁麵
***/
define('ACC', true);
require './include/init.php';
if (isset($_POST['act'])) {
    // 這說明是點擊了登陸按鈕過來的
    // 收用戶名/密碼,驗證....
    $u = $_POST['username'];
    $p = $_POST['passwd'];
    // 合法性檢測,自己做...
    $user = new UserModel();
    // 核對用戶名,密碼
    $row = $user->checkUser($u, $p);
    if (empty($row)) {
        /*登陸失敗*/
        $url = 'login.php?pass=fial';
        Header("Location: {$url}");
        exit;
    } else {
        $msg = '登陸成功!';
        $_SESSION = $row;
        if (isset($_POST['auto_login'])) {
            setcookie('remuser', $u, time() + 14 * 24 * 3600);
        } else {
            setcookie('remuser', '', 0);
        }
        $url = 'index.php';
        Header("Location: {$url}");
開發者ID:hsian,項目名稱:sinsea,代碼行數:31,代碼來源:loginAct.php

示例7: UserModel

define('ACC', true);
require '../system/init.php';
if (!isset($_POST['act'])) {
    if (isset($_COOKIE['keepuser'])) {
        $keepuser = $_COOKIE['keepuser'];
    } else {
        $keepuser = '';
    }
    include __ROOT__ . 'view/front/denglu.html';
    //第一次登陸指向登陸界麵
} else {
    $username = $_POST['username'];
    $password = $_POST['password'];
    //接受登陸界麵的請求,若成功請求,將用戶信息錄入$_SESSION;
    $user = new UserModel();
    if (($res = $user->checkUser($username, $password)) == false) {
        list($error) = $user->getErr();
        $msg = $error;
        include __ROOT__ . 'view/front/msg.html';
    } else {
        $_SESSION = $res;
        $msg = 'login successfully';
        //用戶選擇記住用戶名,保存用戶名7天
        if (isset($_POST['remember'])) {
            setcookie('keepuser', $username, time() + 3600 * 24 * 7);
        } else {
            setcookie('keepuser', '', time() - 42000);
        }
        include __ROOT__ . 'view/front/msg.html';
    }
}
開發者ID:qiushuiqs,項目名稱:myshop,代碼行數:31,代碼來源:user.php

示例8: UserModel

define('ACC', true);
require '../system/init.php';
//顯示user注冊頁麵
$msg = '';
//返回到前台的信息
$user = new UserModel();
$data = $user->_autofill($_POST);
//檢測內容
/*
username: 4-20
password: 非空
email: 有email格式
username是否重複
*/
if (!$user->_validate($data)) {
    list($error) = $user->getErr();
    $msg .= $error;
} else {
    $user->setField($user->showField());
    $data = $user->_facade($data);
    if (!$user->checkUser($data['username'])) {
        list($error) = $user->getErr();
        $msg = $error;
    } else {
        $user->reg($data);
        $msg .= "Register Sucessfully!";
    }
}
include '../view/front/msg.html';
//echo $user->add($data)? "s":"f";
開發者ID:qiushuiqs,項目名稱:myshop,代碼行數:30,代碼來源:regAct.php


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