• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Utility\Route类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Core\Helper\Utility\Route的典型用法代码示例。如果您正苦于以下问题:PHP Route类的具体用法?PHP Route怎么用?PHP Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: GalleryThumb

 /**
  * 根据 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);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:30,代码来源:Goods.php


示例2: preparePage

 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);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:30,代码来源:GoodsComment.php


示例3: get

 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;
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:30,代码来源:Redirect.php


示例4: get

 /**
  * 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}");
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:11,代码来源:Login.php


示例5: get

 public function get($f3)
 {
     AuthHelper::removeAuthUser();
     $f3->clear('SESSION');
     $this->addFlashMessage('成功退出登陆');
     // 返回首页
     RouteHelper::reRoute($this, '/', false);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:8,代码来源:Logout.php


示例6: get

 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, '/');
     // 返回首页
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:58,代码来源:View.php


示例7: smarty_helper_function_make_url

/**
 * 用于生成系统的操作链接,符合系统 URL 调用规范
 *
 * 在模板中的使用方法 {{makeUrl controller='/User/Login' username='xxx' password='xxx' }}
 *
 * 必须要有 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);
}
开发者ID:jackycgq,项目名称:bzfshop,代码行数:17,代码来源:smarty_helper.php


示例8: post

 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:57,代码来源:Register.php


示例9: pluginGetConfigureUrl

 public function pluginGetConfigureUrl($system)
 {
     // manage 系统可以配置这个插件
     if (PluginHelper::SYSTEM_MANAGE === $system) {
         return RouteHelper::makeUrl('/Theme/Shop/Index');
     }
     // 其它系统不需要配置
     return null;
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:9,代码来源:ShopThemePlugin.php


示例10: beforeRoute

 public function beforeRoute($f3)
 {
     parent::beforeRoute($f3);
     // 用户没有登陆,让用户去登陆
     if (!AuthHelper::isAuthUser()) {
         // 如果已经记录了一个回跳 URL ,则不要再覆盖这个记录了
         RouteHelper::reRoute($this, '/User/Login', !RouteHelper::hasRememberUrl());
     }
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:9,代码来源:AuthController.php


示例11: get

 /**
  * 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}");
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:12,代码来源:Login.php


示例12: get

 public function get($f3)
 {
     AdminLog::logAdminOperate('user.logout', '用户退出', 'IP:' . $f3->get('IP'));
     AuthHelper::removeAuthUser();
     $f3->clear('SESSION');
     $this->addFlashMessage('成功退出登陆');
     // 刷新当前页面
     RouteHelper::reRoute($this, '/', false);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:9,代码来源:Logout.php


示例13: get

    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);
    }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:56,代码来源:IncIndex.php


示例14: 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');
     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');
 }
开发者ID:swcug,项目名称:bzfshop,代码行数:55,代码来源:Login.php


示例15: 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:12,代码来源:HeadNav.php


示例16: get

 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:13,代码来源:LinkGoods.php


示例17: beforeRoute

 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());
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:13,代码来源:AuthController.php


示例18: post

 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:50,代码来源:Register.php


示例19: 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:49,代码来源:Login.php


示例20: 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');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:48,代码来源:Profile.php



注:本文中的Core\Helper\Utility\Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Utility\Validator类代码示例发布时间:2022-05-23
下一篇:
PHP event\user_updated类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap