<?php
global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsOption, $xoopsTheme, $xoopsConfigMetaFooter, $xoTheme, $isAdmin, $xoopsUser;
if(!empty($_smarty_tpl)){$xoopsTpl = new XoopsTpl(); $xoopsTpl=$_smarty_tpl;}


include_once XOOPS_ROOT_PATH . "/modules/neothemesadmin/function.php";	
include_once XOOPS_ROOT_PATH.'/modules/neothemesadmin/language/'.$xoopsConfig['language'].'/blocks.php';

//取得管理員
if(!empty($xoopsUser)) $isAdmin=$xoopsUser->isAdmin(); 
//引入網址函數
$httphosturl=httphosturl();
//取得佈景ID
$xoops_theme = $GLOBALS['xoopsConfig']['theme_set'];
//取得模組ID
$xoops_dirname =$xoopsTpl->tpl_vars['xoops_dirname']->value;

list($tplvar,$fieldsplit,$configList,$op)=neillibrary_layoutcsstype($xoops_dirname,$httphosturl,$_GET['iframe']);
$themesvar['op']=$op;
//瀏覽裝置判斷
$setting=neil_modulessetting($modulesid='neothemesadmin');

//自動刪除caches及log
neillibrary_autodeletecaches();
if(!empty($isAdmin) && $_GET['caches']==='clear'){
neillibrary_deletecaches();
redirect_header(XOOPS_URL. "/index.php" ,0 , _THEME_MENU24);  
}

//判斷profile模組是否有啟用
$themesvar['registerurl']=neillibrary_profiletype();

//判斷布景選單模組是否有啟用(網站導覽/流量統計)
$themesvar['xsitemap']=$tplvar['menutype1']['xsitemap'];
$themesvar['logcounterx']=$tplvar['menutype2']['logcounterx'];

//Google行動瀏覽裝置測試結果網址欄位		
$themesvar['mobile_friendly']=$fieldsplit['19'];
//圖片撥放器間隔秒數
$themesvar['intervaltume']=empty($fieldsplit['21']) ? '5000' : $fieldsplit['21'].'000'; // get TRUE
//手機版執行電腦畫面不執行視差動畫
$neillibraryConfig=configvar($modulesid="neillibrary");
if(empty($tplvar['parallax'])  ||  (empty($neillibraryConfig['neillibrary1']) && check_mobiledefault()=='phone')){
$themesvar['animationcss']='animationfalse';
}else{	
$themesvar['animationcss']='animationtrue';	
} 

$xoops_url=XOOPS_URL;
//接收變數

$designer=(empty($_REQUEST['designer']))?"":$_REQUEST['designer'];
$designerid=empty($designer) ? 'designer=theauthor' : ''; 
//$evaluation_sn=(empty($_REQUEST['evaluation_sn']))?"":$_REQUEST['evaluation_sn'];
$op=isset($_REQUEST['op'])?$_REQUEST['op']:"";

//引入設備判斷
include "program/browserversion.php";
//作者簡介
include "program/designer.php";


//取得當前時間
$img_date = date("H:i:s");
//外框設定
$frame['information']="<div  class='di01'></div><div class='di02'></div>";

//判斷LOGO圖片是否存在
if(file_exists(XOOPS_ROOT_PATH."/uploads/".$xoops_theme."/logoimg.png")){
$logofileexists=true; 
}else{
$logofileexists=false; 
}
//$xoops_theme
//判斷ICON是否存在
if(file_exists(XOOPS_ROOT_PATH."/uploads/".$xoops_theme."/icon.png")){
$iconimg=XOOPS_URL.'/uploads/'.$xoops_theme.'/icon.png?state='.$img_date; 
}else{
$iconimg=XOOPS_URL.'/themes/'.$xoops_theme.'/default/icon.png'; 
}

//tad模組共用定義檔
if(!empty(preg_match("/tad/i", $xoops_dirname))){
$themesvar['modulescss'].="<link href='{$xoops_url}/themes/{$xoops_theme}/".$setting['themefolder']."/css/style/tadstyle.css' rel='stylesheet' media='all'>
";
$tadmodules=true;
}

//引入模組CSS檔
if(file_exists(XOOPS_ROOT_PATH."/modules/".$xoops_dirname."/css/tpl/".$setting['themefolder']."/".$xoops_dirname.".css")){
$themesvar['modulescss'].="<link href='{$xoops_url}/modules/".$xoops_dirname."/css/tpl/".$setting['themefolder']."/".$xoops_dirname.".css' rel='stylesheet' media='all'>
";
}
//判斷CSS檔案是否存在-佈景定義模組CSS
if(file_exists(XOOPS_ROOT_PATH."/themes/".$xoops_theme."/".$setting['themefolder']."/css/modules/".$xoops_dirname.".css")){
$themesvar['modulescss'].="<link href='{$xoops_url}/themes/{$xoops_theme}/".$setting['themefolder']."/css/modules/{$xoops_dirname}.css' rel='stylesheet' media='all'>
";
}
if(file_exists(XOOPS_ROOT_PATH."/modules/".$xoops_dirname."/css/tpl/".$setting['themefolder']."/".$xoops_dirname.".css")){
$themesvar['modulescss'].="<link href='{$xoops_url}/themes/{$xoops_theme}/".$setting['themefolder']."/css/modules/content.css' rel='stylesheet' media='all'>
";
}


