コード例 #1
0
 public function loginAction(Request $request, Application $app)
 {
     $adminId = $app['session']->get('adminId');
     $admin = new Admin();
     if ($adminId) {
         $admin->setId($adminId);
         $admin->setLastLoginTime(time());
         $app['repository.admin']->editLastLoginTime($admin);
         $redirect = $app['url_generator']->generate('adminIndex');
         return $app->redirect($redirect);
     }
     $form = $app['form.factory']->create(new AdminLoginType(), $admin);
     $form->handleRequest($request);
     if ($request->isMethod('POST')) {
         //            $form->bind($request);
         if ($form->isValid()) {
             $resultFindByNameAndPassword = $app['repository.admin']->findByNameAndPassword($admin);
             if (!$resultFindByNameAndPassword) {
                 CommonFunc::alertBack('账号或密码错误,请重试');
                 return;
             }
             $resultFindByNameAndPassword->setLastLoginTime(time());
             $app['repository.admin']->editLastLoginTime($resultFindByNameAndPassword);
             $resultFindByNameAndPassword->setLastLoginIp(CommonFunc::getIP());
             $app['repository.admin']->editLastLoginIp($resultFindByNameAndPassword);
             $app['session']->set('adminId', $resultFindByNameAndPassword->getId());
             $redirect = $app['url_generator']->generate('adminIndex');
             return $app->redirect($redirect);
         }
     }
     $data = array('form' => $form->createView(), 'title' => '用户登录');
     return $app['twig']->render('admin/adminLogin.html.twig', $data);
 }
コード例 #2
0
 public function putOnCardKeyAjaxAction(Request $request, Application $app)
 {
     $cardKeyId = $request->query->get('cardKey');
     $cardKey = new CardKey();
     $cardKey->setCardKey($cardKeyId);
     $cardKey->setStatus(1);
     $resultFindById = $app['repository.cardKey']->findById($cardKey);
     if (!$resultFindById) {
         $msg = '没有找到卡密';
         CommonFunc::alertBack($msg);
         return;
     }
     $resultDelete = $app['repository.cardKey']->editStatus($cardKey);
     if ($resultDelete) {
         $data = array('result' => 1);
     } else {
         $data = array('result' => 0);
     }
     return JsonResponse::create($data);
 }
コード例 #3
0
 public function editGoodsClassAjaxAction(Request $request, Application $app)
 {
     $goodsClassId = $request->query->get('goodsClassId');
     $goodsClass = new GoodsClass();
     $goodsClass->setId($goodsClassId);
     $resultFindById = $app['repository.goodsClass']->findById($goodsClass);
     if (!$resultFindById) {
         $app->abort(404, '没有找到此资源大类');
     }
     $form = $app['form.factory']->create(new SaveGoodsClassType(), $resultFindById);
     $form->handleRequest($request);
     if ($request->isMethod('POST')) {
         if ($form->isValid()) {
             $resultSave = $app['repository.goodsClass']->save($resultFindById);
             if ($resultSave) {
                 $msg = '修改成功。';
                 $url = '/admin/goodsClassList';
                 CommonFunc::alertHref($msg, $url);
                 return;
             } else {
                 $msg = '修改失败,请重试。';
                 CommonFunc::alertBack($msg);
                 return;
             }
         }
     }
     $data = array('form' => $form->createview(), 'title' => '资源大类修改');
     return $app['twig']->render('admin/saveGoodsClass.html.twig', $data);
 }
