zoukankan      html  css  js  c++  java
  • 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/

  • 相关阅读:
    CareerCup Questions List 职业杯题目列表
    [CareerCup] Guards in a museum 博物馆的警卫
    [LeetCode] 7. Reverse Integer 翻转整数
    Python笔记11------一个K-means聚类的小例子
    python笔记10-----便捷网络数据NLTK语料库
    Python笔记9-----不等长列表转化成DataFrame
    Python笔记8----DataFrame(二维)
    Python笔记7----Pandas中变长字典Series
    Python笔记6----数组
    Python笔记5----集合set
  • 原文地址:https://www.cnblogs.com/puzi0315/p/2644804.html
Copyright © 2011-2022 走看看