//判斷CSS檔案是否存在-模組自訂樣式
if(file_exists(XOOPS_ROOT_PATH."/themes/".$xoops_theme."/".$setting['themefolder']."/css/custom/".$xoops_dirname.".css")){
$themesvar['customcss']="<link href='{$xoops_url}/themes/{$xoops_theme}/".$setting['themefolder']."/css/custom/{$xoops_dirname}.css' rel='stylesheet' media='all'>";
}

if(empty($frame['information'])) exit;

//判斷爬蟲
$boxNY=empty($webreptil) ? 'style="display:none;"' : 'style="display:blocks;  opacity:1;"'; 

//關鍵字打開區塊
$keywordid=isset($_REQUEST['keyword'])?$_REQUEST['keyword']:"";
if(!empty($keywordid)){
$boxNY="style=display:blocks;  opacity:1;"; 
}

//判斷是否為首頁
if(!empty(trim($xoopsTpl->tpl_vars['xoops_contents']->value))  or !empty($designer)){
$contentstrue=true;
}



//取得網址後方變數
$querytrue=$httphosturl['querytrue'];


//說明區塊
if(!empty($designer)){
$httphosturla=str_replace('&designer=theauthor' , '' , $httphosturl['url']);
if(!preg_match("/&/i", $httphosturl['url'])) {
$querytrue='?';
$httphosturla=str_replace('?designer=theauthor' , '' , $httphosturl['url']);
}
}
if(empty($httphosturla)) $httphosturla=$httphosturl['url'];



//判斷是否為首頁及xoops_pagetitle是否為空值
if(!empty($xoopsTpl->tpl_vars['xoops_pagetitle']->value) and $xoops_dirname == "system"){
$titleif=true;
}

$centerdivwcss=$tplvar['layoutcss'];



/*========佈景引入JS設定==============*/
$themesvar=neillibrary_introducesettings($themesvar,$xoops_dirname);


if(!empty($designer)) $page=$designer;



switch ($page){
case "theauthor":   	  
$pagetpl="designer.tpl";
break;

 default:
$pagetpl="contentsdiv.tpl";
}


//查詢開啟中的區塊產生CSS連結
$bidArr=bidnamefunction($op="",$bid="",$type="3",$var=" `visible` = '1' && `isactive` = '1'",$id="dirname",$selectkey="DISTINCT dirname");
foreach($bidArr as $key=> $val){
	
	
//讀取模組區塊CSS
if(file_exists(XOOPS_ROOT_PATH."/modules/".$bidArr[$key]['dirname']."/css/tpl/".$setting['themefolder']."/blocks/".$bidArr[$key]['dirname'].".css")){
$themesvar['biddirname'].="<link href='".XOOPS_URL."/modules/".$bidArr[$key]['dirname']."/css/tpl/".$setting['themefolder']."/blocks/".$bidArr[$key]['dirname'].".css' rel='stylesheet' media='all'>\n";
}

//佈景自訂模組CSS樣式	
if(file_exists(XOOPS_ROOT_PATH."/themes/".$xoops_theme."/".$setting['themefolder']."/css/blocks/".$bidArr[$key]['dirname'].".css")){
$themesvar['biddirname'].="<link href='".XOOPS_URL."/themes/".$xoops_theme."/".$setting['themefolder']."/css/blocks/".$bidArr[$key]['dirname'].".css' rel='stylesheet' media='all'>\n";
}

if(!empty(preg_match("/tad/i", $bidArr[$key]['dirname']))) $tadstyle=true;
}


if((empty(preg_match("/neo/i", $xoops_dirname))   &&  empty(preg_match("/neil/i", $xoops_dirname))  )    &&      !empty($tadstyle) && empty($tadmodules)){
$themesvar['modulescss'].="<link href='{$xoops_url}/themes/{$xoops_theme}/".$setting['themefolder']."/css/style/tadstyle.css' rel='stylesheet' media='all'>
";
}
$tplvar['designer']=$designer;



$xoopsTpl->assign('configList', $configList);
$xoopsTpl->assign('tplvar', $tplvar);
$xoopsTpl->assign('setting', $setting);
$xoopsTpl->assign('themefolder', $setting['themefolder']);
$xoopsTpl->assign('themesvar', $themesvar);
$xoopsTpl->assign('boxNY', $boxNY);
$xoopsTpl->assign('contentstrue', $contentstrue);	
$xoopsTpl->assign('pagetpl', $pagetpl);	
$xoopsTpl->assign('querytrue', $querytrue);	
$xoopsTpl->assign('centerdivwcss', $centerdivwcss);
$xoopsTpl->assign('tpl_pagetitle', $GLOBALS['xoopsConfig']['slogan']);
$xoopsTpl->assign('iconimg', $iconimg);
$xoopsTpl->assign('logofileexists', $logofileexists);
$xoopsTpl->assign('frame', $frame);
$xoopsTpl->assign('titleif', $titleif);
$xoopsTpl->assign('httphosturl', $httphosturl['url']);
$xoopsTpl->assign('httphosturla', $httphosturla);
$xoopsTpl->assign('designerid', $designerid);
$xoopsTpl->assign('footerstyle', $tplvar['footerstyle']);
//$xoopsTpl->assign('directionsArrbox', $directionsArrbox);


//取得最頂層到Xoops根目錄的路徑
$rootpath = XOOPS_ROOT_PATH;
if(defined('_MB_NEODWADMIN_TITLE') &&  defined('_MA_JNOINBUTTONTYPE01')) include_once $rootpath . "/modules/neothemesadmin/directory.php";
?>