本文整理汇总了PHP中write_static_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP write_static_cache函数的具体用法?PHP write_static_cache怎么用?PHP write_static_cache使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_static_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
$this->CI =& get_instance();
//变量可以在这里定义,或者来自配置文件,也可以去数据
$smtp = read_static_cache("smtp_config");
$website = read_static_cache("website_config");
$upload = read_static_cache("upload_config");
$this->CI->load->model("sk_admin/systemconfig_model");
if (empty($smtp)) {
$where = array("app_name" => "smtp");
$smtp_list = $this->CI->systemconfig_model->getAll($where);
$smtp = array();
if ($smtp_list && count($smtp_list) > 0) {
foreach ($smtp_list as $k => $v) {
$smtp[$v['paras']] = $v['value'];
}
}
if (!empty($smtp)) {
write_static_cache("smtp_config", $smtp);
}
}
if (empty($website)) {
$where = array("app_name" => "website");
$website_list = $this->CI->systemconfig_model->getAll($where);
$website = array();
if ($website_list && count($website_list) > 0) {
foreach ($website_list as $k => $v) {
$website[$v['paras']] = $v['value'];
}
}
if (!empty($website)) {
write_static_cache("website_config", $website);
}
}
if (empty($upload)) {
$where = array("app_name" => "upload");
$upload_list = $this->CI->systemconfig_model->getAll($where);
$upload = array();
if ($upload_list && count($upload_list) > 0) {
foreach ($upload_list as $k => $v) {
$upload[$v['paras']] = $v['value'];
}
}
if (!empty($upload)) {
write_static_cache("upload_config", $upload);
}
}
$this->variable['smtp'] = $smtp;
$this->variable['website'] = $website;
$this->variable['upload'] = $upload;
$this->CI->load->vars($this->variable);
}
示例2: refresh_subsite_cache
function refresh_subsite_cache()
{
global $db, $_CFG;
$cache_file_path = QISHI_ROOT_PATH . "data/cache_subsite.php";
$cache_file_path_m = QISHI_ROOT_PATH . "data/cache_m_subsite.php";
$sql = "SELECT * FROM " . table('subsite') . " WHERE s_effective=1 ORDER BY s_order desc,s_id desc";
$arr = $db->getall($sql);
foreach ($arr as $key => $val) {
$s_m_domain_key = $val['s_m_domain'] ? $val['s_m_domain'] : $val['s_domain'];
$config_arr[$val['s_domain']] = array("id" => $val['s_id'], "sitename" => $val['s_sitename'], "domain" => 'http://' . $val['s_domain'] . '/', "m_domain" => $val['s_m_domain'] ? 'http://' . $val['s_m_domain'] . '/' : 'http://' . $val['s_domain'] . '/m/', "district" => $val['s_district'], "districtname" => $val['s_districtname'], "tpl" => $val['s_tpl'], "logo" => $val['s_logo'], "title" => $val['s_title'], "keywords" => $val['s_keywords'], "description" => $val['s_description']);
$config_m_arr[$s_m_domain_key] = array("id" => $val['s_id'], "sitename" => $val['s_sitename'], "domain" => 'http://' . $val['s_domain'] . '/', "m_domain" => $val['s_m_domain'] ? 'http://' . $val['s_m_domain'] . '/' : 'http://' . $val['s_domain'] . '/m/', "district" => $val['s_district'], "districtname" => $val['s_districtname'], "tpl" => $val['s_tpl'], "logo" => $val['s_logo'], "title" => $val['s_title'], "keywords" => $val['s_keywords'], "description" => $val['s_description']);
}
write_static_cache($cache_file_path, $config_arr);
write_static_cache($cache_file_path_m, $config_m_arr);
}
示例3: transport
$apiget = "ver= {$ecs_version} &ecs_lang= {$ecs_lang} &charset= {$ecs_charset} ";
$t = new transport();
$api_comment = $t->request('http://cloud.ecshop.com/menu_api.php', $apiget);
$api_str = $api_comment["body"];
if (!empty($api_str)) {
include_once ROOT_PATH . 'includes/cls_json.php';
$json = new JSON();
$api_arr = @$json->decode($api_str, 1);
if (!empty($api_arr) && $api_arr['error'] == 0 && md5($api_arr['content']) == $api_arr['hash']) {
$api_arr['content'] = urldecode($api_arr['content']);
if ($ecs_charset != 'UTF-8') {
$api_arr['content'] = ecs_iconv('UTF-8', $ecs_charset, $api_arr['content']);
}
echo $api_arr['content'];
$api_arr['api_time'] = date('dmY');
write_static_cache('menu_api', $api_arr);
exit;
} else {
exit;
}
} else {
exit;
}
} else {
die($data['content']);
}
} elseif ($_REQUEST['act'] == 'first') {
$smarty->assign('countries', get_regions());
$smarty->assign('provinces', get_regions(1, 1));
$smarty->assign('cities', get_regions(2, 2));
$sql = 'SELECT value from ' . $ecs->table('shop_config') . " WHERE code='shop_name'";
示例4: 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;
}
示例5: digui
/**
*@param int $parent_id 父id
*@return array $arr 有层级的数组
*/
function digui($arrayinfo = array(), $parent_id = 0)
{
global $db, $ecs;
$data = read_static_cache('city_tree_68');
if ($data !== false && is_array($data)) {
return $data;
}
if (empty($arrayinfo)) {
$sql = "select * from " . $ecs->table('region');
$arrayinfo = $db->getAll($sql);
}
$arr = array();
foreach ($arrayinfo as $key => $val) {
if ($val['parent_id'] == $parent_id) {
$region_id = $val['region_id'];
$arr[$region_id] = array('id' => $region_id, 'text' => $val['region_name'], 'level' => $val['region_type'], 'parent_id' => $val['parent_id']);
unset($arrayinfo[$key]);
$arr[$region_id]['child'] = digui($arrayinfo, $region_id);
if (empty($arr[$region_id]['child'])) {
$arr[$region_id]['child'] = null;
}
}
}
write_static_cache('city_tree_68', $arr);
return $arr;
}
示例6: refresh_content_key_link_cache
/**
* 内容聚合关键字缓存
* @return [type] [description]
*/
function refresh_content_key_link_cache($cachename)
{
global $db;
$data = "";
$cache_file_path = QISHI_ROOT_PATH . "data/cache_" . $cachename . ".php";
$sql = "SELECT * FROM " . table($cachename);
$arr = $db->getall($sql);
write_static_cache($cache_file_path, $arr);
}
示例7: get_parent_grade
/**
* 取得最近的上级分类的grade值.
*
* @param int $cat_id //当前的cat_id
*
* @return int
*/
function get_parent_grade($cat_id)
{
static $res = null;
if ($res === null) {
$data = read_static_cache('cat_parent_grade');
if ($data === false) {
$sql = 'SELECT parent_id, cat_id, grade ' . ' FROM ' . $GLOBALS['ecs']->table('category');
$res = $GLOBALS['db']->getAll($sql);
write_static_cache('cat_parent_grade', $res);
} else {
$res = $data;
}
}
if (!$res) {
return 0;
}
$parent_arr = array();
$grade_arr = array();
foreach ($res as $val) {
$parent_arr[$val['cat_id']] = $val['parent_id'];
$grade_arr[$val['cat_id']] = $val['grade'];
}
while ($parent_arr[$cat_id] > 0 && $grade_arr[$cat_id] == 0) {
$cat_id = $parent_arr[$cat_id];
}
return $grade_arr[$cat_id];
}
示例8: get_recommend_goods
/**
* 获得推荐商品
*
* @access public
* @param string $type 推荐类型,可以是 best, new, hot
* @return array
*/
function get_recommend_goods($type = '', $cats = '')
{
if (!in_array($type, array('best', 'new', 'hot'))) {
return array();
}
//取不同推荐对应的商品
static $type_goods = array();
if (empty($type_goods[$type])) {
//初始化数据
$type_goods['best'] = array();
$type_goods['new'] = array();
$type_goods['hot'] = array();
$data = read_static_cache('recommend_goods');
if ($data === false) {
$sql = 'SELECT g.goods_id, g.is_best, g.is_new, g.is_hot, g.is_promote, b.brand_name,g.sort_order ' . ' FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . ' LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.is_best = 1 OR g.is_new =1 OR g.is_hot = 1)' . ' ORDER BY g.sort_order, g.last_update DESC';
$goods_res = $GLOBALS['db']->getAll($sql);
//定义推荐,最新,热门,促销商品
$goods_data['best'] = array();
$goods_data['new'] = array();
$goods_data['hot'] = array();
$goods_data['brand'] = array();
if (!empty($goods_res)) {
foreach ($goods_res as $data) {
if ($data['is_best'] == 1) {
$goods_data['best'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['is_new'] == 1) {
$goods_data['new'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['is_hot'] == 1) {
$goods_data['hot'][] = array('goods_id' => $data['goods_id'], 'sort_order' => $data['sort_order']);
}
if ($data['brand_name'] != '') {
$goods_data['brand'][$data['goods_id']] = $data['brand_name'];
}
}
}
write_static_cache('recommend_goods', $goods_data);
} else {
$goods_data = $data;
}
$time = gmtime();
$order_type = $GLOBALS['_CFG']['recommend_order'];
//按推荐数量及排序取每一项推荐显示的商品 order_type可以根据后台设定进行各种条件显示
static $type_array = array();
$type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot');
if (empty($type_array)) {
foreach ($type2lib as $key => $data) {
if (!empty($goods_data[$key])) {
$num = get_library_number($data);
$data_count = count($goods_data[$key]);
$num = $data_count > $num ? $num : $data_count;
if ($order_type == 0) {
//usort($goods_data[$key], 'goods_sort');
$rand_key = array_slice($goods_data[$key], 0, $num);
foreach ($rand_key as $key_data) {
$type_array[$key][] = $key_data['goods_id'];
}
} else {
$rand_key = array_rand($goods_data[$key], $num);
if ($num == 1) {
$type_array[$key][] = $goods_data[$key][$rand_key]['goods_id'];
} else {
foreach ($rand_key as $key_data) {
$type_array[$key][] = $goods_data[$key][$key_data]['goods_id'];
}
}
}
} else {
$type_array[$key] = array();
}
}
}
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' ";
$type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
$type_merge = array_unique($type_merge);
$sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
$sql .= ' ORDER BY g.sort_order, g.last_update DESC';
$result = $GLOBALS['db']->getAll($sql);
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
//.........这里部分代码省略.........
示例9: urlencode
$ecs_style = $style;
$shop_url = urlencode($ecs->url());
$patch_file = file_get_contents(ROOT_PATH.ADMIN_PATH."/patch_num");
$apiget = "ver= $ecs_version &lang= $ecs_lang &release= $ecs_release &php_ver= $php_ver &mysql_ver= $mysql_ver &ocount= $ocount &oamount= $oamount &gcount= $gcount &charset= $ecs_charset &usecount= $ecs_user &template= $ecs_template &style= $ecs_style &url= $shop_url &patch= $patch_file ";
$t = new transport;
$api_comment = $t->request('http://ecshop.ecmoban.com/checkver.php', $apiget);
$api_str = $api_comment["body"];
echo $api_str;
$f=ROOT_PATH . 'data/config.php';
file_put_contents($f,str_replace("'API_TIME', '".API_TIME."'","'API_TIME', '".date('Y-m-d H:i:s',time())."'",file_get_contents($f)));
write_static_cache('api_str', $api_str);
}
else
{
echo $data;
}
}
/*------------------------------------------------------ */
//-- 开店向导第一步
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'first')
{
示例10: die
die($json->encode($result_url));
} elseif ($_POST['act'] == 'word_search') {
$keyword = !empty($_POST['keyword']) ? $_POST['keyword'] : '';
$sql = "SELECT region_id,region_name,pinyin FROM " . $ecs->table('region') . " WHERE region_name LIKE '{$keyword}%' OR pinyin LIKE '{$keyword}%'";
$rows = $db->getAll($sql);
//dump($rows);
die($json->encode($rows));
} elseif ($_POST['act'] == 'capital_search') {
#读取缓存
$rows = read_static_cache('region');
if ($rows === false) {
$sql = "SELECT region_id,region_name,capital FROM " . $ecs->table('region') . " WHERE region_type = 2 ORDER BY capital ASC";
$rows = array();
$rows = $db->getAll($sql);
#写入缓存
write_static_cache('region', $rows);
}
/* 对数据进行组装 start */
$arr = array();
foreach ($rows as $key => $value) {
$arr[$value['capital']][] = $value;
}
$html = '';
foreach ($arr as $k => $v) {
$city = '';
$html .= "<li id='city-A' class=''><div class='cf fn-clear'><div class='label'><strong>" . $k . "</strong></div><div class='label-city fn-clear'>";
foreach ($v as $city_k => $city_v) {
$city .= "<div class='city-content'><a class='link' onclick='jq_cookie({$city_v['region_id']})' value='{$city_v['region_id']}' " . " style='font-size:14px;' target='_self' href='{$url}'>{$city_v['region_name']}</a>" . '<div class="city-county">';
$res = array();
$sql = "SELECT region_id,region_name,capital FROM " . $ecs->table('region') . " WHERE parent_id = {$city_v['region_id']} ORDER BY capital ASC";
$res = $db->getAll($sql);
示例11: digui
/**
*@param int $parent_id 父id
*@return array $arr 有层级的数组
*/
function digui($arrayinfo = array(), $parent_id = 0)
{
global $db, $ecs;
$data = read_static_cache('city_tree_68');
//if($data !== false && is_array($data)){
// return $data;
//}
$select_region = create_ever_sql();
if (count($select_region) > 0) {
$where = " where region_id not in (" . implode(',', $select_region) . ")";
} else {
$where = '';
}
$sql = "select * from " . $ecs->table('region') . $where;
$arrayinfo = $db->getAll($sql);
$arr = array();
$arr = sss($arrayinfo, 0);
write_static_cache('city_tree_68', $arr);
return $arr;
}
示例12: update_configure
update_configure($code, '');
/* 记录日志 */
admin_log('', 'edit', 'shop_config');
/* 清除缓存 */
clear_all_files();
sys_msg($_LANG['save_success'], 0);
} elseif ($_REQUEST['act'] == 'shop_cache') {
/* 检查权限 */
check_authz_json('shop_config');
$sql = "SELECT * FROM " . $ecs->table('shop') . " WHERE status > 0";
$rs = $db->getAll($sql);
$shop_list = array();
foreach ($rs as &$shop) {
$shop_list[$shop['shop_id']] = $shop;
}
write_static_cache('shop_list', $shop_list);
// copy to mobile dir
$src = ROOT_PATH . 'temp/static_caches/shop_list.php';
$dest = ROOT_PATH . 'mobile/data/static_caches/shop_list.php';
@copy($src, $dest);
}
/**
* 设置系统设置
*
* @param string $key
* @param string $val
*
* @return boolean
*/
function update_configure($key, $val = '')
{
示例13: load_config
/**
* 载入配置信息
* @access public
* @return array
*/
public function load_config()
{
$data = read_static_cache('touch_shop_config');
if ($data === false) {
$sql = 'SELECT code, value FROM ' . $this->pre . 'touch_shop_config WHERE parent_id > 0';
$res = $this->query($sql);
$arr1 = array();
foreach ($res as $row) {
$arr1[$row['code']] = $row['value'];
}
$sql = 'SELECT code, value FROM ' . $this->pre . 'shop_config WHERE parent_id > 0';
$res = $this->query($sql);
$arr2 = array();
foreach ($res as $row) {
$arr2[$row['code']] = $row['value'];
}
$arr = array_merge($arr2, $arr1);
/* 对数值型设置处理 */
$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']) : __ROOT__ . '/data/common/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;
// 显示方式默认为列表方式
$ecs_version = C('ecs_version');
if (!isset($ecs_version)) {
/* 如果没有版本号则默认为2.0.5 */
C('ecs_version', 'v2.7.3');
}
//限定语言项
$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('touch_shop_config', $arr);
} else {
$arr = $data;
}
$config = array();
foreach ($arr as $key => $vo) {
$config[strtoupper($key)] = $vo;
}
return $config;
}
示例14: get_parent_grade
/**
* 取得最近的上级分类的grade值
*
* @access public
* @param int $cat_id //当前的cat_id
*
* @return int
*/
function get_parent_grade($cat_id)
{
static $res = NULL;
if ($res === NULL) {
$data = read_static_cache('cat_parent_grade_supplier' . $_GET['suppId']);
if ($data === false) {
$sql = "SELECT parent_id, cat_id, grade " . " FROM " . $GLOBALS['ecs']->table('supplier_category') . "WHERE supplier_id=" . $_GET['suppId'];
$res = $GLOBALS['db']->getAll($sql);
write_static_cache('cat_parent_grade_supplier' . $_GET['suppId'], $res);
} else {
$res = $data;
}
}
if (!$res) {
return 0;
}
$parent_arr = array();
$grade_arr = array();
foreach ($res as $val) {
$parent_arr[$val['cat_id']] = $val['parent_id'];
$grade_arr[$val['cat_id']] = $val['grade'];
}
while ($parent_arr[$cat_id] > 0 && $grade_arr[$cat_id] == 0) {
$cat_id = $parent_arr[$cat_id];
}
return $grade_arr[$cat_id];
}
示例15: cat_options
/**
* 过滤和排序所有分类,返回一个带有缩进级别的数组
*
* @access private
* @param int $cat_id 上级分类ID
* @param array $arr 含有所有分类的数组
* @param int $level 级别
* @return void
*/
function cat_options($spec_cat_id, $arr) {
static $cat_options = array();
if (isset($cat_options[$spec_cat_id])) {
return $cat_options[$spec_cat_id];
}
if (!isset($cat_options[0])) {
$level = $last_cat_id = 0;
$options = $cat_id_array = $level_array = array();
$data = read_static_cache('cat_option_static');
if ($data === false) {
while (!empty($arr)) {
foreach ($arr AS $key => $value) {
$cat_id = $value['cat_id'];
if ($level == 0 && $last_cat_id == 0) {
if ($value['parent_id'] > 0) {
break;
}
$options[$cat_id] = $value;
$options[$cat_id]['level'] = $level;
$options[$cat_id]['id'] = $cat_id;
$options[$cat_id]['name'] = $value['cat_name'];
unset($arr[$key]);
if ($value['has_children'] == 0) {
continue;
}
$last_cat_id = $cat_id;
$cat_id_array = array($cat_id);
$level_array[$last_cat_id] = ++$level;
continue;
}
if ($value['parent_id'] == $last_cat_id) {
$options[$cat_id] = $value;
$options[$cat_id]['level'] = $level;
$options[$cat_id]['id'] = $cat_id;
$options[$cat_id]['name'] = $value['cat_name'];
unset($arr[$key]);
if ($value['has_children'] > 0) {
if (end($cat_id_array) != $last_cat_id) {
$cat_id_array[] = $last_cat_id;
}
$last_cat_id = $cat_id;
$cat_id_array[] = $cat_id;
$level_array[$last_cat_id] = ++$level;
}
} elseif ($value['parent_id'] > $last_cat_id) {
break;
}
}
$count = count($cat_id_array);
if ($count > 1) {
$last_cat_id = array_pop($cat_id_array);
} elseif ($count == 1) {
if ($last_cat_id != end($cat_id_array)) {
$last_cat_id = end($cat_id_array);
} else {
$level = 0;
$last_cat_id = 0;
$cat_id_array = array();
continue;
}
}
if ($last_cat_id && isset($level_array[$last_cat_id])) {
$level = $level_array[$last_cat_id];
} else {
$level = 0;
}
}
//如果数组过大,不采用静态缓存方式
if (count($options) <= 2000) {
write_static_cache('cat_option_static', $options);
}
} else {
$options = $data;
}
$cat_options[0] = $options;
} else {
$options = $cat_options[0];
}
if (!$spec_cat_id) {
return $options;
} else {
if (empty($options[$spec_cat_id])) {
//.........这里部分代码省略.........