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;
}

随机推荐

  1. [转]C服务端与java客户端的socket通信注意事项

    http://blog.csdn.net/gaoxin1076/article/details/7671752 Socket网络通讯开发总结之:Java 与 C进行Socket通讯 注意以下问题: 1 ...

  2. warning: Could not canonicalize hostname: vpn

    warning: Could not canonicalize hostname: vpn vim /etc/hosts 127.0.0.1 hostname

  3. 意大利进口的衬衫面料pH值严重超标·都市快报

    意大利进口的衬衫面料pH值严重超标·都市快报     意大利进口的衬衫面料pH值严重超标         董捷    2007-03-24           通讯员 浙 检 记 者 董 捷      ...

  4. segment

    1.segmentedControlStyle 设置segment的显示样式. typedef NS_ENUM(NSInteger, UISegmentedControlStyle) { UISegm ...

  5. 对于数组(字符串)slice方法的总结

    数组(字符串)使用slice方法的目的就是截取目标数组(字符串),通俗的来讲就是截取想要的.网上有很多slice方法的实例加以说明,在此主要是从特殊到一般对此方法进行了总结. 先说总结的方法,再看下面 ...

  6. 3Dmax导出fbx文件缺失纹理问题

  7. ScheduledExecutorService定时周期运行指定的任务

    一:简单说明 ScheduleExecutorService接口中有四个重要的方法,当中scheduleAtFixedRate和scheduleWithFixedDelay在实现定时程序时比較方便. ...

  8. Spring4.0支持Groovy配置

    介绍 前一段时间观注了一下Spring4.0的一些特性,当中就有对Groovy配置的支持.因为临时还没有很深入的研究.所以举个小样例来说明一下怎样支持Groovy配置. package shuai.s ...

  9. Android中的Surface和SurfaceView

    一.什么是Surface 简单的说Surface对应了一块屏幕缓冲区,每个window对应一个Surface,任何View都要画在Surface的Canvas上(后面有原因解释).传统的view共享一 ...

  10. tinkphp URL重写,支持伪静态

    通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果,通常需要服务器开启URL_REWRITE模块才能支持 ...