// alert error
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);
date_default_timezone_set('Asia/Ho_Chi_Minh');
include("includes/defines.php");
// print_r($_REQUEST);
if(USE_BENMARCH){
require('libraries/Benchmark.class.php');
Benchmark::startTimer();
}
// session
if (!isset($_SESSION)) {
session_start();
}
if(isset($_SESSION['ad_logged']) && $_SESSION['ad_logged']==1) {
$admin_log = 1;
}
else {
$admin_log =0;
}
$folder_admin = URL_ROOT.'admin_navadoen3311'.'/index.php?';
include("includes/ftp_connect.php");
include("includes/config.php");
include("libraries/database/pdo.php");
$db = new FS_PDO();
require_once ("libraries/fsinput.php");
include('libraries/fsfactory.php');
$cache = 0;
global $page_cache;
$page_cache = 1;
$mudule = FSInput::get('module');
$view = FSInput::get('view');
$type = FSInput::get('type');
$alias= FSInput::get('alias');
$id = FSInput::get('id');
$edit = FSInput::get('tmpl');
if($admin_log && $edit) {
$check_edit = 1;
}
else $check_edit = 0;
$raw = FSInput::get('raw');
$print = FSInput::get('print');
require_once ("libraries/fstext.php");
require_once ("libraries/fstable.php");
require_once("libraries/fsrouter.php");
include("includes/functions.php");
//include("libraries/database/mysql.php");
//include("libraries/database/pdo.php");
include("libraries/fscontrollers.php");
include("libraries/fsmodels.php");
include('libraries/fsdevice.php');
$actual_link_uri = "{$_SERVER['REQUEST_URI']}";
if($actual_link_uri != '/'){
$sql = " SELECT *
FROM fs_redirect AS a
WHERE redirect_from = '$actual_link_uri'
";
global $db;
$db->query ( $sql );
$record = $db->getObject();
if($record){
$link2 = $record->redirect_to;
header("Location: ".$link2, true, 301);
exit();
}
}
if ($check_edit) {
$sql = " SELECT title,link_admin
FROM fs_config_modules
WHERE module = '$mudule' AND view = '$view'
AND published = 1 ";
global $db;
$db->query ( $sql );
$resu = $db->getObject();
if($resu)
{
$title_admin = $resu -> title;
$link_admin = $folder_admin.$resu-> link_admin.'&task=edit&id='.$id;
$check_link_admin = $resu-> link_admin;
}
}
/* Phiên bản mobile */
// $mobile = @$_SESSION['run_pc'];
$detect = new FSDevice;
$is_mobile = $detect->isMobile();
if(($detect->isMobile() ) && !$detect->isTablet()){
define('IS_MOBILE', 1);
define('IS_MOBILE_PLUS', 1);
}else{
define('IS_MOBILE', 0);
define('IS_MOBILE_PLUS', 0);
}
if($detect->isTablet() )
define('IS_TABLEt', 1);
else
define('IS_TABLEt', 0);
$module = FSInput::get('module','home');
$view = FSInput::get('view',$module);
$task = FSInput::get('task');
$task = $task ? $task : 'display' ;
// language
$lang_request = FSInput::get('lang');
if($lang_request){
$_SESSION['lang'] = $lang_request;
} else {
$_SESSION['lang'] = isset($_SESSION['lang'])?$_SESSION['lang']:'vi';
}
$insights = 0;
if (isset($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'Chrome-Lighthouse') !== false){
$insights = 1;
}
//echo "request:";
//print_r($_REQUEST);
//echo "
ss:";
//print_r($_SESSION);
$use_cache = USE_CACHE;
if(isset($_COOKI['user_id']) && $_COOKIE['user_id']){
$use_cache = 0;
}
$amp = FSInput::get('amp',0,'int');
$translate = FSText::load_languages('font-end', $_SESSION['lang'], $module);
if($raw){
$global_class = FSFactory::getClass('FsGlobal');
$config = $global_class -> get_all_config();
$module_config = $global_class -> get_module_config($module,$view,$task);
$cache_time = 0;
if($use_cache){
$cache_time = isset($module_config -> cache)?$module_config -> cache:0;
}
// load main content not use Template
$fsCache = FSFactory::getClass('FSCache');
$uri = $_SERVER['REQUEST_URI'];
preg_match('#\/(.*?)\.html#is',$uri,$u);
if(isset($u[0])){
$u = $u[0];
}else{
$u = $uri;
}
$key = md5($u);
$folder_cache = 'modules/'.$module;
$content_cache = $fsCache -> get($key,$folder_cache,$cache_time);
if($content_cache){
echo $content_cache;
}else{
$html = call_module($module,$view,$task);
// put cache
$fsCache -> put($key, $html,$folder_cache);
echo $html;
}
//
}else{
// call config before call Template
$global_class = FSFactory::getClass('FsGlobal');
$config = $global_class -> get_all_config();
$module_config = $global_class -> get_module_config($module,$view,$task);
$cache_time = 0;
if($use_cache){
$cache_time = isset($module_config -> cache)?$module_config -> cache:0;
}
// load main content use Template
include("libraries/templates.php");
global $tmpl;
$tmpl = new Templates();
/* Phiên bản mobile */
// if(IS_MOBILE)
// $tmpl->tmpl_name = 'mobile';
if($print){
$main_content = loadMainContent($module,$view,$task,0);
include_once('templates/'.TEMPLATE.'/print.php');
die;
}
$file_tmpl_load = $amp?'amp.php':'index.php';
$uri = $_SERVER['REQUEST_URI'];
$tmpl_r = FSInput::get('tmpl',0,'int');
if(!$tmpl_r){
if(strpos($uri,'.html') !== false ){
if(strpos($uri,'.html') < strlen($uri) - 5){
// setRedirect(URL_ROOT.substr($uri,1,(strpos($uri,'.html')+4)));
}
}if(strpos($uri,'.amp') !== false ){
if(strpos($uri,'.amp') < strlen($uri) - 4){
setRedirect(URL_ROOT.substr($uri,1,(strpos($uri,'.html')+3)));
}
}
}
if(!$cache_time || !$use_cache || $insights){
$main_content = loadMainContent($module,$view,$task,0);
ob_start();
include_once('templates/'.TEMPLATE.'/'.$file_tmpl_load);
$all_website_content = ob_get_contents();
ob_end_clean();
if($amp){
echo get_wrapper_site($tmpl,'headerAmp',$module,0);
}else{
echo get_wrapper_site($tmpl,'header',$module,0);
}
echo $all_website_content;
if(USE_BENMARCH){
echo '