global $mc_start_time;
$mc_start_time = microtime(true);
if (REWRITE_ON) {
ob_start();//start buffering//@ob_start('ob_gzhandler');
}
function _isHttps()
{
if ($_SERVER['SERVER_ADDR']==='127.0.0.1' || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) {
return true;
} else {
return false;
}
}
function _isPageRequireHttps()
{
return HTTPS_ENABLE == 1 && in_array(@$_GET['page'], array('register', 'sign_in', 'reg_success', 'forgot_password'));
}
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
mb_internal_encoding("UTF-8");
require_once ROOT_PATH . 'core/AutoLoader.php';
require_once ROOT_PATH . 'includes/Solr/Service.php';
require_once ROOT_PATH . 'includes/Solr/Solr_Search.php';
require_once ROOT_PATH . 'includes/_solovn/sololib.php';
if (MEMCACHE_ON) {
CGlobal::$memcache_server = $memcache_server;
}
$server_list = false;
if (MEMCACHE_ON) {
$server_list = eb_memcache::do_get('server_list');
}
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
if ($server_list === false) {
$server_list = array();
$server_list_str = DB::fetch("SELECT conf_val from setting where conf_key='server_list'", 'conf_val');
if ($server_list_str) {
$server_list = unserialize($server_list_str);
}
if (MEMCACHE_ON)
eb_memcache::do_put('server_list', $server_list, 86400);
}
// js version
$eb_version = eb_memcache::do_get('eb_version');
if ($eb_version) {
CGlobal::$version = $eb_version;
} else {
eb_memcache::do_put('eb_version', TIME_NOW);
}
CGlobal::$js_ver = CGlobal::$version;
CGlobal::$css_ver = CGlobal::$version;
//end js version
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
CGlobal::$my_server = $server_list;
CGlobal::$img_server = $img_server;
CGlobal::$img_ftp_server = $img_ftp_server;
CGlobal::$img_server_extra = $img_server_extra;
if (preg_match('/enbac([0-9]+).todo.vn/', $_SERVER['HTTP_HOST'], $match)) {
CGlobal::$site = $match[1];
// die('1');
}
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
unset($memcache_server, $server_list, $img_server, $img_ftp_server);
if (isset($_REQUEST['trigger']) && (int)$_REQUEST['trigger'] == 1) {
EBArrCache::del_cache();
EBCache::auto_delete();
StaticCache::delCache();
EnBac::del_page_cache();
exit;
}
if (empty($_COOKIE)) {
CGlobal::$cityRequire = false;
}
/*$is_search_engine_array = array("Google", "Fast", "Slurp", "Ink", "Atomz", "Scooter", "Crawler", "MSNbot", "Poodle", "Genius");
$is_search_engine = 0;
foreach($is_search_engine_array as $key => $val){
if(strstr($_SERVER['HTTP_USER_AGENT'], $val))
$is_search_engine++;
}*/
if (isset($_GET['page']) && $_GET['page'] == 'error') {
define('ERROR_PAGE', 1);
} else {
define('ERROR_PAGE', 0);
}
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
if (!EnBacLib::is_search_engine() && !defined('NO_SESSION') && !ERROR_PAGE) {
if (SESSION_TYPE == 'db') {
require_once ROOT_PATH . 'includes/session.class.php';//Session db store
} elseif (SESSION_TYPE == 'memcache') {
require_once(ROOT_PATH . "includes/memcache.session.php");//Session memcache store
} else {
session_start();
}
}
define('JOB_DOMAIN', 'enbacjob.todo.vn');
$webRoot = str_replace('\\', '/', $_SERVER['HTTP_HOST'] . (dirname($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : ''));
$webRoot .= $webRoot[strlen($webRoot) - 1] != '/' ? '/' : '';
$webRoot = preg_replace('`/.*`', '', $webRoot) . '/';
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
if (HTTPS_ENABLE == 1 && (User::is_enbac_team() || _isPageRequireHttps()) && ($_SERVER['SERVER_NAME'] != JOB_DOMAIN)) {
define('WEB_ROOT', 'https://' . $webRoot);
define('HTTP_VAR', 'https');
} else {
define('WEB_ROOT', 'https://' . $webRoot);
define('HTTP_VAR', 'https');
}
if (HTTPS_ENABLE == 1) {
define('WEB_ROOT_HTTPS', 'https://' . $webRoot);
} else {
define('WEB_ROOT_HTTPS', 'http://' . $webRoot);
}
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
$list_plaza_server ['beta.enbac.com'] = 'plaza.enbac.todo.vn';
$list_plaza_server ['enbac.com'] = 'nemo.vn';
$list_plaza_server ['dev.enbac.com'] = 'dev.ebplaza.vn';
$list_plaza_server ['ebonline.enbac.com'] = 'ebonline.ebplaza.vn';
$host = $_SERVER['HTTP_HOST'];
if (isset($list_plaza_server[$host])) {
define('WEB_ROOT_EB', '//' . $host . '/');
define('WEB_ROOT_PLAZA', '//' . $list_plaza_server[$host] . '/');
} elseif (in_array($host, $list_plaza_server)) {
foreach ($list_plaza_server as $k => $v) {
if ($host == $v) {
define('WEB_ROOT_EB', '//' . $k . '/');
define('WEB_ROOT_PLAZA', '//' . $v . '/');
}
}
} else {
define('WEB_ROOT_EB', WEB_ROOT);
define('WEB_ROOT_PLAZA', WEB_ROOT . 'Plaza-thoi-trang/');
}
define('CPC_URL', WEB_DIR . EBRewrite::formatUrl("?page=cpc_ad"));
if (isset($_GET['type'])) {
CGlobal::$curItemType = (int)$_GET['type'];
}
// Disable ALL magic_quote
if (get_magic_quotes_runtime()) {
set_magic_quotes_runtime(0);
}
if (get_magic_quotes_gpc() || 1 == 1) {
function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : (EnBacLib::cleanXssAndSqlInjection($value));
return $value;
}
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
EnBacLib::getProvinces();//Get all Provinces
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
if (!ERROR_PAGE) {
//get all config
//EnBacLib::get_config();
//Get all Categories
if (isset($_GET['bds_prid'])) {
$bds_prid = (int)$_GET['bds_prid'];
if (isset(CGlobal::$provinces[$bds_prid]) && CGlobal::$provinces[$bds_prid]) {
/*CGlobal::$curBdsCity = $bds_prid;
EnBacLib::my_setcookie('bds_prid',$bds_prid,time()+3600*24*365);*/
Area::setProvince($bds_prid);
}
if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], WEB_ROOT) !== 0) {
$request_refer = WEB_ROOT;
} else {
$request_refer = $_SERVER['HTTP_REFERER'];
}
Url::redirect_url($request_refer);
}
if (isset($_GET['province_id'])) {
$province_id = $_GET['province_id'];
if ((isset(CGlobal::$provinces[$province_id]) && CGlobal::$provinces[$province_id]) ||
(isset(CGlobal::$provinces_name[strtolower($province_id)]['id']) && CGlobal::$provinces_name[strtolower($province_id)]['id'])
) {
if (isset(CGlobal::$provinces_name[strtolower($province_id)]['id']) && CGlobal::$provinces_name[strtolower($province_id)]['id']) {
$province_id = CGlobal::$provinces_name[strtolower($province_id)]['id'];
}
//Fix theo yêu cầu của CSKH miền nam
CGlobal::$curCity = $province_id;
//Area::setProvince($province_id);
}
}
if (isset($_GET['set_city']) && $_GET['set_city'] == 1) {
Area::setProvince(CGlobal::$curCity);
}
if (isset($_GET['cityid'])) {
$proName = $_GET['cityid'];
$pos = strrpos($proName, "-");
//Nếu tên shop ko có dấu - thì là chọn tỉnh thành
if ($pos !== false) {
if (isset(CGlobal::$provinces_name[strtolower($proName)])) {
if (!isset($_COOKIE["province_id"]) || (CGlobal::$provinces_name[strtolower($proName)]['id'] != $_COOKIE["province_id"])) {
$province_id = CGlobal::$provinces_name[strtolower($proName)]['id'];
Area::setProvince($province_id);
}
} /*elseif(isset(CGlobal::$allZones)){
// die(System::debug(CGlobal::$allZones));
foreach(CGlobal::$allZones as $k=>$v){
if(strtolower($v['ebname'])==strtolower($proName)) {
CGlobal::$curZone=$v;
break;
}
}
}*/
else {
Url::redirect_url(WEB_ROOT);
}
} else {
Url::redirect_url(WEB_ROOT);
}
/*
if(isset($_SERVER['HTTP_REFERER']) && strpos( $_SERVER['HTTP_REFERER'] , WEB_ROOT) == 0)
{
System::debug($_SERVER);
echo CGlobal::$curZone;
$request_refer = $_SERVER['HTTP_REFERER'];
exit;
Url::redirect_url($request_refer);
}
*/
}
if (!CGlobal::$curCity && isset($_COOKIE['province_id'])) {
CGlobal::$curCity = (int)$_COOKIE['province_id'];
}
if (!(isset($_COOKIE['province_id']) && $_COOKIE['province_id']) && isset($_SESSION['province_id']) && $_SESSION['province_id']) {
CGlobal::$curCity = (int)$_SESSION['province_id'];
}
if (isset($_GET['province_id'])) {
if (isset(CGlobal::$provinces_name[strtolower($_GET['province_id'])])) {
CGlobal::$cityName = $_GET['province_id'];
}
}
if (!CGlobal::$curBdsCity && isset($_COOKIE['bds_prid'])) {
CGlobal::$curBdsCity = (int)$_COOKIE['bds_prid'];
}
if (!CGlobal::$curBdsCity && isset($_SESSION['bds_prid'])) {
CGlobal::$curBdsCity = (int)$_SESSION['bds_prid'];
}
CGlobal::$curArea = Area::getArea(CGlobal::$curCity);
EnBacLib::getCats();
#region @disable cate and ZONE disable toàn bộ các cate và zone khác ngoài oTO =>todo: cần tối ưu lại sau
foreach (CGlobal::$allZones as $key => $val) {
if ($key != 5) {
// unset(CGlobal::$allZones[$key]);
}
}
foreach (CGlobal::$allMenuZones as $key => $val) {
if (!in_array($key, CGlobal::$cate_oto)) {
// unset(CGlobal::$allMenuZones[$key]);
}
}
foreach (CGlobal::$allCategories as $key => $val) {
if (!in_array($key, CGlobal::$cate_oto)) {
// unset(CGlobal::$allCategories[$key]);
}
if (($val['lv2'] > 0 || $val['lv3'] > 0) && in_array($val['parent_id'], CGlobal::$cate_oto) && !in_array($val['parent_id'], CGlobal::$cate_oto_layout2)) {
unset(CGlobal::$allCategories[$key]);
}
if (in_array($key, CGlobal::$cate_oto) && !in_array($key, CGlobal::$cate_oto_layout2)) {
unset(CGlobal::$allSubCate[$key]);
}
}
//System::debug(CGlobal::$allCategories);
#endregion @disable cate and ZONE
$zone_id = Url::get('zone_id');
if ($zone_id == 23 && isset($_REQUEST['page']) && $_REQUEST['page'] == 'zone') {
$_REQUEST['page'] = 'zone_23';
}
//if((isset($_GET['category_id']) && $_GET['category_id']) || (isset($_GET['zone_id']) && $_GET['zone_id']) || (Url::get("page","home") == 'home')){
if (isset($_GET['category_id']) && $_GET['category_id']) {
//EnBacLib::getCats();
if (isset($_GET['category_id']) && isset(CGlobal::$allCategories[(int)$_GET['category_id']]) && CGlobal::$allCategories[(int)$_GET['category_id']]) {
CGlobal::$curCategory = (int)$_GET['category_id'];
}
}
if (isset($_GET['href_city'])) {
if (CGlobal::$curCategory) {
$href = EnBacLib::getCateLink(CGlobal::$curCategory, CGlobal::$curCity);
} else {
if (CGlobal::$curZone) {
$href = CGlobal::$provinces[CGlobal::$curCity]['name'] . '/' . CGlobal::$curZone['eb_name'];
} else {
$href = CGlobal::$provinces[CGlobal::$curCity]['name'];
}
}
Url::redirect_url($href);
}
if (!User::is_login()) {
if (isset($_COOKIE['enbac_id']) && isset($_COOKIE['password'])) {
User::check_cookie_login($_COOKIE['enbac_id'], $_COOKIE['password']);
} else {
EnBacLib::my_setcookie('enbac_id', "", TIME_NOW - 3600);
EnBacLib::my_setcookie('password', "", TIME_NOW - 3600);
}
if (isset($_COOKIE['c_province_district'])) {
if (EnBacLib::CheckCookieLogin($_COOKIE['c_province_district'])) {
$partCookie = base64_decode($_COOKIE['c_province_district']);
$partCookie = explode(":", $partCookie);
$user = User::getByUserName($partCookie[0]);
User::LogIn($user);
} else {
EnBacLib::my_setcookie('c_province_district', "", TIME_NOW - 3600);
}
}
} else {
if (isset($_GET['login_as']) || isset($_GET['login_as_id'])) {
if (User::is_admin()) {
$user_id = (int)Url::get('login_as_id', 0);
$user = array();
if ($user_id) {
$user = User::getUser($user_id);
} else {
$user_name = EnBacLib::getParam('login_as');
if ($user_name != '') {
$user = User::getByUserName($user_name);
}
}
if ($user) {
if (User::is_root()) {
//Check root k cho login as của nhau
if (!User::is_root($user)) {
User::LogIn($user);
}
} else {
//Không cho admin login của nhau
if (!User::is_admin($user)) {
User::LogIn($user);
}
}
}
}
Url::redirect_url(Url::build_all(array('login_as', 'login_as_id')));
}
}
}
$proName = CGlobal::$provinces[CGlobal::$curCity]['name'];
$at = "";
if (CGlobal::$curCity) {
$at = "tại";
}
CGlobal::$province_name = " $at $proName";
/*Assign template*/
//Title mac dinh cho website
CGlobal::$website_title = "ÉnBạc.com";
$curCat = (int)Url::get('cat_id', 0);
//Chuyên trang mua bán tổng hợp hàng trăm nghìn sản phẩm thời trang, mỹ phẩm, điện tử, ô tô, nội thất mỗi ngày. Sàn giao dịch TMĐT chính thức của Vccorp
CGlobal::$keywords = 'Thời trang nam, thời trang nữ, mua bán, thời trang, điện thoại, máy tính, kỹ thuật số, ô tô, xe máy, đồ gia dụng, nội thất, bất động sản';
if ($curCat > 0) {
CGlobal::$meta_desc = CGlobal::$allCategories[$curCat]['name'] . ' - ' . 'Mạng mua bán, đấu giá trực tuyến ' . CGlobal::$allCategories[$curCat]['name'] . '.Thông tin sản phẩm cập nhật từng phút với hàng nghìn người tham gia mỗi giờ, Website mua bán, đấu giá lớn nhất Việt Nam';
} else {
CGlobal::$meta_desc = (CGlobal::$allCategories[CGlobal::$curCategory]["name"] ? CGlobal::$allCategories[CGlobal::$curCategory]["name"] . ' - ' : '') . 'Chuyên trang mua bán tổng hợp hàng trăm nghìn sản phẩm thời trang, mỹ phẩm, điện tử, ô tô, nội thất mỗi ngày. Sàn giao dịch TMĐT chính thức của Vccorp ' . CGlobal::$allCategories[CGlobal::$curCategory]["description"] . '';
}
//Tiền tệ:
CGlobal::$currency = array('1' => 'VNĐ');//CGlobal::$currency = array('1'=>'VNĐ','2'=>'$','3'=>'€');//'3'=>'€');
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
register_shutdown_function(array("DB", "close"));
register_shutdown_function(array("EnBacLib", "ftp_image_close"));
register_shutdown_function(array("EnBacLib", "log_slow"));
global $display;
$display = new EBDisplay();
if (isset($_GET['kbug'])) {
echo __FILE__ . __LINE__ . "
";
}
if (User::is_login())
define("EB_GOLD", (int)User::$current->data['gold']);
else
define("EB_GOLD", 0);
if (!in_array($_GET['page'], array('list_fashion', 'detail_fashion', 'home_fashion', 'order_new', 'post_item_fashion'))) {
Item::getBiddingVipConfig();
}
/*NGANNV REWRITE điện máy mới*/
if (isset($_GET['cid']) && $_GET['cid']) {
/*Tạm thời đang xử lý trong Module header*/
}
if (isset($_GET['kbug'])) {
System::debug(CGlobal::$curZone);
echo "session";
System::debug($_SESSION);
echo "GET";
System::debug($_GET);
echo "post";
System::debug($_POST);
echo "SERVER";
die(System::debug($_SERVER));
}
define('TOKEN', User::getToken());
if (isset($_GET["abug"])) {
define('ADV_OFF', (int)(boolean)$_GET["abug"]);
} elseif (isset($_SESSION['abug']) && intval($_SESSION["abug"]) > 0) {
define('ADV_OFF', 1);
} elseif (isset($_REQUEST["abug"]) && intval($_REQUEST["abug"]) > 0) {
define('ADV_OFF', 1);
} else {
define('ADV_OFF', 0);
}
if (!defined('ADV_OFF')) {
define('ADV_OFF', 0);
}
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'eb_ads.php') !== false || ADV_OFF || (isset($_GET['page']) && (in_array($_GET['page'], array('post_item')) || ($_GET['page'] == 'personal' && isset($_GET['cmd']) && $_GET['cmd'] == 'gallery')))) {
define('ADMICRO_ON', 0);
define('EB_ADS_OFF', 1);
} else {
define('EB_ADS_OFF', 0);
if (Mobile_Detect::getInstance()->isTablet()) {
define('ADMICRO_ON', 0);//1
} else {
define('ADMICRO_ON', 1);
}
}
EnBacLib::check_uri();
if (!isset($_GET['forData']) || $_GET['forData'] != 1) {
if (User::is_login()) {
if (User::is_enbac_team() && HTTPS_ENABLE && !_isHttps()) {
Url::redirect_url(str_replace('///', '/', WEB_ROOT_HTTPS . '/' . CGlobal::$request_uri), 302, 0);
}
if (!HTTPS_ENABLE && _isHttps()) {
Url::redirect_url(str_replace('///', '/', 'http://' . $webRoot . '/' . CGlobal::$request_uri), 302, 0);
}
} else {
if (_isHttps()) {
if ($_REQUEST['page'] != 'sign_out'){
// Url::redirect_url(str_replace('///', '/', 'http://' . $webRoot . '/' . CGlobal::$request_uri), 302, 0);
}
}
}
}
//check nếu là admin mà không dùng link https thì redirect về https
if (!_isHttps() && HTTPS_ENABLE == 1 && !Mobile_Detect::getInstance()->isMobile()) {
Url::redirect_url(str_replace('///', '/', WEB_ROOT_HTTPS . '/' . CGlobal::$request_uri), 302, 0);
//redirect về https
}
if (Mobile_Detect::getInstance()->isMobile() && CGlobal::$request_uri =='/' && !_isHttps() && HTTPS_ENABLE == 1) {
Url::redirect_url('https://m.enbac.com/o-to-xe-may-v5', 302, 0);
}
if (User::is_enbac_team() && (!defined('AJAX_ACTION') || !AJAX_ACTION)) {
if (User::is_enbac_team() && (!defined('AJAX_ACTION') || !AJAX_ACTION) || _isPageRequireHttps()) {
//Nếu là chủ nhà (admin) mà khong sài https thì bắt phải sài https
if (!_isHttps() && HTTPS_ENABLE == 1) {
Url::redirect_url(str_replace('///', '/', WEB_ROOT_HTTPS . '/' . CGlobal::$request_uri), 302, 0);
}
//if(!isset($_SERVER['HTTP_X_FORWARDED_PROTO']))
} elseif (!User::is_enbac_team() && !_isPageRequireHttps() && (!defined('AJAX_ACTION') || !AJAX_ACTION)) {
if (_isHttps()) {
Url::redirect_url(str_replace('https://', 'http://', str_replace('///', '/', WEB_ROOT . '/' . CGlobal::$request_uri)), 301, 0);
}
}
}
if (isset($_GET['cka'])) {
echo(__FILE__ . __LINE__);
require_once ROOT_PATH . 'core/enbac_redirect.php';
}