<?php 

// 各模板都需要替换的的东西
// <link rel="alternate" href="https://es.growinbiotech.com" hreflang="es" /> 语种指示
	$ls_weburl=$ls_weburl1; //$ls_canonical
	$ls_canonical=$ls_weburl1;
	$langbutton="";
	$hreflangstr = "";
	$config_sql="select * from ls_config ";
	$config_query=$opendb->query($config_sql);
	$config_row=mysqli_fetch_assoc($config_query);


	$ls_author=date("Y", strtotime("-60 days"))."蓝信科技" ."lanscend.net.txt";
	$ls_year=date("Y");
	$ls_startyear=(trim($row['MSN2'])==""?"":$row['MSN2']." - "); // startyear
	$ls_companyname=$config_row['companyNameCn'];

	$alltrans=explode(",",$transFlags);
	$thisurl=$_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],"/ls_admin"));
	$ls_weburl=str_replace($_SERVER['SERVER_NAME'],$thisurl ,$ls_weburl);
	//echo $thisurl;
	foreach($alltrans as $eachtrans )
	{
		$ls_weburl1=$ls_weburl;
		$eachtrans=trim($eachtrans);
		$thisurl1=$_SESSION['landir']==""?$thisurl:substr($thisurl,0,(strlen($thisurl)-3));
		$ls_weburl1=str_replace($thisurl,$thisurl1."/". $eachtrans ,$ls_weburl1);
		
		$hreflangstr = $hreflangstr==""?"":$hreflangstr."\r\n";  // 英文页面中的其他语种 hreflang 指示
		if($eachtrans!="")	 $hreflangstr.='<link rel="alternate" href="https://'. $ls_weburl1.'/" hreflang="'. $eachtrans .'" />';
		else  $hreflangstr=""; 
		 
		$langbutton.=' <a hreflang="'. $eachtrans .'" href="https://'. $ls_weburl1 .'/"><img src="https://'.$thisurl.'/ls_admin/img/gq/'. $eachtrans .'.jpg" height="22" /></a>';  // 多语种按钮
		
	}
	
	 
	if(!strpos($filename,"index.html")===false) $ls_canonical=$ls_canonical."/index.html";
 	if(!(strpos($ls_canonical,":") ===false))  //增加多语种指示标签
		{ $ls_canonical=$hreflangstr."\r\n"; 		}
		else
		{ 	
			//$ls_canonical=str_replace($ls_weburl,$ls_weburl.'/'.$eachtrans , $ls_canonical);
			$ls_canonical= $_SESSION['landir']!=""?str_replace($thisurl,$thisurl."/". $_SESSION['landir'] ,$ls_canonical):$ls_canonical;
			$ls_canonical= $hreflangstr."\r\n"."<link rel=\"canonical\" href=\"https://".$ls_canonical."\" />"."\r\n";}
		
		if((strpos($ls_canonical,"192.168.2") ===false))
		{ 	$ls_canonical.='<Meta http-equiv="Cache-Control" Content="max-age=2592000">';  // 1个月
	}
		else
		{ $ls_canonical.='<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">';}
		//echo $ls_canonical;
	$content = str_replace("{langbutton}",$langbutton,$content);  //语言按钮
	$content = str_replace("{ls_canonical}",$ls_canonical,$content);

	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$config_row=mysqli_fetch_assoc($tem_query);
	$ls_sitebrand= $config_row['MSN4']; // 品牌
	 
	//{ls_searchkwds} search keywords标签，可提供优化外链
	$keywords = explode(",",$config_row['bottomMenu']);
	
	$ls_searchkwds = "";
	for($index = 0; $index < count($keywords); $index++){
		$ls_searchkwds .= "<a href=\"_".trim($keywords[$index]).".html\">".trim($keywords[$index])."</a> &nbsp; ";
	}

	// 2 $ls_schema
	if(strpos($filename,"index.html")===false) $ls_schema=$ls_schema_article; else $ls_schema=$ls_schema_index;
	$ls_schema=str_replace("{ls_title}",$ls_title==""?$ls_protitle:$ls_title,$ls_schema);	
 	$ls_schema=str_replace("{ls_description}",$ls_description,$ls_schema);	
	$ls_schema=str_replace("{ls_website}","https://".$ls_weburl,$ls_schema);	
	$ls_schema=str_replace("{ls_sitebrand}",$ls_sitebrand,$ls_schema);	
	$ls_schema=str_replace("{ls_currURL}","https://".$ls_weburl,$ls_schema);	
	$ls_schema=str_replace("{ls_proname_nonintegrate}",$ls_proname_nonintegrate,$ls_schema);	
	$ls_schema=str_replace("{ls_currTime}",date('Y-m-d H:i:s'),$ls_schema);	
	$ls_schema=str_replace("{ls_proshow}",$ls_proshow,$ls_schema);	
	$ls_schema=str_replace("{ls_proshow_width}",$showBigPicW,$ls_schema);	
	$ls_schema=str_replace("{ls_proshow_height}",$showBigPicH,$ls_schema);	

	//  constant.php
	$content = str_replace("{ls_schema}",$ls_schema,$content);	
	$content = str_replace("{ls_author}",$ls_author,$content);	
	$content = str_replace("{ls_year}",$ls_year,$content);	
	$content = str_replace("{ls_companyname}",$ls_companyname,$content);	
	
	$content = str_replace("{ls_addprolink}",$ls_addprolink,$content);
	$content = str_replace("{ls_startyear}",$ls_startyear,$content);	
	$content = str_replace("{ls_searchkwds}",$ls_searchkwds,$content);	
	$content=str_replace("{ls_relatedtags}",$ls_relatedtags,$content);  //相关tags
	$content=strippattern($content); //删除注释

	// ls_functioncode
	$code_sql="select * from ls_functioncode where enable=1 order by ID";	
	$code_query=$opendb->query($code_sql);
	while ($code_row=mysqli_fetch_array($code_query)){
		switch($code_row['codeID']){
			case "statistics":
				if($code_row['enable']){
					$statistics = $code_row['code'];
				}
			break;
			case "onlines":
				if($code_row['enable']){
					$onlines = $code_row['code'];
				}
			break;
			case "maps":
				if($code_row['enable']){
					$maps = $code_row['code'];
				}
			break;
			case "share":
				if($code_row['enable']){
					$share = $code_row['code'];
				}
			break;
			case "indexKeywords":
				if($code_row['enable']){
					$indexKeywords = $code_row['code'];
				}
			break;
			case "onlinechart":
				if($code_row['enable']){
					$onlinechart = $code_row['code'];
				}
			break;
			case "shield":
				if($code_row['enable']){
					$shield = $code_row['code'];
				}
			break;
			case "conversion":
				if($code_row['enable']){
					$conversion = $code_row['code'];
				}
			break;
		}
	}

	$content  = str_replace("{ls_conversion}",$conversion,$content); //头部代码
	
