/**

* WK 首页文件

* ============================================================================

* * 版权所有 2005-2012 QQ 80342014,并保留所有权利。

* ;

* ----------------------------------------------------------------------------

* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和

* 使用;不允许对程序代码以任何形式任何目的的再发布。

* ============================================================================

* $Author: liubo $

* $Id: index.php 17217 2011-01-19 06:29:08Z liubo $

*/

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

if ((DEBUG_MODE & 2) != 2)

{

$smarty->caching = true;

}

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);

$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";

if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))

{

$Loaction = 'mobile/';

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;

}

}

//判断是否有ajax请求

$act = !empty($_GET['act']) ? $_GET['act'] : '';

if ($act == 'cat_rec')

{

$rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');

$rec_type = !empty($_REQUEST['rec_type']) ? intval($_REQUEST['rec_type']) : '1';

$cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';

include_once('includes/cls_json.php');

$json = new JSON;

$result = array('error' => 0, 'content' => '', 'type' => $rec_type, 'cat_id' => $cat_id);

$children = get_children($cat_id);

$smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品

$smarty->assign('cat_rec_sign', 1);

$result['content'] = $smarty->fetch('library/recommend_' . $rec_array[$rec_type] . '.lbi');

die($json->encode($result));

}

/*------------------------------------------------------ */

//-- 判断是否存在缓存,如果存在则调用缓存,反之读取相应内容

/*------------------------------------------------------ */

/* 缓存编号 */

$cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang']));

