Example #1
0
 public function get($f3)
 {
     AdminLog::logAdminOperate('user.logout', '用户退出', 'IP:' . $f3->get('IP'));
     AuthHelper::removeAuthUser();
     $f3->clear('SESSION');
     $this->addFlashMessage('成功退出登陆');
     // 刷新当前页面
     RouteHelper::reRoute($this, '/', false);
 }
Example #2
0
 public function post($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('POST'));
     $input = array();
     $input['user_name'] = $validator->required('用户名不能为空')->validate('user_name');
     $input['password'] = $validator->required('密码不能为空')->validate('password');
     $p_captcha = $validator->required('验证码不能为空')->validate('captcha');
     if (!$this->validate($validator)) {
         goto out_fail;
     }
     // 检查验证码是否有效
     $captchaController = new \Controller\Image\Captcha();
     if (!$captchaController->validateCaptcha($p_captcha)) {
         $this->addFlashMessage("验证码错误");
         goto out_fail;
     }
     $adminService = new AdminUserService();
     // 验证用户登陆
     $admin = $adminService->doAuthAdmin($input['user_name'], $input['user_name'], $input['password']);
     if (!$admin) {
         $this->addFlashMessage("登陆失败,用户名、密码错误");
         goto out_fail;
     }
     // 记录用户的登陆信息
     $adminUserInfo = $admin->toArray();
     unset($adminUserInfo['password']);
     // 不要记录密码
     // 取得用户的角色权限
     $adminUserInfo['role_action_list'] = '';
     if ($adminUserInfo['role_id'] > 0) {
         $metaRoleService = new MetaRoleService();
         $role = $metaRoleService->loadRoleById($adminUserInfo['role_id']);
         if (!$role->isEmpty()) {
             // 赋值角色权限
             $adminUserInfo['role_action_list'] = $role['meta_data'];
         }
     }
     AuthHelper::saveAuthUser($adminUserInfo);
     try {
         // 记录用户登录日志
         AdminLog::logAdminOperate('user.login', '用户登录', 'IP:' . $f3->get('IP'));
     } catch (\Exception $e) {
         // do nothing
     }
     $this->addFlashMessage("登陆成功");
     // 跳转到用户之前看的页面,如果之前没有看过的页面那就回到首页
     RouteHelper::jumpBack($this, '/', true);
     return;
     // 这里正常返回
     out_fail:
     // 失败从这里入口
     $smarty->display('user_login.tpl', 'User|Login|post');
 }
Example #3
0
 public function AttrItemEdit($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_goods_type_listtype');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $meta_id = $validator->digits()->min(1)->validate('meta_id');
     if (!$meta_id) {
         $meta_id = 0;
     }
     $goodsTypeService = new GoodsTypeService();
     $goodsAttrItem = $goodsTypeService->loadGoodsTypeAttrItemById($meta_id);
     if (!$f3->get('POST')) {
         // 没有 post ,只是普通的显示
         goto out_display;
     }
     unset($validator);
     $validator = new Validator($f3->get('POST'));
     if (0 === $meta_id) {
         // 新建的组
         $goodsAttrItem->parent_meta_id = $validator->required()->validate('typeId');
     }
     // 属性组
     $goodsAttrItem->meta_key = $validator->digits()->validate('meta_key');
     $goodsAttrItem->meta_name = $validator->required()->validate('meta_name');
     $goodsAttrItem->meta_desc = $validator->required()->validate('meta_desc');
     $goodsAttrItem->meta_sort_order = $validator->digits()->validate('meta_sort_order');
     // 属性类型,单选、单行输入、多行输入
     $goodsAttrItem->meta_ename = $validator->required()->validate('meta_ename');
     // 选项列表,逗号分隔
     $goodsAttrItem->meta_data = $validator->validate('meta_data');
     if (!$this->validate($validator)) {
         goto out_display;
     }
     $goodsAttrItem->save();
     if (0 === $meta_id) {
         $this->addFlashMessage('新建商品属性成功');
     } else {
         $this->addFlashMessage('更新商品属性成功');
     }
     // 记录管理员日志
     AdminLog::logAdminOperate('goods.type.attritem.edit', '商品属性', $goodsAttrItem->meta_name);
     out_display:
     // 新建的,reRoute 到编辑页面
     if (!$meta_id) {
         RouteHelper::reRoute($this, RouteHelper::makeUrl('/Goods/Type/AttrItemEdit', array('meta_id' => $goodsAttrItem->meta_id), true));
     }
     //给 smarty 模板赋值
     $smarty->assign('typeId', $goodsAttrItem->parent_meta_id);
     $smarty->assign($goodsAttrItem->toArray());
     $smarty->display('goods_type_attritemedit.tpl');
     return;
     out_fail:
     // 失败从这里退出
     RouteHelper::reRoute($this, '/Goods/Type/ListType');
 }
