<?php
if(!defined('IN_DEMOSOSO')) {
  exit('this is wrong page,please back to homepage');
}
session_start();
$mempidname = @$_SESSION['mempidname'];
$nickname = @$_SESSION['nickname'];
//-------------
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

define( 'WEB_ROOT', dirname(__FILE__) . '/' );
//define('WEB_ROOT', substr(dirname(__FILE__), 0, -22));


//define('SES_ROOT',WEB_ROOT.'cache/session');
define('INCLUDE_ROOT',WEB_ROOT.'component/dm-include/');
define('PLUGIN_ROOT',WEB_ROOT.'component/plugin/');
define('TEMPLATEROOT',WEB_ROOT.'DM-template/');
define('TEMPLATEPATH',$baseurl.'DM-template/');
//define('REGIONROOT',WEB_ROOT.'DM-region/');
//define('REGIONPATH',$baseurl.'DM-region/');
 define('MEMBERROOT', WEB_ROOT.'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('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


// echo dirname(__FILE__).'<br />';

//  echo TPLBASEROOT.'<br />';
 // echo WEB_ROOT.'<br />';
 //echo SES_ROOT.'<br />';
$installoldname = WEB_ROOT.'install.php';
if(is_file($installoldname)){
  //$installrand = 'install'.rand(1111,9999).'6'.rand(1111,9999).'.php';
  //$installtemp = WEB_ROOT.$installrand;
  //echo $installtemp;
  //rename($installoldname,$installtemp);
   echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' ;
     echo '<p style="background:red;color:#fff;padding-top:10px;text-align:center;font-size:22px">请根据提示操作：</p>';
    // echo '<br>对不起，根目录不能有install.php文件，';
     echo '<p style="background:red;color:#fff;padding:10px;text-align:center;font-size:16px">1.如果还没有安装，<a href="install.php">请点击这里（访问install.php）安装和配置> </a><br />2.如果安装成功，则请删除根目录下的install.php或改名。';
    // echo '<br /><a href="https://www.demososo.com/btdm.html" target="_blank">关于如何在宝塔上配置DM系统，请访问这></a>';
     echo '</p>';
     //已经给其随机改名为:'.$installrand;
    //  echo  '<a href="'.$baseurl.'">(点击重新进入首页)</a>';

     //exit;
}

//----------
$cfg_cinc='component/dm-config/';
require_once WEB_ROOT.$cfg_cinc.'inc_table.php';
require_once WEB_ROOT.$cfg_cinc.'config.php';
require_once WEB_ROOT.$cfg_cinc.'text_can.php';
//require_once WEB_ROOT.$cfg_cinc.'fsession.php';
$arrdatabase =  require_once WEB_ROOT.$cfg_cinc.'database.php';
//print_r($arrdatabase);
require_once WEB_ROOT.$cfg_cinc.'mysql.php';
require_once WEB_ROOT.$cfg_cinc.'global.common.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
 

    //must be here
  if(DMFABU=='n'){ 
    // pre($_COOKIE);
         if(@$_COOKIE["curstyle22"]<>'')   $curstyle = $_COOKIE["curstyle22"];
         else {
          //echo ('<script>alert("这是模板演示，请通过官网链接进入。 www.demososo.com");window.location.href="https://www.demososo.com/mb.html";</script>');
      // echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' ;

         //  echo '如果出现这个页面，请在config.php里把DMFABU改为y  <br /> <br />';

           // echo '本站只是模板演示，请通过<a href="https://www.demososo.com/mb.html">官网www.demososo.com链接进入></a> <br /> ';
            
           //echo '没有选择模板cookie，在后台模板里选择。 <br />';

 
           //echo '<br /> <a href="demo-/mb.php">demo-/mb.php</a>';
         // exit;

         }
     // if(@$_COOKIE["curstyless"]<>'')    $curstyle = $_COOKIE["curstyless"];
     // else  header('Location:http://www.demososo.com/mb.html');
  }


$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';
if($sta_searchpop=='y'){
  $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(isdmmobile()){
           $logoimg = $bsheaderlogomobi==''?$bsheaderlogo:$bsheaderlogomobi;
           $mbhome = $mbhomemob==''? $mbhome:$mbhomemob;

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

        }
    else $logoimg = $bsheaderlogo;


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


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

  }
 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 = UPLOADPATHIMAGE.$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';
//function layoutcur($pid,$type){  //invoke is in page
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;';
}
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';

 