&1x53CB;&8x60C5;&6x94FE;&8x63A5;:&9x8461;&4x4EAC;&1x73B0;&7x91D1;&6x5F00;&8x6237;&1x8461;&3x4EAC;&2x514D;&1x8D39;&6x5F00;&2x6237;&8x5A31;&1x4E50;&8x8461;&6x4EAC;&5x5F00;&3x6237;ag&2x8461;&7x4EAC;&7x5B98;&4x7F51;&9x8461;&8x4EAC;&5x5B98;&3x7F51;ag&8x7EBF;&1x4E0A;&3x8461;&6x4EAC;&3x6CE8;&3x518C;&4x6FB3;&5x95E8;&7x7EBF;&2x4E0A;&8x8461;&8x4EAC;&3x8461;&8x4EAC;&7x5F00;&4x6237;&7x8BD5;&7x73A9;&1x8461;&8x4EAC;&3x516C;&8x53F8;&4x5A31;&7x4E50;&5x8461;&8x4EAC;&7x7535;&9x5B50;&1x5F00;&5x6237;&5x8461;&3x4EAC;&2x4E9A;&4x6D32;&1x5F00;&1x6237;&9x8461;&5x4EAC;&8x5B98;&3x7F51;&8x6251;&3x514B;&4x8461;&7x4EAC;&8x5F69;&7x7968;&9x5B98;&3x7F51;&1x8461;&4x4EAC;&6x624B;&2x673A;&8x6295;&7x6CE8;&1x8461;&1x4EAC;&6x771F;&5x4EBA;&2x8D4C;&5x535A;&6x8461;&4x4EAC;&4x8D26;&2x53F7;&6x6CE8;&6x518C;&6x8461;&9x4EAC;&8x8D4C;&7x573A;&4x68CB;&2x724C;&8x8461;&7x4EAC;&9x767E;&9x5BB6;&5x4E50;&7x7EBF;&9x4E0A;&7x8461;&8x4EAC;&4x771F;&9x4EBA;&6x8461;&9x4EAC;&3x56FD;&4x9645;&5x68CB;&3x724C;&9x8461;&4x4EAC;&4x7F51;&4x7AD9;&4x6E38;&7x620F;&4x6FB3;&8x95E8;&2x8461;&1x4EAC;&2x7F51;&1x7EDC;&1x8461;&4x4EAC;&3x5BFC;&1x822A;&4x6FB3;&4x95E8;&1x8461;&7x4EAC;&1x5BFC;&6x822A;&9x8461;&6x4EAC;&4x73B0;&7x91D1;&2x7F51;&5x5740;&7x8461;&3x4EAC;&4x5F00;&2x6237;&2x8D4C;&6x573A;&9x8461;&3x4EAC;&9x5B98;&7x65B9;&5x5730;&9x5740;&6x8461;&1x4EAC;&3x5A31;&7x4E50;&7x603B;&7x4EE3;&8x5F69;&9x7968;&6x7F51;&6x7AD9;&5x8461;&9x4EAC;&4x8461;&7x4EAC;&2x5F69;&4x7968;app&5x738B;&8x8005;&1x8461;&7x4EAC;&6x5B98;&8x7F51;&1x8461;&9x4EAC;&6x535A;&9x5F69;&9x4EE3;&4x7406;&5x8461;&1x4EAC;&1x767B;&7x5F55;&8x6FB3;&1x95E8;&2x8461;&1x4EAC;&4x767B;&2x5F55;&8x8461;&7x4EAC;&9x7EBF;&3x8DEF;&9x68C0;&2x6D4B;&7x6B63;&5x89C4;&8x8461;&4x4EAC;&5x7EBF;&6x4E0A;&8x8461;&2x4EAC;&7x8D4C;&8x94B1;&4x6FB3;&7x95E8;&9x8461;&3x4EAC;&2x8D4C;&8x94B1;&7x8461;&4x4EAC;&4x6295;&5x6CE8;app&5x8461;&8x4EAC;mg&1x7F51;&3x5740;&6x8461;&2x4EAC;&9x4F53;&4x80B2;&9x6FB3;&4x95E8;&8x8461;&4x4EAC;&9x4F53;&9x80B2;&3x8461;&1x4EAC;&2x4F53;&6x80B2;&8x7F51;&9x7AD9;&2x8461;&9x4EAC;&9x4F53;&9x80B2;&7x5E73;&4x53F0;&1x8461;&2x4EAC;&1x4F53;&1x80B2;&9x6CE8;&5x518C;&8x8461;&4x4EAC;&7x7F51;&9x9875;&5x7248;&5x8461;&7x4EAC;&4x8D4C;&6x573A;app&5x8461;&3x4EAC;&4x7F51;&1x7AD9;&1x6CE8;&8x518C;&1x8461;&1x4EAC;&1x63D0;&7x73B0;&2x6FB3;&5x95E8;&5x8461;&3x4EAC;&6x63D0;&8x73B0;&1x8461;&6x4EAC;&2x7F51;&1x5740;&8x5927;&3x5168;&8x8461;&4x4EAC;&3x56FD;&5x9645;app&5x8461;&2x4EAC;&3x7F51;&6x6295;&6x5E73;&8x53F0;&5x8461;&3x4EAC;&7x624B;&6x673A;&6x7F51;&9x7AD9;&6x8461;&6x4EAC;&1x771F;&1x4EBA;&9x6CE8;&4x518C;&7x8461;&9x4EAC;&3x5916;&1x56F4;&1x6FB3;&2x95E8;&4x8461;&9x4EAC;&6x5916;&3x56F4;&7x8461;&2x4EAC;&4x76D8;&9x53E3;&7x6FB3;&5x95E8;&3x8461;&8x4EAC;&7x76D8;&4x53E3;&1x8461;&4x4EAC;&9x5F69;&2x7968;&6x5A31;&9x4E50;
/** * echula Viet Nam * ============================================================================ * 2012 * http://gianhangchatluong.com * ============================================================================ * $Author: Nguyen Huy $ * $Id: index.php 01-03-2012 $ */ define('IN_ECS', true); require(dirname(__FILE__) . '/includes/init.php'); global $seo_id; $smarty->assign('categories', get_categories_tree()); $smarty->assign('article_categories', article_categories_tree()); $smarty->assign('new_articles', index_get_new_articles()); $smarty->assign('slide', get_slide_xml()); $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()); $links = index_get_links(); $smarty->assign('img_links', $links['img']); $smarty->assign('txt_links', $links['txt']); $smarty->assign('data_dir', DATA_DIR); if ((DEBUG_MODE & 2) != 2) { $smarty->caching = true; } if (!empty($_GET['gOo'])) { if (!empty($_GET['gcat'])) { $Loaction = 'index.php?danh_muc&id=' . $_GET['gcat']; } elseif (!empty($_GET['acat'])) { $Loaction = 'index.php?the_loai&id=' . $_GET['acat']; } elseif (!empty($_GET['goodsid'])) { $Loaction = 'index.php?san_pham&id=' . $_GET['goodsid']; } elseif (!empty($_GET['articleid'])) { $Loaction = 'index.php?bai_viet&id=' . $_GET['articleid']; } if (!empty($Loaction)) { ecs_header("Location: $Loaction\n"); exit; } } $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)); } // Xử lý mod if ($foder = opendir('mod')) { $allmod=''; while (false !== ($file = readdir($foder))) { if (substr_count( $file,".php")) { $allmod.=substr($file,0,strlen($file)-4).'|'; } } $mod_arr=explode('|',$allmod); } $mod=isset($_REQUEST['mod'])?$_REQUEST['mod']:'index'; if (!isset($_REQUEST['mod'])) { $uri=str_replace('https://','',$GLOBALS['ecs']->url()); $uri=str_replace('http://','',$uri); $url=str_replace($uri,'',$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); if ($url!='') { $pos = strpos($url, '.'); if ($pos) $url=substr($url,0,$pos); $mod=$url; $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('seo'). " AS s WHERE s.url = '" . $url . "'"; $seo= $GLOBALS['db']->getRow($sql); if ($seo) { $seo_id=$seo['id']; switch ($seo['loai']) { case 0: //custom $mod=str_replace('-','_',$seo['url']); break; case 1: //sản phẩm $mod='san_pham'; $goods_id=$seo['id']; break; case 2: //Danh mục sản phẩm $mod='danh_muc'; $cat_id=$seo['id']; break; case 3: //Danh mục bài viết $mod='the_loai'; $cat_id=$seo['id']; break; case 4: //Bài viết $mod='bai_viet'; $article_id=$seo['id']; break; case 5: //Thương hiệu $mod='thuong_hieu'; $brand_id=$seo['id']; break; } } elseif (in_array(str_replace('-','_',$url),$mod_arr)) { $mod=str_replace('-','_',$url); } else { $pos1 =strpos($_SERVER['REQUEST_URI'],"?"); if ($pos1) { $mod=end(explode("?", $_SERVER['REQUEST_URI'])); $pos = strpos($mod, '&'); if ($pos) $mod=substr($mod,0,$pos); } } } } $smarty->assign('mod', $mod); if (!in_array($mod,$mod_arr) && $mod!='index') $mod='404'; if ($mod=='404' && isset($_REQUEST['lang'])) $mod='index'; // Trang chủ if ($mod=='index') { $cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . $_SESSION['tien_te']. '-' . $_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('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('group_buy_goods', index_get_group_buy()); $smarty->assign('gioi_thieu', get_article_info(6)); $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 */ $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'); } $smarty->display('index.dwt', $cache_id); } //Mod nằm ngoài danh sách elseif (!in_array($mod,$mod_arr)) { include('mod/404.php'); } // Sản phẩm else { include('mod/'.$mod.'.php'); } // Các hàm của trang chủ function index_get_new_articles() { $sql = 'SELECT a.article_id, a.title, a.content, ac.cat_name, a.add_time, a.file_url,a.img_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]['file_url'] = empty($row['file_url'])?$GLOBALS['_CFG']['no_picture']:$row['file_url']; $arr[$idx]['img_url'] = empty($row['img_url'])?$GLOBALS['_CFG']['no_picture']:$row['img_url']; $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']); $arr[$idx]['content'] = strip_tags($row['content']); $arr[$idx]['content'] = str_replace ("'","\'",$arr[$idx]['content']); $arr[$idx]['content'] = str_replace ('"',"\'",$arr[$idx]['content']); $arr[$idx]['content'] = str_replace ("\n","",$arr[$idx]['content']); } return $arr; } 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; } 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; } /** * * @access private * @return array */ function index_get_links() { $sql = 'SELECT link_logo, link_name,link_name_en, 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 ($_SESSION['lang']=='en' && !empty($row['link_name_en'])) { $row['link_name']=$row['link_name_en']; } 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_slide_xml() { $flashdb = array(); if (file_exists(ROOT_PATH . DATA_DIR . '/flash_data.xml')) { if (!preg_match_all('/item_url="([^"]+)"\slink="([^"]+)"\stext="([^"]*)"\ssort="([^"]*)"/', 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) { $val[4] = isset($val[4]) ? $val[4] : 0; $flashdb[] = array('src'=>$val[1],'url'=>$val[2],'text'=>$val[3],'sort'=>$val[4]); } } } return $flashdb; } function get_article_info($article_id) { $sql = "SELECT a.*, IFNULL(AVG(r.comment_rank), 0) AS comment_rank ". "FROM " .$GLOBALS['ecs']->table('article'). " AS a ". "LEFT JOIN " .$GLOBALS['ecs']->table('comment'). " AS r ON r.id_value = a.article_id AND comment_type = 1 ". "WHERE a.is_open = 1 AND a.article_id = '$article_id' GROUP BY a.article_id"; $row = $GLOBALS['db']->getRow($sql); if ($row !== false) { $row['comment_rank'] = ceil($row['comment_rank']); $row['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); if (empty($row['author']) || $row['author'] == '_SHOPHELP') { $row['author'] = 'Admin'; } } return $row; } ?>