/** * 根据 goods_id 得到一个商品的图片集 * * @param $f3 */ public function GalleryThumb($f3) { // 参数验证 $validator = new Validator($f3->get('GET')); $errorMessage = ''; $goods_id = $validator->required()->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id'); if (!$this->validate($validator)) { $errorMessage = implode('|', $this->flashMessageArray); goto out_fail; } $goodsGalleryService = new GoodsGalleryService(); $galleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsId($goods_id); $thumImageList = array(); foreach ($galleryArray as $galleryItem) { $thumImageList[] = array('img_id' => $galleryItem['img_id'], 'thumb_url' => RouteHelper::makeImageUrl($galleryItem['thumb_url'])); } out: Ajax::header(); echo Ajax::buildResult(null, null, $thumImageList); return; out_fail: // 失败,返回出错信息 Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
private function preparePage($goods_id, $pageNo) { global $smarty; // 设置缺省值 $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0; $pageSize = 10; // 每页显示 10 个 // 查询条件 $condArray = array(); $condArray[] = array('goods_id = ?', $goods_id); $condArray[] = array('is_show = 1'); $baseService = new BaseService(); $totalCount = $baseService->_countArray('goods_comment', $condArray); if ($totalCount <= 0) { // 没数据,可以直接退出了 return; } // 页数超过最大值 if ($pageNo * $pageSize >= $totalCount) { return; } // 查询数据 $goodsCommentArray = $baseService->_fetchArray('goods_comment', '*', $condArray, array('order' => 'comment_id desc'), $pageNo * $pageSize, $pageSize); // 给 smarty 赋值 $smarty->assign('currentUrl', RouteHelper::makeUrl('/Ajax/GoodsComment', array('goods_id' => $goods_id))); $smarty->assign('totalCount', $totalCount); $smarty->assign('pageNo', $pageNo); $smarty->assign('pageSize', $pageSize); $smarty->assign('goodsCommentArray', $goodsCommentArray); }
public function get($f3) { // 设置 order_refer 记录,记录在客户端 $orderRefer = array(); // 检查彩贝的记录 $caibeiRefer = $f3->get('SESSION[yiqifa_caibei_order_refer]'); if (!empty($caibeiRefer)) { $orderRefer = $caibeiRefer; unset($orderRefer['refer_host']); // 去掉彩贝的 refer_host } // 清除彩贝记录 $f3->set('SESSION[yiqifa_caibei_order_refer]', null); $orderRefer['utm_source'] = 'YIQIFACPS'; // 保存额外的 亿起发 参数 $validator = new Validator($_REQUEST); $referParamArray = array(); $referParamArray['src'] = $validator->validate('src'); $referParamArray['cid'] = $validator->validate('cid'); $referParamArray['wi'] = $validator->validate('wi'); $referParamArray['channel'] = $validator->validate('channel'); $orderRefer['refer_param'] = json_encode($referParamArray); //设置 cookie ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration')); // 页面跳转到商品 $url = $validator->validate('url'); $redirectUrl = empty($url) ? '/' : $url; RouteHelper::reRoute($this, $redirectUrl); return; }
/** * 360 一站通登陆 */ public function get($f3) { // 标准动态链接,不能伪静态地址 $callback = RouteHelper::makeUrl('/Thirdpart/Dev360Auth/Callback', null, false, true, false); $params = array('client_id' => Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_key'), 'redirect_uri' => $callback, 'response_type' => 'code'); $url = 'https://openapi.360.cn/oauth2/authorize?' . http_build_query($params); header("Location: {$url}"); }
public function get($f3) { AuthHelper::removeAuthUser(); $f3->clear('SESSION'); $this->addFlashMessage('成功退出登陆'); // 返回首页 RouteHelper::reRoute($this, '/', false); }
public function get($f3) { global $smarty; // 首先做参数合法性验证 $validator = new Validator($f3->get('GET')); $goods_id = $validator->required('商品id不能为空')->digits('商品id非法')->min(1, true, '商品id非法')->validate('goods_id'); if (!$this->validate($validator)) { goto out_fail; } // 生成 smarty 的缓存 id $smartyCacheId = 'Goods|' . $goods_id . '|View'; // 开启并设置 smarty 缓存时间 enableSmartyCache(true, MobileThemePlugin::getOptionValue('smarty_cache_time_goods_view')); // 缓存页面 if ($smarty->isCached('goods_view.tpl', $smartyCacheId)) { goto out_display; } // 查询商品信息 $goodsBasicService = new GoodsBasicService(); $goodsInfo = $goodsBasicService->loadGoodsById($goods_id); // 商品不存在,退出 if ($goodsInfo->isEmpty() || !Utils::isTagExist(PluginHelper::SYSTEM_MOBILE, $goodsInfo['system_tag_list'])) { $this->addFlashMessage('商品 [' . $goods_id . '] 不存在'); goto out_fail; } // 取商品推广信息设置 $goodsPromote = $goodsBasicService->loadGoodsPromoteByGoodsId($goods_id); // 取商品图片集 $goodsGalleryArray = GoodsGalleryCache::getGoodsGallery($goods_id); foreach ($goodsGalleryArray as &$galleryItem) { $galleryItem['img_url'] = RouteHelper::makeImageUrl($galleryItem['img_url']); $galleryItem['thumb_url'] = RouteHelper::makeImageUrl($galleryItem['thumb_url']); } unset($galleryItem); // 设置商品页面的 SEO 信息 $smarty->assign('seo_title', $goodsInfo['seo_title'] . ',' . $f3->get('sysConfig[site_name]')); $smarty->assign('seo_description', $goodsInfo['seo_description']); $smarty->assign('seo_keywords', $goodsInfo['seo_keyword']); // 给模板赋值 $smarty->assign('goodsInfo', $goodsInfo); $smarty->assign('goodsPromote', $goodsPromote); if (!Utils::isEmpty($goodsGalleryArray)) { $smarty->assign('goodsGalleryArray', $goodsGalleryArray); } // 设置商品规格 if (!empty($goodsInfo['goods_spec'])) { $goodsSpecService = new GoodsSpecService(); $goodsSpecService->initWithJson($goodsInfo['goods_spec']); $smarty->assign('goodsSpec', $goodsSpecService->getGoodsSpecDataArray()); } out_display: $smarty->display('goods_view.tpl', $smartyCacheId); return; out_fail: // 失败从这里返回 RouteHelper::reRoute($this, '/'); // 返回首页 }
/** * 用于生成系统的操作链接,符合系统 URL 调用规范 * * 在模板中的使用方法 {{makeUrl controller='/User/Login' username='******' password='******' }} * * 必须要有 controller 用于指定控制器,其它参数可以没有 * * */ function smarty_helper_function_make_url(array $paramArray, $smarty) { $controller = isset($paramArray['controller']) ? $paramArray['controller'] : '/Error/E404'; $static = isset($paramArray['static']) ? $paramArray['static'] : null; // 去除 controller, static ,其它都是控制器的参数 unset($paramArray['controller']); unset($paramArray['static']); return RouteHelper::makeUrl($controller, $paramArray, false, false, $static); }
public function post($f3) { global $smarty; // 首先做参数合法性验证 $validator = new Validator($f3->get('POST')); $input = array(); $input['user_name'] = $validator->required('用户名不能为空')->minLength(2, '用户名最短为2个字符')->validate('user_name'); $input['password'] = $validator->required('密码不能为空')->minLength(6, '密码最短为6个非空字符')->validate('password'); $input['email'] = $validator->validate('email'); $input['mobile_phone'] = $validator->digits('手机号格式不对')->validate('mobile_phone'); $p_captcha = $validator->required('验证码不能为空')->validate('captcha'); // 手机输入,输入法经常无故添加空格,我们需要去除所有的空额,防止出错 $p_captcha = Utils::filterAlnumStr($p_captcha); // 需要跳转回去的地址 $returnUrl = $validator->validate('returnUrl'); if (!$this->validate($validator)) { goto out_fail; } // 检查验证码是否有效 $captchaController = new \Controller\Image\Captcha(); if (!$captchaController->validateCaptcha($p_captcha)) { $this->addFlashMessage('验证码错误[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']'); goto out_fail; } $userService = new UserService(); // 检查用户是否已经注册 $isUserExist = $userService->isUserExist($input['user_name'], $input['email']); if ($isUserExist) { $this->addFlashMessage($isUserExist . '已经存在'); goto out_fail; } // 注册用户 $user = $userService->registerUser($input); if (!$user) { $this->addFlashMessage('用户注册失败,请稍后刷新页面重试'); goto out_fail; } // 记录用户的登陆信息 $userInfo = $user->toArray(); unset($userInfo['password']); // 不要记录密码 AuthHelper::saveAuthUser($userInfo, 'normal'); $this->addFlashMessage("注册成功"); if ($returnUrl) { header('Location:' . $returnUrl); return; } else { // 跳转到用户之前看的页面,如果之前没有看过的页面那就回到首页 RouteHelper::jumpBack($this, '/', true); } return; // 这里正常返回 out_fail: // 失败,从这里出口 $smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time()))); $smarty->display('user_register.tpl', 'User|Register|post'); }
public function pluginGetConfigureUrl($system) { // manage 系统可以配置这个插件 if (PluginHelper::SYSTEM_MANAGE === $system) { return RouteHelper::makeUrl('/Theme/Shop/Index'); } // 其它系统不需要配置 return null; }
public function pluginGetConfigureUrl($system) { // manage 系统可以配置这个插件 if (PluginHelper::SYSTEM_MANAGE === $system) { return RouteHelper::makeUrl('/Payment/Alipay/Configure'); } // 其它系统不需要配置 return null; }
public function pluginGetConfigureUrl($system) { // manage 系统可以配置这个插件 if (PluginHelper::SYSTEM_MANAGE === $system) { return RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Configure'); } // 其它系统不需要配置 return null; }
public function beforeRoute($f3) { parent::beforeRoute($f3); // 用户没有登陆,让用户去登陆 if (!AuthHelper::isAuthUser()) { // 如果已经记录了一个回跳 URL ,则不要再覆盖这个记录了 RouteHelper::reRoute($this, '/User/Login', !RouteHelper::hasRememberUrl()); } }
/** * QQ 登陆 */ public function get($f3) { $callback = RouteHelper::makeUrl('/Thirdpart/QQAuth/Callback', null, false, true); $qqLoginState = md5(uniqid(rand(), true)); // 防止 csrf 攻击 $f3->set('SESSION[qq_login_state]', $qqLoginState); $loginUrl = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=" . QQAuthPlugin::getOptionValue('qqauth_appid') . "&redirect_uri=" . urlencode($callback) . "&state=" . $qqLoginState . "&scope=get_user_info"; header("Location:{$loginUrl}"); }
public function get($f3) { AdminLog::logAdminOperate('user.logout', '用户退出', 'IP:' . $f3->get('IP')); AuthHelper::removeAuthUser(); $f3->clear('SESSION'); $this->addFlashMessage('成功退出登陆'); // 刷新当前页面 RouteHelper::reRoute($this, '/', false); }
public function get($f3) { global $smarty; $smartyCacheId = 'EtaoFeed|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '_\\' . __METHOD__); // 判断是否有缓存 enableSmartyCache(true, 1200); // 缓存 20 分钟 if ($smarty->isCached('empty.tpl', $smartyCacheId)) { goto out_display; } $currentStamp = Time::localTimeStr(); $sellerId = EtaoFeedPlugin::getOptionValue('etaofeed_seller_id'); $categoryUrl = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Category', null, false, true); $itemDir = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Item', null, false, true); $itemIdXmlList = ''; // 处理 delete 的商品 $currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance(); $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 0'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray())))); if ($totalGoodsCount <= 0) { goto query_update_goods; } $totalPageCount = ceil($totalGoodsCount / Item::$pageSize); for ($index = 0; $index < $totalPageCount; $index++) { $itemIdXmlList .= '<outer_id action="delete">1' . $index . '</outer_id>'; } query_update_goods: // 处理修改过的商品 $totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 1'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray())))); if ($totalGoodsCount <= 0) { goto out_output; } $totalPageCount = ceil($totalGoodsCount / Item::$pageSize); for ($index = 0; $index < $totalPageCount; $index++) { $itemIdXmlList .= '<outer_id action="upload">2' . $index . '</outer_id>'; } out_output: $apiXml = <<<XML <?xml version="1.0" encoding="utf-8" ?> <root> <version>1.0</version> <modified>{$currentStamp}</modified> <seller_id>{$sellerId}</seller_id> <cat_url>{$categoryUrl}</cat_url> <dir>{$itemDir}/</dir> <item_ids>{$itemIdXmlList}</item_ids> </root> XML; $smarty->assign('outputContent', $apiXml); // 更新查询时间 //EtaoFeedPlugin::saveOptionValue('etaofeed_query_timestamp', Time::gmTime()); out_display: header('Content-Type:text/xml;charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 //查询信息 $smarty->display('empty.tpl', $smartyCacheId); }
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'); }
public function post($f3) { // 权限检查 $this->requirePrivilege('manage_plugin_theme_configure'); // 保存数据 ShopThemePlugin::saveOptionValue('head_nav_json_data', json_encode($f3->get('POST[headNav]'))); // 清除 所有页面 $shopClear = new ShopClear(); $shopClear->clearAllCache(); $this->addFlashMessage('保存设置成功'); RouteHelper::reRoute($this, '/Theme/Shop/HeadNav'); }
public function get($f3) { // 权限检查 $this->requirePrivilege('manage_goods_edit_edit_get'); global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $goods_id = $validator->required('商品ID不能为空')->digits()->min(1)->validate('goods_id'); $smarty->display('goods_edit_linkgoods.tpl'); return; out_fail: RouteHelper::reRoute($this, '/Goods/Search'); }
public function beforeRoute($f3) { global $smarty; parent::beforeRoute($f3); // 用户没有登陆,让用户去登陆 if (!AuthHelper::isAuthUser()) { // 如果已经记录了一个回跳 URL ,则不要再覆盖这个记录了 RouteHelper::reRoute($this, '/User/Login', !RouteHelper::hasRememberUrl()); return; } //把认证用户放入到 smarty 中 $smarty->assign('authSupplierUser', AuthHelper::getAuthUser()); }
public function post($f3) { global $smarty; // 首先做参数合法性验证 $validator = new Validator($f3->get('POST')); $input = array(); $input['user_name'] = $validator->required('用户名不能为空')->minLength(2, '用户名最短为2个字符')->validate('user_name'); $input['password'] = $validator->required('密码不能为空')->minLength(6, '密码最短为6个非空字符')->validate('password'); $input['email'] = $validator->validate('email'); $input['mobile_phone'] = $validator->digits('手机号格式不对')->validate('mobile_phone'); $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; } $userService = new UserService(); // 检查用户是否已经注册 $isUserExist = $userService->isUserExist($input['user_name'], $input['email']); if ($isUserExist) { $this->addFlashMessage($isUserExist . '已经存在'); goto out_fail; } // 注册用户 $user = $userService->registerUser($input); if (!$user) { $this->addFlashMessage('用户注册失败,请稍后刷新页面重试'); goto out_fail; } // 记录用户的登陆信息 $userInfo = $user->toArray(); unset($userInfo['password']); // 不要记录密码 AuthHelper::saveAuthUser($userInfo, 'normal'); // 设置用户名在网页显示 ClientData::saveClientData(Login::$clientDataIsUserLoginKey, true); ClientData::saveClientData(Login::$clientDataUserNameDisplayKey, $user->user_name); $this->addFlashMessage("注册成功"); // 跳转到用户之前看的页面,如果之前没有看过的页面那就回到首页 RouteHelper::jumpBack($this, '/', true); return; // 这里正常返回 out_fail: // 失败,从这里出口 $smarty->display('user_login.tpl', 'User|Register|post'); }
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'); // 手机输入,输入法经常无故添加空格,我们需要去除所有的空额,防止出错 $p_captcha = Utils::filterAlnumStr($p_captcha); // 需要跳转回去的地址 $returnUrl = $validator->validate('returnUrl'); if (!$this->validate($validator)) { goto out_fail; } // 检查验证码是否有效 $captchaController = new \Controller\Image\Captcha(); if (!$captchaController->validateCaptcha($p_captcha)) { $this->addFlashMessage('验证码错误[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']'); goto out_fail; } $userService = new UserService(); // 验证用户登陆 $user = $userService->doAuthUser($input['user_name'], $input['user_name'], $input['password']); if (!$user) { $this->addFlashMessage("登陆失败,用户名、密码错误"); goto out_fail; } // 记录用户的登陆信息 $userInfo = $user->toArray(); unset($userInfo['password']); // 不要记录密码 AuthHelper::saveAuthUser($userInfo, 'normal'); $this->addFlashMessage("登陆成功"); if ($returnUrl) { header('Location:' . $returnUrl); return; } else { // 跳转到用户之前看的页面,如果之前没有看过的页面那就回到首页 RouteHelper::jumpBack($this, '/', true); } return; // 这里正常返回 out_fail: // 失败从这里出口 $smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time()))); $smarty->display('user_login.tpl', 'User|Login|post'); }
public function post($f3) { global $smarty; // 首先做参数合法性验证 $validator = new Validator($f3->get('POST')); $input = array(); $input['oldpassword'] = $validator->validate('oldpassword'); $input['password'] = $validator->validate('password'); $input['email'] = $validator->validate('email'); $input['mobile_phone'] = $validator->digits('手机号格式不对')->validate('mobile_phone'); // 用户打算修改密码 if (!Utils::isBlank($input['password'])) { $validator->required('必须提供旧密码才能修改密码')->validate('oldpassword'); } // 提供的旧密码,但是新密码为空 if (!Utils::isBlank($input['oldpassword'])) { $validator->required('新密码不能为空')->validate('password'); } if (!$this->validate($validator)) { goto out_fail; } $userInfo = AuthHelper::getAuthUser(); $userService = new UserService(); $user = $userService->loadUserById($userInfo['user_id']); if (!$user) { // 非法用户,应该让它自动登陆出去 $this->addFlashMessage('非法登陆用户'); RouteHelper::reRoute($this, '/User/Logout', false); } // 用户打算修改密码,但是旧密码不对 if (!empty($input['password']) && !$userService->verifyPassword($userInfo['user_id'], $input['oldpassword'])) { $this->addFlashMessage('旧密码不对'); goto out_fail; } // 更新数据 unset($input['oldpassword']); $userService->updateUser($user, $input); // 更新认证记录 AuthHelper::removeAuthUser(); AuthHelper::saveAuthUser($user->toArray()); $this->addFlashMessage('资料更新成功'); RouteHelper::reRoute($this, '/My/Profile'); return; // 这里正常返回 out_fail: // 失败返回 $smarty->display('my_profile.tpl', 'post'); }
public function post($f3) { global $smarty; // 首先做参数合法性验证 $validator = new Validator($f3->get('POST')); $input = array(); $input['phone'] = $validator->validate('phone'); $input['address'] = $validator->validate('address'); $input['oldpassword'] = $validator->validate('oldpassword'); $input['password'] = $validator->validate('password'); // 用户打算修改密码 if (!Utils::isBlank($input['password'])) { $validator->required('必须提供旧密码才能修改密码')->validate('oldpassword'); } // 提供的旧密码,但是新密码为空 if (!Utils::isBlank($input['oldpassword'])) { $validator->required('新密码不能为空')->validate('password'); } if (!$this->validate($validator)) { goto out; } $authSupplierUser = AuthHelper::getAuthUser(); $supplierUserService = new SupplierUserService(); // 验证用户登陆 $supplierUser = $supplierUserService->loadSupplierById($authSupplierUser['suppliers_id']); if ($supplierUser->isEmpty()) { $this->addFlashMessage("非法登陆用户"); RouteHelper::reRoute($this, '/User/Logout', false); } // 用户打算修改密码,但是旧密码不对 if (!empty($input['password']) && !$supplierUserService->verifyPassword($authSupplierUser['suppliers_id'], $input['oldpassword'])) { $this->addFlashMessage('旧密码不对'); goto out; } // 更新数据 unset($input['oldpassword']); $supplierUserService->updateSupplier($supplierUser, $input); // 记录用户的登陆信息 $supplierUserInfo = $supplierUser->toArray(); unset($supplierUserInfo['password']); // 不要记录密码 AuthHelper::saveAuthUser($supplierUserInfo); $this->addFlashMessage("修改资料成功"); $smarty->assign($supplierUserInfo); out: // 从这里出去 $smarty->display('my_profile.tpl'); }
public function clearArticleCacheById($f3) { // 权限检查 $this->requirePrivilege('manage_misc_cache'); // 参数验证 $validator = new Validator($f3->get('POST')); $article_id = $validator->required('商品ID不能为空')->digits()->validate('article_id'); if (!$this->validate($validator)) { goto out; } ClearHelper::clearArticleCacheById($article_id); $this->addFlashMessage('商品[' . $article_id . ']页面清理成功'); out: // 从这里退出 RouteHelper::reRoute($this, RouteHelper::getRefer(), false); }
public function get($f3) { // 清除客户端所有数据 ClientData::clearClientData(); // 清除服务器端数据 AuthHelper::removeAuthUser(); $f3->clear('SESSION'); $this->addFlashMessage('成功退出登陆'); $backUrl = RouteHelper::getRefer(); if (Utils::isBlank($backUrl)) { // 没有来路域名则返回首页 $backUrl = '/'; } // 刷新当前页面 RouteHelper::reRoute($this, $backUrl, false); }
public function get($f3) { // 权限检查 $this->requirePrivilege('manage_goods_edit_edit_get'); // 参数验证 $validator = new Validator($f3->get('GET')); $goods_id = $validator->required('商品ID不能为空')->digits()->min(1)->validate('goods_id'); if (!$this->validate($validator)) { goto out; } // 清除商品缓存 ClearHelper::clearGoodsCacheById($goods_id); $this->addFlashMessage('商品[' . $goods_id . '] 缓存清除成功'); out: RouteHelper::reRoute($this, RouteHelper::getRefer(), false); }
/** * 更新或者新建一个快递公司 * * @param $f3 */ public function Edit($f3) { // 权限检查 $this->requirePrivilege('manage_misc_express_edit'); global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $meta_id = $validator->digits()->validate('meta_id'); $meta_id = $meta_id ?: 0; // 加载 快递信息 $expressService = new ExpressService(); $expressInfo = $expressService->loadMetaById($meta_id); if (Request::isRequestGet()) { goto out_assign; } // 安全性检查 if ($meta_id > 0) { if ($expressInfo->isEmpty() || ExpressService::META_TYPE != $expressInfo->meta_type) { $this->addFlashMessage('非法ID[' . $meta_id . ']'); goto out; } } unset($validator); $validator = new Validator($f3->get('POST')); $inputArray = array(); $inputArray['meta_type'] = ExpressService::META_TYPE; $inputArray['meta_name'] = $validator->required()->validate('meta_name'); $inputArray['meta_ename'] = $validator->required()->validate('meta_ename'); $inputArray['meta_sort_order'] = $validator->digits()->validate('meta_sort_order'); $inputArray['meta_status'] = $validator->digits()->validate('meta_status'); $inputArray['meta_desc'] = $validator->validate('meta_desc'); if (!$this->validate($validator)) { goto out; } // 保存 $expressInfo->copyFrom($inputArray); $expressInfo->save(); $this->addFlashMessage('快递信息保存成功'); // POST 成功从这里退出 RouteHelper::reRoute($this, RouteHelper::makeUrl('/Misc/Express/Edit', array('meta_id' => $expressInfo->meta_id), true)); return; out_assign: $smarty->assign($expressInfo->toArray()); out: $smarty->display('misc_express_edit.tpl'); }
public function get($f3) { global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $pageNo = $validator->digits()->min(0)->validate('pageNo'); $pageSize = $validator->digits()->min(0)->validate('pageSize'); // 设置缺省值 $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0; $pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10; if (!$this->validate($validator)) { goto out_display; } $userInfo = AuthHelper::getAuthUser(); // 构造查询条件 $searchFormQuery = array(); $searchFormQuery['oi.user_id'] = $userInfo['user_id']; // 合并查询参数 $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray); // 查询订单 $totalCount = SearchHelper::count(SearchHelper::Module_OrderGoodsOrderInfo, $searchParamArray); if ($totalCount <= 0) { // 没订单,可以直接退出了 goto out_display; } // 页数超过最大值,返回第一页 if ($pageNo * $pageSize >= $totalCount) { RouteHelper::reRoute($this, '/My/Order'); } // 订单排序 $orderByParam = array(); $orderByParam[] = array('og.rec_id', 'desc'); // 订单列表 $orderGoodsArray = SearchHelper::search(SearchHelper::Module_OrderGoodsOrderInfo, 'og.order_id, og.goods_id, og.goods_attr, og.goods_number, og.goods_price, og.shipping_fee' . ', og.create_time, og.order_goods_status, oi.order_sn, oi.pay_time', $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize); foreach ($orderGoodsArray as &$orderGoodsItem) { $orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']]; } unset($orderGoodsItem); // 给模板赋值 $smarty->assign('totalCount', $totalCount); $smarty->assign('pageNo', $pageNo); $smarty->assign('pageSize', $pageSize); $smarty->assign('orderGoodsArray', $orderGoodsArray); out_display: $smarty->display('my_order.tpl', 'get'); }
public function get($f3) { global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $pageNo = $validator->digits()->min(0)->validate('pageNo'); $pageSize = $validator->digits()->min(0)->validate('pageSize'); // 设置缺省值 $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0; $pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10; if (!$this->validate($validator)) { goto out_display; } $userInfo = AuthHelper::getAuthUser(); $userBasicService = new UserBasicService(); $userInfo = $userBasicService->loadUserById($userInfo['user_id']); // 用户总共有资金余额 $smarty->assign('userMoney', $userInfo['user_money']); $accountLog = new AccountLogService(); // 用户总共有多少account_log $totalCount = $accountLog->countUserMoneyArray($userInfo['user_id'], 10); //缓存 10 秒钟 if ($totalCount <= 0) { // 没资金变动记录,可以直接退出了 goto out_display; } $smarty->assign('totalCount', $totalCount); // 页数超过最大值,返回第一页 if ($pageNo * $pageSize >= $totalCount) { RouteHelper::reRoute($this, '/My/Money'); } // 传递分页的变量 $smarty->assign('pageNo', $pageNo); $smarty->assign('pageSize', $pageSize); // account_log 列表 $accountLogArray = $accountLog->fetchUserMoneyArray($userInfo['user_id'], $pageNo * $pageSize, $pageSize, 10); //缓存 10 秒钟 foreach ($accountLogArray as &$accountLogItem) { $accountLogItem['change_type_desc'] = AccountLogService::$changeTypeDesc[$accountLogItem['change_type']]; } unset($accountLogItem); $smarty->assign('accountLogArray', $accountLogArray); out_display: $smarty->display('my_money.tpl', 'get'); }
public function Edit($f3) { // 权限检查 $this->requirePrivilege('manage_article_category_edit'); global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $meta_id = $validator->digits()->validate('meta_id'); $meta_id = $meta_id ?: 0; // 加载 分类信息 $articleCategoryService = new ArticleCategoryService(); $articleCategory = $articleCategoryService->loadArticleCategoryById($meta_id); if (Request::isRequestGet()) { goto out_assign; } // 安全性检查 if ($meta_id > 0) { if ($articleCategory->isEmpty() || ArticleCategoryService::META_TYPE != $articleCategory->meta_type) { $this->addFlashMessage('非法ID[' . $meta_id . ']'); goto out; } } unset($validator); $validator = new Validator($f3->get('POST')); $inputArray = array(); $inputArray['meta_type'] = ArticleCategoryService::META_TYPE; $inputArray['meta_name'] = $validator->required()->validate('meta_name'); $inputArray['meta_sort_order'] = $validator->digits()->validate('meta_sort_order'); $inputArray['meta_desc'] = $validator->validate('meta_desc'); if (!$this->validate($validator)) { goto out; } // 保存 $articleCategory->copyFrom($inputArray); $articleCategory->save(); $this->addFlashMessage('分类信息保存成功'); // POST 成功从这里退出 RouteHelper::reRoute($this, RouteHelper::makeUrl('/Article/Category/Edit', array('meta_id' => $articleCategory->meta_id), true)); return; out_assign: $smarty->assign($articleCategory->toArray()); out: $smarty->display('article_category_edit.tpl'); }