<?php
if(!defined('IN_DEMOSOSO')) {
  exit('this is wrong page,please back to homepage');
}
//-------------
define('BASEURL',$baseurl);
define("HOSTNAME", $_SERVER['HTTP_HOST']);

ini_set('display_errors', TRUE);//false
//ini_set("error_reporting","E_ALL & ~E_NOTICE");
  //ini_set('display_errors', FALSE);
//define('WEB_ROOT', substr(dirname(__FILE__), 0, -4));
//define('TPLBASEROOT',WEB_ROOT.'html/');
//define('SES_ROOT',WEB_ROOT.'cache\ses');
//change below in single website
$curwebroot = str_replace('\\','/',dirname(__FILE__));
define( 'WEB_ROOT', $curwebroot . '/' );
//define('WEB_ROOT', substr(dirname(__FILE__), 0, -22));


require_once WEB_ROOT.'component/dm-config/session_config.php';

 
define('INCLUDE_ROOT',WEB_ROOT.'component/dm-include/');
define('PLUGIN_ROOT',WEB_ROOT.'component/plugin/');
define('TEMPLATEROOT',WEB_ROOT.'DMYI-template/');
define('TEMPLATEPATH',$baseurl.'DMYI-template/');
//define('REGIONROOT',WEB_ROOT.'DM-region/');
//define('REGIONPATH',$baseurl.'DM-region/');
 define('MEMBERROOT', WEB_ROOT.'DM-member/'); 
 define('BLOCKROOT', WEB_ROOT.'DM-block/');//base hmtl dir
 define('SYSBLOCKROOT', WEB_ROOT.'DM-block/sysblock/');//base hmtl dir
define('BLOCKPATH',$baseurl.'DM-block/');
define('JTHOMEROOT', WEB_ROOT.'DM-block/jthome/'); define('JTHOMEPATH',$baseurl.'DM-block/jthome/');
define('JTEFFECTROOT', WEB_ROOT.'DM-block/jteffect/'); define('JTEFFECTPATH',$baseurl.'DM-block/jteffect/');
define('ZSTATICROOT', WEB_ROOT.'DM-block/jteffect/zstatic/'); define('ZSTATICPATH',$baseurl.'DM-block/jteffect/zstatic/');

define('JTBLOCKROOT', WEB_ROOT.'DM-block/jtblock/'); define('JTBLOCKPATH',$baseurl.'DM-block/jtblock/');
define('HEADERROOT', WEB_ROOT.'DM-block/header/'); define('HEADERPATH',$baseurl.'DM-block/header/');
define('ADMINDIR',@$_COOKIE['admindir']);
define('ISADMIN',@$_COOKIE['isadmin']);
$PHP_SELF=$_SERVER['PHP_SELF'];
 
//see vendor/wxido/dm_wxico.php
//----------
$cfg_cinc='component/dm-config/';
 define('CONFIG_ROOT', WEB_ROOT.$cfg_cinc);
require_once WEB_ROOT.$cfg_cinc.'inc_table.php';
require_once CONFIG_ROOT.'config.php';
require_once CONFIG_ROOT.'text_can.php';
//require_once WEB_ROOT.$cfg_cinc.'fsession.php';
$arrdatabase =  require_once CONFIG_ROOT.'database.php';
//print_r($arrdatabase);
require_once CONFIG_ROOT.'mysql.php';
require_once CONFIG_ROOT.'global.common.php';
 //require_once CONFIG_ROOT.'sqlite_func.php';
//front func echo SES_ROOT.'<br />';

$targetv = ''; //$targetv is set in page_search, and list_text.php
$routeid='';$alias='';$ifalias='';$offset=5;$page_total='';

$routeid = @htmlentitdm($_GET['routeid']);
$alias = @htmlentitdm($_GET['alias']);
$ifalias = @htmlentitdm($_GET['ifalias']);
if(@$file=='')  $file = @htmlentitdm($_GET['file']);
$detailid = @htmlentitdm($_GET['detailid']);$brandid = @htmlentitdm($_GET['brandid']);
$page = @htmlentitdm($_GET['page']);
 if (!isset($page)) $page=1;
$pagelayout ='';

  /*------------some variable------------*/
    $title='';
    $pid=$curpidname = $pidname ='';
    $maintitle = $mainpid= $mainpidname= $mainalias='';//parent parent
    $modtype='';
    $sidebarcss =  $contentcss =  $bodycss='';

    $maxline= $listfg ='';
    $breadarr = array();
    $seo1 = array();$seo2 = array();$seo3 = array();
    //array_push($stack, "apple", "raspberry");
    //array_unshift($seo1, $row['seo1']);


//
$act = @htmlentitdm($_GET['act']);$act2 = @htmlentitdm($_GET['act2']);$pidname = @htmlentitdm($_GET['pidname']);
$alias = @htmlentitdm($_GET['alias']);$tid = @intval($_GET['tid']);
$catid = @intval($_GET['catid']);