if (!$smarty->is_cached('index.dwt', $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('flash_theme', $_CFG['flash_theme']); // Flash轮播图片模板

$smarty->assign('feed_url', ($_CFG['rewrite'] == 1) ? 'feed.xml' : 'feed.php'); // RSS URL

$smarty->assign('categories', get_categories_tree()); // 分类树

$smarty->assign('helps', get_shop_help()); // 网店帮助

$smarty->assign('top_goods', get_top10()); // 销售排行

$smarty->assign('best_goods', get_recommend_goods('best')); // 推荐商品

$smarty->assign('new_goods', get_recommend_goods('new')); // 最新商品

$smarty->assign('hot_goods', get_recommend_goods('hot')); // 热点文章

$smarty->assign('promotion_goods', get_promote_goods()); // 特价商品

$smarty->assign('brand_list', get_brands());

$smarty->assign('promotion_info', get_promotion_info()); // 增加一个动态显示所有促销信息的标签栏

$smarty->assign('invoice_list', index_get_invoice_query()); // 发货查询

$smarty->assign('new_articles', index_get_new_articles()); // 最新文章

$smarty->assign('group_buy_goods', index_get_group_buy()); // 团购商品

$smarty->assign('auction_list', index_get_auction()); // 拍卖活动

$smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告

/* 首页主广告设置 */

$smarty->assign('index_ad', $_CFG['index_ad']);

if ($_CFG['index_ad'] == 'cus')

{

$sql = 'SELECT ad_type, content, url FROM ' . $ecs->table("ad_custom") . ' WHERE ad_status = 1';

$ad = $db->getRow($sql, true);

$smarty->assign('ad', $ad);

}

/* links */

$links = index_get_links();

$smarty->assign('img_links', $links['img']);

$smarty->assign('txt_links', $links['txt']);

$smarty->assign('data_dir', DATA_DIR); // 数据目录

/* 首页推荐分类 */

$cat_recommend_res = $db->getAll("SELECT c.cat_id, c.cat_name, cr.recommend_type FROM " . $ecs->table("cat_recommend") . " AS cr INNER JOIN " . $ecs->table("category") . " AS c ON cr.cat_id=c.cat_id");

if (!empty($cat_recommend_res))

{

$cat_rec_array = array();

foreach($cat_recommend_res as $cat_recommend_data)

{

$cat_rec[$cat_recommend_data['recommend_type']][] = array('cat_id' => $cat_recommend_data['cat_id'], 'cat_name' => $cat_recommend_data['cat_name']);

}

$smarty->assign('cat_rec', $cat_rec);

}

// if($_CFG['template'] == 'aoyou')

// {

/* 首页轮播图 fanny 09.30 start */

$flashplay = index_get_ads();

$smarty->assign('flashplay', $flashplay);

// }

/* 页面中的动态内容 */

assign_dynamic('index');

}

$indxe_ads = get_index_ad('首页品牌下8个广告位');

$smarty->assign('indxe_ads', $indxe_ads);

/* wk 首页 tab 切换特价 S */

$index_xianshi = get_index_goods('is_promote',4);// 特价

$index_xianshi5 = get_index_goods('is_promote',5);// 特价

$index_new = get_index_goods('is_new',9);// 新品上市

$index_naifen = get_index_goods('is_naifen',9);// 奶粉专区

$index_aozou = get_index_goods('is_aozou',9);// 澳洲直邮

$index_jiamei = get_index_goods('is_jiamie',9);// 价美团购

$index_nimai = get_index_goods('is_nimai',9);// 你买我送

$index_tejia = get_index_goods('is_tejia',9);// 清仓特价

$smarty->assign('index_xianshi', $index_xianshi);

$smarty->assign('index_new', $index_new);

$smarty->assign('index_naifen', $index_naifen);

$smarty->assign('index_aozou', $index_aozou);

$smarty->assign('index_jiamei', $index_jiamei);

$smarty->assign('index_nimai', $index_nimai);

$smarty->assign('index_tejia', $index_tejia);

$smarty->assign('index_xianshi5', $index_xianshi5);

/* wk 首页 tab 切换特价 E */

/* wk 首页楼层 S */

$index_loucheng = index_loucheng();

$smarty->assign('index_loucheng', $index_loucheng);

/* wk 首页楼层 E */

$smarty->display('index.dwt', $cache_id);

/*------------------------------------------------------ */

//-- PRIVATE FUNCTIONS

/*------------------------------------------------------ */

function index_loucheng(){

/* 获取设置的首页显示的分类 */

$sql = "select c.* from ".$GLOBALS['ecs']->table('cat_recommend')." as cat LEFT JOIN ".$GLOBALS['ecs']->table('category')." as c ON c.cat_id = cat.cat_id where c.show_status = 1 and cat.recommend_type = 3 order by sort_order asc ,cat_id desc";

$category = $GLOBALS['db']->getAll($sql);

$list = array();

if($category){

foreach($category as $key => $val){

$children = array();

$children = get_children($val['cat_id']);

$where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".

"g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';

/* fanny 判定是否是分销商,如果是则下降的产品不显示 start */

$sql .= ' AND g.goods_id '.db_create_notin(get_goods_down());

/* fanny 判定是否是分销商,如果是则下降的产品不显示 end */

/* 获得商品列表 */

$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.click_count, g.market_price, 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.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('member_price') . ' AS mp ' .

"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .

"WHERE $where $ext ORDER BY click_count desc , sort_order asc limit 6";

$res = $GLOBALS['db']->getAll($sql);

$arr = array();

foreach($res as $k => $row){

/* fanny 分销商商品价格信息 start */

$shop_price = get_goods_prices($row['goods_id']);

if($shop_price > 0){$row['shop_price'] = $shop_price;}

/* fanny 分销商商品价格信息 end */

if ($row['promote_price'] > 0)

{

$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);

}

else

{

$promote_price = 0;

}

/* 处理商品水印图片 */

$watermark_img = '';

if ($promote_price != 0)

{

$watermark_img = "watermark_promote_small";

}

elseif ($row['is_new'] != 0)

{

$watermark_img = "watermark_new_small";

}

elseif ($row['is_best'] != 0)

{

$watermark_img = "watermark_best_small";

}

elseif ($row['is_hot'] != 0)

{

$watermark_img = 'watermark_hot_small';

}

if ($watermark_img != '')

{

$arr[$row['goods_id']]['watermark_img'] = $watermark_img;

}

$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];

/*if($display == 'grid')

{

$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];

}

else

{*/

$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];

/*}*/

$arr[$row['goods_id']]['name'] = $row['goods_name'];

$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];

$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);

