ECShop代码剖析

来源:互联网 发布:php语言能做什么 编辑:程序博客网 时间:2024/05/26 17:48
ECShop代码分析:
1:index.php首页:
index.php->init.php
require(ROOT_PATH . 'includes/inc_constant.php');//定义系统使用到的一些全局常量
require(ROOT_PATH . 'includes/cls_ecshop.php');//class ECS:获取表,图片数据,md5密码, URL, http/https协议数据工作.
require(ROOT_PATH . 'includes/cls_error.php');
require(ROOT_PATH . 'includes/lib_time.php');
require(ROOT_PATH . 'includes/lib_base.php');//字符编码,全角/半角转码, utf-8转码, 读写缓存文件.上传文家,防止script攻击.
require(ROOT_PATH . 'includes/lib_common.php');//数据库交互,获取配置,商品,商品分类,价格,重量等信息,总之读写数据库.
require(ROOT_PATH . 'includes/lib_main.php');//根据用户行为来显示当前位置,商品列表,商品详情,购买记录,购买评论等信息.
require(ROOT_PATH . 'includes/lib_insert.php');//根据用户行为对需要信息插入行为进行记录.如浏览历史,商品评论等.
require(ROOT_PATH . 'includes/lib_goods.php');//商品相关信息
require(ROOT_PATH . 'includes/lib_article.php');//文章信息

/* 载入系统参数 */
$_CFG = load_config(); //读取数据库的ecs_shop_config表,里面有一些诸如:网站标题,备案ICP路径, 语言设置, 缓存等配置信息, 
                                      //以后看到诸如 $_CFG['stylename'],  stylename就是表里面配置项参数之一.

/* 载入语言文件 */
require(ROOT_PATH . 'languages/' . $_CFG['lang'] . '/common.php'); //languages/common.php文件保存所有网站硬编码信息.

//登陆时创建 session.
//创建smarty对象, 规定了语言(lang),字符集编码(ecs_charset),  ecs的css路径(ecs_css_path).
$smarty->assign('lang', $_LANG);
          $smarty->assign('ecs_charset', EC_CHARSET);
         //如果stylename在数据库表ecs_shop_config配置不为空,那么路径就是"themes/$_CFG['template']/style_$_CFG['stylename'].css",
         //否则路径即为 "themes/ $_CFG['template']/style$_CFG['stylename'] .css"
if (!empty($_CFG['stylename']))
{
       $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style_' . $_CFG['stylename'] . '.css');
}
else
{
      $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style.css');
}

//会员登陆进来后相关信息获取, 如广告相关信息,没有详细看.
//如果启动调试模式4的话,会包含进include/lib.debug.php文件.
//判断是否支持gzip模式. ob_start('ob_gzhandler') 或 ob_start();

$smarty->display('index.dwt', $cache_id);//调用index.dwt模板.

1.1: index.dwt过程分析.
head部分:
<link href="{$ecs_css_path}" rel="stylesheet" type="text/css" />//加载的样式路径
{insert_scripts files='common.js, index.js'}//加载需要使用的脚本文件. common.js index.js
body部分:
加载library/page_header.lbi库文件.

待续:
原创粉丝点击