$fid = @intval($_GET['fid']);$search = @htmlentitdm($_GET['search']);$searchpage = @htmlentitdm($_GET['searchpage']);//htmlspecialchars
//
if(empty($act)) $act='index';
if($catid=='') $catid=0;

/*------------some variable------------*/

$dateall = date("Y-m-d H:i:s");
$dateday = date("Y-m-d");

//-----begin lang-------------

    

define('MAINLANG', $mainlang);  //must here ,only use in front
define('LANG', $mainlang);
define('LANGPATH',  $mainlang); //when no multi lang...
define('BASEURLPATH',  $baseurl);

 
//-----end lang-------------

/*------------------------------------*/
$sql = "SELECT bh from ".TABLE_USER." where userdir='$userdir'   limit 1";
  if(getnum($sql)==0){ echo  'not exist user...';exit;}
  else{
    $row = getrow($sql);
    $user2510= $userbh = $row['bh'];
    define('USERBH', $userbh);
    $andlangbh=" and lang='".LANG."'  and pbh='".USERBH."' ";
    $noandlangbh=" lang='".LANG."'  and pbh='".USERBH."' ";
    define('ANDLANGBH', $andlangbh);
    define('NOANDLANGBH', $noandlangbh);



    $sql = "SELECT * from ".TABLE_LANG." where lang='".LANG."'  limit 1";
    $row = getrow($sql);
    if($row=='no') die('sorry,no lang...'.LANG);
    $websitename = $row['sitename']; define('WEBSITENAME', $websitename);
   // $langfile = $row['langfile'];
    $cssversion = $row['cssversion'];
     //$arr_assets = $row['arr_assets'];
    $arr_basicset = $row['arr_basicset'];
    $arr_font = $row['arr_font'];
    $arr_smtp = $row['arr_smtp'];
   
    $arr_textcfg = $row['arr_textcfg'];

    $curstyle = $row['curstyle'];//use for if editlink
 



$tagmaxline=20; //just init.
$searcherror=$linkfont = $sitecss = $procatpid = '';
        //-----arr_basicset---------------------
  $bscntarr = explode('==#==',$arr_basicset);
     if(count($bscntarr)>1){
          foreach ($bscntarr as   $bsvalue) {
             if(strpos($bsvalue, ':##')){
               $bsvaluearr = explode(':##',$bsvalue);
               $bsccc = $bsvaluearr[0];
               $$bsccc=$bsvaluearr[1];
             }
          }
      }
       //-----arr_font---------------------
  $bscntarr = explode('==#==',$arr_font);
     if(count($bscntarr)>1){
          foreach ($bscntarr as   $bsvalue) {
             if(strpos($bsvalue, ':##')){
               $bsvaluearr = explode(':##',$bsvalue);
               $bsccc = $bsvaluearr[0];
               $$bsccc=$bsvaluearr[1];
             }
          }
      }

     //-----arr_lang_textcfg---------------------
  $bscntarr = explode('==#==',$arr_textcfg);
     if(count($bscntarr)>1){
          foreach ($bscntarr as   $bsvalue) {
             if(strpos($bsvalue, ':##')){
               $bsvaluearr = explode(':##',$bsvalue);
               $bsccc = strtoupper($bsvaluearr[0]);
              // $$bsccc=$bsvaluearr[1];
               define($bsccc,$bsvaluearr[1]);
             }
          }
      }

//--------------------------------------
 $jssearchpop1 ='jssearchrg';
 $jssearchpop2='prog_searchinput';
 $sta_searchpop = '';
if($sta_searchpop=='y'){//no use...
  $jssearchpop1 ='jssearchrg_pop';
    $jssearchpop2='prog_searchinput_pop';
}

if(DMFABU=='n')  $cssversion = rand(1111,9999);
    define('CSSVERSION',$cssversion);
    define('STA_FRONTEDIT',$sta_frontedit);

    /*---------some config, other in config.php above require*/
        $uploaddir=LANG.'/';
        $stapath=$baseurl.$stadir;
        define('STAPATH', $stapath);
        define('STAROOT',WEB_ROOT.$stadir);
        define('UPLOADROOT',STAROOT.'upload/');
        define('UPLOADROOTIMAGE',STAROOT.'upload/image/'.$uploaddir);
        define('TMIMG',STAPATH.'img/tm.gif');




        define('ADMIN', 'n');//use url function when link target
    //---------------

// $bsbanner=$bsbannermob=$bsindex=$bsindexmob=$bsmenu=$bsfooter=$bsfootermob=$bsfooternavmob='';
$sqlstyle = "SELECT * from ".TABLE_STYLE." where pidname='$curstyle' $andlangbh limit 1";
 //echo $sqlstyle;exit;
$color='';
if(getnum($sqlstyle)>0){
  $rowstyle = getrow($sqlstyle);
   // pre($rowstyle);

   $style_blockid = $rowstyle['style_blockid'];

  $htmldir = $rowstyle['htmldir'];

  $addcss = $rowstyle['addcss'];
  $addjs = $rowstyle['addjs'];


  if(DMFABU=='n'){
         if(@$_COOKIE["cookiehtmldir"]<>'')   $htmldir = $_COOKIE["cookiehtmldir"];
      }


  /*------------css dir--------------------------------------*/
 
          define('HTMLDIR', $htmldir);
           define('TPLCURROOT', TEMPLATEROOT.$htmldir.'/'); //cur html dir

      //echo TPLCURROOT;

       if(!is_dir(TPLCURROOT))
        {
          echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><p style="padding:10px;background:red"> 模板目录'.$htmldir.'不存在！请到官网确定此模板是否需要购买，或参考视频教程来创建模板。</p>';
          exit;
        }


     define('TPLCURPATH',TEMPLATEPATH.$htmldir.'/');


       define('DEFAULTIMG',STAPATH.'img/defaultimg.jpg');
       define('DEFAULTIMGDIV','<img src="'.DEFAULTIMG.'" alt="" />');


  /*-----------style_blockid-----------------*/
  $mbhome = $mbhomemob = '';
    $bscntarr = explode('==#==',$style_blockid);
    // pre($bscntarr);
     if(count($bscntarr)>1){
        foreach ($bscntarr as   $bsvalue) {
           $bsvaluearr = explode(':##',$bsvalue);
           $bsccc = $bsvaluearr[0];
           $$bsccc=$bsvaluearr[1];
        }
    }
    //------------
   if($header_pc_cus<>'') $header_pc = $header_pc_cus;
    if(isdmmobile()){
           $logoimg = $bsheaderlogomobi==''?$bsheaderlogo:$bsheaderlogomobi;
           $mbhome = $mbhomemob==''? $mbhome:$mbhomemob;
           $mbbannerhome = $mbbannerhome_mobi==''? $mbbannerhome:$mbbannerhome_mobi;


           if($bsfootermob<>'') $bsfooter= $bsfootermob; 
           if($header_mobi<>'') $header_pc= $header_mobi;  

        }
    else $logoimg = $bsheaderlogo;




    //-------------------

  }
 else{
  echo 'sorry,not found,maybe style and lang not match（当前语言是不是没有启用模板）......pls refresh page, or contact us: www.demososo.com';
  setcookie("curstyle",'');//the reste cookie........
  exit;
 }


//----------------------

}


  $bodysetattr = '';
  
  //---some tpl hook file---
 

 define('PAGE404', tplhookfile('404.php'));
 define('PAGELANG404', tplhookfile('lang404.php'));
 