$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);

$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);

$arr[$row['goods_id']]['type'] = $row['goods_type'];

$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';

$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);

$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);

}

$val['goods'] = $arr;

/* 获取当前楼层广告 */

$ad = array();

$_tinm = time();

$ad_position_name = '首页楼层广告位';

$ad_name = '首页楼层id_'.$val['cat_id'];

$sqlad = "select a.* from ". $GLOBALS['ecs']->table('ad') ." as a LEFT JOIN ". $GLOBALS['ecs']->table('ad_position') ." as ap ON a.position_id = ap.position_id WHERE ap.position_name = '$ad_position_name' and a.start_time < $_tinm and a.end_time > $_tinm and a.enabled = 1 and a.ad_name = '$ad_name'";

$ad = $GLOBALS['db']->getRow($sqlad);

$val['ad'] = $ad;

$list[] = $val;

}

}

return $list;

}

/**

* wk 获取首页 7个类型下的商品

*

* @access private

* @return array

*/

function get_index_goods($type='is_promote',$num){

$currency = array();

/* wk 新增查询 字段汇率 currency_rate 计算前台显示的汇率 */

/* 判定是否是分销商 */

if(isset($GLOBALS['_CFG']['merchant_shop']))

{

if($GLOBALS['_CFG']['merchant_shop']['secondary'])

{

$sql = 'SELECT id, currency_name,currency_short,currency_format,currency_rate FROM ' .$GLOBALS['ecs']->table('currency').' WHERE id = 2 AND is_use = 0 AND (currency_name = "'.$GLOBALS['_CFG']['merchant_shop']['secondary'].'" OR currency_name = "'.$GLOBALS['_CFG']['currency'].'") ORDER BY id ASC';

$currency = $GLOBALS['db']->getRow($sql);

}

}

else

{

$sql = 'SELECT id, currency_name,currency_short,currency_format,currency_rate FROM ' .$GLOBALS['ecs']->table('currency').' WHERE id = 2 AND is_use = 0 ORDER BY id ASC';

$currency = $GLOBALS['db']->getRow($sql);

}

if(empty($currency)){

$currency['currency_rate'] = '1';

}

$time = gmtime();

$order_type = $GLOBALS['_CFG']['recommend_order'];

/*判断类型 */

$where = '';

if($type == 'is_promote'){

$where .= " AND g.is_promote = 1 AND promote_start_date <= '$time' AND promote_end_date >= '$time'";

}elseif($type == 'is_new'){

$where .= " AND g.is_new = 1 "; // 新品上市

}elseif($type == 'is_naifen'){

$where .= " AND g.is_naifen = 1 "; //奶粉专区

}elseif($type == 'is_aozou'){

$where .= " AND g.is_aozou = 1 ";//澳洲直邮

}elseif($type == 'is_jiamie'){

$where .= " AND g.is_jiamie = 1 "; //价美团购

}elseif($type == 'is_nimai'){

$where .= " AND g.is_nimai = 1 "; //你买我送

}elseif($type == 'is_tejia'){

$where .= " AND g.is_tejia = 1 "; //清仓特价

}

$sql = 'SELECT g.goods_id, g.goods_name, g.goods_brief, g.goods_name_style,g.goods_number, 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, goods_img, b.brand_name, " .

"g.is_best, g.is_new, g.is_hot, g.is_promote,g.is_naifen,g.is_aozou,g.is_jiamie,g.is_nimai,g.is_tejia, RAND() AS rnd " .

'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .

'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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' .

" $where ";

/* fanny 判定是否是分销商,如果是则下降的产品不显示 start */

$mer_downgoods = get_goods_down();

if($mer_downgoods){

$sql .= ' AND g.goods_id '.db_create_notin($mer_downgoods);

}

/* fanny 判定是否是分销商,如果是则下降的产品不显示 end */

$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd';

$sql .= " LIMIT $num ";

$result = $GLOBALS['db']->getAll($sql);

if($type == 'is_jiamie'){

// echo "

"; print_r($sql);

// echo "

"; print_r($result);

// die();

}

$goods = array();

foreach ($result AS $idx => $row)

{

/* fanny 分销商商品价格信息 start */

$shop_price = get_goods_prices($row['goods_id']);

if($shop_price > 0){$row['shop_price'] = $shop_price;}

/* fanny 分销商商品价格信息 end */

// print_r($row);

// echo(gmtime());

// die("0");

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'] = $row['brand_name'];

$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'];

$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']);

$goods[$idx]['market_price'] = price_format($row['market_price']);

$goods[$idx]['shop_price'] = price_format($row['shop_price']);

$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);

$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);