Example #4
0
 /**
  * 管理员操作日志
  *
  * @param $f3
  */
 public function ListLog($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_account_admin_listlog');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits()->min(0)->validate('pageNo');
     $pageSize = $validator->digits()->min(0)->validate('pageSize');
     //查询条件
     $formQuery = array();
     $formQuery['user_id'] = $validator->filter('ValidatorIntValue')->validate('user_id');
     $formQuery['operate'] = $validator->validate('operate');
     $formQuery['operate_desc'] = $validator->validate('operate_desc');
     //操作时间
     $operateTimeStartStr = $validator->validate('operate_time_start');
     $operateTimeStart = Time::gmStrToTime($operateTimeStartStr) ?: null;
     $operateTimeEndStr = $validator->validate('operate_time_end');
     $operateTimeEnd = Time::gmStrToTime($operateTimeEndStr) ?: null;
     $formQuery['operate_time'] = array($operateTimeStart, $operateTimeEnd);
     // 设置缺省值
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 20;
     if (!$this->validate($validator)) {
         goto out_display;
     }
     // 建立查询条件
     $condArray = QueryBuilder::buildQueryCondArray($formQuery);
     // 查询管理员列表
     $adminLogService = new AdminLogService();
     $totalCount = $adminLogService->countAdminLogArray($condArray);
     if ($totalCount <= 0) {
         // 没数据,可以直接退出了
         goto out_display;
     }
     // 页数超过最大值,返回第一页
     if ($pageNo * $pageSize >= $totalCount) {
         RouteHelper::reRoute($this, '/Account/Admin/ListLog');
     }
     // 管理员列表
     $adminLogArray = $adminLogService->fetchAdminLogArray($condArray, $pageNo * $pageSize, $pageSize);
     // 给模板赋值
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('adminLogArray', $adminLogArray);
     out_display:
     $smarty->display('account_admin_listlog.tpl');
 }
Example #5
0
 public function Edit($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_goods_brand_listbrand');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $brand_id = $validator->digits()->min(1)->validate('brand_id');
     if (!$brand_id) {
         $brand_id = 0;
     }
     $goodsBrandService = new GoodsBrandService();
     $goodsBrand = $goodsBrandService->loadBrandById($brand_id);
     if (!$f3->get('POST')) {
         // 没有 post ,只是普通的显示
         goto out_display;
     }
     unset($validator);
     $validator = new Validator($f3->get('POST'));
     $goodsBrand->brand_name = $validator->required()->validate('brand_name');
     $goodsBrand->brand_desc = $validator->required()->validate('brand_desc');
     $goodsBrand->brand_logo = $validator->validate('brand_logo');
     $goodsBrand->is_custom = $validator->digits()->filter('ValidatorIntValue')->validate('is_custom');
     $goodsBrand->custom_page = $f3->get('POST[custom_page]');
     if (!$this->validate($validator)) {
         goto out_display;
     }
     $goodsBrand->save();
     if (0 == $brand_id) {
         $this->addFlashMessage('新建商品品牌成功');
     } else {
         $this->addFlashMessage('更新商品品牌成功');
     }
     // 记录管理员日志
     AdminLog::logAdminOperate('goods.brand.edit', '编辑品牌', $goodsBrand->brand_name);
     out_display:
     // 新建的品牌,reRoute 到编辑页面
     if (!$brand_id) {
         RouteHelper::reRoute($this, RouteHelper::makeUrl('/Goods/Brand/Edit', array('brand_id' => $goodsBrand->brand_id), true));
     }
     //给 smarty 模板赋值
     $smarty->assign($goodsBrand->toArray());
     $smarty->display('goods_brand_edit.tpl');
     return;
     out_fail:
     // 失败从这里退出
     RouteHelper::reRoute($this, '/Goods/Brand/ListBrand');
 }