• ecshop index.php源代码分析


    <?php 
    
    // 根据某人的说法, 挂个鸟牌. 
    define('IN_ECS', true); 
    // 引入内核文件 
    require(dirname(__FILE__) . '/includes/init.php'); 
    
    // DEBUG_MODE在init.php中定义了0,根据常量不可重复定义的原则, 估计下面的判断永远都将是真.即不需要更新缓存. 
    // $smarty->caching 为true时, 表示不强制更新缓存. 
    if ((DEBUG_MODE & 2) != 2){ 
        $smarty->caching = true; 
    } 
    
    /*------------------------------------------------------ */ 
    //-- Shopex系统地址转换 
    /*------------------------------------------------------ */ 
    if (!empty($_GET['gOo'])) 
    { 
        if (!empty($_GET['gcat'])) 
         { 
            /* 商品分类。*/ 
            $Loaction = 'category.php?id=' . $_GET['gcat']; 
         } 
        elseif (!empty($_GET['acat'])) 
         { 
            /* 文章分类。*/ 
            $Loaction = 'article_cat.php?id=' . $_GET['acat']; 
         } 
        elseif (!empty($_GET['goodsid'])) 
         { 
            /* 商品详情。*/ 
            $Loaction = 'goods.php?id=' . $_GET['goodsid']; 
         } 
        elseif (!empty($_GET['articleid'])) 
         { 
            /* 文章详情。*/ 
            $Loaction = 'article.php?id=' . $_GET['articleid']; 
         } 
    
        if (!empty($Loaction)) 
         { 
             ecs_header("Location: $Loactionn"); 
    
            exit; 
         } 
    } 
    //判断是否有ajax请求 
    $act = !empty($_GET['act']) ? $_GET['act'] : ''; 
    if ($act == 'cat_rec') 
    { 
        $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 
        //假如有类型传过来就设置为数值类型,否则为1 
        $rec_type = !empty($_REQUEST['rec_type']) ? intval($_REQUEST['rec_type']) : '1'; 
        //同样的道理. 
        $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 
        //json应用. 
        include_once('includes/cls_json.php'); 
        $json = new JSON; 
        $result    = array('error' => 0, 'content' => '', 'type' => $rec_type, 'cat_id' => $cat_id); 
    //获得指定分类下所有底层分类的ID 
        $children = get_children($cat_id); 
        $smarty->assign($rec_array[$rec_type] . '_goods',       get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 
        $smarty->assign('cat_rec_sign', 1); 
        $result['content'] = $smarty->fetch('library/recommend_' . $rec_array[$rec_type] . '.lbi'); 
        die($json->encode($result)); 
    } 
    
    /*------------------------------------------------------ */ 
    //-- 判断是否存在缓存,如果存在则调用缓存,反之读取相应内容 
    /*------------------------------------------------------ */ 
    /* 缓存编号 */ 
    // ecshop似乎没有用户选择模式功能吧, 以下加密串多少有点令人难理解. 
    $cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang'])); 
    
    // $smarty->is_cached 方法有多低能就有多低能. 方法将返回false 或者 true. 
    if (!$smarty->is_cached('index.dwt', $cache_id)) 
    { 
    //设置默认的smarty变量数据. 
         assign_template(); 
      
        //取得当前页信息.比如标题,链接等. 
        $position = assign_ur_here(); 
        //将它赋给smarty. 
        $smarty->assign('page_title',      $position['title']);    // 页面标题 
        $smarty->assign('ur_here',         $position['ur_here']);  // 当前位置

    作者:沐雪
    文章均系作者原创或翻译,如有错误不妥之处,欢迎各位批评指正。本文版权归作者和博客园共有,如需转载恳请注明。
    如果您觉得阅读这篇博客让你有所收获,请点击右下方【推荐】
    找一找教程网-随时随地学软件编程 http://www.zyiz.net/

  • 相关阅读:
    Centos7开启telnet登录
    Centos7编译openssh8.9p1
    20220613复盘
    20220614复盘
    20220610复盘
    Maven打包遇到No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    如何隐藏滚动条,但是保留滚动效果?(考虑兼容性)
    Oracle高效查询数据是否已经存在
    Django框架redder函数的功能
    VUE框架 ajax请求案例天气预报
  • 原文地址:https://www.cnblogs.com/puzi0315/p/2644804.html
Copyright © 2020-2023  润新知