if($row['promote_price'] > 0 && $row['promote_end_date'] > gmtime() && $row['promote_start_date'] < gmtime()){

$goods[$idx]['zg_price'] = $currency['currency_format'] . round($row['promote_price'] * $currency['currency_rate'],2);

}else{

$goods[$idx]['zg_price'] = $currency['currency_format'] . round($row['shop_price'] * $currency['currency_rate'],2);

}

// $goods[$idx]['zg_price'] = $currency['currency_format'] . round($row['shop_price'] * $currency['currency_rate'],2);

if($row['promote_end_date'] > gmtime()){

$goods[$idx]['end_time'] = $row['promote_end_date'] - gmtime();

}else{

$goods[$idx]['end_time'] = 0;

}

/*计算销量 */

$order_count = $GLOBALS['db']->getOne("select count(*) from ". $GLOBALS['ecs']->table('order_goods') . " where goods_id = '$row[goods_id]'");

/* 总库存 */

$z_kucun = $order_count + $row['goods_number'];

$goods[$idx]['z_kucun'] = $order_count + $row['goods_number'];

/*已买 */

$goods[$idx]['yimia'] = round(($order_count/$z_kucun )*100,2);

}

return $goods;

}

/**

* wk 获取首页 8个广告位

*

* @access private

* @return array

*/

function get_index_ad($text = ''){

$_tinm = time();

$sql = "select a.* from ". $GLOBALS['ecs']->table('ad') ." as a LEFT JOIN ". $GLOBALS['ecs']->table('ad_position') ." as ap ON a.position_id = ap.position_id WHERE ap.position_name = '$text' and a.start_time < $_tinm and a.end_time > $_tinm and a.enabled = 1";

$all = $GLOBALS['db']->getAll($sql);

$lsit = array();

foreach($all as $key => $val){

$nams = explode('_',$val['ad_name']);

$val['key'] = $nams['1'];

$val['name'] = $nams['2'];

$val['yingwen'] = $nams['3'];

$lsit[] = $val;

}

return $lsit;

}

/**

* 调用发货单查询

*

* @access private

* @return array

*/

function index_get_invoice_query()

{

$sql = 'SELECT o.order_sn, o.invoice_no, s.shipping_code FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o' .

' LEFT JOIN ' . $GLOBALS['ecs']->table('shipping') . ' AS s ON s.shipping_id = o.shipping_id' .

" WHERE invoice_no > '' AND shipping_status = " . SS_SHIPPED .

' ORDER BY shipping_time DESC LIMIT 10';

$all = $GLOBALS['db']->getAll($sql);

foreach ($all AS $key => $row)

{

$plugin = ROOT_PATH . 'includes/modules/shipping/' . $row['shipping_code'] . '.php';

if (file_exists($plugin))

{

include_once($plugin);

$shipping = new $row['shipping_code'];

$all[$key]['invoice_no'] = $shipping->query((string)$row['invoice_no']);

}

}

clearstatcache();

return $all;

}

/**

* 获得最新的文章列表。

*

* @access private

* @return array

*/

function index_get_new_articles()