コード例 #4
0
 public function checkIsLoginHeader($user, $request, $app)
 {
     $data = array();
     $userId = $user->getId();
     $data['id'] = $userId;
     if ($userId) {
         $user->setId($userId);
         $user = $app['repository.user']->findById($user);
         if ($user->getStatus() == 0) {
             CommonFunc::alertBack('未激活,请联系管理员或到邮箱激活');
             return;
         }
         $data['id'] = $userId;
         $data['isLogin'] = 1;
         $data['name'] = $user->getName();
         $data['lastLoginTime'] = date("Y-m-d H:i:s", $user->getLastLoginTime());
         $data['integration'] = $user->getIntegration();
         $data['vipStartTime'] = date("Y-m-d H:i:s", $user->getVipStartTime());
         $data['vipEndTime'] = date("Y-m-d H:i:s", $user->getVipEndTime());
         $data['vipTime'] = intval(($user->getVipEndTime() - $user->getVipStartTime()) / (24 * 60 * 60));
         if ($user->getVipEndTime() < time() and $user->getIsVip() == 1) {
             $user = new User();
             $user->setId($userId);
             $user->setIsVip(0);
             $resultChangeIsVip = $app['repository.user']->changeIsVip($user);
             if (!$resultChangeIsVip) {
                 CommonFunc::alertBack('系统错误,请联系管理员');
                 return;
             }
         }
         $data['isVip'] = $user->getIsVip();
         $data['lastSignInTime'] = $user->getLastSignInTime();
         $data['purchasedGoodsId'] = $user->getPurchasedGoodsId();
         $data['shareKey'] = $user->getShareKey();
         if ($data['lastSignInTime'] > strtotime(date("Y-m-d"))) {
             $data['isSignIn'] = 1;
         } else {
             $data['isSignIn'] = 0;
         }
     } else {
         $form = $app['form.factory']->create(new UserLoginType(), $user);
         if ($request->isMethod('POST')) {
             $form->bind($request);
             if ($form->isValid()) {
                 $resultFindByNameAndPassword = $app['repository.user']->findByNameAndPassword($user);
                 if (!$resultFindByNameAndPassword) {
                     CommonFunc::alertBack('账号或密码错误,请重试');
                     return;
                 }
                 if ($resultFindByNameAndPassword->getStatus() == 0) {
                     CommonFunc::alertBack('未激活,请联系管理员或到邮箱激活');
                     return;
                 }
                 $resultFindByNameAndPassword->setLastLoginTime(time());
                 $app['repository.user']->editLastLoginTime($resultFindByNameAndPassword);
                 $resultFindByNameAndPassword->setLastLoginIp(CommonFunc::getIP());
                 $app['repository.user']->editLastLoginIp($resultFindByNameAndPassword);
                 $userId = $resultFindByNameAndPassword->getId();
                 $app['session']->set('userId', $userId);
                 //                    $redirect = $app['url_generator']->generate('userIndex');
                 //                    return $app->redirect($redirect);
                 $user->setId($userId);
                 $user = $app['repository.user']->findById($user);
                 $data['id'] = $userId;
                 $data['isLogin'] = 1;
                 $data['name'] = $user->getName();
                 $data['lastLoginTime'] = date("Y-m-d H:i:s", $user->getLastLoginTime());
                 $data['integration'] = $user->getIntegration();
                 $data['vipStartTime'] = date("Y-m-d H:i:s", $user->getVipStartTime());
                 $data['vipEndTime'] = date("Y-m-d H:i:s", $user->getVipEndTime());
                 $data['vipTime'] = intval(($user->getVipEndTime() - $user->getVipStartTime()) / (24 * 60 * 60));
                 if ($user->getVipEndTime() < time() and $user->getIsVip() == 1) {
                     $user = new User();
                     $user->setId($userId);
                     $user->setIsVip(0);
                     $resultChangeIsVip = $app['repository.user']->changeIsVip($user);
                     if (!$resultChangeIsVip) {
                         CommonFunc::alertBack('系统错误,请联系管理员');
                         return;
                     }
                 }
                 $data['isVip'] = $user->getIsVip();
                 $data['lastSignInTime'] = $user->getLastSignInTime();
                 $data['purchasedGoodsId'] = $user->getPurchasedGoodsId();
                 $data['shareKey'] = $user->getShareKey();
                 if ($data['lastSignInTime'] > strtotime(date("Y-m-d"))) {
                     $data['isSignIn'] = 1;
                 } else {
                     $data['isSignIn'] = 0;
                 }
                 return $data;
             }
         }
         $data['isLogin'] = 0;
         $data['isVip'] = 0;
         $data['form'] = $form->createView();
     }
     return $data;
 }
コード例 #5
0
 public function resetPasswordAction(Request $request, Application $app)
 {
     $name = $request->query->get('name');
     $password = $request->query->get('password');
     $email = $request->query->get('email');
     $user = new User();
     $user->setName($name);
     $user->setPassword($password);
     $resultFindByNameAndPassword = $app['repository.user']->findByNameAndPassword($user);
     if (!$resultFindByNameAndPassword) {
         CommonFunc::alertBack('链接参数被更改,请联系管理员');
         return;
     }
     $data = array();
     $data['title'] = '重置密码';
     $data['name'] = $name;
     $data['id'] = $resultFindByNameAndPassword->getId();
     return $app['twig']->render('user/userResetPassword.html.twig', $data);
 }