//-------------

function dmlogin(){
    if(ISADMIN=='y' &&STA_FRONTEDIT=='y') return true;
    else return false;

}




 define('UPLOADPATH', $stapath.'upload/');
define('UPLOADPATHIMAGE', UPLOADPATH.'image/'.$uploaddir);

$logoimgorg = $logoimg;//$logoimgorg use for mb logo img
$logoimg = UPLOADPATH.'image/'.$logoimg;
  define('LOGOIMG',$logoimg);

?>
<?php
require  INCLUDE_ROOT.'func_frontcommon.php';

//$langfileV = WEB_ROOT.'component/lang/'.$langfile;
//if(checkfile($langfileV)) require_once($langfileV);

require  INCLUDE_ROOT.'func_block.php';
require  INCLUDE_ROOT.'func_jtchangearr.php';
 //require  CONFIG_ROOT.'sqlite_conn.php';



//function layoutcur($pid,$type){  //invoke is in page
//layout will not use from 2022.5
//require  INCLUDE_ROOT.'func_layout.php';
//layoutcommon(); //must need

//$tplfunction = TPLCURROOT.'/tplfunction.php';
//if(is_file($tplfunction)) require $tplfunction;

//--------for member---
$filefilefile = $file; //use in meta_cssjs.php,when member,add member.css...just avoid repeat name $file,
//echo $filefilefile;
 //判断tpl在哪个目录。
$tplroot = is_dir(TPLCURROOT.'tpl')?TPLCURROOT.'tpl/':BLOCKROOT.'tpl/';
define('TPLROOT',$tplroot);
//echo TPLROOT;
//---------------

 //if(is_int(strpos($file,'ajaxmem/'))) {   //use for $file='file_formpost/formpost_'.$type; ... in dmpostform.php
 // $filev = MEMBERROOT.$file.'.php';
  //if(checkfile($filev)) require $filev;
       //if(is_file($filev)) require  $filev;
      // else echo $file.'.php  - file not exist;';
//}

if($file=='member') {   
  $filev = MEMBERROOT.'file_member.php';
   if(checkfile($filev)) require $filev; 
 }
else if(is_int(strpos($file,'file_formpost/'))) {
      $filev = INCLUDE_ROOT.$file.'.php';
      if(checkfile($filev)) require $filev; 
  }
 else  require  INCLUDE_ROOT.'file_inc.php';

 