caching = true; } //$smarty->display('_tan_test2.htm'); //$smarty->display('main.dwt'); //exit; $cache_id = sprintf('%X', crc32('main-' .$_SESSION['user_rank'].$_CFG['lang'])); if (!$smarty->is_cached('main.dwt', $cache_id)) { assign_template(); // print_r(get_article_children('18')); $position = assign_ur_here(0,'产品信息' ); $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()); // 分类? // echo "==================categories
"; // var_dump(get_categories_tree()); $smarty->assign('helps', get_shop_help()); // 网店帮助 // $smarty->assign('top_goods', get_top10()); // 销售排? // $smarty->assign('new_goods', get_recommend_goods('new','',10)); // 最新商? // print_r(get_recommend_goods('best')); $smarty->assign('best_goods', get_recommend_goods('best','',12)); // 推荐商品 // $smarty->assign('new_goods', get_recommend_goods('new')); // 最新商? // $smarty->assign('hot_goods', get_recommend_goods('hot')); // 热点文章 // $smarty->assign('hot_goods_calipers', get_recommend_goods_bycatids('hot','',array("1","2","3","6"),9,'_calipers')); // 首页卡尺 // $smarty->assign('hot_goods_indicators', get_recommend_goods_bycatids('hot','',array("8","9","10"),6,'_indicators')); // $smarty->assign('hot_goods_micrometers', get_recommend_goods_bycatids('hot','',array("7"),6,'_micrometers')); // $smarty->assign('hot_goods_others', get_recommend_goods_bycatids('hot','',array("4","5","11"),10,'_others')); // $smarty->assign('reco_goods_calipers', get_recommend_goods_bycatids('hot','',array("1","2","3","6"),9,'_calipers')); // $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('pc_best',tuijuan('hot', 4)); //热销 // $smarty->assign('zuixin',tuijuan('new', 3)); //最? // $smarty->assign('cxcp',tuijuan('best', 3)); //最? // $smarty->assign('dmdz',dmdz(3)); //多买多折 /* 首页主广告设?*/ $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); } $playerdb = get_flash_xml(); foreach ($playerdb as $key => $val) { if (strpos($val['src'], 'http') === false) { // echo $uri . $val['src']; $playerdb[$key]['src'] = $uri . $val['src']; } } // print_r(index_get_new_articles_childens('18',10,'66')); // $smarty->assign('new_goods', get_recommend_goods('new')); // 最新商? $smarty->assign('shop_note', index_get_new_articles(11,5)); // 最新文? $smarty->assign('standart_arcticle_list',index_get_new_articles_childens('18',10,'66')); $smarty->assign('showslist', index_get_new_articles(23,5,66)); $smarty->assign('top_goods', get_top10('0',10)); // printf($playerdb[0]); // var_dump($playerdb[0]); $smarty->assign('playerdb', $playerdb); /* 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); } /*广告调制*/ $ads = array( 'num'=>'1',//广告数量 'id'=>'12'//广告位置id 这个id 你打开后台广告位置列表 鼠标放到每一条可以看到袄? ); $caliper_ads =insert_adsArray($ads); $smarty->assign("caliper_ads",$caliper_ads); /* 页面中的动态内?*/ assign_dynamic('main'); // echo "vvvvvvvvvvvvvvvvvssssssssssss"; } $smarty->display('main.dwt', $cache_id); function index_get_new_articles_childens($cat_id,$num=5,$titlelen = 20) { $childens=get_article_children($cat_id); // print_r($childens); // RAND() AS rnd $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id,RAND() as rnd ' . ' 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 and a.'.$childens . ' ORDER BY rnd,a.article_type DESC, a.add_time DESC LIMIT ' . $num; // echo $sql; // exit; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res AS $idx => $row) { $arr[$idx]['id'] = $row['article_id']; $arr[$idx]['title'] = sub_str($row['title'], 30);//$row['title']; $arr[$idx]['short_title'] = sub_str($row['title'], 30);//$GLOBALS['_CFG']['article_title_length'] > 0 ? // sub_str($row['title'], $titlelen) : $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'])); } // print_r($arr); return $arr; } function index_get_new_articles($cat_id,$num=5,$titlelen = 20) { $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id ' . ' 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 and a.cat_id='.$cat_id.'' . ' ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $num; $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'] = sub_str($row['title'], 30);//$GLOBALS['_CFG']['article_title_length'] > 0 ? // sub_str($row['title'], $titlelen) : $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'])); } return $arr; } function index_get_new_articlesori() { $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_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; } /** * 获得cat_id精品列表? * * @access private * @param integer * @return array */ function index_get_cat_id_goods_best_list($cat_id, $num) { $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = 1 AND (" . $cat_id . " OR " . get_extension_goods($cat_id) .")"; $cats = get_children($cat_id); $where = !empty($cats) ? "AND ($cats OR " . get_extension_goods($cats) . ") " : ''; $sql .=$where." LIMIT $num"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $goods[$idx]['id'] = $row['article_id']; $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'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $goods; } function dmdz($sum) { $sql = "SELECT g.*,count( v.goods_id) FROM ". $GLOBALS['ecs']->table('volume_price'). "as v right join ". $GLOBALS['ecs']->table('goods'). " as g on v.goods_id=g.goods_id where g.goods_id=v.goods_id group by v.goods_id desc limit ". $sum; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $goods[$idx]['goods_id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['market_price'] = price_format($row['market_price']); $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]['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']); } return $goods; } /** * 获得推荐商品 * * @access public * @param string $type 推荐类型,可以是 best, new, hot * @return array * @writer aibo */ function tuijuan($type = '', $num =0) { switch($type) { case "new": $type_sql=" and g.is_new=1 "; break; case "hot": $type_sql=" and g.is_hot=1 "; break; case "best": $type_sql=" and g.is_best=1 "; break; case "cx": $type_sql=" and g.is_promote=1 "; break; } $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.keywords, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". 'g.promote_price, promote_start_date, 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 g.is_on_sale = 1 AND g.is_alone_sale = 1 AND '. 'g.is_delete = 0 ' . $type_sql . 'ORDER BY g.sort_order, g.goods_id DESC'; if ($num > 0) { $sql .= ' LIMIT ' . $num; } $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res 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]['market_price'] = price_format($row['market_price']); $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]['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']); } return $goods; } function get_flash_xml() { $flashdb = array(); if (file_exists(ROOT_PATH . DATA_DIR . '/flash_data.xml')) { // 兼容v2.7.0及以前版? if (!preg_match_all('/item_url="([^"]+)"\slink="([^"]+)"\stext="([^"]*)"\ssort="([^"]*)"\sposition="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER)) { preg_match_all('/item_url="([^"]+)"\slink="([^"]+)"\stext="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER); } if (!empty($t)) { foreach ($t as $key => $val) { // echo $key."
"; // print_r($val); $val[4] = isset($val[4]) ? $val[4] : 0; if (isset($val[5])) { if ($val[5]==1) { $flashdb[] = array('src'=>$val[1],'url'=>$val[2],'text'=>$val[3],'sort'=>$val[4],'position'=>$val[5]); } } } } } return $flashdb; } ?> ߳ Ӱ Ƭ