/** 北京赛车pk10 pk10开奖直播 北京赛车pk10开奖结果历史记录 * ECSHOP 首页文件 * ============================================================================ * 版权所有 2005-2010 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liuhui $ * $Id: index.php 17063 2010-03-25 06:35:46Z liuhui $ */ define('IN_ECS', true); require (dirname(__FILE__) . '/includes/init.php'); if ((DEBUG_MODE & 2) != 2) { $smarty->caching = true; } if ($GLOBALS['is_phone'] == 1) { $Loaction = 'http://m.cnbwatch.com/'; if (!empty($Loaction)) { ecs_header("Location: $Loaction\n"); exit; } } /*------------------------------------------------------ */ //-- 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: $Loaction\n"); exit; } } if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'get_hot_goods') { include('includes/cls_json.php'); $json = new JSON; $res = array('err_msg' => '', 'result' => ''); $hot_page = $_REQUEST['page'] ; $count = get_category_catgoods_count(); $max_page = ($count > 0) ? ceil($count / 5) : 1; if ($hot_page > $max_page) { $hot_page = $max_page; } if($max_page == $hot_page){ $res['err_msg'] = '没有啦!'; } $hotgoods = category_get_catgoods( 5 , $hot_page,'goods_id' ,'DESC') ; $smarty->assign('hotgoods', $hotgoods); $res['result'] = $GLOBALS['smarty']->fetch('library/index_hot_goods.lbi'); die($json->encode($res)); } $smarty->assign('article_dianpin',get_cat_articles(132,1,8)); $smarty->assign('article_xinwen',get_cat_articles(8,1,8)); $smarty->assign('article_weixiu',get_cat_articles(112,1,8)); $smarty->assign('article_yuanchuang',get_cat_articles(124,1,8)); /*新版文章调用*/ $smarty->assign('article_zhishi',get_cat_articles(112,1,5)); $smarty->assign('article_pince',get_cat_articles(134,1,5)); $smarty->assign('article_shai',get_cat_articles(97,1,5)); $smarty->assign('article_zn',get_cat_articles(8,1,5)); /* 初始化分页信息 */ /*$page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; $size = 12; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'goods_id'; //不管判断如何 都是按照后台商品排序来排序 $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; $time_select = isset($_REQUEST['time_select']) ? $_REQUEST['time_select'] : '5'; $act = $_REQUEST['act'] ? $_REQUEST['act'] : ''; if ($act == 'goods_select') { include ('includes/cls_json.php'); $json = new JSON; $res = array( 'error' => '', 'content' => '', 'g_sort' => $sort, 'g_order' => $order, 'time_select' => $time_select, 'page' => '' ); $count = get_new_goods_count($time_select); $max_page = ($count > 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = new_goods_list($page, $order, $size, $time_select, $sort); $smarty->assign('goods_list', $goodslist); $smarty->assign('sort', $sort); $smarty->assign('order', $order); $smarty->assign('time_select', $time_select); $smarty->assign('max_page', $max_page); $smarty->assign('page', $page); $res['content'] = $GLOBALS['smarty']->fetch('library/new_goods_list.lbi'); if ($max_page > $page) { $res['page'] = "
正在加载
"; } die($json->encode($res)); exit; } if ($act == 'goods_date') { include ('includes/cls_json.php'); $json = new JSON; $res = array( 'error' => '', 'content' => '', 'time_select' => $time_select, 'menu' => '', 'page' => '' ); $count = get_new_goods_count($time_select); $max_page = ($count > 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = new_goods_list($page, $order, $size, $time_select, $sort); $smarty->assign('goods_list', $goodslist); $smarty->assign('sort', $sort); $smarty->assign('order', $order); $smarty->assign('time_select', $time_select); $bannian_num = get_new_goods_count(5); //半年内 $smarty->assign('bannian_num', $bannian_num); $jintian_num = get_new_goods_count(1); //今天 $smarty->assign('jintian_num', $jintian_num); $zuotian_num = get_new_goods_count(2); //昨天 $smarty->assign('zuotian_num', $zuotian_num); $yizhou_num = get_new_goods_count(3); //最近7天 $smarty->assign('yizhou_num', $yizhou_num); $yigeyue_num = get_new_goods_count(4); //最近一个月内 $smarty->assign('yigeyue_num', $yigeyue_num); $smarty->assign('max_page', $max_page); $smarty->assign('page', $page); if ($max_page > $page) { $res['page'] = "
正在加载
"; } $res['content'] = $GLOBALS['smarty']->fetch('library/new_goods_list.lbi'); $res['menu'] = $GLOBALS['smarty']->fetch('library/menu_second.lbi'); die($json->encode($res)); exit; } if ($act == 'cat_num') { include ('includes/cls_json.php'); $json = new JSON; $res = array( 'error' => '', 'menu' => '', 'time_select' => $time_select ); $count = get_new_goods_count($time_select); $max_page = ($count > 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = new_goods_list($page, $order, $size, $time_select, $sort); $smarty->assign('goods_list', $goodslist); $smarty->assign('sort', $sort); $smarty->assign('order', $order); $smarty->assign('time_select', $time_select); $bannian_num = get_new_goods_count(5); //半年内 $smarty->assign('bannian_num', $bannian_num); $jintian_num = get_new_goods_count(1); //今天 $smarty->assign('jintian_num', $jintian_num); $zuotian_num = get_new_goods_count(2); //昨天 $smarty->assign('zuotian_num', $zuotian_num); $yizhou_num = get_new_goods_count(3); //最近7天 $smarty->assign('yizhou_num', $yizhou_num); $yigeyue_num = get_new_goods_count(4); //最近一个月内 $smarty->assign('yigeyue_num', $yigeyue_num); $res['menu'] = $GLOBALS['smarty']->fetch('library/menu_second.lbi'); die($json->encode($res)); exit; } if ($act == 'goods_page_list') { include ('includes/cls_json.php'); $json = new JSON; $res = array( 'error' => '', 'content' => '', 'time_select' => $time_select, 'page' => '' ); $count = get_new_goods_count($time_select); $max_page = ($count > 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = new_goods_list($page, $order, $size, $time_select, $sort); $smarty->assign('goods_list', $goodslist); $smarty->assign('sort', $sort); $smarty->assign('order', $order); $smarty->assign('time_select', $time_select); $smarty->assign('max_page', $max_page); $smarty->assign('page', $page); if ($max_page > $page) { $res['page'] = "
正在加载
"; } $res['content'] = $GLOBALS['smarty']->fetch('library/new_ajax_goods_list.lbi'); die($json->encode($res)); exit; }*/ $cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang'])); if (!$smarty->is_cached($templates, $cache_id)) { assign_template(); $position = assign_ur_here(); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 /* meta information */ $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords'])); $smarty->assign('description', htmlspecialchars($_CFG['shop_desc'])); $smarty->assign('new_goods', get_recommend_goods('new')); // 最新商品 $smarty->assign('is_index', 'yes'); // 判断是否隐藏导航 $smarty->assign('wh_is_index', 'yes'); // 判断是否隐藏导航 $smarty->assign('show_marketprice', $_CFG['show_marketprice']); $sql = "SELECT c.* , g.goods_id , g.goods_name FROM " . $GLOBALS['ecs']->table('comment') . ' AS c ' . "LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id = c.id_value " . " WHERE c.status = 1 AND c.parent_id = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 ORDER BY c.add_time DESC LIMIT 6 "; $comment_goods = $GLOBALS['db']->getAll($sql); foreach ($comment_goods as $key => $val) { $comment_goods[$key]['url'] = build_uri('goods', array( 'gid' => $val['goods_id'] ) , $val['goods_name']); } $smarty->assign('comment_goods', $comment_goods); // 评论列表 $smarty->assign('index_none', 'yes'); // 是否显示 /*$count = get_new_goods_count($time_select); $max_page = ($count> 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = new_goods_list($page , $order , $size , $time_select,$sort); $smarty->assign('goods_list', $goodslist); $smarty->assign('sort', $sort); $smarty->assign('max_page', $max_page); $smarty->assign('page', $page); $smarty->assign('order', $order); $smarty->assign('time_select', $time_select); */ //$smarty->assign('cat_index_list_96', index_get_new_articles(96)); $smarty->assign('cat_index_list_5', index_get_new_articles(5,10)); //$smarty->assign('my_comments',get_comments(10)); // 数据条数 $links = index_get_links(); $smarty->assign('img_links', $links['img']); $smarty->assign('txt_links', $links['txt']); $smarty->assign('hotgoods', category_get_catgoods(5,1 ,get_children(82))); $smarty->assign('sggoods', category_get_catgoods(5,1 , get_children(81))); //$smarty->assign('promotion_goods', get_promote_goods()); // 特价商品 $smarty->assign('articles97', get_articles(97)); $smarty->assign('articles96', get_articles(96)); } /* 页面中的动态内容 */ assign_dynamic('index'); $smarty->display('index.dwt', $cache_id); function new_goods() { $sql = 'SELECT brand_id,goods_id, goods_thumb, cat_id , goods_name, shop_price , market_price, promote_price, promote_start_date, promote_end_date ,add_time FROM ' . $GLOBALS['ecs']->table('goods') . ' WHERE is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 ORDER BY add_time DESC LIMIT 12 '; $res = $GLOBALS['db']->query($sql); $arr = array(); $k = 1; while ($row = $GLOBALS['db']->fetchRow($res)) { $attr_order = array( '217', '220', '214', '' ); $sql = "SELECT attr_value , attr_id FROM " . $GLOBALS['ecs']->table('goods_attr') . ' WHERE attr_id IN(223,217,220,214) AND goods_id = ' . $row['goods_id']; $attr_value = $GLOBALS['db']->getAll($sql); $attr_value_x = array(); $kv = 0; foreach ($attr_value as $k => $v) { if ($v['attr_id'] != 223) { foreach ($attr_value as $val) { if (in_array($val['attr_id'], $attr_order) && $val['attr_id'] == $attr_order[$kv]) { $attr_value_x[] = $val['attr_value']; $kv++; } } } else { $attr_value_xl = $v['attr_value']; } } $sql = "SELECT cat_name , cat_id FROM " . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $row['cat_id']; $cat = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $time = date('Y-m-d', $row['add_time'] + 8 * 3600); $now_time = date('Y-m-d', time() + 8 * 3600); if ($time == $now_time) { $arr[$row['goods_id']]['is_today'] = 1; } else { $arr[$row['goods_id']]['is_today'] = 0; } $arr[$row['goods_id']]['time'] = date('Y-m-d', $row['add_time'] + 8 * 3600); $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); if ($row['promote_price'] > 0) { $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); } else { $arr[$row['goods_id']]['promote_price'] = 0; } $sql = "SELECT brand_ch , brand_en FROM " . $GLOBALS['ecs']->table('brand') . ' WHERE brand_id = ' . $row['brand_id']; $brand = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['brand_ch'] = $brand['brand_ch']; $arr[$row['goods_id']]['brand_en'] = $brand['brand_en']; $arr[$row['goods_id']]['goods_xh'] = $row['goods_xh']; $arr[$row['goods_id']]['cat_name'] = $cat['cat_name']; $arr[$row['goods_id']]['cat_url'] = build_uri('category', array( 'cid' => $cat['cat_id'] ) , $cat['cat_name']); $arr[$row['goods_id']]['attr_value'] = implode(',', $attr_value_x); $arr[$row['goods_id']]['attr_xl'] = $attr_value_xl; $k++; } return $arr; } function tj_goods() { $sql = 'SELECT brand_id,goods_id, goods_thumb, cat_id , goods_name, shop_price , market_price, promote_price, promote_start_date, promote_end_date ,add_time FROM ' . $GLOBALS['ecs']->table('goods') . ' WHERE is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 AND is_tj = 1 ORDER BY sort_order DESC LIMIT 5 '; $res = $GLOBALS['db']->query($sql); $arr = array(); $k = 1; while ($row = $GLOBALS['db']->fetchRow($res)) { $attr_order = array( '217', '220', '214', '' ); $sql = "SELECT attr_value , attr_id FROM " . $GLOBALS['ecs']->table('goods_attr') . ' WHERE attr_id IN(223,217,220,214) AND goods_id = ' . $row['goods_id']; $attr_value = $GLOBALS['db']->getAll($sql); $attr_value_x = array(); $kv = 0; foreach ($attr_value as $k => $v) { if ($v['attr_id'] != 223) { foreach ($attr_value as $val) { if (in_array($val['attr_id'], $attr_order) && $val['attr_id'] == $attr_order[$kv]) { $attr_value_x[] = $val['attr_value']; $kv++; } } } else { $attr_value_xl = $v['attr_value']; } } $sql = "SELECT cat_name , cat_id FROM " . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $row['cat_id']; $cat = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $time = date('Y-m-d', $row['add_time'] + 8 * 3600); $now_time = date('Y-m-d', time() + 8 * 3600); if ($time == $now_time) { $arr[$row['goods_id']]['is_today'] = 1; } else { $arr[$row['goods_id']]['is_today'] = 0; } $arr[$row['goods_id']]['time'] = date('Y-m-d', $row['add_time'] + 8 * 3600); $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); if ($row['promote_price'] > 0) { $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); } else { $arr[$row['goods_id']]['promote_price'] = 0; } $sql = "SELECT brand_ch , brand_en FROM " . $GLOBALS['ecs']->table('brand') . ' WHERE brand_id = ' . $row['brand_id']; $brand = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['brand_ch'] = $brand['brand_ch']; $arr[$row['goods_id']]['brand_en'] = $brand['brand_en']; $arr[$row['goods_id']]['goods_xh'] = $row['goods_xh']; $arr[$row['goods_id']]['cat_name'] = $cat['cat_name']; $arr[$row['goods_id']]['cat_url'] = build_uri('category', array( 'cid' => $cat['cat_id'] ) , $cat['cat_name']); $arr[$row['goods_id']]['attr_value'] = implode(',', $attr_value_x); $arr[$row['goods_id']]['attr_xl'] = $attr_value_xl; $k++; } return $arr; } function tj_cat_goods($cat_id) { $children = get_children($cat_id); $sql = 'SELECT brand_id,goods_id, goods_thumb, cat_id , goods_name, shop_price , market_price, promote_price, promote_start_date, promote_end_date ,add_time FROM ' . $GLOBALS['ecs']->table('goods') . " AS g WHERE $children AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 AND is_tj = 1 ORDER BY sort_order DESC LIMIT 12 "; $res = $GLOBALS['db']->query($sql); $arr = array(); $k = 1; while ($row = $GLOBALS['db']->fetchRow($res)) { $attr_order = array( '217', '220', '214', '' ); $sql = "SELECT attr_value , attr_id FROM " . $GLOBALS['ecs']->table('goods_attr') . ' WHERE attr_id IN(223,217,220,214) AND goods_id = ' . $row['goods_id']; $attr_value = $GLOBALS['db']->getAll($sql); $attr_value_x = array(); $kv = 0; foreach ($attr_value as $k => $v) { if ($v['attr_id'] != 223) { foreach ($attr_value as $val) { if (in_array($val['attr_id'], $attr_order) && $val['attr_id'] == $attr_order[$kv]) { $attr_value_x[] = $val['attr_value']; $kv++; } } } else { $attr_value_xl = $v['attr_value']; } } $sql = "SELECT cat_name , cat_id FROM " . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $row['cat_id']; $cat = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $time = date('Y-m-d', $row['add_time'] + 8 * 3600); $now_time = date('Y-m-d', time() + 8 * 3600); if ($time == $now_time) { $arr[$row['goods_id']]['is_today'] = 1; } else { $arr[$row['goods_id']]['is_today'] = 0; } $arr[$row['goods_id']]['time'] = date('Y-m-d', $row['add_time'] + 8 * 3600); $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); if ($row['promote_price'] > 0) { $arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); } else { $arr[$row['goods_id']]['promote_price'] = 0; } $sql = "SELECT brand_ch , brand_en FROM " . $GLOBALS['ecs']->table('brand') . ' WHERE brand_id = ' . $row['brand_id']; $brand = $GLOBALS['db']->getRow($sql); $arr[$row['goods_id']]['brand_ch'] = $brand['brand_ch']; $arr[$row['goods_id']]['brand_en'] = $brand['brand_en']; $arr[$row['goods_id']]['goods_xh'] = $row['goods_xh']; $arr[$row['goods_id']]['cat_name'] = $cat['cat_name']; $arr[$row['goods_id']]['cat_url'] = build_uri('category', array( 'cid' => $cat['cat_id'] ) , $cat['cat_name']); $arr[$row['goods_id']]['attr_value'] = implode(',', $attr_value_x); $arr[$row['goods_id']]['attr_xl'] = $attr_value_xl; $k++; } return $arr; } function new_goods_list($page, $order, $size, $time_select, $sort) { $now = gmtime(); $sql = 'SELECT g.goods_id, g.last_update, g.cat_id , g.goods_name, g.add_time , g.shop_price , g.market_price, g.promote_name , g.promote_price, g.promote_start_date, g.promote_end_date , g.click_count , g.goods_name_f FROM ' . $GLOBALS['ecs']->table('goods') . " AS g " . 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . " AS gc ON gc.cat_id = g.cat_id " . " WHERE g.is_on_sale = 1 AND g.is_hot = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ORDER BY g.$sort $order "; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); $k = 1; while ($row = $GLOBALS['db']->fetchRow($res)) { $sql = "SELECT cat_name , cat_id FROM " . $GLOBALS['ecs']->table('category') . ' WHERE cat_id = ' . $row['cat_id']; $cat = $GLOBALS['db']->getRow($sql); $arr['goods_list'][$row['goods_id']]['goods_id'] = $row['goods_id']; $arr['goods_list'][$row['goods_id']]['goods_name'] = $row['goods_name']; $arr['goods_list'][$row['goods_id']]['click_count'] = $row['click_count']; $arr['goods_list'][$row['goods_id']]['goods_name_f'] = $row['goods_name_f']; $arr['goods_list'][$row['goods_id']]['add_time'] = date('Y-m-d', $row['add_time']); $arr['goods_list'][$row['goods_id']]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); if ($row['promote_price'] > 0) { $arr['goods_list'][$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr['goods_list'][$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); $arr['goods_list'][$row['goods_id']]['promote_name'] = $row['promote_name']; } else { $arr['goods_list'][$row['goods_id']]['promote_price'] = 0; } $arr['goods_list'][$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr['goods_list'][$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $k++; } //$arr['cat_list'] = $cat_list; return $arr; } /** * 获得分类下的商品总数 * * @access public * @param string $cat_id * @return integer */ function get_new_goods_count($time_select) { $now = gmtime(); if ($time_select == 1) { // 今天 $beginTime = strtotime(date('Y-m-d 00:00:00', $now)); $endTime = strtotime(date('Y-m-d 23:59:59', $now)); } elseif ($time_select == 2) { // 昨天 $time = strtotime('-1 day', $now); $beginTime = strtotime(date('Y-m-d 00:00:00', $time)); $endTime = strtotime(date('Y-m-d 23:59:59', $time)); } elseif ($time_select == 3) { // 本周 $text = '本周'; $time = strtotime('-6 day', $now); $beginTime = strtotime(date('Y-m-d 00:00:00', $time)); $endTime = strtotime(date('Y-m-d 23:59:59', $now)); } elseif ($time_select == 4) { // 本月 $text = '本月'; $time = strtotime('-29 day', $now); $beginTime = strtotime(date('Y-m-d 00:00:00', $time)); $endTime = strtotime(date('Y-m-d 23:59:59', $now)); } elseif ($time_select == 5) { // 半年内 $text = '半年内'; $time = strtotime('-180 day', $now); $beginTime = strtotime(date('Y-m-d 00:00:00', $time)); $endTime = strtotime(date('Y-m-d 23:59:59', $now)); } $where = " AND $beginTime < g.add_time AND g.add_time < $endTime "; /* 返回商品总数 */ return $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('goods') . " AS g WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 $where"); } function click10() { $sql = 'SELECT g.goods_id, g.last_update, g.cat_id , g.goods_name, g.goods_name_f , g.add_time , g.shop_price , g.market_price, g.promote_name , g.promote_price, g.promote_start_date, g.promote_end_date FROM ' . $GLOBALS['ecs']->table('goods') . " AS g " . 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . " AS gc ON gc.cat_id = g.cat_id " . " WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ORDER BY g.click_count DESC LIMIT 3 "; $res = $GLOBALS['db']->query($sql); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $arr['goods_list'][$row['goods_id']]['goods_id'] = $row['goods_id']; $arr['goods_list'][$row['goods_id']]['goods_name'] = $row['goods_name']; $arr['goods_list'][$row['goods_id']]['goods_name_f'] = $row['goods_name_f']; $arr['goods_list'][$row['goods_id']]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); if ($row['promote_price'] > 0) { $arr['goods_list'][$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $arr['goods_list'][$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']); $arr['goods_list'][$row['goods_id']]['promote_name'] = $row['promote_name']; } else { $arr['goods_list'][$row['goods_id']]['promote_price'] = 0; } $arr['goods_list'][$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr['goods_list'][$row['goods_id']]['shop_price'] = price_format($row['shop_price']); } return $arr; } function topic_index($topic_id) { $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('topic') . " WHERE topic_id = " . $topic_id; $topic = $GLOBALS['db']->getRow($sql); $topic['data'] = addcslashes($topic['data'], "'"); $tmp = @unserialize($topic["data"]); $arr = (array)$tmp; $goods_id = array(); foreach ($arr AS $key => $value) { foreach ($value AS $k => $val) { $opt = explode('|', $val); $arr[$key][$k] = $opt[1]; $goods_id[] = $opt[1]; } } $sql = 'SELECT b.brand_ch , b.brand_en , g.goods_xh , gc.cat_id,gc.cat_name , g.goods_id, g.goods_name,g.goods_name_f, g.goods_name_style, g.market_price,g.college_price,g.promote_name, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price,g.promote_name, g.goods_type ," . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS gc ON gc.cat_id = g.cat_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE " . db_create_in($goods_id, 'g.goods_id') . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ORDER BY g.add_time DESC LIMIT 5 "; $res = $GLOBALS['db']->query($sql); $sort_goods_arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $row['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $row['promote_price'] = ''; } if ($row['shop_price'] > 0) { $row['shop_price'] = price_format($row['shop_price']); } else { $row['shop_price'] = ''; } $row['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); $row['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img'], true); $row['short_style_name'] = add_style($row['short_name'], $row['goods_name_style']); $row['goods_name'] = $row['goods_name']; $row['goods_name_f'] = $row['goods_name_f']; $row['cat_name'] = $row['cat_name']; $row['cat_url'] = build_uri('category', array( 'cid' => $row['cat_id'] ) , $row['cat_name']); $row['type'] = $row['goods_type']; $row['market_price'] = price_format($row['market_price']); $row['goods_id'] = $row['goods_id']; $row['brand_ch'] = $row['brand_ch']; $row['brand_en'] = $row['brand_en']; $row['goods_xh'] = $row['goods_xh']; foreach ($arr AS $key => $value) { foreach ($value AS $val) { if ($val == $row['goods_id']) { $key = $key == 'default' ? $_LANG['all_goods'] : $key; $sort_goods_arr[$key][] = $row; } } } } /* 模板赋值 */ foreach ($arr as $key1 => $val1) { //var_dump($key1); foreach ($sort_goods_arr as $key2 => $val2) { if ($key1 == $key2) { //var_dump($key2); $sort_goods_arr_2[$key2] = $val2; } } } return $sort_goods_arr_2; } function get_comments($num) { $sql = 'SELECT a.*,b.goods_id,b.brand_id , b.goods_thumb,b.goods_xh,b.goods_name FROM ' . $GLOBALS['ecs']->table('comment') . ' AS a,' . $GLOBALS['ecs']->table('goods') . 'AS b WHERE a.status = 1 AND a.parent_id = 0 and a.comment_type=0 and a.id_value=b.goods_id ' . ' ORDER BY a.add_time DESC'; if ($num > 0) { $sql.= ' LIMIT ' . $num; } //echo $sql; $res = $GLOBALS['db']->getAll($sql); $comments = array(); foreach ($res AS $idx => $row) { $comments[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']); $comments[$idx]['content'] = $row['content']; $comments[$idx]['id_value'] = $row['id_value']; $comments[$idx]['goods_thumb'] = get_image_path($row['id_value'], $row['goods_thumb'], true); $comments[$idx]['goods_name'] = $row['goods_name']; $comments[$idx]['goods_xh'] = $row['goods_xh']; $sql = "SELECT brand_ch , brand_en FROM " . $GLOBALS['ecs']->table('brand') . ' WHERE brand_id = ' . $row['brand_id']; $brand = $GLOBALS['db']->getRow($sql); $comments[$idx]['brand_ch'] = $brand['brand_ch']; $comments[$idx]['brand_en'] = $brand['brand_en']; $attr_order = array( '217', '220', '214', '' ); $sql = "SELECT attr_value , attr_id FROM " . $GLOBALS['ecs']->table('goods_attr') . ' WHERE attr_id IN(223,217,220,214) AND goods_id = ' . $row['goods_id']; $attr_value = $GLOBALS['db']->getAll($sql); $attr_value_x = array(); $kv = 0; foreach ($attr_value as $k => $v) { if ($v['attr_id'] != 223) { foreach ($attr_value as $val) { if (in_array($val['attr_id'], $attr_order) && $val['attr_id'] == $attr_order[$kv]) { $attr_value_x[] = $val['attr_value']; $kv++; } } } else { $attr_value_xl = $v['attr_value']; } } $comments[$idx]['attr_value'] = implode(',', $attr_value_x); $comments[$idx]['attr_xl'] = $attr_value_xl; $comments[$idx]['url'] = build_uri('goods', array( 'gid' => $row['goods_id'] ) , $row['goods_name']); } return $comments; } function get_articles($article_catid) { $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND cat_id = '. $article_catid.' order by article_id desc LIMIT 1' ; $res = $GLOBALS['db']->getRow($sql); $res['content'] = sub_str(strip_tags($res['content']),20); $res['url'] = build_uri('article', array('aid' => $res['article_id']), $res['title']); return $res; } ?>