//config replace	
	$ls_feedbackemail=$config_row['feedbackEmail'];
	$ls_whatsappmb=$config_row['tel2'];
	$ls_brandword=$config_row['MSN4'];
	$ls_skype=$config_row['skype']; 	
	$ls_corekeyword=$config_row['MSN3'];
	$ls_runyear=(date("Y")-$config_row['MSN2'])+1; //经营年份
	
	$content = str_replace("{ls_feedbackemail}",$ls_feedbackemail,$content);	
	$content = str_replace("{ls_whatsappmb}",$ls_whatsappmb,$content);	
	$content = str_replace("{ls_brandword}",$ls_brandword,$content);	
	$content = str_replace("{ls_skype}",$ls_skype,$content);	
	$content = str_replace("{ls_corekeyword}",$ls_corekeyword,$content);	
	$content = str_replace("{ls_runyear}",$ls_runyear,$content);
	$content = str_replace($editorfile,$_SESSION['dda'].$editorfile,$content); //多语图片，文件路径替

	//联系我们
	$ls_tel11=$config_row['tel']; 	
	$ls_tel12=$config_row['fax']; 	
	$ls_email11=$config_row['email']; 	
	$ls_email12=$config_row['MSN']; 	
	$ls_address11=$config_row['address']; 	
	$ls_wechat11=$config_row['statistics']; 	
	$ls_postcode11=$config_row['onlines'];
	$ls_other11=$config_row['maps'];
	
	$content = str_replace("{ls_tel11}",$ls_tel11,$content);	
	$content = str_replace("{ls_tel12}",$ls_tel12,$content);	
	$content = str_replace("{ls_email11}",$ls_email11,$content);	
	$content = str_replace("{ls_email12}",$ls_email12,$content);	
	$content = str_replace("{ls_address11}",$ls_address11,$content);	
	$content = str_replace("{ls_wechat11}",$ls_wechat11,$content);	
	$content = str_replace("{ls_postcode11}",$ls_postcode11,$content);	
	$content = str_replace("{ls_other11}",$ls_other11,$content);	

	//echo $mainpartsubject."--1--".$nybnstr."--2--".$cateName; 
	if($ls_local && $ifshowbannername)echo "--".$nybnstr."-- ";
	if($nybnstr!=""){
		$addnybn=$showFolders!=""?"../":"";
		$ls_banner = "images/".$nybnstr."_banner.jpg"; //存在各内页banner 则替换 '.$nyheight.'
		if(file_exists("../".$ls_banner)) { 
			list($nywidth, $nyheight, $nytype, $nyattr) = getimagesize("../".$ls_banner);
			$content =   str_replace('<div class="nybanner"','<div class="nybanner" style="background-image:url('.$addnybn.$ls_banner.');height:px;"',$content); }
	}
	$nybnstr=""; //
	
