$_CFG = load_config(); /* 载入系统参数 */
ecshop 中
$_CFG数组主要是放置一些系统参数,并且全站共享的数据,在使用的时候,ecshop里面常常以$GLOBALS['_CFG']全局变量的模式来处理。
ecshop 的$GLOBALS['_CFG'],主要是在includes/init.php中出现并且初始化,
$_CFG = load_config();
load_config()函数负责将参数取出来。
includes\lib_common.php 文件中包含了这个load_config()函数。
/**
* 载入配置信息
*
* @access public
* @return array
*/
function load_config()
{
$arr = array(); $data = read_static_cache('shop_config');
if ($data === false)
{
$sql = 'SELECT code, value FROM ' . $GLOBALS['ecs']->table('shop_config') . ' WHERE parent_id > 0';
$res = $GLOBALS['db']->getAll($sql); foreach ($res AS $row)
{
$arr[$row['code']] = $row['value'];
} /* 对数值型设置处理 */
$arr['watermark_alpha'] = intval($arr['watermark_alpha']);
$arr['market_price_rate'] = floatval($arr['market_price_rate']);
$arr['integral_scale'] = floatval($arr['integral_scale']);
//$arr['integral_percent'] = floatval($arr['integral_percent']);
$arr['cache_time'] = intval($arr['cache_time']);
$arr['thumb_width'] = intval($arr['thumb_width']);
$arr['thumb_height'] = intval($arr['thumb_height']);
$arr['image_width'] = intval($arr['image_width']);
$arr['image_height'] = intval($arr['image_height']);
$arr['best_number'] = !empty($arr['best_number']) && intval($arr['best_number']) > 0 ? intval($arr['best_number']) : 3;
$arr['new_number'] = !empty($arr['new_number']) && intval($arr['new_number']) > 0 ? intval($arr['new_number']) : 3;
$arr['hot_number'] = !empty($arr['hot_number']) && intval($arr['hot_number']) > 0 ? intval($arr['hot_number']) : 3;
$arr['promote_number'] = !empty($arr['promote_number']) && intval($arr['promote_number']) > 0 ? intval($arr['promote_number']) : 3;
$arr['top_number'] = intval($arr['top_number']) > 0 ? intval($arr['top_number']) : 10;
$arr['history_number'] = intval($arr['history_number']) > 0 ? intval($arr['history_number']) : 5;
$arr['comments_number'] = intval($arr['comments_number']) > 0 ? intval($arr['comments_number']) : 5;
$arr['article_number'] = intval($arr['article_number']) > 0 ? intval($arr['article_number']) : 5;
$arr['page_size'] = intval($arr['page_size']) > 0 ? intval($arr['page_size']) : 10;
$arr['bought_goods'] = intval($arr['bought_goods']);
$arr['goods_name_length'] = intval($arr['goods_name_length']);
$arr['top10_time'] = intval($arr['top10_time']);
$arr['goods_gallery_number'] = intval($arr['goods_gallery_number']) ? intval($arr['goods_gallery_number']) : 5;
$arr['no_picture'] = !empty($arr['no_picture']) ? str_replace('../', './', $arr['no_picture']) : 'images/no_picture.gif'; // 修改默认商品图片的路径
$arr['qq'] = !empty($arr['qq']) ? $arr['qq'] : '';
$arr['ww'] = !empty($arr['ww']) ? $arr['ww'] : '';
$arr['default_storage'] = isset($arr['default_storage']) ? intval($arr['default_storage']) : 1;
$arr['min_goods_amount'] = isset($arr['min_goods_amount']) ? floatval($arr['min_goods_amount']) : 0;
$arr['one_step_buy'] = empty($arr['one_step_buy']) ? 0 : 1;
$arr['invoice_type'] = empty($arr['invoice_type']) ? array('type' => array(), 'rate' => array()) : unserialize($arr['invoice_type']);
$arr['show_order_type'] = isset($arr['show_order_type']) ? $arr['show_order_type'] : 0; // 显示方式默认为列表方式
$arr['help_open'] = isset($arr['help_open']) ? $arr['help_open'] : 1; // 显示方式默认为列表方式 if (!isset($GLOBALS['_CFG']['ecs_version']))
{
/* 如果没有版本号则默认为2.0.5 */
$GLOBALS['_CFG']['ecs_version'] = 'v2.0.5';
} //限定语言项
$lang_array = array('zh_cn', 'zh_tw', 'en_us');
if (empty($arr['lang']) || !in_array($arr['lang'], $lang_array))
{
$arr['lang'] = 'zh_cn'; // 默认语言为简体中文
} if (empty($arr['integrate_code']))
{
$arr['integrate_code'] = 'ecshop'; // 默认的会员整合插件为 ecshop
}
write_static_cache('shop_config', $arr);
}
else
{
$arr = $data;
} return $arr;
}
随机推荐
- 【二分】NEERC15 L Landscape Improved(2015-2016 ACM-ICPC)(Codeforces GYM 100851)
题目链接: http://codeforces.com/gym/100851 题目大意: 一个宽度为N的网格图,i上有h[i]高的方块.现在你有W个方块,问怎么放使得最终的最高点最高. 只要一个格子的 ...
- 《算法问题实战策略》-chaper21-树的实现和遍历
这一章节开始介绍一个数据结构中的一个基本概念——树. 我们从数据结构的解读来解释树结构的重要性,现实世界的数据除了最基本的线性结构(我们常用队列.数组和链表等结构表征),还有一个重要的特性——层级结构 ...
- 10382 - Watering Grass
Problem E Watering Grass Input: standard input Output: standard output Time Limit: 3 seconds n sprin ...
- Angular过滤器 自定义及使用方法
首先设置自定义过滤器. 定义模块名:angular .module('myApp') .filter('filterName',function(){ return function(要过滤的对象,参 ...
- dom4j处理java中xml还是很方便的
http://blog.csdn.net/chenghui0317/article/details/11486271 输入: String flighter = RequestUtil.get(&qu ...
- JavaScript--execCommand指令集
execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令.处理Html数据时常用 如下格式:document.execCommand(sCmd,交互方式, 动态参数) .其中:sCm ...
- 几种任务调度的 Java 实现方法与比较--转载
前言 任务调度是指基于给定时间点,给定时间间隔或者给定执行次数自动执行任务.本文由浅入深介绍四种任务调度的 Java 实现: Timer ScheduledExecutor 开源工具包 Quartz ...
- Java基础知识强化之IO流笔记18:FileOutputStream写入数据
1. 创建字节输出流对象,做了几件事情: (1)调用系统功能去创建文件(2)创建fos对象(3)把fos对象指向这个文件 2. 代码示例: package com.himi.fileoutputstr ...
- codevs 1281 Xn数列 (矩阵乘法)
/* 再来个题练练手 scanf longlong 有bug....... */ #include<cstdio> #include<iostream> #include< ...
- HUD 2089 位数dp
/* 做的不多的位数dp 暴力的话 不知道多少组数据 会T 所以写dp 思路就和数学课本上那种“不超过xxx的x位偶数有几个” 这里可以类似的维护一个前缀和模样的东西(但又不同于前缀和) 状态:f[i ...