{

$sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ' .

' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' .

$GLOBALS['ecs']->table('article_cat') . ' AS ac' .

' WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1' .

' ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $GLOBALS['_CFG']['article_number'];

$res = $GLOBALS['db']->getAll($sql);

$arr = array();

foreach ($res AS $idx => $row)

{

$arr[$idx]['id'] = $row['article_id'];

$arr[$idx]['title'] = $row['title'];

$arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?

sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];

$arr[$idx]['cat_name'] = $row['cat_name'];

$arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);

$arr[$idx]['url'] = $row['open_type'] != 1 ?

build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);

$arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);

}

return $arr;

}

/**

* 获得最新的团购活动

*

* @access private

* @return array

*/

function index_get_group_buy()

{

$time = gmtime();

$limit = get_library_number('group_buy', 'index');

$group_buy_list = array();

if ($limit > 0)

{

$sql = 'SELECT gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name, g.goods_thumb, g.goods_img ' .

'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS gb, ' .

$GLOBALS['ecs']->table('goods') . ' AS g ' .

"WHERE gb.act_type = '" . GAT_GROUP_BUY . "' " .

"AND g.goods_id = gb.goods_id " .

"AND gb.start_time <= '" . $time . "' " .

"AND gb.end_time >= '" . $time . "' " .

"AND g.is_delete = 0 " .

"ORDER BY gb.act_id DESC " .

"LIMIT $limit" ;

$res = $GLOBALS['db']->query($sql);

while ($row = $GLOBALS['db']->fetchRow($res))

{

/* 如果缩略图为空,使用默认图片 */

$row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);

$row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

/* 根据价格阶梯,计算最低价 */

$ext_info = unserialize($row['ext_info']);

$price_ladder = $ext_info['price_ladder'];

if (!is_array($price_ladder) || empty($price_ladder))

{

$row['last_price'] = price_format(0);

}

else

{

foreach ($price_ladder AS $amount_price)

{

$price_ladder[$amount_price['amount']] = $amount_price['price'];

}

}

ksort($price_ladder);

$row['last_price'] = price_format(end($price_ladder));

$row['url'] = build_uri('group_buy', array('gbid' => $row['group_buy_id']));

$row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?

sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];

$row['short_style_name'] = add_style($row['short_name'],'');

$group_buy_list[] = $row;

}

}

return $group_buy_list;

}

/**

* 取得拍卖活动列表

* @return array

*/

function index_get_auction()