//响应式主菜单 $ls_mainmenu
	$addcatestr=substr(str_replace(",","' or cateName='",$defaultmenu),1)."' ";
	$addcatestr2=substr(str_replace(",","' and cateName!='",$defaultmenu),1)."' ";

	$menu_prosql="select * from ls_functioncates where ( cateName='' or cateName is NULL  ".$addcatestr." ) and ( subCateName='' or subCateName is NULL ) and enable=1 order by Num ASC ";
	//echo $menu_prosql;

	$menu_proquery=$opendb->query($menu_prosql);
	$mi=1;
	while ($menu_prorows=mysqli_fetch_assoc($menu_proquery))
	{
	 	include("_ls_menu.php"); // {ls_mainmenu}
		$mi++;
	}
	$menu_mainpc.='         </ul>
        </div>';
	$menu_mainmb.='            </ul>
          </div>
		</div>';
	$ls_mainmenu=$menu_mainpc.$menu_mainmb;
	$ls_menuurl=$ls_url==""?($ls_prourl==""?"":$ls_prourl):$ls_url; //$ls_links
	//$relurl=($mainpartsubject=="index"?"{ls_url}":"{ls_url}../");
	$ls_mainmenu  = str_replace("../","{ls_url}".$addmnurl,$ls_mainmenu); //$addmnurl syscode
	$ls_mainmenu  = str_replace("{ls_url}",$ls_menuurl,$ls_mainmenu);
	$content = str_replace("{ls_mainmenu}",$ls_mainmenu,$content);	 //主菜单
 

	//首页文章
	include("_home_article.php"); //  
	$content  = str_replace("{ls_homeartile}",$ls_homeartile,$content);
	
	//首页按类别展示热点文章，先搜索大类，然后搜索中类
	 
	$p = "%{ls_article_(.*?)<}>%si"; //{ls_article_functionName 或 cateName}
	preg_match_all($p, $content ,$arr);
	$temarr = $arr[1];
	$las=count($temarr);
	if($las!=0){ //如果有
		foreach($temarr as $val){
			include("_home_article.php"); //  
			$content = str_replace("{ls_article_".$val."}", $ls_homeartile, $content);
		}
	}	
	
	//主题图链接
	$banner_sql="select * from ls_motif where enable=1 ";
	$banner_query=$opendb->query($banner_sql);
	while($banner_rows=mysqli_fetch_assoc($banner_query)) 
	{
		$bannerpic=$banner_rows['motifPic'];
		$bannerhref=trim($banner_rows['motif_href']);
		$bannerflag=substr($bannerpic,0,strpos($bannerpic,"_"));
		//echo "_src=\"url('images/".$bannerpic."')\" ";
		//var_dump(strpos($content,$bannerpic),strpos($content,"banner-img"));
		if(!strpos($content,$bannerpic)===false &&!strpos($content,"banner-img")===false && $bannerhref!="" )  //首页链接
			$content=str_replace("_src=\"url('images/".$bannerpic."')\" style=\"background:#fff center 0 no-repeat;\"","_src=\"url('images/".$bannerpic."')\" style=\"cursor:pointer;background:#fff center 0 no-repeat;\" onclick=\"self.location='".$bannerhref."';\" ",$content);
			
		else if( !strpos($content,"nybanner")===false && $bannerhref!="" && $bannerflag==$mainpartsubject )  //首页链
			$content=str_replace("<div class=\"nybanner\">","<div class=\"nybanner\" onclick=\"self.location='".$bannerhref."';\" style=\"cursor:pointer;\" > ",$content);
	}	
	
	$content  = str_replace("{ls_srcset}",$ls_srcset,$content); //分级图片

	$content = str_replace($ls_foreach_s0,$ls_list_s,$content);	//侧边栏列表
	$content = str_replace($ls_foreach_s0cate,$ls_list_scate,$content);	//侧边栏中类列表
	
	//视频会议{ls_onlinemeeting} 
	$liveurl =  $config_row['email3'];
	$livePath = "../images/".$config_row['tel4'];
	$ls_onlinemeeting='<a href="'.$liveurl.'" target="_blank" title="'.$config_row['email4'].'"><img src="'.$livePath.' width="252" height="" border="0" ></a>';
	$content = str_replace("{ls_onlinemeeting}",$ls_onlinemeeting,$content);	//侧边栏中类列表
	
	$ls_selecton=$selecton?"":'onselectstart="return false"';
	$content = str_replace("{ls_selecton}",$ls_selecton,$content);	//允许选择页面内容

?>