assign('user_id', $user_id); 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('helps', get_shop_help()); // 网店帮助 $arr_best_goods = get_index_recommend_goods($user_id); $smarty->assign('best_one', $arr_best_goods[0] ); // 推荐拍品 $smarty->assign('best_two', $arr_best_goods[1] ); // 推荐拍品 $smarty->assign('best_three', $arr_best_goods[2] ); // 推荐拍品 $smarty->assign('best_four', $arr_best_goods[3] ); // 推荐拍品 $smarty->assign('best_official', get_recommend_areas('official')); // 推荐专场:官方 $smarty->assign('best_seller', get_recommend_areas('seller')); // 推荐专场:商家 $smarty->assign('end_goods', get_index_goods('end')); // 即将结束的拍品 $smarty->assign('new_goods', get_index_goods('new')); // 最新发布的拍品 $smarty->assign('pre_goods', get_index_goods('pre')); // 预展中的拍品 /* 首页主广告设置 */ $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); } /* 页面中的动态内容 */ //assign_dynamic('index'); //} $rand_goods = get_index_goods_rand(); $smarty->assign('rand_goods', $rand_goods); $smarty->assign('cur_url', $_SERVER['REQUEST_URI']); $smarty->assign('user_id', $_SESSION['user_id']); // 用户id $smarty->display('index.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTIONS /*------------------------------------------------------ */ /*获取推荐专场*/ function get_recommend_areas($type) { $arr = array(); $sql = "SELECT id,title,prepare_time,start_time,end_time,zhuanchanglogo,real_goods_num,sort FROM " . $GLOBALS['ecs']->table('area') . " WHERE is_recommend = '1'"; if($type == 'official' || $type == ''){ /*官方专场推荐*/ $sql .= " AND `type` = '1' ORDER BY sort ASC,end_time DESC LIMIT 4"; }else{ /*商家专场推荐*/ $sql .= " AND `type` = '2' ORDER BY sort ASC,end_time DESC LIMIT 6"; } $arr = $GLOBALS['db']->getAll($sql); foreach ($arr as $key => $val){ $arr[$key]['title'] = sub_str($val['title'],20); //获取当前专场的状态 $now = time(); if($val['start_time'] < $now && $val['end_time'] > $now){ $arr[$key]['state'] = 2;//拍卖中 }elseif($val['start_time'] > $now && $val['prepare_time'] < $now){ $arr[$key]['state'] = 1;//预展中 }elseif($val['prepare_time'] > $now){ $arr[$key]['state'] = 0;//待预展 }else{ $arr[$key]['state'] = 3;//已结束 } $arr[$key]['prepare_time'] = date("Y-m-d H:i:s",$val['prepare_time']); $arr[$key]['start_time'] = date("Y-m-d H:i:s",$val['start_time']); $arr[$key]['end_time'] = date("Y-m-d H:i:s",$val['end_time']); if($type == 'official' || $type == ''){//官方专场 $arr[$key]['producer'] = ''; $arr_apply_user = $GLOBALS['db']->getAll("SELECT user_id,user_name FROM " . $GLOBALS['ecs']->table('area_apply') ." WHERE area_id = '$val[id]' AND `status` = '1'"); if(!empty($arr_apply_user)){ foreach ($arr_apply_user as $k => $v){ $arr[$key]['producer'] .= ''.$v['user_name'].' '; } } if($key == 0){//获取排序为0的官方专场中推荐的拍品 $arr[$key]['goods'] = $GLOBALS['db']->getAll("SELECT ag.goods_id,g.goods_name,g.goods_thumb FROM " . $GLOBALS['ecs']->table('area_goods') ." AS ag LEFT JOIN " . $GLOBALS['ecs']->table('goods') ." AS g ON ag.goods_id = g.goods_id WHERE ag.is_recommend = '1' AND area_id = '$val[id]' ORDER BY ag.recommend_time DESC LIMIT 2"); if(!empty($arr[$key]['goods'])){ foreach ($arr[$key]['goods'] as $k => $v){ $arr[$key]['goods'][$k]['goods_name'] = sub_str($v['goods_name'],20); } } } } } //print_r($arr); return $arr; } /*推荐热拍单品*/ function get_index_recommend_goods($user_id){ $arr = array(); $sql = "SELECT goods_id,goods_name,shop_price,reserve_price,add_range,goods_thumb,goods_img,pre_starttime,pai_starttime,pai_endtime,time_type,delay,commission_bear,carriage_bear,payment_type,`status` FROM " . $GLOBALS['ecs']->table('goods') ." WHERE is_online = '1' AND pai_endtime > '".time()."' AND is_recommend = '1' AND is_delete = 0 "; //获取所有属于专场的拍品id $arr_area_goods = $GLOBALS['db']->getAll("SELECT goods_id FROM " . $GLOBALS['ecs']->table('area_goods') ." WHERE end_time > '".time()."'"); if(count($arr_area_goods)>0){ $str_area_goods_id = ''; foreach ($arr_area_goods as $key => $v){ $str_area_goods_id .= $v['goods_id'].','; } $arr_area_goods = explode(',',trim($str_area_goods_id,',')); $str_area_goods_id = "'".implode("','",$arr_area_goods)."'"; $sql .= " AND goods_id NOT IN ($str_area_goods_id)"; } $sql .= " ORDER BY sort_order ASC,add_time ASC LIMIT 4"; $arr = $GLOBALS['db']->getAll($sql); //print_r($arr); if(!empty($arr)){ foreach ($arr as $key => $val){ if($val['pai_starttime'] > time()){ $arr[$key]['status'] = 1;//预展中 }elseif($val['pai_starttime'] < time() && $val['pai_endtime'] > time()){ $arr[$key]['status'] = 2;//拍卖中 } $arr[$key]['pai_starttime'] = date('Y-m-d H:i:s',$val['pai_starttime']); $arr[$key]['pai_endtime'] = date('Y-m-d H:i:s',$val['pai_endtime']); $arr_bid = $GLOBALS['db']->getAll("SELECT goods_id,bid_price FROM " . $GLOBALS['ecs']->table('auction_log') ." WHERE goods_id = '$val[goods_id]' ORDER BY bid_price DESC"); $arr[$key]['bid_count'] = count($arr_bid); if(!empty($arr_bid)){ $arr[$key]['bid_top_price'] = $arr_bid[0]['bid_price']; }else{ $arr[$key]['bid_top_price'] = $val['shop_price']; } //当前拍品应出的价格 (当前出价+加价幅度) $arr[$key]['next_price'] = (!empty($arr_bid)? $arr_bid[0]['bid_price'] : $val['shop_price']) + (empty($val['add_range'])?1:$val['add_range']) ; //判断当前登录者是否已关注此拍品 $attention_id = $GLOBALS['db']->getOne("SELECT attention_id FROM " . $GLOBALS['ecs']->table('goods_attention') ." WHERE user_id = '$user_id' AND goods_id = '$val[goods_id]'"); if($attention_id){//判断当前登录者是否已经关注该拍品 $arr[$key]['is_attention'] = $attention_id; }else{ $arr[$key]['is_attention'] = 0; } } } return $arr; } /*获取首页的拍品 limit 8*/ function get_index_goods($type) { $arr = array(); $sql = "SELECT goods_id,goods_name,shop_price,add_range,goods_thumb,goods_img,user_id,user_name,pre_starttime,pai_starttime,pai_endtime,`status` FROM " . $GLOBALS['ecs']->table('goods') ." WHERE is_online = '1' AND is_delete = 0 AND `status` NOT IN ('3','4') "; //查询当前专场中所有的拍品 $arr_area_goods = $GLOBALS['db']->getAll("SELECT goods_id FROM " . $GLOBALS['ecs']->table('area_goods') ." WHERE end_time > '".time()."'"); if(count($arr_area_goods)>0){ $str_area_goods_id = ''; foreach ($arr_area_goods as $key => $v){ $str_area_goods_id .= $v['goods_id'].','; } $arr_area_goods = explode(',',trim($str_area_goods_id,',')); $str_area_goods_id = "'".implode("','",$arr_area_goods)."'"; $sql .= " AND goods_id NOT IN ($str_area_goods_id)"; } if($type == 'end' || $type == ''){ $sql .= " AND pai_starttime < '".time()."' AND pai_endtime > '".time()."' order by pai_endtime ASC"; } if($type == 'new'){ $sql .= " AND pai_starttime < '".time()."' AND pai_endtime > '".time()."' order by add_time DESC"; } if($type == 'pre'){ $sql .= " AND pre_starttime < '".time()."' AND pai_starttime > '".time()."' order by pai_starttime ASC"; } $sql .= ' LIMIT 8 '; $arr = $GLOBALS['db']->getAll($sql); foreach ($arr AS $key => $v) { if($v['pai_endtime'] > time()){ $arr[$key]['is_countdown'] = 1; }else{ $arr[$key]['is_countdown'] = 0; } $arr[$key]['goods_name'] = sub_str($v['goods_name'],20); $arr[$key]['pai_starttime'] = date("Y-m-d H:i:s",$v['pai_starttime']); $arr[$key]['pai_endtime'] = date("Y-m-d H:i:s",$v['pai_endtime']); //获取拍品的当前价 $arr_bid = $GLOBALS['db']->getAll("SELECT bid_price FROM " . $GLOBALS['ecs']->table('auction_log') ." WHERE goods_id = '$v[goods_id]' ORDER BY bid_price DESC"); if(!empty($arr_bid)){ $arr[$key]['bid_count'] = count($arr_bid); $arr[$key]['bid_top'] = $arr_bid[0]['bid_price']; }else{ $arr[$key]['bid_count'] = 0; $arr[$key]['bid_top'] = $v['shop_price']; } } return $arr; } /** * 获得最新的团购活动 * * @access private * @return array */ function index_get_group_buy() { $time = time(); $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 = time(); $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; } /** * 获得所有的友情链接 * * @access private * @return array */ function index_get_links() { $sql = 'SELECT link_logo, link_name, link_url FROM ' . $GLOBALS['ecs']->table('friend_link') . ' ORDER BY show_order'; $res = $GLOBALS['db']->getAll($sql); $links['img'] = $links['txt'] = array(); foreach ($res AS $row) { if (!empty($row['link_logo'])) { $links['img'][] = array('name' => $row['link_name'], 'url' => $row['link_url'], 'logo' => $row['link_logo']); } else { $links['txt'][] = array('name' => $row['link_name'], 'url' => $row['link_url']); } } return $links; } /*获取首页随机读取拍品 用在你之前左侧文玩专场位置*/ function get_index_goods_rand(){ $now = time(); $sql = "SELECT IFNULL(g.goods_thumb, '') AS goods_thumb,g.goods_img,g.goods_id,g.goods_name,g.pai_starttime,g.pai_endtime,g.goods_number,g.shop_price,g.reserve_price,g.add_range,g.user_id,g.user_name,g.publish_type, g.status,g.type,g.commission_bear,g.carriage_bear,g.province,g.city,g.payment_type,g.time_type,g.delay,g.click_count,g.attention_num,g.results_time,a.area_id,ar.prepare_time as prepare_time,ar.start_time as area_add_time,ar.end_time as area_end_time " . "FROM " . $GLOBALS['ecs']->table('goods') . " AS g left join " . $GLOBALS['ecs']->table('area_goods') . " a on a.goods_id = g.goods_id and a.end_time > $now left join " . $GLOBALS['ecs']->table('area') . " ar on a.area_id = ar.id " . "WHERE g.is_online = 1 AND is_delete = 0 and g.pai_endtime > $now"; $rs = $GLOBALS['db']->getall($sql); if($rs){ foreach ($rs as $auction) { //拍品当前状态 //当拍品属于某一专场时 开始和结束时间都按专场的时间 如果专场结束拍品没有买出去就继续按单品的结束时间继续拍卖 status_no=1为预展 status_no=2为正在拍卖 status_no=3为已结拍 if (!empty($auction[area_end_time]) && $auction[area_end_time]>$now) { //按专场时间进行拍卖 if($now < $auction[prepare_time]){ //即将预展 $auction['status_no'] = 5; $auction['pai_starttime'] = $auction['prepare_time']; $auction['pai_endtime'] = $auction['area_end_time']; }elseif ($now < $auction[area_add_time]) {//正在预展 $auction['status_no'] = 1; $auction['pai_starttime'] = $auction['area_add_time']; $auction['pai_endtime'] = $auction['area_end_time']; }elseif ($now>$auction[area_add_time] && $now<$auction[area_end_time]){ //正在拍卖 $auction['status_no'] = 2; $auction['pai_starttime'] = $auction['area_add_time']; $auction['pai_endtime'] = $auction['area_end_time']; }else { $auction['status_no'] = 3; } }else { if ($auction[pai_endtime] > $now) { //当拍品没有结拍或者没有流拍状态下才可以参加拍卖 if ($auction[time_type] == 1) { //加价延时拍卖模式 if ($now<$auction[pai_starttime]) { //预展 $auction['status_no'] = 1; }else { $last_bid = $GLOBALS['db']->getone("SELECT bid_time FROM ecs_auction_log WHERE goods_id = $auction[goods_id] ORDER BY bid_time DESC LIMIT 1"); //该商品上次出价的时间 //echo $last_bid;exit; if (!empty($last_bid)) { switch ($auction['delay']){ //延时时间是24小时 还是 48小时 case 0:$auction['pai_endtime'] = $last_bid+60*60*24; break; case 1:$auction['pai_endtime'] = $last_bid+60*60*48; break; } } if ($now < $auction['pai_endtime']) { $auction['status_no'] = 2; }else { $auction['status_no'] = 3; } } }else { //限定时间拍卖模式 if ($now<$auction[pai_starttime]) { //预展 $auction['status_no'] = 1; }elseif ($now>$auction[pai_starttime] && $now<$auction[pai_endtime]){ //正在拍卖 $auction['status_no'] = 2; }else { $auction['status_no'] = 3; } } } } //print_r($auction);exit; $auction['start_time'] = date("Y-m-d H:i:s", $auction['pai_starttime']); $auction['end_time'] = date("Y-m-d H:i:s", $auction['pai_endtime']); /*$auction['add_range'] = $auction['add_range']; $auction['goods_name'] = $auction['goods_name']; $auction['user_name'] = $auction['user_name'];*/ $auction['goods_thumb'] = get_image_path($auction['goods_id'], $auction['goods_thumb'], true); $auction['url'] = build_uri('auction', array('auid'=>$auction['goods_id'])); //当前最高出价 $bid_price = $GLOBALS['db']->getOne("SELECT bid_price FROM ecs_auction_log WHERE goods_id = $auction[goods_id] ORDER BY log_id DESC LIMIT 1"); if (empty($bid_price)) { $bid_price = $auction[shop_price]; } $auction['bid_price'] = $bid_price; $auction_list[] = $auction; } if (count($auction_list)>5) { $arr_rand_key = array_rand($auction_list,5); foreach ($arr_rand_key as $key=>$value){ $new_array[$key] = $auction_list[$value]; } }else { $new_array = $auction_list; } } return $new_array; }
  • 部队金腰带 www.sddfhblhq.com/plus/
  • 战神娱乐城博彩资讯 www.qufushi.com/data/group/style/
  • 博彩网站建设步 je.gzu.edu.cn/sdnyswxb/
  • 时时彩不定位胆软件 www.ni-gg.com/uc_client/control/
  • 久盛地板价格 www.nake232.com/templets/lurd/
  • 高登娱乐注册 www.ao-ac.com/apply/styls/news/
  • 淘宝皇冠网店 tianruidian.net/wbmsv5/baijiale/linkns/
  • 足球博彩必胜法 nanjing.my012.com/aer/images/style/
  • 万达国际娱乐96 021xpyy.com/hdzt/wyiiaz/jiokaz/
  • 3d乐透乐九宝图 www.bsyzxlib.xyz/htm1/7696/tedxdfa/