{

$now = gmtime();

$limit = get_library_number('auction', 'index');

$sql = "SELECT a.act_id, a.goods_id, a.goods_name, a.ext_info, g.goods_thumb ".

"FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS a," .

$GLOBALS['ecs']->table('goods') . " AS g" .

" WHERE a.goods_id = g.goods_id" .

" AND a.act_type = '" . GAT_AUCTION . "'" .

" AND a.is_finished = 0" .

" AND a.start_time <= '$now'" .

" AND a.end_time >= '$now'" .

" AND g.is_delete = 0" .

" ORDER BY a.start_time DESC" .

" LIMIT $limit";

$res = $GLOBALS['db']->query($sql);

$list = array();

while ($row = $GLOBALS['db']->fetchRow($res))

{

$ext_info = unserialize($row['ext_info']);

$arr = array_merge($row, $ext_info);

$arr['formated_start_price'] = price_format($arr['start_price']);

$arr['formated_end_price'] = price_format($arr['end_price']);

$arr['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

$arr['url'] = build_uri('auction', array('auid' => $arr['act_id']));

$arr['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?

sub_str($arr['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $arr['goods_name'];

$arr['short_style_name'] = add_style($arr['short_name'],'');

$list[] = $arr;

}

return $list;

}

/**

* 获得轮播图广告

*

* @author fanny 2016-09-29

* @access private

* @return array

*/

function index_get_ads()

{

$sql = 'SELECT content,url,imgbg FROM '.$GLOBALS['ecs']->table('ad_custom').' WHERE ad_type = 0 ORDER BY ad_id';

$res = $GLOBALS['db']->getAll($sql);

return $res;

}

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

index2.php,index2.php相关推荐

  1. python之list[index1:index2]是左闭右开

    python之list[index1:index2]是左闭右开 代码: 运行:

  2. Django Response对象3.4

    HttpResponse对象 在django.http模块中定义了HttpResponse对象的API HttpRequest对象由Django自动创建,HttpResponse对象由程序员创建 不调 ...

  3. 剑指offer-丑数

    题目描述 把只包含质因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含质因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 解析来 ...

  4. CUDA Samples: approximate image reverse

    以下CUDA sample是分别用C++和CUDA实现的对图像进行某种类似reverse的操作,并对其中使用到的CUDA函数进行了解说,各个文件内容如下: common.hpp: #ifndef FB ...

  5. 连连看html游戏全代码js、jquery操作

    连连看html游戏全代码js.jquery操作 运行图片 目录路径 连连看水果方块版.html 连连看算法 进行下一个游戏的开发! 注意事项 我会把html文件.css文件提供下载地址,文件夹路径也展 ...

  6. 第六十一节,html超链接和路径

    html超链接和路径 学习要点:     1.超链接的属性     2.相对与绝对路径     3.锚点设置                              本章主要探讨HTML5中文本元素 ...

  7. lua学习:使用Lua处理游戏数据

    在之前lua学习:lua作配置文件里,我们学会了用lua作配置文件. 其实lua在游戏开发中可以作为一个强大的保存.载入游戏数据的工具. 1.载入游戏数据 比如说,现在我有一份表单: data.xls ...

  8. 从零开始的webpack生活-0x003:html模板生成

    0x001 概述 上一章之后已经可以自动刷新浏览器了,大大方便了我们的开发,这章开始讲插件,第一个插件将会解决上一章节的一个问题,那就是index.html需要手动插入打包好的js,同时不会将inde ...

  9. vue根据不同权限显示图片_vue如何实现路由权限控制

    前言在实际的开发过程中,我们通常会涉及到权限的问题,不同的用户进来只能看到他对应的菜单权限,页面上的菜单渲染是比较好实现的,这里就不多提,唯一比较难的就是路由的权限控制. 解决思路目前大概有两种思路可 ...

最新文章

  1. CImage 是基于GDI+的,很老的一篇文章,我很久很久以前看到过的
  2. 容器编排技术 -- kubernetes 通过环境变量向容器暴露 Pod 信息
  3. 消费者Heartbeat分析
  4. 大数据心得体会_20年备受关注的6款数据工具!谁最好用?毫无争议的答案来了...
  5. 一步步写俄罗斯方块(二)
  6. 关联规则挖掘算法之Apriori算法
  7. 麒麟系统stty测试串口
  8. 暮光之城3蓝光BD高清下载
  9. Warez 入门指南
  10. 操作 神通数据库_国产神通数据库操作备忘(Linux)
  11. 十字消除 - Cocos2d-x 2.0.1
  12. 从“星空”主题绘画系统出发寻求绘画的可能性
  13. PID参数自整定库之一:继电反馈整定算法
  14. cf虚拟服务器设置方法,【WGCF】连接CF WARP为服务器添加IPv4/IPv6网络
  15. tp6 时间戳查询 自动转换
  16. 企业微信会员运营 打破传统营销方式开启全渠道会员营销新模式
  17. shell学习笔记:变量篇
  18. 王者服务器维修2019年四月份,王者荣耀2019年4月新皮肤有哪些?4月新皮肤什么时候出...
  19. 少儿编程网站源码和scratch课程
  20. win7 32/64位系统安装ug nx4.0

热门文章

  1. VB常见错误和难点分析
  2. 获取系统时间GetSystemTime、GetLocalTime、GetTickTime
  3. 工业级无线路由器的Flash可扩展性以及作用
  4. thinkphp6多应用多语言包架构
  5. mysql做生日日期字段的用到的类型_MySQL 日期类型函数及使用
  6. 生产者消费者之无锁队列
  7. dinic网络流前向星写法
  8. C# 面试题整理与分享
  9. DTC 2019 数据技术嘉年华·金融峰会(深圳站)来袭,直面架构君
  10. 帝国时代之苹果复兴 Mac剑指Windows