Example #1
0
 public function login($username = '', $password = '', $verify = '', $ajax = true)
 {
     layout(false);
     if (IS_POST) {
         if (C('VERIFY') && $verify != session(C('VERIFY_CODE'))) {
             // 验证码不对
             if ($ajax) {
                 $this->ajaxReturn(['status' => -1, 'msg' => '验证码错误']);
             }
             $this->error('验证码错误');
         }
         $userInfo = UserModel::instance()->findByName($username);
         if (!$userInfo) {
             $this->assign("error", "用户不存在");
         } else {
             if ($userInfo && $userInfo['password'] == processPwd($password)) {
                 // 登陆成功
                 session(C('LOGIN_SESSION'), $userInfo);
                 $this->redirect('index/index');
             } else {
                 $this->assign("error", "密码错误");
             }
         }
         $this->assign("username", $username);
         $this->assign("password", $password);
     }
     if (I("error")) {
         $this->assign("error", "抱歉,您的账号已被禁用~");
     }
     $this->display();
 }
Example #2
0
 public function addShop($data)
 {
     $m = M($this->_table);
     $m->startTrans();
     $dataShop = $data;
     $data['password'] = processPwd($data['password']);
     $dataShop['name'] = $data['shopName'];
     $mu = M('user');
     if ($mu->create($data)) {
         $flag2 = $mu->add();
     }
     $dataShop['uid'] = $flag2;
     $dataShop['created_at'] = time();
     if ($m->create($dataShop)) {
         $flag1 = $m->add();
     }
     if ($flag1 && $flag2) {
         $m->commit();
         return true;
     } else {
         $m->rollback();
     }
     return false;
 }