コード例 #1
0
 /**
  * 修改用户密码
  * 
  */
 public function changePwd()
 {
     $res = array();
     $pwd_old = isset($_REQUEST['pwdOld']) ? (string) $_REQUEST['pwdOld'] : null;
     $pwd_new = isset($_REQUEST['pwdNew']) ? (string) $_REQUEST['pwdNew'] : null;
     $pwd_new_confirm = isset($_REQUEST['pwdNewConfirm']) ? (string) $_REQUEST['pwdNewConfirm'] : null;
     $vendor = isset($_SESSION['vendor']) ? $_SESSION['vendor'] : null;
     $name = null;
     if (!$vendor) {
         header('Location:?action=Index');
         return;
     } else {
         $name = $vendor['vendor_name'];
     }
     $loginmodel = new LoginModel();
     $usermodel = new UserModel();
     //判断是否为空
     if (!$name || !$pwd_old || !$pwd_new || !$pwd_new_confirm) {
         $res['result'] = 0;
         $res['info'] = "数据不能为空";
     } else {
         if (md5("") == $pwd_old || md5("") == $pwd_new) {
             //应为name和pwd是经过MD5加密的,所以应该判断是否为空
             $res['result'] = 0;
             $res['info'] = "数据不能为空";
         } else {
             if ($pwd_new != $pwd_new_confirm) {
                 $res['result'] = 0;
                 $res['info'] = "新两次密码不一致";
             } else {
                 if ($loginmodel->UserLogin($name, $pwd_old) == null) {
                     //判断旧密码是否正确
                     $res['result'] = 0;
                     $res['info'] = "原始密码不对";
                 } else {
                     if ($usermodel->updateUserPwd($name, $pwd_new)) {
                         $res['result'] = 1;
                         $res['info'] = "修改成功";
                     } else {
                         $res['result'] = 0;
                         $res['info'] = "执行失败";
                     }
                 }
             }
         }
     }
     echo json_encode($res);
 }
コード例 #2
0
ファイル: LoginAction.class.php プロジェクト: PengLinTest/qnr
 public function userLoginNotCode()
 {
     $res = array();
     $name = isset($_REQUEST['UserName']) ? $_REQUEST['UserName'] : null;
     $pwd = isset($_REQUEST['Password']) ? $_REQUEST['Password'] : null;
     if ($name == null) {
         $res['result'] = 0;
         $res['info'] = "用户名不能为空";
         echo json_encode($res);
         return;
     }
     if ($pwd == null) {
         $res['result'] = 0;
         $res['info'] = "密码不能为空";
         echo json_encode($res);
         return;
     }
     //判断用户名,密码是否正确
     $model = new LoginModel();
     if ($vendor = $model->UserLogin($name, $pwd)) {
         //设置Session
         User::_setVendor($vendor);
         $res['result'] = 1;
         $res['vendorId'] = $vendor['vendor_id'];
         $res['lastLoginTime'] = $vendor['vendor_lastLoginTime'];
         $res['vendor_type'] = $vendor['vendor_type'];
     } else {
         $res['result'] = 0;
         $res['info'] = "用户不存在";
     }
     echo json_encode($res);
 }