<?php
/*
// 生成模块： writeMainMenuItemFile（写入主菜单项文件） writeIndexPages writeProPageIndex（写入产品页和产品详细页文件）  文章类详细页  writeShowPages; circleNavigationLinkNews 下一页
// 写入模块： writelog writeconstant writegeneralfile（写入一般文件） 
// 获取模块： getproductfolder
// 图片函数：  addWatermark ImageResize   getimagewh   ifanimationgif
*/
require_once('ls_tinyfunc.php');

	
/*
------------------------------------------------------
参数：
$path	路径
程序功能：夹函数
------------------------------------------------------
*/

	function createFolder($path){
		if (!file_exists($path)){		//假如文件夹不存在
			createFolder(dirname($path));	//取得最后一个文件夹的全路径返回开始的地方
	//		$path=iconv("UTF-8","GB2312","$path");
			mkdir($path, 0775);
		}
	}


/*
------------------------------------------------------
参数：
$path	路径

程序功能：清理文件夹字符串函数
------------------------------------------------------
*/
function replaceCatesName($path)
{
	$searchstr=array(">","<");
	$replacestr=array("]","[");

	$path=str_replace($searchstr,$replacestr,$path);
  
	return($path);
}

/*
------------------------------------------------------
参数：
$path	路径

程序功能：清理文件夹字符串函数(替换多个空格)
------------------------------------------------------
*/
function clearSpace($path)
{
	$path=preg_replace("/\s+/"," ",$path);

	return($path);	
}

 

/*
------------------------------------------------------
参数：
$str_cut	需要截断的字符串
$length	 允许字符串显示的最大长度 
程序功能：截取全角和半角（汉字和英文）混合的字符串以避免乱码
------------------------------------------------------
*/
function substr_cut($str_cut,$length)
{ 
	if (strlen($str_cut) > $length)
	{ 
		for($i=0; $i < $length; $i++) 
		if (ord($str_cut[$i]) > 128)	$i++; 
		$str_cut = substr($str_cut,0,$i); 
	} 
	return $str_cut; 
}

function getimagewh($srcFile)
{
	$info = "";
	$data = GetImageSize($srcFile,$info);
	switch ($data[2]) 
	{
	 case 1:
	   if(!function_exists("imagecreatefromgif")){
		echo "你的GD库不能使用GIF格式的图片，请使用Jpeg或PNG格式！<a href='javascript:go(-1);'>返回</a>";
		exit();
	   }
	   $im = ImageCreateFromGIF($srcFile);
	   break;
	 case 2:
	   if(!function_exists("imagecreatefromjpeg")){
		echo "你的GD库不能使用jpeg格式的图片，请使用其它格式的图片！<a href='javascript:go(-1);'>返回</a>";
		exit();
	   }
	   $im = ImageCreateFromJpeg($srcFile);	
	   break;
	 case 3:
	   $im = ImageCreateFromPNG($srcFile);	
	   break;
   }
   $srcW=ImageSX($im);
   $srcH=ImageSY($im);
   $srcWH=$srcW/$srcH;
   return array($srcW,$srcH);
}
/*
------------------------------------------------------
参数：
$srcFile 源图片地址
$toW	 生成图片宽度 
$toH		 生成图片高度 
$toFile  输出目录

$sourceFile 源图片地址
$destinationWidth	 生成图片宽度 
$destinationHeight		 生成图片高度 
$destinationFile  输出文件
$useAutoPadding		是否使用自动补白，默认不使用
$qualityLevel		输出图片质量，默认8，可选值0-10
$sameSide			输出图默认高宽都限制，W 等宽， H等高

程序功能：生成缩略图
------------------------------------------------------
*/
function ImageResize($sourceFile,$destinationWidth,$destinationHeight,$destinationFile="",$useAutoPadding=false,$qualityLevel=9,$sameSide="N"){
	global $autoPaddingColor;

	list($sourceWidth,$sourceHeight,$sourceType)=getimagesize($sourceFile);
	$sourceRatio=$sourceWidth/$sourceHeight;
	switch($sourceType){
		case IMG_GIF:
			if(!function_exists("imagecreatefromgif")){
				echo "你的GD库不能使用GIF格式的图片，请使用Jpeg或PNG格式！<a href='javascript:go(-1);'>返回</a>";
				exit();
			}
			$sourceImage=imagecreatefromgif($sourceFile);
			break;
		case IMG_JPG:
		case IMG_JPEG:
			if(!function_exists("imagecreatefromjpeg")){
				echo "你的GD库不能使用jpeg格式的图片，请使用其它格式的图片！<a href='javascript:go(-1);'>返回</a>";
				exit();
			}
			$sourceImage=imagecreatefromjpeg($sourceFile);
			break;
		case 3:
			if(!function_exists("imagecreatefrompng")){
				echo "你的GD库不能使用jpeg格式的图片，请使用其它格式的图片！<a href='javascript:go(-1);'>返回</a>";
				exit();
			}
			$sourceImage=imagecreatefrompng($sourceFile);
			break;
	}
	//echo $sourceType."--==".$sourceFile;exit;
	if($useAutoPadding){
		$compositeImage=imagecreatetruecolor($destinationWidth,$destinationHeight);
		imagefill($compositeImage,0,0,imagecolorallocate($compositeImage,$autoPaddingColor["red"],$autoPaddingColor["green"],$autoPaddingColor["blue"]));
		if($sourceRatio>=1){
			
			$newWidth=$destinationWidth;
			$newHeight=round($newWidth/$sourceRatio);
			$coordinatesX=0;
			$coordinatesY=round(($destinationHeight-$newHeight)/2);
		}else{
			$newHeight=$destinationHeight;
			$newWidth=round($newHeight*$sourceRatio);
			$coordinatesY=0;
			$coordinatesX=round(($destinationWidth-$newWidth)/2);
		}
		if($sameSide=="W")
		{
			$newWidth=$destinationWidth;
			$newHeight=round($newWidth/$sourceRatio);
			$coordinatesX=0;
			$coordinatesY=round(($destinationHeight-$newHeight)/2);
		}
		if($sameSide=="H")
		{
			$newHeight=$destinationHeight;
			$newWidth=round($newHeight*$sourceRatio);
			$coordinatesY=0;
			$coordinatesX=round(($destinationWidth-$newWidth)/2);
		}
		imagesavealpha($sourceImage,true);
		imagealphablending($compositeImage,false);
		imagesavealpha($compositeImage,true);
		
		imagecopyresampled($compositeImage,$sourceImage,$coordinatesX,$coordinatesY,0,0,$newWidth,$newHeight,$sourceWidth,$sourceHeight);
	}else{
		if($sourceRatio>=1){
			$newWidth=$destinationWidth;
			$newHeight=round($newWidth/$sourceRatio);
		}else{
			$newHeight=$destinationHeight;
			$newWidth=round($newHeight*$sourceRatio);
		}
		
		if($sameSide=="W")
		{
				$newWidth=$destinationWidth;
				$newHeight=round($newWidth/$sourceRatio);

		}
		if($sameSide=="H")
		{
				$newHeight=$destinationHeight;
				$newWidth=round($newHeight*$sourceRatio);
		}

		$compositeImage=imagecreatetruecolor($newWidth,$newHeight);
		//if($sourceType="IMG_GIF"){  $compositeImage=ImageCreate($newWidth,$newHeight);  }
		
		imagesavealpha($sourceImage,true);
		imagealphablending($compositeImage,false);
		imagesavealpha($compositeImage,true);
		
		imagecopyresampled($compositeImage,$sourceImage,0,0,0,0,$newWidth,$newHeight,$sourceWidth,$sourceHeight);
	}
	
	switch($sourceType){
		case IMG_GIF:
			imagegif($compositeImage,$destinationFile);
			
			break;
		case IMG_JPG:
		case IMG_JPEG:
			$qualitySetting=round(($qualityLevel/10)*100);
			imagejpeg($compositeImage,$destinationFile,$qualitySetting);
			break;
		case 3:

			$qualitySetting=9-round(($qualityLevel/10)*9);
			imagepng($compositeImage,$destinationFile,$qualitySetting);
			break;
	}
	if(get_extension($sourceFile)=="webp") copy($sourceFile,$destinationFile);
	//5.6 不支持 webp  
	//echo get_extension($sourceFile)."--==";exit;
	imagedestroy($sourceImage);
	imagedestroy($compositeImage);
}
/*
------------------------------------------------------
参数：
$srcPic 源图片文件名
$desPic 目标图片文件名
$wtString 水印字符串
$wtFont 水印字符串字体
$wtSize 水印字符串大小
$wtColor 水印字符串颜色
$wtPosition 水印字符串位置 1 2 3
$wtType 水印字符串或者图片
$picFile 水印图片文件名
$GLOBALS['wPic']   constant文件 $waterMarkPic定义的 路径
13-11-9 zhao 在ls_syscode addWatermark函数加上了扩展名
程序功能：把水印图片或字符串加到$srcPic写到$desPic
------------------------------------------------------
*/
function addWatermark($srcPic,$desPic,$wtString,$wtFont,$wtSize,$wtMargin,$wtColor,$wtPosition,$wtType,$picFile,$qualityLevel=9)
{
	list($srcwidth, $srcheight, $srctype, $srcattr) = getimagesize($srcPic);//获取文件类型
	switch($srctype) 
	{
		case 1:		$im = imageCreatefromgif($srcPic); break;
		case 2:		$im = imageCreatefromjpeg($srcPic); break;
		case 3:		$im = imageCreatefrompng($srcPic); break;
		default: return(" 测试图片文件类型错误，只能是.gif,.jpg.png");
	}
	 if($wtType=="pic") 
	 { //图片水印  
		list($wtmwidth, $wtmheight, $wtmtype, $wtmattr)  = getimagesize($picFile);//获取文件类型
		switch($wtmtype)
		{
			//waterMarkPic 在constant中定义
			case 1:   $im2 = imagecreatefromgif($picFile);  $wtmfile=$GLOBALS['waterMarkPic'].".gif";break;  
			case 2:   $im2 = imagecreatefromjpeg($picFile); $wtmfile=$GLOBALS['waterMarkPic'].".jpg";break;
			case 3:   $im2 = imagecreatefrompng($picFile); $wtmfile=$GLOBALS['waterMarkPic'].".png";break;
			default: return("水印图片文件类型错误，只能是.gif,.jpg.png");
		}
		imagesavealpha($im2,true);  //透明处理
		imagesavealpha($im,true);
	} else {  //文字水印
		$temp = imagettfbbox(ceil($wtSize),0,"./arial.ttf",$wtString);//取得使用 TrueType 字体的文本的范围
		$wtmwidth = $temp[2] - $temp[6] + 1;   //文字宽度
		$wtmheight = $temp[3] - $temp[7] + 1;  //文字高度
		
		$fontPicFile = "images/fontwatermark.png";
		$wcolor = rgbToHex($wtColor);
		$img = imagecreatetruecolor($wtmwidth, $wtmheight);
		$color=imagecolorallocatealpha($img, 0, 0, 0, 127);
		imagecolortransparent($img,$color);
		imagealphablending($img , false);//关闭混合模式，以便透明颜色能覆盖原画板
		imagefill($img,0,0,$color);
		$textcolor=imagecolorallocatealpha($img, $wcolor['r'], $wcolor['g'], $wcolor['b'], 0);
		imagettftext($img, $wtSize, 0, 0, $wtSize, $textcolor, "./arial.ttf", $wtString);
		imagesavealpha($img , true);//设置保存PNG时保留透明通道信息   
		imagepng($img,$fontPicFile);
		imagedestroy($img);
		
		list($wtmwidth, $wtmheight, $wtmtype, $wtmattr)  = getimagesize($fontPicFile);//获取文件类型
		switch($wtmtype)
		{
			//waterMarkPic 在constant中定义
			case 1:   $im2 = imagecreatefromgif($fontPicFile);  $wtmfile=$GLOBALS['waterMarkPic'].".gif";break;  
			case 2:   $im2 = imagecreatefromjpeg($fontPicFile); $wtmfile=$GLOBALS['waterMarkPic'].".jpg";break;
			case 3:   $im2 = imagecreatefrompng($fontPicFile); $wtmfile=$GLOBALS['waterMarkPic'].".png";break;
			default: return("水印图片文件类型错误，只能是.gif,.jpg.png");
		}
		imagesavealpha($im2,true);  //透明处理
		imagesavealpha($im,true);
	}
		//copy($picFile,$wtmfile);
		$GLOBALS['wPic']=$wtmfile;

	switch($wtPosition) {
 
		case 1://为左上
			$posX = 0 + $wtMargin;
			$posY = 0 + $wtMargin;
			break;
		
		case 2://为中上
			$posX = ($srcwidth - $wtmwidth) / 2;
			$posY = 0 + $wtMargin;
			break;
	   
		case 3://为右上
			$posX = $srcwidth - $wtmwidth - $wtMargin;
			$posY = 0 + $wtMargin;
			break;
		
		case 4://中心居中
			$posX = ($srcwidth - $wtmwidth) / 2;
			$posY = ($srcheight - $wtmheight) / 2;
			break;
		
		case 5://为左下
			$posX = 0 + $wtMargin;
			$posY = $srcheight - $wtmheight - $wtMargin;
			break;
	   
		case 6://中下
			$posX = ($srcwidth - $wtmwidth) / 2;
			$posY = $srcheight - $wtmheight - $wtMargin;
			break;
		
		case 7://右下
			$posX = $srcwidth - $wtmwidth - $wtMargin;
			$posY = $srcheight - $wtmheight - $wtMargin;
			break;
		  
	}
	//读取水印文件
	if($wtType=="pic")//水印图片
	{
		//拷贝水印到目标文件
		imagecopy($im, $im2,$posX,$posY, 0, 0, $wtmwidth,$wtmheight);
	}
	else// string
	{ 
		//拷贝水印到目标文件
		imagecopy($im, $im2,$posX,$posY, 0, 0, $wtmwidth,$wtmheight);
	}
	
	
	//输出图片
	$result="";
	if($srctype==1)
	{
		$result=imagegif($im,$desPic);
	}
   if($srctype==2)
   { //同上
		$qualitySetting=round(($qualityLevel/10)*100);
		$result=imagejpeg($im,$desPic,$qualitySetting);
	}
	if($srctype==3)
	{
		$qualitySetting=9-round(($qualityLevel/10)*9);
		$result=imagepng($im,$desPic,$qualitySetting);
	}

	imagedestroy($im);
	if($result!="")
	{return(TRUE);}
	else
	{return(FALSE);}
}
/*
------------------------------------------------------
参数：
$image_file  图片文件名
程序功能：判断GIF是否为动画，读取1024字节
date: 2013-10-27
------------------------------------------------------
*/
function ifanimationgif($image_file){

$fp = fopen($image_file, 'rb');

$image_head = fread($fp,1024);

fclose($fp);

return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$image_head)  ? true : false;

}

/*
------------------------------------------------------
参数：

$moduleFile 链接文件名
$allpages 总页数
返回 页间导航链接
程序功能：获取产品页页间导航链接
------------------------------------------------------
*/
function getPages($moduleFile,$allpages)
{
	for ($i=0; $i< $allpages; $i++)
	{ 
	if(($allpages-$i-1)==0)
	{
		$indexp=$moduleFile;
	}
	else
	{
		$indexp=str_replace(".",($allpages-$i-1).".",$moduleFile) ;
	}
	$propage.="<div class=\"propage\"><a data-ajax='false' href=\"".$indexp."\">".($allpages-$i)."</a></div>\r\n";
			}
	if($allpages==1)
	{$propage="";}
	else
	{$propage="<div class=\"propageall\">".$propage."</div>\r\n";}
	return($propage);
}

function getPagess($moduleFile,$allpages,$ls_current_page,$ifpro=false)
{
	require("inc/constant.php");//22-4-19
	for ($i=0; $i< $allpages; $i++){
		
		if($i==0)
		{
			$indexp=($ifpro?"./".($oldcatepath?$moduleFile:""):$moduleFile); //22-4-19
		}
		else
		{
			$indexp=str_replace(".","-".$i.".",$moduleFile);
		}
		$a_p = $i+1;
		if($a_p != $ls_current_page){
			$propage.="<li><a href=\"".$indexp."\">".($i+1)."</a></li>\r\n";
		}else{
			$propage.="<li class=\"active\"><span>".($i+1)."</span></li>\r\n";
		}
	}
	$starthref=($ifpro?"./":$moduleFile);
	if($ls_current_page == 1){
		$star = " class=\"disabled\" ";
	}else{
		$star = "";
	}
	if($ls_current_page == $allpages){
		$end = " class=\"disabled\" ";
	}else{
		$end = "";
	}
	if($allpages<=1)
	{$propage="";}
	else
	{
		include("_propage.php");  //列表页 中间分页 {ls_propage} 
	}
	return($propage);
}


/*
------------------------------------------------------
参数：
$products_sql 某类的sql查询串
$PageNum

程序功能：写入某类下产品页所有index文件调用（writeIndexPages）、类别详细页cateDetail.html、产品详细内容index.html,productsshow.html文件
------------------------------------------------------
*/
function writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid,$translate){
	global $PageNum,$s_pro_cate,$s_cate,$s_pro2_cate,$s_pro3_cate,
	$s_pro4_cate,$d_pro_cate,$d_cate,$d_pro2_cate,$d_pro3_cate,
	$d_pro4_cate,$pro_cate,$cate,$pro2_cate,$pro3_cate,$pro4_cate,$menu,
	$menu_pro,$menu_pro2,$menu_pro3,$menu_pro4,$showproductsFolders,$lsproshowmenu,$foot,
	$SmallFoldersProducts,$BigFoldersProducts,$minCateDetailLength,$detail,$foot,$menuListscateid,$DetailPage,
	$ls_about,$ls_news,$ls_faq,$ls_classpro,$ls_hotpro,$ls_designby,$ls_newsdongtai,$ls_newsgonggao,$ls_newstieshi,$ls_procurrentpage,
	$ls_newsall2,$ls_newsdongtai2,$ls_newsgonggao2,$ls_newstieshi2,
	$ls_newsall3,$ls_newsdongtai3,$ls_newsgonggao3,$ls_newstieshi3,
	$ls_newsall4,$ls_newsdongtai4,$ls_newsgonggao4,$ls_newstieshi4,$s_site_cate,$site_cate1,$s_site2_cate,$s_site3_cate,$s_site4_cate,
	$ls_link,$link,$pro_link,$pro2_link,$pro3_link,$pro4_link,$ls_catenews,$ls_addprolink,$ls_addnewprolink,
	$pro_revo,$pro2_revo,$pro3_revo,$pro4_revo,$facebook_twitter,$facebook_twitter_share,
	$productDescriptionTitle,$productshowstyl, $s_p_cate, $s_p0_cate, $s_p1_cate, $s_p2_cate, $s_p3_cate, $s_p4_cate, $ls_h1_news, $ls_h2_news, $ls_h3_news, $ls_h4_news,$languages0,$languages,$languages2,$languages3,$languages4,$ls_sitebrand,$ls_corekeyword;
	$mynum=0;//总产品数
	$allpages=0;//共有页数
	$pathprofilename = ""; //新型产品详细页文件名
	
	$opendb=new mydb();
	require('char_set.php');
	require('constant.php');
	
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	
	//echo "=======".$products_sql."===========";
	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$row=mysqli_fetch_array($tem_query);
	$templates_var = $row['templates'];
	//if $mynum=0 or $detail>$minCateDetailLength write index.html 没有产品或者类别详细页面有内容只生成 类别单页
	$detail="";  //set the cat subcat midcate detail flag

	$motif_sql="select * from ls_motif where enable=1 order by Num desc ";
	$motif_query=$opendb->query($motif_sql);
	
	$s_motif_cate.="";
	while($motif_rows=mysqli_fetch_assoc($motif_query))
	{
		if($motif_rows['motif_href'] !=''){
			$s_motif_cate.="<div class=\"pic_box\"><a href=\"".$motif_rows['motif_href']."\" style=\"background-image: url(../".$MotifFolders."/".$BigFoldersProducts."/".$motif_rows['motifPic']."); background-repeat: no-repeat; background-position: center top; background-color:#dcdcdc;\" ></a></div>";
		}else{
			$s_motif_cate.="<div class=\"pic_box\"><a href=\"javascript:void(0)\" style=\"background-image: url(../".$MotifFolders."/".$BigFoldersProducts."/".$motif_rows['motifPic']."); background-repeat: no-repeat; background-position: center top; background-color:#dcdcdc;\" ></a></div>";
		}
		
	}
	$s_motif_cate.="";
	$s_m_cate=str_replace("../","../",$s_motif_cate);//cate
	$s_m2_cate=str_replace("../","../../",$s_motif_cate);//pro2_cate
	$s_m3_cate=str_replace("../","../../",$s_motif_cate);//pro3_cate
	$s_m4_cate=str_replace("../","../../",$s_motif_cate);//pro4_cate

	if($cateid!="" && $midcateid=="" && $subcateid=="")//大类 catedetial
	{
		$procateid=$cateid;
		$sqldetail="select * from ls_products where ID =".$cateid." ";
		$querydetail=$opendb->query($sqldetail);
		$myrowsdetail=mysqli_fetch_assoc($querydetail);
		if($myrowsdetail['cateDetail']!="")
		{$detail=htmlspecialchars_decode($myrowsdetail['cateDetail'],ENT_QUOTES);
		}
		$procate=$myrowsdetail['cateName'];
		
		include("_crumbs_product.php");  //中类 面包屑导航 {ls_indicatebar} 
		$indicatebar=$indicatebar1;

		$catetitle=$myrowsdetail['cateTitle'];
		$cateKeywords=$myrowsdetail['cateKeywords'];
		$cateDescription=$myrowsdetail['cateDescription'];
		$banner=(file_exists("../".$myrowsdetail['cateFolders']."/".$myrowsdetail['cateFolders']."_banner.jpg")?  $myrowsdetail['cateFolders']."_banner.jpg":	"../images/banner.jpg");		
		//$myrowsdetail['cateFolders']."_banner.jpg"; //不用catePagePic
		 
		$_SESSION['catebanner']=$banner;
		
		$file=$myrowsdetail['cateFolders']."/".($oldcatepath?$myrowsdetail['cateFolders'].".html":"index.html");//22-4-19
		
		$lsbrief=$myrowsdetail['cateBrief'];
		$echoname="大类".$myrowsdetail['cateName'];
		$prolistfilename = $myrowsdetail['cateFolders'];
		$ls_characteristics=$myrowsdetail['characteristics'];
		$ls_parameters=$myrowsdetail['parameters'];
		$ls_advantages=$myrowsdetail['advantages'];
		$ls_attachedfile=$myrowsdetail['attachedfile'];
		//echo $ls_characteristics."--==".$ls_attachedfile;
		
		$url="";
		$leftcate=$pro_cate;
		$s_cate=$s_pro_cate;			//左侧产品类别
		$d_cate=$d_pro_cate;			//左侧产品类别
		$s_news=$ls_h1_news;			//新闻
		$s_p_cate=$s_p0_cate;			//左侧产品类别
		$ls_languages=$languages;		//语言国旗
		$s_f_cate=get_pro_cate(1);
		
		$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-INSTAGRAM",$row['google'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
		
		$ls_facebook_twitter = str_replace("../","../",$facebook_twitter);//cate
		$ls_facebook_twitter2 = str_replace("../","../",$facebook_twitter);//cate
		
		$site_cate = $s_site2_cate;
		$site_cate_pro = $s_site_cate;
		
		$leftprocate=$pro2_cate;
		$lspro_menu=$menu_pro;
		$lsproshowmenu=$menu_pro2;
		$ls_link=$pro_link;
		$lspro_link=$pro2_link;
		$ls_revo=$pro_revo;
		$lspro_revo=$pro2_revo;
		$ls_motif=$s_m_cate;   //产品相册主题图片
		$lspro_motif=$s_m2_cate;  //产品详细页主题图片

		$ls_newsdongtai=$ls_newsdongtai2;
		$ls_newstieshi=$ls_newstieshi2;
		$ls_newsgonggao=$ls_newsgonggao2;
		$ls_newsall=$ls_newsall2;
		
		//中类代表图
		$midcate_pic_sql="SELECT * FROM `ls_products` WHERE `midcateID`=".$cateid."  order by Num";
		$midcate_pic_query=$opendb->query($midcate_pic_sql);
		
		include("_products_catedetail.php");  //上级类页面生成

		$behalf = $mid_pic;
		
	}

	if($cateid!="" && $midcateid!="" && $subcateid=="")//中类 midcatedetial
	{
		$procateid=$midcateid;
		$sqldetail="select * from ls_products where ID =".$midcateid." ";
		$querydetail=$opendb->query($sqldetail);
		$myrowsdetail=mysqli_fetch_assoc($querydetail);
		if($myrowsdetail['midcateDetail']!=""){
			$detail=htmlspecialchars_decode($myrowsdetail['midcateDetail'],ENT_QUOTES);
		}
		$procate=$myrowsdetail['midcateName'];
		
		$catetitle=$myrowsdetail['cateTitle'];
		$cateKeywords=$myrowsdetail['cateKeywords'];
		$cateDescription=$myrowsdetail['cateDescription'];
		$ls_characteristics=$myrowsdetail['characteristics'];
		$ls_attachedfile=$myrowsdetail['attachedfile'];

		$sqldetail2="select * from ls_products where ID =".$myrowsdetail['midcateID']." ";
		$querydetail2=$opendb->query($sqldetail2);
		$myrowsdetail2=mysqli_fetch_assoc($querydetail2);
		
		$sql_path="select * from ls_products where midcateID =".$myrowsdetail['midcateID']." ORDER BY Num ASC ";
		$query_path=$opendb->query($sql_path);
		$rows_path=mysqli_fetch_assoc($query_path);
		
		$catetitle=($catetitle=="")?$myrowsdetail2['cateTitle']:$catetitle;
		$cateKeywords=($cateKeywords=="")?$myrowsdetail2['cateKeywords']:$cateKeywords;
		$cateDescription=($cateDescription=="")?$myrowsdetail2['cateDescription']:$cateDescription;
		
		$banner=(file_exists("../".$myrowsdetail2['cateFolders']."/".$myrowsdetail['midcateFolders']."/".$myrowsdetail['midcateFolders']."_banner.jpg")?  $myrowsdetail['midcateFolders']."_banner.jpg":	"../".$_SESSION['catebanner']);
		$_SESSION['midcatebanner']=$banner;
		 
		$file=$myrowsdetail2['cateFolders']."/".$myrowsdetail['midcateFolders']."/".($oldcatepath?$myrowsdetail['midcateFolders'].".html":"index.html");//22-4-19
		$detailsfile2="../".$templates_var."/catedetail.html";
		if(file_exists($detailsfile2)){
			$path_pro=$myrowsdetail2['cateFolders']."/"; //".$myrowsdetail2['cateFolders']."
		}else{
			$path_pro=$myrowsdetail2['cateFolders']."/".$rows_path['midcateFolders']."/";//".$rows_path['midcateFolders']."
		}
		$lsbrief=$myrowsdetail['midcateBrief'];
		$echoname=" 中类".$myrowsdetail['midcateName'];
				
		include("_crumbs_product.php");  //中类 面包屑导航 {ls_indicatebar} 
		$indicatebar=$indicatebar2;
		
		$prolistfilename = $myrowsdetail['midcateFolders'];
	
		$url="../";
		$leftcate=$pro2_cate;
		$s_cate=$s_pro2_cate;			//左侧产品类别
		$d_cate=$d_pro2_cate;			//左侧产品类别
		$s_news=$ls_h2_news;			//新闻
		$s_p_cate=$s_p2_cate;			//左侧产品类别
		$ls_languages=$languages2;      //语言国旗
		$s_f_cate=get_pro_cate(2);
		
		$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-INSTAGRAM",$row['google'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
		
		$ls_facebook_twitter = str_replace("../","../../",$facebook_twitter);//cate
		$ls_facebook_twitter2 = str_replace("../","../../",$facebook_twitter);//cate
		$site_cate = $s_site3_cate;
		$site_cate_pro = $s_site2_cate;
		
		$leftprocate=$pro3_cate;
		$lspro_menu=$menu_pro2;
		$lsproshowmenu=$menu_pro3;
		$ls_link=$pro2_link;
		$lspro_link=$pro3_link;
		$ls_revo=$pro2_revo;
		$lspro_revo=$pro3_revo;
		$ls_motif=$s_m2_cate;   //产品相册主题图片
		$lspro_motif=$s_m3_cate;  //产品详细页主题图片

		$ls_newsdongtai=$ls_newsdongtai3;
		$ls_newstieshi=$ls_newstieshi3;
		$ls_newsgonggao=$ls_newsgonggao3;
		$ls_newsall=$ls_newsall3;
		include("_products_midcatedetail.php");  //中类 类页面
		$behalf = $sub_pic;
		
	}				

	if($cateid!="" && $midcateid!="" && $subcateid!="")//小类 subcatedetial
	{
		$procateid=$subcateid;
		$sqldetail="select * from ls_products where ID =".$subcateid." ";
		$querydetail=$opendb->query($sqldetail);
		$myrowsdetail=mysqli_fetch_assoc($querydetail);
		if($myrowsdetail['subcateDetail']!="")
		{$detail=htmlspecialchars_decode($myrowsdetail['subcateDetail'],ENT_QUOTES);
		}
		$procate=$myrowsdetail['subcateName'];
		
		$catetitle=$myrowsdetail['cateTitle'];
		$cateKeywords=$myrowsdetail['cateKeywords'];
		$cateDescription=$myrowsdetail['cateDescription'];
		$ls_characteristics=$myrowsdetail['characteristics'];
		$ls_attachedfile=$myrowsdetail['attachedfile'];
	
		$sqldetail2="select * from ls_products where ID =".$myrowsdetail['subcateID']." ";
		$querydetail2=$opendb->query($sqldetail2);
		$myrowsdetail2=mysqli_fetch_assoc($querydetail2);
		
		$catetitle=($catetitle=="")?$myrowsdetail2['cateTitle']:$catetitle;
		$cateKeywords=($cateKeywords=="")?$myrowsdetail2['cateKeywords']:$cateKeywords;
		$cateDescription=($cateDescription=="")?$myrowsdetail2['cateDescription']:$cateDescription;

		$sqldetail3="select * from ls_products where ID =".$myrowsdetail2['midcateID']." ";
		$querydetail3=$opendb->query($sqldetail3);
		$myrowsdetail3=mysqli_fetch_assoc($querydetail3);

		$catetitle=($catetitle=="")?$myrowsdetail3['cateTitle']:$catetitle;
		$cateKeywords=($cateKeywords=="")?$myrowsdetail3['cateKeywords']:$cateKeywords;
		$cateDescription=($cateDescription=="")?$myrowsdetail3['cateDescription']:$cateDescription;
		
		$banner=(file_exists("../".$myrowsdetail3['cateFolders']."/".$myrowsdetail2['midcateFolders']."/".$myrowsdetail['subcateFolders']."/".$myrowsdetail['subcateFolders']."_banner.jpg")?  $myrowsdetail['subcateFolders']."_banner.jpg":"../". $_SESSION['midcatebanner']);  //没小类banner，用上级

		$file=$myrowsdetail3['cateFolders']."/".$myrowsdetail2['midcateFolders']."/".$myrowsdetail['subcateFolders']."/".($oldcatepath?$myrowsdetail['subcateFolders'].".html":"index.html");//22-4-19
		$lsbrief=$myrowsdetail['subcateBrief'];
		$echoname=" 小类".$myrowsdetail['subcateName'];
		include("_crumbs_product.php");  //小类 面包屑导航 {ls_indicatebar} 
		$indicatebar=$indicatebar3;
		$prolistfilename = $myrowsdetail['subcateFolders'];

		$url="../../";
		$s_cate=$s_pro3_cate;			//左侧产品类别
		$d_cate=$d_pro3_cate;			//左侧产品类别
		$s_news=$ls_h3_news;			//新闻
		$s_p_cate=$s_p3_cate;			//左侧产品类别
		$ls_languages=$languages3;		//语言国旗
		$s_f_cate=get_pro_cate(3);
		$site_cate = $s_site4_cate;
		$site_cate_pro = $s_site3_cate;
		
		$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-INSTAGRAM",$row['google'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
		
		$ls_facebook_twitter = str_replace("../","../../../",$facebook_twitter);//cate
		$ls_facebook_twitter2 = str_replace("../","../../../",$facebook_twitter);//cate
		$leftcate=$pro3_cate;
		$leftprocate=$pro4_cate;
		$lspro_menu=$menu_pro3;
		$lsproshowmenu=$menu_pro4;
		$ls_link=$pro3_link;
		$lspro_link=$pro4_link;
		$ls_revo=$pro3_revo;
		$lspro_revo=$pro4_revo;		
		$ls_motif=$s_m3_cate;   //产品相册主题图片
		$lspro_motif=$s_m4_cate;  //产品详细页主题图片

		$ls_newsdongtai=$ls_newsdongtai4;
		$ls_newstieshi=$ls_newstieshi4;
		$ls_newsgonggao=$ls_newsgonggao4;
		$ls_newsall=$ls_newsall4;
		
	}
		//if(strlen($detail)>$minCateDetailLength)  // 叶类小于预定长度将不生成,否则生成一个详细页
		if($cateDetailPageCreate)
		{
			$echoname="详细: ".$echoname;
			
			$index_path2="../".$templates_var."/catedetail.html";	//类详细页面
			$detailsfile= $file; //str_replace("index.html","indexdetails.html",$file);
			
			writeIndexPages($index_path2,$catetitle,$cateKeywords,$cateDescription,$url,$banner,$leftcate,$lspro_menu,
			$lsbrief,$procate,$procateid,$propage,$pro,$detailsfile,$echoname,$mynum,$allpages,$detail,$s_cate,$s_news,$s_p_cate,$ls_languages,$s_f_cate,$site_cate_pro,$ls_motif,$ls_revo,$foot,$indicatebar,$behalf,$ls_facebook_twitter2,$translate);
		}
		if($DetailPage==1)		//0 叶类生成详细说明页面，函数继续执行 1枝类生成详细说明页面，函数返回
		{
			$DetailPage=0; //reset flag
			return;
		}		
		//产品排序
		$sort='Num';
		$products_sql.=" and enable=1 order by $sort asc ";
		$result=$opendb->query($products_sql);
		$result2=$opendb->query($products_sql);		//for the browseNo
		$mynum = mysqli_num_rows($result);//总产品数
		// 每页数量
		$onepage = $PageNum; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		if($mynum==0)  // 没有产品
		{
			$echoname="无产品: ".$echoname;
			$mynum=0;
			$allpages=1;
			$index_path="../".$templates_var."/catedetail.html";	//没产品，输出 详细页或者 产品页没内容

			if(is_file($index_path)){}
			else
			{$index_path="../".$templates_var."/products.html";}
			writeIndexPages($index_path,$catetitle,$cateKeywords,$cateDescription,$url,$banner,$leftcate,$lspro_menu,
			$lsbrief,$procate,$procateid,$propage,$pro,$file,$echoname,$mynum,$allpages,$detail,$s_cate,$s_news,$s_p_cate,$ls_languages,$s_f_cate,$site_cate_pro,$ls_motif,$ls_revo,$foot,$indicatebar,$behalf,$ls_facebook_twitter2,$translate);
			return;
		}
		
			//end  没有产品或者类别详细页面有内容只生成 类别单页
			//页码计算
			$j=1;
			for ($iii=0; $iii<$allpages; $iii++)
			{ 
				$ls_procurrentpage="";
				if ($iii == 0)
				{ 
					$indexpath = ($oldcatepath?$prolistfilename.".html":"index.html"); 
					//22-4-19 $prolistfilename "index.html"; 
				} 
				else 
				{ 
				  $indexpath = $prolistfilename."-".$iii.".html";
				}
				$start = $iii * $onepage;
				if($allpages!=1){
					$ls_current_page=$iii+1;
				}
				$pro="";
		 //查询产品
			 $products_sql2=$products_sql." limit ".$start.",".$onepage." ";
			 //echo $products_sql2."<br>";
			 $products_query=$opendb->query($products_sql2);
			 //echo "$products_sql2";
			 while($products_rows=mysqli_fetch_assoc($products_query))
			 {
				//查询小类
				$search_subcate_sql="select * from ls_products where ID = ".$products_rows['productID']."";
				$search_subcate_query=$opendb->query($search_subcate_sql);
				$search_subcate_rows=mysqli_fetch_assoc($search_subcate_query);

				if($search_subcate_rows['subcateName']=="")
				{

					if($search_subcate_rows['midcateName']=="")//大类
					{						
					$procate=$search_subcate_rows['cateName'];//cate name in products 
					$procateid=$search_subcate_rows['ID'];
						
					$imgpic=$SmallFoldersProducts."/".$products_rows['productPic'];
						//生成文件地址
					$file=$search_subcate_rows['cateFolders']."/".$indexpath;
					 
						//生成大图地址
					$pathprofilename = $search_subcate_rows['cateFolders'];
					$pathprofile = "../";
					$profile=$search_subcate_rows['cateFolders']."/".pathProName($products_rows['productName'])."-".$products_rows['ID'].".html";
					$profile=$products_rows['filename']==""?$profile:$search_subcate_rows['cateFolders']."/".$products_rows['filename']; //21-7-28					
					$proFiles=$search_subcate_rows['cateFolders']."/";
						
					$catetitle=$search_subcate_rows['cateTitle'];
					$cateKeywords=$search_subcate_rows['cateKeywords'];
					$cateDescription=$search_subcate_rows['cateDescription'];
					$_SESSION['catebanner']=$banner;
					$lsbrief=$search_subcate_rows['cateBrief'];
						
					$url="";
					$s_cate=$s_pro_cate;
					$d_cate=$d_pro_cate;
					$s_news=$ls_h1_news;			//新闻
					$s_p_cate=$s_p0_cate;
					$ls_languages = $languages;
					$s_f_cate=get_pro_cate(1);
					$s_procate=$s_pro_cate;	//左侧产品类别
					$d_procate=$d_pro_cate;	//左侧产品类别
					$ss_p_cate=$s_p_cate;
					$ss_f_cate=get_pro_cate(2);
					$leftcate=$pro_cate;
					$leftprocate=$pro2_cate;
					$lspro_menu=$menu_pro;
					$lsproshowmenu=$menu_pro2;
					$ls_link=$pro_link;
					$lspro_link=$pro2_link;
					$ls_revo=$pro_revo;
					$lspro_revo=$pro2_revo;
					}
					else //大类+中类
					{
					
					$catetitle=$search_subcate_rows['cateTitle'];
					$cateKeywords=$search_subcate_rows['cateKeywords'];
					$cateDescription=$search_subcate_rows['cateDescription'];
					
					$procate=$search_subcate_rows['midcateName'];
					$search_cate_sql="select * from ls_products where ID = ".$search_subcate_rows['midcateID']."";
					$search_cate_query=$opendb->query($search_cate_sql);
					$search_cate_rows=mysqli_fetch_assoc($search_cate_query);

					$imgpic=$SmallFoldersProducts."/".$products_rows['productPic'];
					//生成文件地址
					$file=$search_cate_rows['cateFolders']."/".$search_subcate_rows['midcateFolders']."/".$indexpath;
					//生成大图文件地址
					$pathprofilename = $search_subcate_rows['midcateFolders'];
					$pathprofile = "../../";
					$profile=$search_cate_rows['cateFolders']."/".$search_subcate_rows['midcateFolders']."/".pathProName($products_rows['productName'])."-".$products_rows['ID'].".html";
					$profile=$products_rows['filename']==""?$profile:$search_cate_rows['cateFolders']."/".$search_subcate_rows['midcateFolders']."/".$products_rows['filename']; //21-7-28
					
					$proFiles=$search_cate_rows['cateFolders']."/".$search_subcate_rows['midcateFolders']."/";

					$catetitle=($catetitle=="")?$search_cate_rows['cateTitle']:$catetitle;
					$cateKeywords=($cateKeywords=="")?$search_cate_rows['cateKeywords']:$cateKeywords;
					$cateDescription=(($cateDescription==" ")||($cateDescription==""))?$search_cate_rows['cateDescription']:$cateDescription;
					
					//$banner="../".$search_cate_rows['catePagePic']."jpg";;
					$banner=(file_exists("../".$search_cate_rows['cateFolders']."/".$search_subcate_rows['midcateFolders']."/".$search_subcate_rows['midcateFolders']."_banner.jpg")?  $search_subcate_rows['midcateFolders']."_banner.jpg":"../".$_SESSION['catebanner']);
					$_SESSION['midcatebanner']=$banner;
					
					$lsbrief=$search_subcate_rows['midcateBrief'];
					$url="../";
					$s_cate=$s_pro2_cate;	//左侧产品类别
					$d_cate=$d_pro2_cate;	//左侧产品类别
					$s_news=$ls_h2_news;			//新闻
					$s_p_cate=$s_p2_cate;
					$ls_languages = $languages2;
					$s_f_cate=get_pro_cate(2);
					$s_procate=$s_pro2_cate;	//左侧产品类别
					$d_procate=$d_pro2_cate;	//左侧产品类别
					$ss_p_cate=$s_p2_cate;
					$ss_f_cate=get_pro_cate(3);
					$leftcate=$pro2_cate;
					$leftprocate=$pro3_cate;
					$lspro_menu=$menu_pro2;
					$lsproshowmenu=$menu_pro3;
					$ls_link=$pro2_link;
					$lspro_link=$pro3_link;
					$ls_revo=$pro2_revo;
					$lspro_revo=$pro3_revo;						
					}
				}
				else//大类+中类+小类
				{
					$catetitle=$search_subcate_rows['cateTitle'];
					$cateKeywords=$search_subcate_rows['cateKeywords'];
					$cateDescription=$search_subcate_rows['cateDescription'];
					
					$procate=$search_subcate_rows['subcateName'];
					$procateid=$search_subcate_rows['ID'];
				  //查询中类
					$search_midcate_sql="select * from ls_products where ID = ".$search_subcate_rows['subcateID']."";
					$search_midcate_query=$opendb->query($search_midcate_sql);
					$search_midcate_rows=mysqli_fetch_assoc($search_midcate_query);
					
					$catetitle=($catetitle=="")?$search_midcate_rows['cateTitle']:$catetitle;
					$cateKeywords=($cateKeywords=="")?$search_midcate_rows['cateKeywords']:$cateKeywords;
					$cateDescription=(($cateDescription==" ")||($cateDescription==""))?$search_midcate_rows['cateDescription']:$cateDescription;
					  
				  //查询大类
					$search_cate_sql="select * from ls_products where ID = ".$search_midcate_rows['midcateID']."";
					$search_cate_query=$opendb->query($search_cate_sql);
					$search_cate_rows=mysqli_fetch_assoc($search_cate_query);
					
					$catetitle=($catetitle=="")?$search_cate_rows['cateTitle']:$catetitle;
					$cateKeywords=($cateKeywords=="")?$search_cate_rows['cateKeywords']:$cateKeywords;
					$cateDescription=(($cateDescription==" ")||($cateDescription==""))?$search_cate_rows['cateDescription']:$cateDescription;
						
					$imgpic=$SmallFoldersProducts."/".$products_rows['productPic'];
					//生成文件地址
					$file=$search_cate_rows['cateFolders']."/".$search_midcate_rows['midcateFolders']."/".$search_subcate_rows['subcateFolders']."/".$indexpath;
					//生成大图地址
					$pathprofilename = $search_subcate_rows['subcateFolders'];
					$pathprofile = "../../../";
					$profile=$search_cate_rows['cateFolders']."/".$search_midcate_rows['midcateFolders']."/".$search_subcate_rows['subcateFolders']."/".pathProName($products_rows['productName'])."-".$products_rows['ID'].".html";
					$profile=$products_rows['filename']==""?$profile:$search_cate_rows['cateFolders']."/".$search_midcate_rows['midcateFolders']."/".$search_subcate_rows['subcateFolders']."/".$products_rows['filename']; //21-7-28

					$proFiles=$search_cate_rows['cateFolders']."/".$search_midcate_rows['midcateFolders']."/".$search_subcate_rows['subcateFolders']."/";
					
					$banner=(file_exists("../".$search_cate_rows['cateFolders']."/".$search_midcate_rows['midcateFolders']."/".$search_subcate_rows['subcateFolders']."/".$search_subcate_rows['subcateFolders']."_banner.jpg")?  $search_subcate_rows['subcateFolders']."_banner.jpg":"../". $_SESSION['midcatebanner']);  //没小类banner，用上级
					
					$lsbrief=$search_subcate_rows['subcateBrief'];
					
					$url="../../";
					$s_cate=$s_pro3_cate;				//左侧产品类别
					$d_cate=$d_pro3_cate;				//左侧产品类别
					$s_news=$ls_h3_news;			//新闻
					$s_p_cate=$s_p3_cate;
					$ls_languages = $languages3;
					$s_f_cate=get_pro_cate(3);
					$s_procate=$s_pro3_cate;				//左侧产品类别
					$d_procate=$d_pro3_cate;
					$ss_p_cate=$s_p3_cate;
					$ss_f_cate=get_pro_cate(4);
					$leftcate=$pro3_cate;
					$leftprocate=$pro4_cate;
					$lspro_menu=$menu_pro3;
					$lsproshowmenu=$menu_pro4;
					$ls_link=$pro3_link;
					$lspro_link=$pro4_link;
					$ls_revo=$pro3_revo;
					$lspro_revo=$pro4_revo;					
					$ls_motif=$s_m3_cate;   //产品相册主题图片
					$lspro_motif=$s_m4_cate;  //产品详细页主题图片
				}
				
				$prodda= $_SESSION['dda']==""?"": $_SESSION['dda'].$pathprofile.$proFiles ; 
				//echo $prodda."==";
				
				switch($productshowstyle)
				{
					case "name":
					$pro.="<li id='pro_list_li_name'>".(file_exists("../Templates1/images/name_prefix.gif")?"<img src=\"{ls_url}../Templates1/images/name_prefix.gif\" id='pro_list_li_img_name'/ >":'').
					"\r\n<a id='pro_list_li_a_name' href=\"".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html\"  target=\"_blank\">".$products_rows['productItemNo']."</a></li>\r\n";
					break;
					
					case "list":  // 相册
						include("_inc_products_gallary.php");
					break;
					
					case "style4":
					$pro.="<li id='pro_list_li_style4' ><a id='pro_list_li_a_name' href=\"".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html\"   target=\"_blank\">".$products_rows['productItemNo']."</a></li>\r\n";
					break;
					
					case "style5":
					$pro.="<li id='pro_list_li_style4' ><a id='pro_list_li_a_name' href=\"".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html\"   target=\"_blank\">".$products_rows['productItemNo']."</a></li>\r\n";
					break;
					
					
					case "":
					case "gallary":
					default:
					$pro.="<li><a href=\"".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html\"  target=\"_blank\"><img width=\"".($showSmallPicW!=""?$showSmallPicW:'188')."\" src=\"".$imgpic."\" alt=\"".$products_rows['productItemNo']."\" /></a>".$products_rows['productItemNo']."</li>\r\n";
					
				}
		//页码计算
		$propage=getPagess($pathprofilename.".html",$allpages,$ls_current_page,true);
		$proshow_path="../".$templates_var."/productsshow.html";			//大图模板地址
		if(!file_exists($proshow_path))
		{
			echo "模板文件".$proshow_path."不存在！请设计好模板后重新生成。</br></br>";
			return;
		}
		
			
			$ls_menu=$lsproshowmenu;	//主菜单
			$ls_protitle=$products_rows['productTitle']==""?$catetitle:$products_rows['productTitle'];				  		//产品title
			$ls_prokeywords=$products_rows['productKeywords']==""?$cateKeywords:$products_rows['productKeywords'];			//产品Keywords
			$ls_description=$products_rows['productDescription']==""?$cateDescription:$products_rows['productDescription'];		//产品Description
			$ls_prourl=$url;
			$ls_s_cate=$s_procate;				//左侧产品类别
			$ls_d_cate=$d_procate;				//左侧产品类别
			$ls_s_news=$s_news;				//新闻
			$ls_p_cate=$ss_p_cate;				//左侧产品类别
			$ls_f_cate=$ss_f_cate;
			$needleonmouseover="<ul  id=\"menuLists".$menuListscateid."\" style=\"display:none;\">\r\n";	//替换悬停菜单内容
			$replaceonmouseover="<ul  id=\"menuLists".$menuListscateid."\" style=\"display:block;\">\r\n";

			if($menuListscateid!=0){$ls_s_cate=str_replace($needleonmouseover,$replaceonmouseover,$ls_s_cate);}
			$ls_probanner=$banner;						//大类主体图
			$ls_procate=$leftprocate;						//左侧产品类别
			
			if(strpos($indicatebar, "../../") !== false){
				$ls_indicatebar=str_replace("../../","../../",$indicatebar);
			}else{
				$ls_indicatebar=str_replace("../","../",$indicatebar);
			}
			//相关产品 -- 前10产品与后10产品   --有图片
			$pn_sql="select * from ls_products where productID = ".$products_rows['productID']."  and enable=1 ORDER BY ID asc ";
			 
			$pn_query=$opendb->query($pn_sql);
			$pn_num = mysqli_num_rows($pn_query);
			// echo "--".$pn_num. "--";
			/*if($pn_num<=2 ){ //同类产品<=2,找同类
				$relaprocate=getprocate($products_rows['productID']);
				$relatedpIDstr= $relaprocate[1]  ;
			}else{ $relatedpIDstr=" enable=1   and productID = ".$products_rows['productID']." and ID > ".$products_rows['ID'];} //本类多余2个，用本类相关产品 error*/
			$relatedpIDstr=" enable=1   and productID = ".$products_rows['productID']." and ID > ".$products_rows['ID'];
			
			$p_sql="select * from ls_products where ".$relatedpIDstr." ORDER BY ID asc ";
			$p_query=$opendb->query($p_sql);
			$p_num = mysqli_num_rows($p_query);
			//echo $p_sql;
			$n_sql="select * from ls_products where ".str_replace(">","<",$relatedpIDstr)."  ORDER BY ID desc";
			$n_query=$opendb->query($n_sql);
			$n_num = mysqli_num_rows($n_query);
			$limitnum = 0;
			if($p_num < $related_products_num){
				$limitnum = $related_products_num + ($related_products_num - $p_num);
			}elseif($n_num < $related_products_num){
				$limitnum = $related_products_num + ($related_products_num - $n_num);
			}else{
				$limitnum = $related_products_num;
			}
			
			$related_sql="select * from ls_products where ".$relatedpIDstr."  ORDER BY ID asc LIMIT 0 , ".($relaprocate[0]=="" ? $limitnum: $limitnum*2);
			
			$relastr=trim($products_rows['relatedpros']);  //选择相关产品
			
			if($relastr!="") $related_sql="select * from ls_products where ID=". str_replace(","," or ID=",substr($relastr,1,(strlen($relastr)-2)))    ;

			//前10 或 选择的相关产品
			$related_query=$opendb->query($related_sql);
			$related_products.="<div  class=\"row related\">";
			while($related_rows=mysqli_fetch_array($related_query)){
				include("_relative_products_prev_10.php");
			}
			if($relastr=="") {  //未选择相关产品
			//后10产品
				$related_sql2="select * from ls_products where ".str_replace(">","<",$relatedpIDstr)." ORDER BY ID desc LIMIT 0 , ".$limitnum;
				$related_query2=$opendb->query($related_sql2);
				while($related_rows2=mysqli_fetch_array($related_query2)){
					include("_relative_products_next_10.php");
				}
			}
			$related_products.="</div>";
			
		//相关产品 -- 前10产品与后10产品   --无图片
			$related_products_nopic = "";
			//前10个产品
			$related_sql_nopic="select * from ls_products where productID = ".$products_rows['productID']." and ID > ".$products_rows['ID']." ORDER BY ID asc LIMIT 0 , ".$related_products_num;
			$related_query_nopic=$opendb->query($related_sql_nopic);
			$related_products_nopic.="<h3>Related Products</h3>
			<ul class=\"related_nopic\">";
			while($related_rows_nopic=mysqli_fetch_array($related_query_nopic)){
				$related_products_nopic.="<li>
				<a href=\"".pathProName($related_rows_nopic['productName'])."-".$related_rows_nopic['ID'].".html\" target=\"_blank\"  title='<translate>".$related_rows_nopic['productName']."</translate>' >".$related_rows_nopic['productItemNo']."</a>
				</li>";
			}
			//后10产品
			$related_sql2_nopic="select * from ls_products where productID = ".$products_rows['productID']." and ID < ".$products_rows['ID']." ORDER BY ID desc LIMIT 0 , ".$related_products_num;
			$related_query2_nopic=$opendb->query($related_sql2_nopic);
			while($related_rows2_nopic=mysqli_fetch_array($related_query2_nopic)){
				$related_products_nopic.="<li>
				<a href=\"".pathProName($related_rows2_nopic['productName'])."-".$related_rows2_nopic['ID'].".html\" target=\"_blank\"   title='<translate>".$related_rows_nopic['productName']."</translate>' >".$related_rows2_nopic['productItemNo']."</a>
				</li>";
			}
			
			$related_products_nopic.="</ul>";
			

			/*产品详细页多角度产品展示*/
			$search_cate_sql='select * from ls_propic where productID = '.$products_rows["ID"].'';
			$search_cate_query=$opendb->query($search_cate_sql);
			
			$picnum=mysqli_num_rows($search_cate_query);
			$str="<li><div class=\"small-img\"><img src='".$BigFoldersProducts."/".$products_rows['productPic']."' ></div></li>";
		
 			while($picname=mysqli_fetch_assoc($search_cate_query)){
			 if($picname['num']==0){
				//$newBigFoldersProduct=$BigFoldersProducts;
				//$newSmallFoldersProduct=$SmallFoldersProducts;
			 }
			else
			{
				$str.="<li><div class=\"small-img\"><img src='".$newSmallFoldersProducts."/".$picname["picName"]."' ></div></li>";
			}
			$newBigFoldersProduct=$newBigFoldersProducts;
			$newSmallFoldersProduct=$newSmallFoldersProducts;	
 		}
			if($ifmutipic) $ls_proshow=$str; else 
				$ls_proshow=$prodda.$BigFoldersProducts."/".$products_rows['productPic'] ;//大图

			$ls_proshow_s=$prodda.$SmallFoldersProducts."/".$products_rows['productPic'] ;//小图
			$ls_provideo=$prodda.$BigFoldersProducts."/".$products_rows['productVideo'] ;//视频
			$ls_proshow_id = $products_rows['ID'];
			$ls_proitemno=$products_rows['productItemNo'];							//编号
			$ls_proshow_img="../".$BigFoldersProducts."/".$products_rows['productPic']."";//select大图
			$ls_matealt=(trim($products_rows['ls_matealt'])==""?$products_rows['productName']:$products_rows['ls_matealt']);							//编号
			$ls_proname=$products_rows['productName'];								//名字
			$ls_prodescription=htmlspecialchars_decode($products_rows['productSpecification'],ENT_QUOTES);	//规格
			//$ls_prodescription=deployvideo($ls_prodescription);			
			/****************************编号、名称外的其他参数***********************************/
			
			$select_sql="select * from ls_functioncode ";
			$select_query=$opendb->query($select_sql);
			while ($select_rows = mysqli_fetch_assoc($select_query)){
				switch($select_rows['codeID']){
					case "canshu":  //业务信息
						$canshu2_enable = $select_rows['enable'];
					break;
					case "basicInfo":  //基本信息
						$basicInfo2_enable = $select_rows['enable'];
					break;
					case "additionalInfo":  //附加信息
						$additionalInfo2_enable = $select_rows['enable'];
					break;
				}
			}
			
			$ls_morecontent_p =htmlspecialchars_decode( $products_rows['canshu']);   //产品业务信息
			if($ls_morecontent_p != "" && $canshu2_enable == 1){
				$morearray = explode('
[[[', $ls_morecontent_p);  //用 回车+[[[分隔
				$newarray = array();
				foreach($morearray as $moreval){
					//$morearray2 = explode(':', $moreval);
					$morearray2 = explode(':::', $moreval);  //用 :::分隔
					
					$newarray[] = $morearray2;
				}
				$ls_moreparamstr_p = "<div class=\"ny_c3\">";
				$num_i = 0;
				foreach($newarray as $newval){
					//$ls_moreparamstr_p .= "<p>".str_replace(" ", "&nbsp;",$newval[0])."</p>".$newval[1]."";
			$ls_moreparamstr_p .= $newval[0].$newval[1]."";
				}
				$ls_moreparamstr_p .= "</div>"; 
			}else {
				$ls_moreparamstr_p="";
			}
			
			$ls_basicInfo = $products_rows['basicInfo'];  //产品基本信息
			if($ls_basicInfo != "" && $basicInfo2_enable == 1){
				$morearray = explode('
[[[', $ls_basicInfo); //用 回车+[[[分隔
				$newarray = array();
				foreach($morearray as $moreval){
					$morearray2 = explode(':::', $moreval); //用 :::分隔
					$newarray[] = $morearray2;
				}
				$ls_moreBasicInfo_p = "<div class=\"panel panel-info\">
              <div class=\"panel-heading\">
                <h3 class=\"panel-title\">Basic Info</h3>
              </div>
              <div class=\"panel-body box_cont\">";
				$num_i = 0;
				foreach($newarray as $newval){
					//$ls_moreBasicInfo_p .= "<p><span><b>".str_replace(" ", "&nbsp;", $newval[0])."</b></span>: ".$newval[1]."</p>";
					$ls_moreBasicInfo_p .= $newval[0].$newval[1]."";
				}
				$ls_moreBasicInfo_p .= "</div>
            </div>"; 
			}else {
				$ls_moreBasicInfo_p="";
			}
			
			$ls_additionalInfo_p = $products_rows['additionalInfo'];  //产品附加信息
			if($ls_additionalInfo != "" && $additionalInfo2_enable == 1){
				$morearray = explode('
[[[', $ls_additionalInfo); //用 回车+[[[分隔
				$newarray = array();
				foreach($morearray as $moreval){
					$morearray2 = explode(':::', $moreval);//用 :::分隔
					$newarray[] = $morearray2;
				}
				$ls_moreAdditionalInfo_p = "<div class=\"panel panel-info\">
              <div class=\"panel-heading\">
                <h3 class=\"panel-title\">FUNCTION & APPLICATION</h3>
              </div>
              <div class=\"ny_c2\">";
				$num_i = 0;
				foreach($newarray as $newval){
					//$ls_moreAdditionalInfo_p .= "<p>".str_replace(" ", "&nbsp;", $newval[0]).$newval[1]."</p>";
					$ls_moreAdditionalInfo_p .= $newval[0].$newval[1]."";

				}
				$ls_moreAdditionalInfo_p .= "</div>
            </div>"; 
			}else {
				$ls_moreAdditionalInfo_p="";
			}

			$ls_characteristics_p = $products_rows['characteristics']; //4-8
			$ls_advantages_p = $products_rows['advantages'];
			$ls_parameters_p = $products_rows['parameters'];
			$ls_attachedfile_p = $products_rows['ls_attachedfile'];

			/**********************************************************************************/
			//产品属性
			$select_sql2="select * from ls_prospec where productID = ".$products_rows['ID'];
			$select_query2=$opendb->query($select_sql2);
			$select_rows2=mysqli_num_rows($select_query2); //总产品数
			if($select_rows2>0)
			{
				$ls_spec = "";
				while($prospec_row=mysqli_fetch_assoc($select_query2))  //循环处理变量处理 变量名
				{	
					if(trim($prospec_row['specValue'])!=''){$ls_spec .= "".$prospec_row['specValue']."";}	
				}
				$ls_spec .= "";
				//echo $ls_spec;
				//die();
			}//产品属性
			//整合产品页面详细信息
			$ls_proitemno_nonintegrate=$ls_proitemno;
			$ls_proname_nonintegrate=$ls_proname;
			$ls_proitemno="<b>Item No.</b>: ".$ls_proitemno."<br />";
			$ls_proname="<b>Name</b>:".$ls_proname."<br />";
			$ls_prodescription_test=preg_replace("/<[\/|\w+]+?.*?\/?>/",null,$ls_prodescription);		//替换html标签到null
			$ls_prodescription_test=preg_replace("/$\w{2,7};/",null,$ls_prodescription_test);			//替换html转义字符
			$ls_prodescription_test=preg_replace("/\s*?/",null,$ls_prodescription_test);			//替换所有不可见的字符
			$ls_prodescription_test=trim($ls_prodescription_test);			//删除两端的空白字符
			
			if($ls_prodescription != null){
				$ls_prodescription=$ls_spec ."".($productDescriptionTitle==''?'':($productDescriptionTitle."")).$ls_prodescription;
			}else{
				$ls_prodescription="";
			}
			
			$ls_foot=$foot;	

			//产品更多信息
			file_exists("widget/ls_moreinfo.php")?include "widget/ls_moreinfo.php":"";

			// 深入一级目录，适应 productshow
			$ls_pronewsdongtai=str_replace('="../','="../../',$ls_newsdongtai);
			$ls_pronewsgonggao=str_replace('="../','="../../',$ls_newsgonggao);
			$ls_pronewstieshi=str_replace('="../','="../../',$ls_newstieshi);
			//底部信息
			
			//相关新闻
			file_exists("widget/ls_relative_news.php")?include "widget/ls_relative_news.php":"";

//组合数字导航
			if($j>$productBrowerNoOffset)
			{
				$startk=$j-$productBrowerNoOffset;
				$endk=$j+$productBrowerNoOffset;
			}
			else
			{
				$startk=1;
				$endk=$j+$productBrowerNoOffset;
			}
			if($endk>$mynum)
			{$endk=$mynum;}
			
			$k=1;									//产品大图数字导航下标
			$productBrowerStr='';					//产品大图数字导航页
			mysqli_data_seek($result2, 0);
			while($products_rows_br=mysqli_fetch_assoc($result2))
			{
				$productBrowerNo[$k]="<a href=\"".trim(str_replace(substr($products_rows_br['productPic'],-4),"",$products_rows_br['productPic'])).".html\" >".$k."</a>";		// get the array of no brower
				
				$k++;
			}
			
			for($ik=$startk;$ik<=$endk;$ik++)
			{
				if($ik==$j)
				{
					$productBrowerStr.="[".$productBrowerNo[$ik]."]";
				}
				else
				{
					$productBrowerStr.=$productBrowerNo[$ik];
				}
			}
			
			//echo $productBrowerStr;
			$ls_productBrowerStr=$productBrowerStr;
			//组合数字导航 end

			$code_sql="select * from ls_functioncode where enable=1 order by ID";	
			$opendb=new mydb();
			$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;
				}
			}
			
			$j++;
			$ls_prodescription = str_replace('../', $pathprofile, $ls_prodescription);
		
			$fp = fopen($proshow_path,"r");
			$procontent  = fread($fp,filesize ($proshow_path));

			$procontent  = str_replace("../","{ls_url}../",$procontent);
			$procontent  = str_replace("{ls_url}",$ls_prourl,$procontent);
			$procontent  = str_replace("{ls_title}",$ls_protitle,$procontent);
			$procontent  = str_replace("{ls_keywords}",$ls_prokeywords,$procontent);
			$procontent  = str_replace("{ls_prodescription}",$ls_prodescription,$procontent);
			$procontent  = str_replace("{ls_banner}",$ls_probanner,$procontent);
			$procontent  = str_replace("{ls_menu}",$ls_menu,$procontent);

			$procontent  = str_replace("{ls_statistics}",$statistics,$procontent);
			$procontent  = str_replace("{ls_onlines}",$onlines,$procontent);
			$procontent  = str_replace("{ls_maps}",$maps,$procontent);
			$procontent  = str_replace("{ls_share}",$share,$procontent);
			$procontent  = str_replace("{ls_onlinechart}",$onlinechart,$procontent);
			$procontent  = str_replace("{ls_shield}",$shield,$procontent);
			// 头部代码 在 _inc_allrepltags.php
			$procontent  = str_replace("{ls_productsKeywords}",$productsKeywords,$procontent);
			
			$procontent  = str_replace("{ls_canshu}",$ls_morecontent_p,$procontent); //21-4-8
			$procontent = str_replace("{ls_proitem_canshu}",$ls_moreparamstr_p,$procontent);//产品详细页中，业务信息。
			$procontent = str_replace("{ls_proitem_basicInfo}",$ls_moreBasicInfo_p,$procontent);//产品详细页中，基本信息。
			$procontent = str_replace("{ls_proitem_additionalInfo}",$ls_moreAdditionalInfo_p,$procontent);//产品详细页中，附加信息。
			$procontent  = str_replace("{ls_characteristics}",$ls_characteristics_p,$procontent); //4-8
			$procontent  = str_replace("{ls_attachedfile}",$ls_attachedfile_p,$procontent);
			$procontent  = str_replace("{ls_advantages}",$ls_advantages_p,$procontent);
			$procontent  = str_replace("{ls_parameters}",$ls_parameters_p,$procontent);
			
			$procontent  = str_replace("{ls_languages}",$ls_languages,$procontent);
			$procontent  = str_replace("{ls_indicatebar}",$ls_indicatebar,$procontent);
			if( $products_rows['productVideo']!="")$procontent = strippattern($procontent, '<img src="{ls_proshow}"', "/>");else $procontent = strippattern($procontent, "<video width=", "/></video>"); //图片视频保留一个

			$procontent = str_replace("{ls_provideo}",$ls_provideo,$procontent);//视频。
			$procontent  = str_replace("{ls_proshow}",$ls_proshow,$procontent);
			$ls_srcset=srcsetpic($ls_proshow,$proFiles); //分级处理图片
			$procontent  = str_replace ("{ls_proshow_s}",$ls_proshow_s,$procontent);
			$procontent  = str_replace("{ls_proshow_img}",$ls_proshow_img,$procontent);//select 图			
			$procontent  = str_replace("{ls_proshow_width}",($showBigPicW==""?"530":$showBigPicW),$procontent);  //设置显示大图宽度则显示，否则 使用530 宽度
			$procontent  = str_replace("{ls_proitemno}",$ls_proitemno,$procontent);
			$procontent  = str_replace("{ls_proname}",$ls_proname,$procontent);
			$procontent  = str_replace("{ls_proitemno_nonintegrate}",$ls_proitemno_nonintegrate,$procontent);
			$procontent  = str_replace("{ls_matealt}",$ls_matealt,$procontent);

			$procontent  = str_replace("{ls_proshow_id}",$ls_proshow_id,$procontent);
			
			$procontent  = str_replace("{ls_proname_nonintegrate}",$ls_proname_nonintegrate,$procontent);
			$procontent  = str_replace("{ls_description}",$ls_description,$procontent);
			$procontent  = str_replace("{ls_foot}",$ls_foot,$procontent);
			$procontent  = str_replace("{ls_procurrentpage}",$ls_procurrentpage,$procontent);
			$procontent  = str_replace("{ls_revo}",$lspro_revo,$procontent);
			$procontent  = str_replace("{ls_motif}",$s_m3_cate,$procontent);
			
			$procontent  = str_replace("{ls_relative_news}",$relative_new,$procontent);
			$procontent  = str_replace("{ls_current_id}",$products_rows['ID'],$procontent);
			$procontent  = str_replace("{ls_moreinfo}",$ls_moreinfo2,$procontent);
			$procontent  = str_replace("{ls_site_cate}",$site_cate,$procontent);
			$procontent  = str_replace("{ls_weiboshare}",$facebook_twitter_share,$procontent);
			$procontent  = str_replace("{ls_weibo}",$ls_facebook_twitter,$procontent);
		
			$procontent  = str_replace("{ls_copyright}",$row['copyright'],$procontent);
			$procontent  = str_replace("{relative_products_nopic}",$related_products_nopic,$procontent);
			$procontent  = str_replace("{relative_products_pic}",$related_products,$procontent);

			$procontent	= str_replace("{ls_newsdongtai}",$ls_pronewsdongtai,$procontent);
			$procontent	= str_replace("{ls_newsgonggao}",$ls_pronewsgonggao,$procontent);
			$procontent	= str_replace("{ls_newstieshi}",$ls_pronewstieshi,$procontent);

			$procontent	= str_replace("{ls_about}",$ls_about,$procontent);
			$procontent	= str_replace("{ls_news}",$ls_s_news,$procontent);
			$procontent	= str_replace("{ls_faq}",$ls_faq,$procontent);
			$procontent	= str_replace("{ls_classpro}",$ls_classpro,$procontent);
			$procontent	= str_replace("{ls_hotpro}",$ls_hotpro,$procontent);
			$procontent	= str_replace("{ls_designby}",$ls_designby,$procontent);
			$procontent	= str_replace("{ls_links}",$lspro_link,$procontent);
			$procontent	= str_replace("{ls_productBrowerStr}",$ls_productBrowerStr,$procontent);
			$procontent	= str_replace("{ls_left_contact}",$ls_left_contact,$procontent);
			$procontent = str_replace("{ls_addprolink}",$ls_addprolink,$procontent);	//指向主菜单中的Products链接
			$procontent = str_replace("{ls_addnewprolink}",$ls_addnewprolink,$procontent);	//指向主菜单中的NewProducts链接
			$procontent = str_replace("{ls_revo}",$ls_revo,$procontent);//滚动图片。
			
			$procontent = circleNavigationLink2($products_rows['ID'],'B','{ls_previouslink}',$procontent, $pathprofilename);
			$procontent = circleNavigationLink2($products_rows['ID'],'F','{ls_nextlink}',$procontent, $pathprofilename);
			$procontent = str_replace("{ls_search}",ls_search("../../".$ls_prourl),$procontent); //搜索框
			$ls_banner=$banner;
			$procontent =  $ifcatepic   ? str_replace('<div class="nybanner"','<div class="nybanner" style="background-image:url('.$ls_banner.');" ',$procontent) : $procontent ;
			//echo $ls_banner."-----";

			$profilename="../".$profile;
			$content=$procontent;
			$ls_weburl1=  $_SERVER['HTTP_HOST'].str_replace("..","",$profilename); // 非80端口，会输出端口
			$addmnurl="../";			
			include("_inc_allrepltags.php");
			$procontent=$content;
			
			$procontent  = str_replace("{ls_procate}",$ls_procate,$procontent);
			$procontent  = str_replace("{ls_s_cate}",$ls_s_cate,$procontent);
			$procontent  = str_replace("{ls_d_cate}",$ls_d_cate,$procontent);
			$procontent  = str_replace("{ls_p_cate}",$ls_p_cate,$procontent);
			$procontent  = str_replace("{ls_f_cate}",$ls_f_cate,$procontent);

		
		if($translate != ''){
		//翻译代码
		$folder_name = $translate;
		
		$r_name = deep_in_array($folder_name, $translate_name);
		
		$translateFile = "../".$r_name['folder_name'];
		createFolder($translateFile);
		$trans = "";
		$transFile = $profile;
		$trans = $proFiles.$showproductsFolders;
		createFolder($translateFile."/".$trans);
		$io = substr_count($proFiles, "/");
		$ipath = "";
		for($i=0; $i<$io; $i++){
			$ipath .= "../";
		}
		$replace = $proFiles;
		$procontent2 = str_replace($ls_proshow, $prodda."../".$ipath.$replace.$ls_proshow,$procontent);
		$procontent2 = str_replace("thumbnails/", $prodda."../".$ipath.$replace."/thumbnails/",$procontent2);
		$procontent2 = str_replace("src='images", "src='".$prodda."../".$ipath.$replace."/images/",$procontent2);  // 放大镜大图路径 翻译

		if( ifNeedTrans($translateFile."/".$transFile,$translate)||$_SESSION['transAll']==1){  //产品详细页，不存在和模拟翻译要生成，或者覆盖
		
			  if(translateApp($procontent2, $translateFile."/".$transFile, $r_name['translate_name'])){
				  echo "生成 <a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a>";
				  if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
	  
				  echo "<br>";
	  
			  }else{
				  if($ls_debug) echo "".$translateFile."/".$transFile."失败！<br>";
			  }
		}
		else{
			echo "<a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a> 已存在， ".($_SESSION['transAll']==0?" 未生成。</br>":" ");
			}
	
	}else{
		if (is_file ($profilename)){ 
			@unlink ($profilename); //若文件已存在，则删除
		}
		//英文网站去除<translate>标签
		$translate_str = $procontent;
		$p = "%<translate>(.*?)</translate>%si";    //正则表达式
		preg_match_all($p, $procontent, $arr);
		$temarr = $arr[1];
		
		$source="en";
		$targets = $target;
	
		foreach($temarr as $val){
			$procontent = str_replace("<translate>".$val."</translate>", $val, $procontent);
		}
		//echo $proFiles;
		if (!is_dir("../".$proFiles)) crmkdir("../".$proFiles);		// 产品文件夹不存在则建
	 	$handle   = fopen($profilename,"w"); //打开文件指针，
		  /*
		　检查文件是否被创建且可写
		  */
		  if (!is_writable ($profilename))
		  { 
				if($ls_debug) 	 echo "文件：".$profilename."不可写，请检查其属性后重试！";
		  }
		  else
		 {
			 
				$writeimportent=true;
				$writeurl=str_replace("..","",$profilename);
				include("_inc_when_write_file.php");

				if (!fwrite ($handle,$procontent))
				{  //将信息写入文件
				  if($ls_debug)  echo "".$profilename."失败！";
				} 
				else
				{
					  echo "生成<a href='".$profilename."' target='_blank'>".$profilename."</a>";
					  if($ifcatelink) cpoldproname($profilename,$products_rows['productPic']);  //旧产品详细页文件名兼容 /page/2313221.jtml					   
					  if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
	  
					  echo "<br>";
				}
			}
			 fclose ($handle); //关闭指针
		}

		fclose ($fp);
		unset($ls_about,$ls_s_news,$ls_faq,$ls_left_contact,$related_products,$relative_new,$ls_description,$ls_proshow,$ls_prodescription,$procontent,$ls_revo,$ls_moreparamstr,$ls_productBrowerStr,$ls_prodescription,$ls_prokeywords,$ls_protitle);  //释放内存

	 } //end of while, end of one page
		$pro.="";
		
		$ls_motif = $s_m2_cate;
		$index_path="../".$templates_var."/products.html";	
		//echo $propage."===";
		writeIndexPages($index_path,$catetitle,$cateKeywords,$cateDescription,$url,$banner,$leftcate,$lspro_menu,
			$lsbrief,$procate,$procateid,$propage,$pro,$file,$echoname,$mynum,$allpages,$detail,$s_cate,$s_news,$s_p_cate,$ls_languages,$s_f_cate,$site_cate_pro,$ls_motif,$ls_revo,$foot,$indicatebar,$behalf,$ls_facebook_twitter2,$translate,$d_cate,$ls_characteristics,$ls_parameters,$ls_advantages,$ls_moreparam,$ls_attachedfile);
//echo $pro;
		}	// end of for, all pages
		//if($mynum==1) copy($pathprofilename.".html",$file) ; //一个产品，覆盖列表页
}

/*
------------------------------------------------------
参数：
$productID		当前页产品id
$direction		跳转方向(值:'F'下一条,'B'上一条)
$tag			替换标签
$content		需要处理的内容
返回值：替换完成的内容
程序功能：将指定标签替换成向前翻页以及向后翻页的链接
备注：仅支持本类中的页面跳转，不支持类间的。
------------------------------------------------------
*/

function circleNavigationLink($productID,$direction,$tag,$content){
	require('inc/constant.php');
	$opdb=new mydb();
	$lan = array();
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	//Get product information
	$productInfoSql="select * from ls_products where ID={$productID}";
	$productInfoR=$opdb->query($productInfoSql);
	$productInfo=mysqli_fetch_object($productInfoR);
	//Get Max and Min Num value
	$numLimitSql="select min(Num) as minNum, max(Num) as maxNum from ls_products where productID={$productInfo->productID}";
	$numLimitR=$opdb->query($numLimitSql);
	$numLimit=mysqli_fetch_object($numLimitR);
	//According to $direction, search the next product
	if(($productInfo->Num==$numLimit->minNum)&&('B'==strtoupper($direction))){
		$linkProductNum=$numLimit->maxNum;
	}else if(($productInfo->Num==$numLimit->maxNum)&&('F'==strtoupper($direction))){
		$linkProductNum=$numLimit->minNum;
	}else{
		$searchCount=0;
		do{
			$searchCount++;
			$linkProductNum=('B'==strtoupper($direction))?($productInfo->Num-$searchCount):($productInfo->Num+$searchCount);
			$checkSql="select ID from ls_products where productID={$productInfo->productID} and Num={$linkProductNum}";
			$checkR=$opdb->query($checkSql);
		}while(0==mysqli_num_rows($checkR));
	}
	//Get target product information and return the ready content
	$targetProductSql="select * from ls_products where productID={$productInfo->productID} and Num={$linkProductNum}";
	$targetProductR=$opdb->query($targetProductSql);
	$targetProduct=mysqli_fetch_object($targetProductR);
	$targetProductFile=strrev(ltrim(stristr(strrev($targetProduct->productPic),'.'),'.')).'.html';
	$targetProductLink="<a href=\"{$targetProductFile}\">".(('B'==strtoupper($direction))?$lan['previous']:$lan['next'])."</a>";
	return str_replace($tag,$targetProductLink,$content);
}

//产品详页  跳转方向(值:'F'下一条,'B'上一条)  首不接尾
function circleNavigationLink2($productID,$direction,$tag,$content,$pathprofilename){
	require('inc/constant.php');
	$opdb=new mydb();
	$lan = array();
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	//Get product information

	$productInfoSql="select * from ls_products where ID={$productID}";
	$opdb = new mydb();
	$productInfoR=$opdb->query($productInfoSql);
	$productInfo=mysqli_fetch_object($productInfoR);
	//Get Max and Min Num value
	$numLimitSql="select min(Num) as minNum, max(Num) as maxNum from ls_products where productID={$productInfo->productID}"; 
	$numLimitR=$opdb->query($numLimitSql);
	$numLimit=mysqli_fetch_object($numLimitR);

	if(($productInfo->Num==$numLimit->minNum)&&('B'==strtoupper($direction))){
		$linkProductNum=$numLimit->maxNum;
	}else if(($productInfo->Num==$numLimit->maxNum)&&('F'==strtoupper($direction))){
		$linkProductNum=$numLimit->minNum;
	}else{
		$searchCount=0;
		do{
			$searchCount++;
			$linkProductNum=('B'==strtoupper($direction))?($productInfo->Num-$searchCount):($productInfo->Num+$searchCount);

			$checkSql="select * from ls_products where productID={$productInfo->productID} and Num={$linkProductNum}";
			$checkR=$opdb->query($checkSql);
			$targetProduct=mysqli_fetch_object($checkR);
			if(mysqli_num_rows($checkR) != 0){
				$targetProductFile=pathProName($targetProduct->productName)."-".$targetProduct->ID.'.html';
				$targetProductLink="<a href=\"{$targetProductFile}\">".(('B'==strtoupper($direction))?$lan['previous']:$lan['next'])."</a>";
			}
		}while(0==mysqli_num_rows($checkR));
	}
	return str_replace($tag,$targetProductLink,$content);
}
/*
------------------------------------------------------
参数：
程序功能：写入类下产品列表页index文件,相册页
------------------------------------------------------
*/
function writeIndexPages($index_path,$catetitle,$cateKeywords,$cateDescription,$url,$banner,$leftcate,$lspro_menu,$lsbrief,$procate,$procateid,$propage,$pro,$file,$echoname,$mynum,$allpages,&$detail,$s_cate,$s_news,$s_p_cate,$ls_languages,$s_f_cate,$site_cate_pro,$ls_motif,$ls_revo,$foot,$indicatebar,$behalf,$ls_facebook_twitter2,$translate){
	global $ls_procurrentpage,$menuListscateid,$ls_about,$ls_news,$ls_classpro,$ls_hotpro,$ls_link,$ls_designby,$ls_news,$ls_faq,$ls_newsdongtai,$ls_newsgonggao,$ls_newstieshi,$ls_addprolink,$ls_addnewprolink,$ls_moreparam,$facebook_twitter_share,$facebook_twitter, $ls_sitebrand,$ls_corekeyword,$ifcatepic,$d_cate;//22-5-12
	
	$needleonmouseover="<ul id=\"menuLists".$menuListscateid."\" style=\"display:none;\">\n";	//替换悬停菜单内容
	$replaceonmouseover="<ul id=\"menuLists".$menuListscateid."\" style=\"display:block;\">\n";

	if($menuListscateid!=0){$s_cate=str_replace($needleonmouseover,$replaceonmouseover,$s_cate);}
	
	if(!file_exists($index_path)){
		if($ls_debug) echo "模板文件".$index_path."不存在！请设计好模板后重新生成。</br></br>";
		return;
	}
	
	$code_sql="select * from ls_functioncode where enable=1 order by ID";	
	$opendb=new mydb();
	$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;
		}
	}
	
	$ls_facebook_twitter = $ls_facebook_twitter2;

	//产品模板地址
	$ls_lineno=__LINE__.(__FUNCTION__==""?"":" 函数:". __FUNCTION__).(__CLASS__==""?"":" 类:".__CLASS__) ;
	$ls_title=$catetitle;//===================================网站标题
	$ls_keywords=$cateKeywords;	//============================网站关键字
	$ls_description=$cateDescription;//=======================网站描述
	$ls_url=$url;
	$ls_banner=$banner;//=====================================大类主体图
	$ls_cate=$leftcate;	
	$ls_s_cate=$s_cate;//=====================================左侧产品类别
	$ls_d_cate=$d_cate;//=====================================底部产品类别
	
	//$ls_s_cate=str_replace("><translate>".$procate," class='dangqiandao' ><translate>".$procate,$ls_s_cate); // 主菜单 横排大类产品时，替换当前类
	require('constant.php');

	$ls_s_news=$s_news;
	$ls_p_cate=$s_p_cate;//=====================================左侧产品类别
	$ls_f_cate=$s_f_cate;
	$ls_menu=$lspro_menu;//主菜单
	$ls_indicatebar=$indicatebar;
	if($lsbrief!=""){
		$ls_brief="<div id=\"brief\">".htmlspecialchars_decode($lsbrief)."</div>";
	}
	$ls_procate=$procate;//===================================产品类别
	$ls_procateid=$procateid;//===============================产品类别ID
	$ls_propage=$propage;//===================================产品分页数字
	$ls_pro=$pro;//===========================================产品信息
	$ls_pro = str_replace("{ls_url}",$ls_url,$pro);
	$ls_foot=$foot;//=========================================底部信息
	$fp	= fopen($index_path,"r");//===========================打开产品详细页模版
	$content = fread($fp,filesize ($index_path));//===========读取产品详细页模版所有内容
	$content = str_replace("{ls_title}",$ls_title,$content);
	$cateinsideflg=is_numeric(getStrbyTag("-",".",$file,false)); //是数字，就是第二页以后的
	if($cateinsideflg){
		$content = str_replace("{ls_detail}","",$content); //首页处理,避免重复
		$content = str_replace("{ls_brief}","",$content);
	}
	$content = str_replace("{ls_detail}",htmlspecialchars_decode($detail),$content); //类别首页处理,避免重复
	$content = str_replace("{ls_brief}",htmlspecialchars_decode($ls_brief),$content);
	$content = str_replace("{ls_characteristics}",$ls_characteristics,$content);
	$content = str_replace("{ls_parameters}",$ls_parameters,$content);
	$content = str_replace("{ls_advantages}",$ls_advantages,$content);
	$content = str_replace("{ls_d_cate}",$ls_d_cate,$content);
	$content = str_replace("{ls_attachedfile}",$ls_attachedfile,$content);// catedetail 21-4-7   
	
	$content = str_replace("../","{ls_url}../",$content);
	$content = str_replace("{ls_url}",$ls_url,$content);
	$content = str_replace("{ls_keywords}",$ls_keywords,$content);
	//$content = str_replace("{ls_banner}",$ls_banner,$content);
	$content =  $ifcatepic   ? str_replace('<div class="nybanner"','<div class="nybanner" style="background-image:url('.$ls_banner.');" ',$content) : $content ;
	//echo $ls_banner."----";
	//替换产品类别图
	
	$content = str_replace("{ls_menu}",$ls_menu,$content);
	$content = str_replace("{ls_motif}",$ls_motif,$content);
	$content = str_replace("{ls_languages}",$ls_languages,$content);
	
	require('constant.php');
	
	$content = str_replace("{ls_statistics}",$statistics,$content);
	$content = str_replace("{ls_onlines}",$onlines,$content);
	$content = str_replace("{ls_maps}",$maps,$content);
	$content = str_replace("{ls_share}",$share,$content);
	$content = str_replace("{ls_onlinechart}",$onlinechart,$content);
	$content = str_replace("{ls_shield}",$shield,$content);
	$content = str_replace("{ls_productsKeywords}",$productsKeywords,$content);
	
	$content = str_replace("{ls_site_cate}",$site_cate_pro,$content);
	$content = str_replace("{ls_weiboshare}",$facebook_twitter_share,$content);
	$content = str_replace("{ls_weibo}",$ls_facebook_twitter2,$content);
	
	$content = str_replace("{ls_foot}",$ls_foot,$content);
	$content = str_replace("{ls_procate}",$ls_procate,$content);
	$cateinsideflg=is_numeric(getStrbyTag("-",".",$file,false)); //是数字，就是第二页以后的
	$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
	$content = str_replace("{ls_behalf}",$behalf,$content);
	$content = str_replace("{ls_description}",$ls_description,$content);
	$content = str_replace("{ls_procateid}",$ls_procateid,$content);
	 
	$content = str_replace("{ls_propage}",$ls_propage,$content);
	$content = str_replace("{ls_pro}",$ls_pro,$content);
	$content = str_replace("{ls_procurrentpage}",$ls_procurrentpage,$content);
	$content = str_replace("{ls_about}",$ls_about,$content);
	$content = str_replace("{ls_news}",$ls_s_news,$content);
	$content = str_replace("{ls_faq}",$ls_faq,$content);
	$content = str_replace("{ls_newsdongtai}",$ls_newsdongtai,$content);
	$content = str_replace("{ls_newsgonggao}",$ls_newsgonggao,$content);
	$content = str_replace("{ls_newstieshi}",$ls_newstieshi,$content);
	$content = str_replace("{ls_classpro}",$ls_classpro,$content);
	$content = str_replace("{ls_hotpro}",$ls_hotpro,$content); 
	$content = str_replace("{ls_designby}",$ls_designby,$content);
	$content = str_replace("{ls_links}",$ls_link,$content);
	$content = str_replace("{ls_addprolink}",$ls_addprolink,$content);	//指向主菜单中的Products链接
	$content = str_replace("{ls_addnewprolink}",$ls_addnewprolink,$content);	//指向主菜单中的NewProducts链接
	$content = str_replace("{ls_revo}",$ls_revo,$content);	//指向主菜单中的NewProducts链接
	$content = str_replace("{ls_search}",ls_search("../".$ls_url),$content); //搜索框
	$filename="../".$file;
	
	$ls_weburl1=  $_SERVER['HTTP_HOST'].str_replace("..","",$filename); // 非80端口，会输出端口
	$addmnurl="../";
	include("_inc_allrepltags.php");
	
	$content = str_replace("{ls_cate}",$ls_cate,$content);
	$content = str_replace("{ls_s_cate}",$ls_s_cate,$content);
	$content = str_replace("{ls_d_cate}",$ls_d_cate,$content);
	$content = str_replace("{ls_p_cate}",$ls_p_cate,$content);
	$content = str_replace("{ls_f_cate}",$ls_f_cate,$content);

	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$row=mysqli_fetch_array($tem_query);
	$content = str_replace("{ls_copyright}",$row['copyright'],$content);
	if($translate != ''){
		//翻译代码
		$folder_name = $translate;
		
		$r_name = deep_in_array($folder_name, $translate_name);
		
		$translateFile = "../".$r_name['folder_name'];
		createFolder($translateFile);
		$trans = "";
		$transFile = str_replace("../", "", $filename);
		$trWords = explode("/", $transFile);
		for($i = 0; $i < (count($trWords)-1); $i++){
			$trans .="/".$trWords[$i];
		}
		createFolder($translateFile.$trans);
		$content2 = str_replace("<img src=\"", "<img src=\"..".$trans."/",$content);
		
		if($proGallaryPageWr||ifNeedTrans($translateFile."/".$transFile,$translate,true)||$_SESSION['transAll']==1){  //相册页翻译，不存在和模拟翻译要生成，或者覆盖

			  if(translateApp($content2, $translateFile."/".$transFile, $r_name['translate_name'])){
				  echo "生成 <a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a>";
				  if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
	  
				  echo "<br>";
			  }else{
				  if($ls_debug) echo "生成文件".$translateFile."/".$transFile."失败！<br>";
			  }
		}
		else
		{echo "<a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a> 已存在， ".($_SESSION['transAll']==0?" 未生成。</br>":" ");}	  
	}else{
		if (is_file($filename)){
			//若文件已存在，则删除
			@unlink($filename); 
		}
		//英文网站去除<translate>标签
		$translate_str = $content;
		$p = "%<translate>(.*?)</translate>%si";    //正则表达式
		preg_match_all($p, $content, $arr);
		$temarr = $arr[1];
		
		$source="en";
		$targets = $target;
	
		foreach($temarr as $val){
			$content = str_replace("<translate>".$val."</translate>", $val, $content);
		}
		$handle = fopen($filename,"w"); //打开文件指针，
		//		　检查文件是否被创建且可写
		if(!is_writable($filename)){ 
			if($ls_debug) echo "文件：".$filename."不可写，请检查其属性后重试！";
		}
		else
		{
			//$writeurl=$_SERVER['HTTP_HOST'].str_replace("..","",$filename);
			$writeurl=str_replace("..","",$filename);
			//$writeimportent=true;
			include("_inc_when_write_file.php");

			if(!fwrite($handle,$content)){
				//将信息写入文件
				if($ls_debug) echo "生成文件".$filename."失败！";
			}else{
				
				echo "生成<a href='".$filename."' target='_blank'>".$filename."</a>";
				if($ls_procateid!=0){
					$updatepro="update ls_products set wholepath='".$filename."' where ID=".$ls_procateid." ";
					$down_query=$opendb->query($updatepro); //记录文件名 
				}

				if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
	
				echo "<br>";
				
			}
		}
		
		fclose($handle);//关闭文件指针
	}
	fclose($fp);	//关闭文件指针
	
	if($index_path=="../".$templates_var."/catedetail.html"){
		echo $echoname." 详细页面成功。";
		if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
		echo "<br><br>";
	}else{
		echo $echoname."共有".$mynum."个产品。总共生成".$allpages."类别页。"; 
		if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;

		echo "<br><br>";
	}
}
/*
------------------------------------------------------
参数：
$index_path  //模板地址
$filename  //生成文件名
$mainpart  //主体内容
$mainpartsubject  //switch生成文件指针
程序功能：二级页（列表页）index,aboutus,contacuts,news,download
,rd,certificate,workshop,feedback,packing,quality
------------------------------------------------------
*/

function writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_motif,$ls_menu,$ls_foot,
$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$s_p_cate,$ls_languages,$ls_addprolink,$ls_addnewprolink,$newstag,$translate,$contact_array=''){
	require_once('conn.php');
	global $contact_array;
	if(!file_exists($index_path)){
		echo "模板文件".$index_path."不存在！请设计好模板后重新生成。</br></br>";
		return;
	}
	global $ls,$subFolder,$ls_m_news, $homecertNum ;
	global $ls_about,$ls_news,$ls_faq,$ls_homepro,$ls_newpro,$ls_classpro,$ls_hotpro,$ls_designby,$ls_link,$ls_newsdongtai,$ls_newsgonggao,$ls_newstieshi,	$ls_revo,$ls_allcatepics,$site_cate1,$p_m_cate,$p_m_cate1,$p_m_cate2,$p_m_cate3,$facebook_twitter,$facebook_twitter_share,$ls_h1_news,$ls_brief,$nybnstr,$d_cate;	//22-5-12

	$opendb=new mydb();
	require('char_set.php');
	require('constant.php');
	
	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$row=mysqli_fetch_array($tem_query);
	$templates_var = $row['templates'];
	$tel = $row['tel'];
	$copyright=$row['copyright'];
	$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;
		}
	}
	
	$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-INSTAGRAM",$row['google'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
	
	$ls_facebook_twitter = str_replace("../","",$facebook_twitter);//cate
	$ls_facebook_twitter_m =$facebook_twitter;
	
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	
	$mobi_tem_sql="select * from ls_mobiconfig order by ID";	
	$mobi_tem_query=$opendb->query($mobi_tem_sql);
	$mobi_row=mysqli_fetch_array($mobi_tem_query);
	$mobi_logo = $mobi_row['logo'];
	$mobi_companyName = $mobi_row['companyName'];
	$mobi_siteKeywords = $mobi_row['siteKeywords'];
	$mobi_siteDescription = $mobi_row['siteDescription'];
	$ls_m_logo = "<img src='images/".$mobi_logo."' />";
	//echo $templates_var;

	$menu_sql="select * from ls_menu where argument='".$mainpartsubject."' ";
	$menu_query=$opendb->query($menu_sql);
	$menu_row=mysqli_fetch_assoc($menu_query);
	//echo $ls."kk".$menu_row['enable'];
	if($menu_row['enable']==0&&$menu_row['argument']==$mainpartsubject){
		// 如果主菜单项没有启动则退出函数 
	}
	
	//首页友情链接  start
	$links_sql = "select * from ls_links where enable = 1 and cateName != 'Blog'";
	$links_query = $opendb->query($links_sql);
	while($links_rows=mysqli_fetch_assoc($links_query)){
		
		include("_home_link.php"); //首页友情链接 {ls_links}
		
	}
	$ls_links = $links_str;
	//首页友情链接  end
	
	//首页视频  start {ls_video}
	$video_sql = "select * from ls_video where enable = 1 and videoBool = 1 limit 0,2";
	$video_query = $opendb->query($video_sql);
	if("192.168.2.20"==$_SERVER["SERVER_ADDR"] || "pmf.lanscend.cn" == $_SERVER['SERVER_NAME']){
		$url=explode("/", $_SERVER["REQUEST_URI"]);
		$path = "/".$url[1];
	}else{
		$url="";
	}
	$i = 0;
	//$video_str = "<ul class=\"p_list\">";
	while($news_rows=mysqli_fetch_assoc($video_query)){
		$i++;
				
		include("_home_video.php");  //首页视频  {ls_video} 

	}
	//$video_str .= "</ul>";
	$ls_video = $video_str;
	//首页视频  end
	
	$fp = fopen($index_path,"r");
	$ls_s_cate = $s_cate;				//左侧产品类别
	$ls_d_cate = $d_cate;				//底部产品类别
	$ls_p_cate = $s_p_cate;				//左侧产品类别
	$ls_languages = $ls_languages;        //语言国旗
	$ls_motif = $ls_motif;
	$content = fread($fp,filesize ($index_path));
	$content = str_replace("href=\"../m/","href=\"",$content);
	$content = str_replace("src=\"../m/","src=\"",$content);
	//$content = str_replace("href=\"css/","href=\"Templates/css/",$content);
	//$content = str_replace("src=\"images/","src=\"Templates/images/",$content);
	
	if($mainpartsubject != 'blog'){
		if($subFolder){
			//如果在子目录里面有"../../"则换成"../"
			$content = str_replace("../../","../",$content);}
		else{
			//用来预防根目录下有其他语言版本
			$content = str_replace("../.","../x",$content);
			$content = str_replace("../","",$content);
			$content = str_replace("x./","../",$content);
		}
	}else{
		$content = str_replace("{ls_news}",$ls_h1_news,$content);
		$ls_facebook_twitter = $facebook_twitter;
	}
	 
	
	$content = str_replace("template=\"/Templates/all.dwt\"","",$content);	//清除模板地址
	$content = str_replace("{ls_title}",$ls_title,$content);
	$content = str_replace("{ls_keywords}",$ls_keywords,$content);
	$content = str_replace("{ls_description}",$ls_description,$content);
	$content = str_replace("{ls_brief}",$ls_brief,$content);
	$content = str_replace("{ls_menu}",$ls_menu,$content);
	$content = str_replace("{ls_motif}",$ls_motif,$content);
	$content = str_replace("{ls_m_news}",$ls_m_news,$content);
	$content = str_replace("{ls_m_tel}",$tel,$content);
	$content = str_replace("{ls_about}",$ls_about,$content);
		
	//首页新闻列表  {ls_news}, {ls_news_dongtai}, {ls_news_gonggao}, {ls_news_tieshi}
	if(!$homesuffStr){ //首页按Num顺序不分类输出；形式按news 输出
		$news_cate_sql3="select * from `ls_functioncates` where functionName='新闻分类' and cateName='news'  order by Num asc ";
		$news_cate_query3=$opendb->query($news_cate_sql3);
		$news_cate_rows3=mysqli_fetch_assoc($news_cate_query3);
			
		include("_home_news.php");  //首页新闻 
		$content = str_replace("{ls_news}",$news,$content);
		
	}else{

		$news_cate_sql3="select * from `ls_functioncates` where functionName='新闻分类' order by Num asc ";
		$news_cate_query3=$opendb->query($news_cate_sql3);
		$i=0;
		
		while($news_cate_rows3=mysqli_fetch_assoc($news_cate_query3)){
			$sort='';
			if($newsSort=="ID"){
				$sort = "ID";
			}else if($newsSort=="Num"){
				$sort = "Num";
			}else{
				$sort = "ID";
			}
			//equire_once('inc/char_set.php');
		
			$nui = 0;
		
			//$news_sql="select * from ls_news where cate = '".$news_cate_rows3['cateName']."' and enable=1 order by $sort desc limit 0, ".($newsNum-1);
			 
			//$news_query=$opendb->query($news_sql);
			//while($news_rows=mysqli_fetch_assoc($news_query)){
				include("_home_news.php");  //首页新闻 
			//}
	
			
			$ls_news = $news;
			$content = str_replace("{ls_news".$suffix_str2."}",$ls_news,$content);
			$i++;
		}
	}
	//首页新闻列表 End
	
 	$content = str_replace("{ls_statistics}",$statistics,$content); //统计代码
	$content = str_replace("{ls_onlines}",$onlines,$content);  //在线联系(QQ)
	$content = str_replace("{ls_maps}",$maps,$content);  //地图代码
	$content = str_replace("{ls_share}",$share,$content);  //分享代码
	$content = str_replace("{ls_onlinechart}",$onlinechart,$content);  //在线联系
	$content = str_replace("{ls_shield}",$shield,$content);  //首页屏蔽
	
	$content = str_replace("{ls_site_cate}",$site_cate1,$content);
	$content = str_replace("{ls_weiboshare}",$facebook_twitter_share,$content);
	$content = str_replace("{ls_faq}",$ls_faq,$content);
	$content = str_replace("{ls_newsdongtai}",$ls_newsdongtai,$content);
	$content = str_replace("{ls_newsgonggao}",$ls_newsgonggao,$content);
	$content = str_replace("{ls_newstieshi}",$ls_newstieshi,$content);
	$content = str_replace("{ls_homepro}",$ls_homepro,$content);
	$content = str_replace("{ls_languages}",$ls_languages,$content);
	$content = str_replace("{ls_designby}",$ls_designby,$content);
	$content = str_replace("{ls_cate}",$ls_cate,$content);
	$content = str_replace("{ls_foot}",$ls_foot,$content);
	
	$content = str_replace("{ls_copyright}",$copyright,$content);
	$content = str_replace("{ls_addprolink}",$ls_addprolink,$content);	//指向主菜单中的Products链接
	$content = str_replace("{ls_addnewprolink}",$ls_addnewprolink,$content);	//指向主菜单中的NewProducts链接
	$content = str_replace("{ls_classpro}",$ls_classpro,$content); //类别产品链接
	
	$content = str_replace("{ls_hotpro}",$ls_hotpro,$content); //热点产品链接
	$content = str_replace("{ls_revo}",$ls_revo,$content); //主题流动图片
	$content = str_replace("{ls_search}",ls_search(),$content); //搜索框
	$content = str_replace("{ls_allcatepics}",$ls_allcatepics,$content); //搜索框
	
	$content = str_replace("{ls_m_logo}",$ls_m_logo,$content); //logo
	$content = str_replace("{ls_m_title}",$mobi_companyName,$content); //手机网页标题
	$content = str_replace("{ls_m_keywords}",$mobi_siteKeywords,$content);
	$content = str_replace("{ls_m_description}",$mobi_siteDescription,$content);
	
	$content = str_replace("{ls_m_cate}",$p_m_cate,$content); //手机产品分类
	
	//首页二维码程序  start
	if($mainpartsubject=='index'){
			if(file_exists('code/png/2.png')){
				$code = '
						<script type="text/javascript">
							$(function(){
							$(window).scroll(function(){
							var scrollTop = document.body.scrollTop || document.documentElement.scrollTop || 0;
							$(".christmas_ad").stop();
							var scrollTop2 = (scrollTop+160) - $(".christmas_ad").position().top;
							$(".christmas_ad:not(:animated)").animate({top:"+="+scrollTop2+"px"},100);
							})
							}) 
							</script>
							<div class="christmas_ad" style="width:155px; height:220px; position:absolute; top:250px; right:0px;">
								<a href="javascript:void(0)" ><img src="ls_admin/code/png/2.png" style="border 1px red" /></a>
							</div>
							</body>
						';
			}else{
				$code = "</body>";
				}
		}
	//首页二维码程   end
	switch($mainpartsubject){
		case "index":
		
		$inf_sql="select * from ls_information where inMenu = 'notice' order by ID";
		$inf_query=$opendb->query($inf_sql);
		$inf_row=mysqli_fetch_array($inf_query);
		$ls_canonical=  $_SERVER['HTTP_HOST']; // 非80端口，会输出端口
		$ls_weburl1=$ls_canonical;
		
		$content = str_replace("{ls_allabout}",$mainpart,$content);
		$content = str_replace("{ls_notice}",$inf_row['content'],$content);
		$content = str_replace("{ls_video}",$ls_video,$content);
		$content = str_replace("{ls_indexKeywords}",$indexKeywords,$content);
		
		//首页工厂展示 Start {ls_workshop}
		$products_sql="select * from ls_workshop where enable=1 ";
		$products_sql.=" order by Num asc ";
		$products_query=$opendb->query($products_sql);
		$homework="";
		$i = 0;
		while($news_rows=mysqli_fetch_assoc($products_query)){
						  
			  include("_home_workshop.php"); //首页工厂 {ls_workshop}
			  
			$count++;
			$i++;
		}
		//首页工厂展示 End

		//首页证书展示 Start
		$products_sql="select * from ls_certificate where enable=1  order by Num desc limit 0, ". $homecertNum ;
		$products_query=$opendb->query($products_sql);
		$homecer="";
		$i = 0;
		while($news_rows=mysqli_fetch_assoc($products_query)){
			
			 include("_home_certificate.php");  //首页证书  {ls_certificate}
			 
			$count++;
			$i++;
		}
		//首页证书展示 End
		
		//首页包装展示 Start
		$products_sql="select * from ls_packing where enable=1 ";
		$products_sql.=" order by Num asc ";
		$products_query=$opendb->query($products_sql);
		$homepack="";
		$animation = array("bounceInLeft", "bounceInUp", "bounceInUp", "bounceInRight");
		$count2=0.4;
		$i = 0;
		while($news_rows=mysqli_fetch_assoc($products_query)){
			$count2 = $count2 + 0.2;
			
			include("_home_packing.php"); //首页包装 {ls_packing}
			
			$count++;
			$i++;
		}
		//首页包装展示 End

		$content = str_replace("{contact_tel}",$contact_array['contact_tel'],$content);
		$content = str_replace("{contact_email}",$contact_array['contact_email'],$content);
		$content = str_replace("{contact_qq}",$contact_array['contact_qq'],$content);
		$content = str_replace("{contact_fax}",$contact_array['contact_fax'],$content);
		$content = str_replace("{contact_skype}",$contact_array['contact_skype'],$content);
		$content = str_replace("{contact_http}",$contact_array['contact_http'],$content);
		$content = str_replace("{contact_name}",$contact_array['contact_name'],$content);
		$content = str_replace("{contact_address}",$contact_array['contact_address'],$content);
		$content = str_replace("{contact_companyname}",$contact_array['contact_companyname'],$content);
		
		$content = str_replace("{ls_workshop}",$homework,$content);
		$content = str_replace("{ls_certificate}",$homecer,$content);
		$content = str_replace("{ls_packing}",$homepack,$content);
		
		$content = str_replace("</body>",$code,$content);
		 
		include("_inc_allrepltags.php");
		$content = str_replace("{ls_s_cate}",$ls_s_cate,$content);
		$content = str_replace("{ls_d_cate}",$ls_d_cate,$content);
		$content = str_replace("{ls_p_cate}",$ls_p_cate,$content);
		$content = str_replace("{ls_f_cate}",get_pro_cate(0),$content);

		break;
		case "aboutus":
		include("_crumbs_article.php");
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_allabout}","<translate>".$mainpart."</translate>",$content);

		break;
		case "feedback": 
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['feedback']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_feedbackemail}",$ls_feedbackemail,$content);
		$content = str_replace("{ls_feedback}",$mainpart,$content);
		break;
		case "contactus":
		include("_crumbs_article.php");

		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_contact}",$mainpart,$content);
		
		$content = str_replace("{contact_tel}",$contact_array['contact_tel'],$content);
		$content = str_replace("{contact_email}",$contact_array['contact_email'],$content);
		$content = str_replace("{contact_qq}",$contact_array['contact_qq'],$content);
		$content = str_replace("{contact_fax}",$contact_array['contact_fax'],$content);
		$content = str_replace("{contact_skype}",$contact_array['contact_skype'],$content);
		$content = str_replace("{contact_http}",$contact_array['contact_http'],$content);
		$content = str_replace("{contact_name}",$contact_array['contact_name'],$content);
		$content = str_replace("{contact_address}",$contact_array['contact_address'],$content);
		$content = str_replace("{contact_companyname}",$contact_array['contact_companyname'],$content);
		
		break;
		// 文章列表页，核心内容
		case "article":
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\" style='text-transform : capitalize;'>".$ls_cate."</li>";
						  
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_downlist}","{ls_newslist}",$content); //替换download下载模版
		$content = str_replace("{ls_newslist}",$mainpart,$content);
		$content = str_replace("{articletag}",$articletag,$content);
		 
		break;
		
		// 新闻列表页，核心内容
		case "news":
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\" style='text-transform : capitalize;'>".$lan['news']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_newslist}",$mainpart,$content);
		$content = str_replace("{newstag}",$newstag,$content);
		 
		break;
		case "blog":
		$ls_links = $ls_foot;
		$ls_indicatebar = "<li><a href=\"../index.html\">".$lan['home']."</a></li>
                           <li class=\"active\" style='text-transform : capitalize;'>".$lan['blog']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_blogtag}",$newstag,$content);
		$content = str_replace("{ls_links}",$ls_links,$content);
		
		$linksblog_sql = "select * from ls_links where enable = 1 and cateName = 'Blog'";
		$linksblog_query = $opendb->query($linksblog_sql);
		while($linksblog_rows=mysqli_fetch_assoc($linksblog_query)){
			$linksblog_str .= "<li><a href ='".$linkblogs_rows['linkURL']."' target='_blank'>".$linksblog_rows['linkTitle']."</a></li>";
		}
		$ls_linkblog = $linksblog_str;
		$content = str_replace("{ls_linkblog}",$ls_linkblog,$content);
		
		$content = preg_replace("%<ls_blogcate>(.*?)</ls_blogcate>%si", get_blog_cate($index_path), $content);
		$content = preg_replace("%<ls_foreach>(.*?)</ls_foreach>%si", $mainpart, $content);
		//$content = str_replace("{ls_newslist}",$mainpart,$content);
		$content = str_replace("{newstag}",$newstag,$content);
		break;
		case "faq":
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['faq']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_newslist}",$mainpart,$content);
		$content = str_replace("{newstag}",$newstag,$content);

		break;
		case "prolist.html":
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['products']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_classpro}",$ls_classpro,$content);
		break;
		
		case "download": //生成下载
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['download']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_downlist}",$mainpart,$content);
		 
		break;
		
		case "management": //生成管理团队(Management)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);

		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['management']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "workshop": //生成车间图片(Workshop)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['workshop']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		if(strpos($filename,"workshop-")===false)		$content = str_replace("{ls_introduction}",$ls_introduction,$content); else $content = str_replace("{ls_introduction}","",$content);
		break;
		
		case "video": //生成视频 
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['video']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);

		break;
		
		case "qualitycontrol": //生成质量控制图片qualitycontrol)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['quality']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "rd": //生成研发(R&D)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['rd']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "certificate": //生成证书(Certificate)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['certificate']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "packing": //生成包装(Packing)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['packing']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "brand": //生成品牌(Brand)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['brand']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_list}",$mainpart,$content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);
		break;
		
		case "history": //生成品牌(history)
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['history']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = preg_replace("%<ls_foreach>(.*?)</ls_foreach>%si", $mainpart, $content);
		$content = str_replace("{ls_introduction}",$ls_introduction,$content);

		break;
		
		case "hotpro.html":  //生成热点产品页
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['hotpro']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_hotpro}",$ls_hotpro,$content);
		break;
		
		case "newpro.html":  //生成新产品页
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['newpro']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$content = str_replace("{ls_propage}",$ls_propage,$content);
		$content = str_replace("{ls_newpro}",$ls_newpro,$content);
		break;
		
		case "links.html":  //友情链接页
		$ls_lineno=__LINE__.(__FUNCTION__==""?"":"， 函数：".__FUNCTION__).(__CLASS__==""?"":"， 类：".__CLASS__);
		$ls_indicatebar = "<li><a href=\"index.html\">".$lan['home']."</a></li>
                           <li class=\"active\">".$lan['links']."</li>";
		$content = str_replace("{ls_indicatebar}",$ls_indicatebar,$content);
		$linkssql="select * from ls_links where enable=1 order by linkNum asc";
		$linksquery=$opendb->query($linkssql);
		$links_str = "";
		while($linksitem=mysqli_fetch_assoc($linksquery)){			
			$links_str .= "<a href ='".$linksitem['linkURL']."' target='_blank'>".$linksitem['linkTitle']."</a> &nbsp; &nbsp; ";
		}
		$ls_links=$links_str;
		$content = str_replace("{ls_url}",$ls_links,$content);
		break;
		
		default:
		include("inc/_inc_when_write_file.php");
	}
	$content = str_replace("{ls_links}",$ls_links,$content);
	$content = str_replace("{ls_weibo}",$ls_facebook_twitter,$content);
	
	
	if($mainpartsubject!="index")
	{
		$ls_weburl1=  $_SERVER['HTTP_HOST'].str_replace("..","",$filename); // 非80端口，会输出端, 后面 _inc_allrepltags
		$nybnstr=$mainpartsubject!="article"?$mainpartsubject:$nybnstr;
		include("_inc_allrepltags.php");
		$content = str_replace("{ls_s_cate}",$ls_s_cate,$content);
		$content = str_replace("{ls_d_cate}",$ls_d_cate,$content);
		$content = str_replace("{ls_p_cate}",$ls_p_cate,$content);
		$content = str_replace("{ls_f_cate}",get_pro_cate(0),$content);
	}

	if($translate != ''){
		//翻译代码
		$folder_name = $translate;
		$r_name = deep_in_array($folder_name, $translate_name);

		$translateFile = "../".$r_name['folder_name'];
		createFolder($translateFile);
		$transFile = str_replace("../", "", $filename);
		$content = str_replace("require_once('ls_admin", "require_once('../ls_admin", $content);
		$content = str_replace("require('ls_admin", "require('../ls_admin", $content);
		$content = str_replace("include('ls_admin/widget/sendmail_inc.php", "include('../ls_admin/widget/sendmail_inc_ml.php", $content);
		$content = str_replace("ls_admin/vplayer/cmpn.swf", $mutiLangDomianFlag."ls_admin/vplayer/cmpn.swf", $content);
		
		if( ifNeedTrans($translateFile."/".$transFile,$translate)||$_SESSION['transAll']==1){  //新闻等其他二级页（列表页，含手机）不存在和模拟翻译要生成，或者覆盖

			  if(translateApp($content, $translateFile."/".$transFile, $r_name['translate_name'])){
				  echo "创建 <a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a>成功！<a href=\"temp.php?ls=normal\">返回</a>";  if($ls_debug) echo " - - -  - - - - - -  - - - ".basename($_SERVER['PHP_SELF'])."  行号  ".__LINE__ ;
				  echo "<br><br>";
	  
			  }else{
				  if($ls_debug) echo "生成文件".$translateFile."/".$transFile."失败！<br>";
			  }
				}
		else
		{echo "<a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a> 已存在， ".($_SESSION['transAll']==0?" 未生成。</br>":" ");}

	
	}else{
		//英文网站去除<translate>标签
		$translate_str = $content;
		$p = "%<translate>(.*?)</translate>%si";    //正则表达式
		preg_match_all($p, $content, $arr);
		$temarr = $arr[1];
		
		$source="en";
		$targets = $target;
	
		foreach($temarr as $val){
			$content = str_replace("<translate>".$val."</translate>", $val, $content);
		}
		  
		$handle = fopen($filename,"w"); //打开文件指针，
			
		if (!is_writable ($filename))
		{ 
			if($ls_debug) echo "<script>alert('文件：".$filename."不可写，请检查其属性后重试！');history.go(-1);</script>";
		}
		 else
		{
			//$writeurl=$_SERVER['HTTP_HOST'].str_replace("..","",$filename);
			$writeurl=str_replace("..","",$filename);
			//$writeimportent=true;
			include("_inc_when_write_file.php");
			
			if (!fwrite ($handle,$content))
			{  //将信息写入文件
				if($ls_debug) echo "<script>alert('生成文件".$filename."失败！');history.go(-1);</script>";
			}
			else
			{
		
				$target = "target='_blank'";
		
				echo "创建 <a href='".$filename."' ".$target." >".$filename."</a>成功！<a href=\"temp.php?ls=normal\">返回</a>";
				if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
				echo "<br/><br/>";
			}
		}
 		fclose ($handle); //关闭指针

	}
	fclose($fp);	//关闭文件指针
}

/*
------------------------------------------------------
参数：
$querys   传递进入的查询结果
$srDirection 排序方向，目前本参数不起作用
程序功能：对传入的查询结果中的Num字段进行降序赋值。
注意：请不要随意调用本函数，本函数是为之后的排序函数缩减重复代码所设立。
------------------------------------------------------
*/

function SortRows($querys,$srDirection){
	$sortdb=new mydb();
	$totalRows=mysqli_num_rows($querys);
	while($queryRows=mysqli_fetch_assoc($querys)){
		$updateSql="update ls_products set Num=".$totalRows." where ID=".$queryRows['ID']." ";
		$updateQuery=$sortdb->query($updateSql);
		$totalRows--;
	}
}

/*
------------------------------------------------------
参数：
$spCate   排序产品所属的大类ID
$spMidCate 排序产品所属的中类ID
$spSubCate  排序产品所属的小类ID
$spKind  排序所采用的字段名称
$spDirection  排序方向
$ignore  是否开启整类排序功能
程序功能：对指定的类别中的产品进行批量排序。
注意：本函数中部分参数直接参与SQL语句的组装，直接键入参数时请注意格式是否正确。Products.php文件中的参数指定均为预先固定的，可参考。
------------------------------------------------------
*/
function SortPros($spCate,$spMidCate,$spSubCate,$spKind,$spDirection,$ignore,$onlyGrandCate){
	$sortdb=new mydb();
	if($spCate!="" && $spMidCate=="" && $spSubCate=="" )
	{
		$sortSql="select * from ls_products where productID=".$spCate." order by ".$spKind." ".$spDirection." ";
		//echo $sortSql;
		$sortQuery=$sortdb->query($sortSql);
		SortRows($sortQuery,$spDirection);
	}
	
	if($spCate!="" && $spMidCate!="" && $spSubCate=="" )
	{
		$sortSql="select * from ls_products where productID=".$spMidCate." order by ".$spKind." ".$spDirection." ";
		$sortQuery=$sortdb->query($sortSql);
		SortRows($sortQuery,$spDirection);
	}

	if($spCate!="" && $spMidCate!="" && $spSubCate!="" )
	{
		$sortSql="select * from ls_products where productID=".$spSubCate." order by ".$spKind." ".$spDirection." ";
		$sortQuery=$sortdb->query($sortSql);
		SortRows($sortQuery,$spDirection);
	}
	return true;
}
/*
------------------------------------------------------
参数：
程序功能：格式化输出变量内容。用于调试。
------------------------------------------------------
*/

function dump()
{
	$argAmount=func_num_args();
	if ($argAmount==0)
	{
		echo "<pre>";
		echo "Arguements can NOT be empty.";
		echo "</pre>";
	}
	else 
	{
		ob_start();
		echo "<pre>";
		for($i=0;$i<$argAmount;$i++)
		{
			echo "Arguement ".($i+1)."<br>";
			var_dump(func_get_arg($i));
			echo "<br>";
		}
		echo "</pre>";
		$output=ob_get_clean();
		$output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
		echo $output;
	}
}

/*
------------------------------------------------------
参数：
程序功能：对类别进行扫描，并对有错误的类别进行纠正。
------------------------------------------------------
*/

function scancates()
{
	$opdb=new mydb();
	$startsql="select ID from ls_products where cateName is not null order by Num asc, ID asc";
	$startq=$opdb->query($startsql);
	$sentryi=1;
	while($gcate=mysqli_fetch_assoc($startq))
	{
		repairseq($gcate['ID'],$sentryi);
		$secondsql="select ID from ls_products where midcateName is not null and midcateID='{$gcate['ID']}' order by Num asc, ID asc";
		$secondq=$opdb->query($secondsql);
		$sentryj=1;
		while($mcate=mysqli_fetch_assoc($secondq))
		{
			repairseq($mcate['ID'],$sentryj);
			$thirdsql="select ID from ls_products where subcateID is not null and subcateID={$mcate['ID']} order by Num asc, ID asc";
			$thirdq=$opdb->query($thirdsql);
			$sentryk=1;
			while($scate=mysqli_fetch_assoc($thirdq))
			{
				repairseq($scate['ID'],$sentryk);
				$sentryk++;
			}
			$sentryj++;
		}
		$sentryi++;
	}
}

/*
------------------------------------------------------
参数：	$opid		要操作的记录ID
		$opnum		设定的数值
返回值：无
程序功能：重新将指定ID的Num字段赋值，此为复杂功能拆解模块，请勿直接调用
------------------------------------------------------
*/

function repairseq($opid,$opnum)
{
	$opdb=new mydb();
	$resetsql="update ls_products set Num={$opnum} where ID={$opid}";
	$resetq=$opdb->query($resetsql);
}

/*
------------------------------------------------------
参数：	$opid		查询产品ID
返回值：布尔值
程序功能：查询与产品是否有同级别的类别，有返回真，无返回假。
------------------------------------------------------
*/

function hassameclass($opid)
{
	$opdb=new mydb();
	$checksql="select * from ls_products where midcateID='{$opid}' or subcateID={$opid}";
	$checkq=$opdb->query($checksql);
	if(mysqli_num_rows($checkq)!=0){
		return true;
	}else{
		return false;
	}
}


//文章详页  跳转方向(值:'B'下一条,'F'上一条) $direction 方向 $db 数据库名 $functionName 大类 $cate 小类 $filename 文件名 $str_list 类别ID $catebool 是否跨小类, $catePreNxt 类别条件串
function circleNavigationLinkNews($ID,$direction,$tag,$content,$db,$catePreNxt,$fileName,$suffix_str,$catebool){
	$opdb=new mydb();
	//Get product information
	require('inc/constant.php');
	$lan = array();
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	$opdb=new mydb();
	//Get product information
	$productInfoSql="select * from $db where ID={$ID}";
	$productInfoR=$opdb->query($productInfoSql);
	$productInfo=mysqli_fetch_object($productInfoR);
	if($db=="ls_article") $addstr=" ".$catePreNxt." and "; else $addstr=$catebool?" cate='".$catePreNxt."' and ":" "; //11-25
	//Get Max and Min Num value
	if($catebool){
		$numLimitSql="select min(Num) as minNum, max(Num) as maxNum from $db where ".$addstr." enable ='1'";
	}else{
		$numLimitSql="select min(Num) as minNum, max(Num) as maxNum from $db where ".$addstr." enable ='1'";
	}
	$numLimitR=$opdb->query($numLimitSql);
	$numLimit=mysqli_fetch_object($numLimitR);
	//According to $direction, search the next product
	if(($productInfo->Num==$numLimit->minNum)&&('B'==strtoupper($direction))){
		$linkProductNum=$numLimit->maxNum;
	}else if(($productInfo->Num==$numLimit->maxNum)&&('F'==strtoupper($direction))){
		$linkProductNum=$numLimit->minNum;
	}else{
		$searchCount=0;
		do{
			$searchCount++;
			$linkProductNum=('B'==strtoupper($direction))?($productInfo->Num-$searchCount):($productInfo->Num+$searchCount);
			if($db=="ls_article") $addstr=" ".$catePreNxt." and "; else $addstr=$catebool?" cate='".$catePreNxt."' and ":" "; //11-25
			if($catebool){
				$checkSql="select * from $db where ".$addstr." enable ='1' and Num={$linkProductNum}";
			}else{
				$checkSql="select * from $db where ".$addstr." Num={$linkProductNum}";
			}
			$checkR=$opdb->query($checkSql);
			$targetProduct=mysqli_fetch_object($checkR);
			if(mysqli_num_rows($checkR) != 0){
				if($catebool){
					$targetProductFile=$fileName.$suffix_str.$targetProduct->ID.".html";
					$targetProductLink="<a href=\"{$targetProductFile}\">".(('F'==strtoupper($direction))?$lan['previous']:$lan['next'])."</a>";
				}else{
					$targetProductFile=$fileName.$targetProduct->ID.".html";
					$targetProductLink="<a href=\"{$targetProductFile}\">".(('F'==strtoupper($direction))?$lan['previous']:$lan['next'])."</a>";
				}
			}
		}while(0==mysqli_num_rows($checkR));
	}
	//Get target product information and return the ready content
	return str_replace($tag,$targetProductLink,$content);
}

/*
//生成新闻、证书、工厂、品牌、质量等详细页
//参数为查询出的一条记录
//在article中 $suffix_str2 是$index_newspath
*/
function writeShowPages($news_rows, $suffix_str2, $cateName, $s_table, $menu_pro, $pro_cate, $s_pro_cate, $s_m2_cate, $ls_propage, $facebook_twitter, $s_site_cate, $foot, $ls_addprolink, $ls_addnewprolink, $ls_h_news, $s_p_cate, $ls_languages, $get_pro_cate, $indicatebarpath, $translate, $d_pro_cate){
	global $nybnstr,$newsshowtypeurl;
	require_once('conn.php');
	$opendb=new mydb();
	require_once('char_set.php');
	require('constant.php');
	require('switchShowPage.php');
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$row=mysqli_fetch_array($tem_query);

	$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-INSTAGRAM",$row['google'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
	$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
	//$facebook_twitter = str_replace("../","",$facebook_twitter);
	
	$code_sql="select * from ls_functioncode where enable=1 order by ID";	
	$opendb=new mydb();
	$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;
		}
	}
	
	$newstag=$cate==""?trim($news_rows['functionName']):$cate;
	$newstitle=$news_rows[$s_title];   //不翻译代码
	$clickTotal=$news_rows['ID']; //浏览量  新闻id 
	$newstext=$news_rows[$s_text];
	$newsmatealt=($news_rows['matealt']==""?$newstitle:$news_rows['matealt']);

	include("_show_detail.php"); // show 详细 {ls_newimg}  : $newimg   {ls_newstext} : $newsdetail 
	$ls_newstime = $news_rows[$s_newstime];
	$ls_newid = $news_rows['ID'];
	$ls_click_n = $news_rows[$s_click];
	createFolder("../".$newsshowFolders);

	$ls_title = (trim($row['MSN4'])!="" && strpos($ls_title ,$row['MSN4']) || strpos($ls_title ," - ")) ? $ls_title : $ls_title ." - ". $row['companyNameCn'] ;  //没 品牌加公司名
 
	$ls_cate=$pro_cate;
	$ls_s_cate=$s_pro_cate;								//左侧产品类别;
	$ls_d_cate=$d_pro_cate;								//左侧产品类别;
	$ls_s_news = $ls_h_news;
	$ls_p_cate=$s_p_cate;								//左侧产品类别;
	$ls_f_cate=$get_pro_cate;
	$ls_motif=$s_m2_cate;
	$ls_menu=$menu_pro;									//主菜单
	$ls_newstitle=$newstitle ;							//新闻标题
	$ls_clickTotal=$clickTotal;//浏览量  新闻id
	$ls_newimg=$newimg;
	$ls_newsdetail = $newsdetail;
	$ls_newstext=$newstext;
	if($s_table=="video")$ls_newstext=$s_m2_cate."<br/>".$newstext; //视频
	$ls_url="../";										//链接		
	$ls_foot=$foot;										//底部信息
	
	if($suffix_str2!=""||$suffix_str2=="_dongtai" || $suffix_str2=="_gonggao" || $suffix_str2=="_tieshi" )
	{ $index_newspath="../".$templates_var."/newsshow".$suffix_str2.".html";	}
	else
	{
		$index_newspath="../".$templates_var."/".$cateName."show.html";		//模板地址
	}	
	if($s_table=="article"){
		$index_newspath=$suffix_str2;
	}
	if($s_table=="video"){
		$index_newspath="../".$templates_var."/".$suffix_str2."show.html";;
	}
	if($s_show=="news"){ 
		$index_newspath=  file_exists($newsshowtypeurl)?$newsshowtypeurl:"../".$templates_var."/newsshow.html"; 
		$s_fileName=$suffix_str2; $s_show="";  
	} //news分类 不加 news
	
	$filename="../".$showFolders."/".$s_show.$s_fileName.$news_rows['ID'].".html";
	 
	if (!is_dir("../".$showFolders)) crmkdir("../".$showFolders);
	
	$fp	   = fopen ($index_newspath,"r");
	 
	$newscontent = fread ($fp,filesize ($index_newspath));
	 
	$newscontent = str_replace("{ls_statistics}",$statistics,$newscontent); //统计代码
	$newscontent = str_replace("{ls_onlines}",$onlines,$newscontent);  //在线联系(QQ)
	$newscontent = str_replace("{ls_maps}",$maps,$newscontent);  //地图代码
	$newscontent = str_replace("{ls_share}",$share,$newscontent);  //分享代码
	$newscontent = str_replace("{ls_onlinechart}",$onlinechart,$newscontent);  //在线联系
	$newscontent = str_replace("{ls_shield}",$shield,$newscontent);  //首页屏蔽
	
	$newscontent = str_replace("{ls_title}",$ls_title,$newscontent);
	
	$newscontent = str_replace("{ls_keywords}",$ls_keywords,$newscontent);
	$newscontent = str_replace("{ls_description}",$ls_description,$newscontent);
	$newscontent = str_replace("{ls_menu}",$ls_menu,$newscontent);
	$newscontent = str_replace("{ls_languages}",$ls_languages,$newscontent);
	$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
	$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
	$newscontent = str_replace("{ls_copyright}",$row['copyright'],$newscontent);
	
	$ls_facebook_twitter = $facebook_twitter;
	$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
	$ls_facebook_twitter_share = $facebook_twitter_share;
	$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
	
	include("_crumbs_article.php");  //面包屑导航
	
	$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$newscontent);
	
	$newscontent = str_replace("{ls_news}",$ls_s_news,$newscontent);
	
	$newscontent = str_replace("{ls_newstime}",$ls_newstime,$newscontent);
	$newscontent = str_replace("{ls_newid}",$ls_newid,$newscontent);
	$newscontent = str_replace("{ls_click_n}",$ls_click_n,$newscontent);
	$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
	$newscontent = str_replace("{ls_clickTotal}",$ls_clickTotal,$newscontent);//浏览量
	$newscontent = str_replace("{ls_shield}",'',$newscontent);
	 
	$newscontent = str_replace("{ls_newimg}",$ls_newimg,$newscontent);
	
	$newscontent = str_replace("{ls_newsdetail}",$ls_newsdetail,$newscontent);
	$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
	$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻 
	$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);   //new
	$newscontent = str_replace("{ls_newsall}",$ls_newsall2,$newscontent);
	$newscontent = str_replace("{ls_newstieshi}",$ls_newstieshi2,$newscontent);
	$newscontent = str_replace("{ls_site_cate}",$s_site_cate,$newscontent);
	$newscontent = str_replace("{ls_url}",$ls_url,$newscontent);
	$newscontent = str_replace("{ls_foot}",$ls_foot,$newscontent);
	$newscontent = str_replace("{ls_addprolink}",$ls_addprolink,$newscontent);	//指向主菜单中的Products链接
	$newscontent = str_replace("{ls_addnewprolink}",$ls_addnewprolink,$newscontent);	//指向主菜单中的NewProducts链接
	//if($s_show=="news")$s_fileName=$suffix_str2;
	
	//$filename="../".$showFolders."/".$s_show.$s_fileName.$news_rows['ID'].".html";
	//if (!is_dir("../".$showFolders)) crmkdir("../".$showFolders);

	$content=$newscontent;
	$nybnstr= $nybnstr!=""?$nybnstr:$s_table;
	$ls_weburl1=  $_SERVER['HTTP_HOST'].str_replace("..","",$filename); // 非80端口，会输出端口
	$ls_srcset=srcsetpic( $BigFoldersProducts."/".$news_rows[$workshopPic],$showFolders."/"); //分级处理图片
	include("_inc_allrepltags.php"); 
	$newscontent=$content;

	//var_dump($news_rows);
	$newscontent = str_replace("{ls_cate}",$ls_cate,$newscontent);
	$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
	$newscontent = str_replace("{ls_d_cate}",$ls_d_cate,$newscontent);
	$newscontent = str_replace("{ls_p_cate}",$ls_p_cate,$newscontent);
	$newscontent = str_replace("{ls_f_cate}",$ls_f_cate,$newscontent);
		
	if(strtolower($cateName) == "news" || strtolower($cateName) == "faq"  || strtolower($cateName) == "faqs"){
		$booleam = true;
	}else{
		$booleam = false;
	}
	$arcate=$news_rows['cateName'];
	$arfunc=$news_rows['functionName'];
	if($s_table=="article"){$cate=$arcate==""?" functionName='".$arfunc."' ":" cateName='".$arcate."' ";} //类别 11-25
	
	$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_".$s_table,$cate,$s_show,$suffix_str2,$booleam);
	$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_".$s_table,$cate,$s_show,$suffix_str2,$booleam);
			
	createFolder("../".$showFolders);
	if($translate != ''){
		//翻译代码
		$folder_name = $translate;
		$r_name = deep_in_array($folder_name, $translate_name);

		$translateFile = "../".$r_name['folder_name'];
		createFolder($translateFile);
		createFolder("../".$r_name['folder_name']."/".$showFolders);
		$transFile = str_replace("../", "", $filename);
		
		if( ifNeedTrans($translateFile."/".$transFile,$translate)||$_SESSION['transAll']==1){  //新闻等其他三级页（详细页，不含手机）不存在和模拟翻译要生成，或者覆盖

			  if(translateApp($newscontent, $translateFile."/".$transFile, $r_name['translate_name'])){
				  echo "创建<a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a>成功！<a href=\"temp.php?ls=normal\">返回</a>";
				  if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
	  
				  echo "<br/><br/>";
			  }else{
				  if($ls_debug) echo "'生成文件".$translateFile."/".$transFile."失败！<br>";
			  }
			}
		else
		{echo "<a href='".$translateFile."/".$transFile."' target='_blank'>".$translateFile."/".$transFile."</a> 已存在， ".($_SESSION['transAll']==0?" 未生成。</br>":" ");}
	
	}else{
		if (is_file ($filename)){ 
			 @unlink ($filename); //若文件已存在，则删除
		}
		//英文网站去除<translate>标签
		$translate_str = $newscontent;
		$p = "%<translate>(.*?)</translate>%si";    //正则表达式
		preg_match_all($p, $newscontent, $arr);
		$temarr = $arr[1];
		
		$source="en";
		$targets = $target;
	
		foreach($temarr as $val){
			$newscontent = str_replace("<translate>".$val."</translate>", $val, $newscontent);
		}
	   $handle   = fopen ($filename,"w"); //打开文件指针，
			/*
			检查文件是否被创建且可写
			 */
		if (!is_writable ($filename)){ 
			if($ls_debug) echo "<script>alert('文件：".$filename."不可写，请检查其属性后重试！');history.go(-1);</script>";
		}
		else
		{
			//$writeurl=$_SERVER['HTTP_HOST'].str_replace("..","",$filename);
			$writeurl=str_replace("..","",$filename);
			//$writeimportent=true;
			$content=$newscontent;
			include("_inc_when_write_file.php");
			$newscontent=$content;
			if($newscontent=="") {echo $news_rows['ID']."、".$news_rows[$s_title]." newscontent没有内容，可能模板没有，详细页没生成。<br/>";return;} //一般是模板文件错了，没内容"<br>-".$news_rows[$s_text].
			if (!fwrite ($handle,$newscontent)){  //将信息写入文件
				if($ls_debug) echo "'生成文件".$filename."失败！<br>";
			 } 
			 else
			 {
				 echo "创建<a href='".$filename."'  target='_blank'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\">返回</a>";
				 if($ls_debug) echo " - - -  - - - ".basename($_SERVER['PHP_SELF'])." ， 行号： ".($ls_lineno==""?__LINE__:$ls_lineno) ;
				 echo "<br/><br/>";
			 }
		}
	 	fclose ($handle); //关闭指针
	}
	 
	fclose ($fp);
}


/*
创建search标签函数
返回标签变量$ls_search
参数 路径 $url
*/
function ls_search($url="")
{
	global $specNames;
    $specificationName=explode(',',$specNames);
	
	$ls_search="<form action='".$url."search.php' name='searchFrom' method='post'>\r\n
            	<input type='hidden' value='allProducts' name='keywords' />\r\n
            	<input type='hidden' value='productName' name='searchItem' />\r\n
			<input type='text' class='inp_srh'  value='Keywords' onclick=\"this.value=''\"  onblur='document.searchFrom.keywords.value=this.value'   />\r\n";
               if(count($specificationName)>0)  //如果有参数，则有下拉参数搜索
			  	{
          		$ls_search.="<select   class='inp_srh_list' name='selectSearchItem' onchange='document.searchFrom.searchItem.value=this.value'  >\r\n
			  	<option value='productName'  'selected'>Name</option>\r\n";
                   
					for($i=0;$i<(count($specificationName));$i++)  //循环处理变量处理 变量名
					{	
					
                    $ls_search.=" <option value='".$specificationName[$i]."'   >".str_replace('Number','No.',str_replace('number','No.',$specificationName[$i]))."</option>\r\n";
                 	 }
			 
					$ls_search.="</select>\r\n";
				 }
            $ls_search.=" <input  class='btn_srh' type='submit'    id='button'   />\r\n
</form>\r\n";

return($ls_search);	
}



/*返回文件扩展名*/

function get_extension ($pic){
	$pics = explode('.' , $pic); 
	$num = count($pics); 
	return strtolower($pics[$num-1]); 
}

function getSubstr($str, $leftStr, $rightStr)
{
 $left = strpos($str, $leftStr);
 //echo '左边:'.$left;
 $right = strpos($str, $rightStr,$left);
 //echo '<br>右边:'.$right;
 if($left < 0 or $right < $left) return '';
 return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr)-1);
}

//得到博客分类列表函数
function get_blog_cate($blog_file){
	
	$opendb=new mydb();
	require('char_set.php');
	require('constant.php');
	
	$news_cate_sql2="select * from `ls_functioncates` where functionName='博客分类' and enable=1 order by Num asc ";

	$result_cate=$opendb->query($news_cate_sql2);
	$num_cate=mysqli_num_rows($result_cate);
	$i_news=1;
	
	$blog_path = $blog_file;
	
	$fp	= fopen ($blog_path,"r");
	$blogcontent = fread ($fp,filesize ($blog_path));
	//$blogcontent = str_replace("../","",$blogcontent);
	$bcate = $blogcontent;
	$sort='';
	
	$p = "%<ls_blogcate>(.*?)</ls_blogcate>%si";    //正则表达式
	preg_match_all($p, $bcate, $arr);
	$blogcatearr = $arr[1];
	foreach($blogcatearr as $val){
		$blog22 = "";
		$result_cate2=$opendb->query($news_cate_sql2);
		while($catenews = mysqli_fetch_assoc($result_cate2))
		{
			$news_sql2="select * from ls_news where enable=1 and cate='".$catenews['cateName']."' order by Num desc ";
			$suffix_str2=$catenews['suffStr'];
			
			$cate_val = str_replace("{ls_blogtag}",$catenews['cateName'],$val);
			$cate_val = str_replace("{ls_blogmore}","blog".$catenews['suffStr'].".html",$cate_val);
			$p2 = "%<ls_foreach>(.*?)</ls_foreach>%si";    //正则表达式
			preg_match_all($p2, $cate_val, $arr);
			$blogarr = $arr[1][0];

			$blogindex = "";
			
			$news_sql=$news_sql2;
				
			$news_query=$opendb->query($news_sql);
			$blog_i = 0;
			while($news_rows=mysqli_fetch_assoc($news_query))
			{
				$blog_i++;
				if(strpos($news_rows['newsText'],'<img') !== false){
					
					$newsImgStr=getStrbyTag("<img ","/>",$news_rows['newsText']);
					$imgHeight=getStrbyTag('height="','" ',$newsImgStr,false);
					$imgWidth=getStrbyTag('width="','" ',$newsImgStr,false);
					$newsImg=getStrbyTag('src="','" ',$newsImgStr);
					$srcImg = getSubstr($newsImg,"src=\"",'"');
					$srcImg = strtolower(getSubstr($newsImg,'src="','"'));  //变小写，清除 src= " 等
					$imgurl = $srcImg;
					$srcImg = str_replace('src=','',$srcImg);
					$srcImg = str_replace('"','',$srcImg);

					$proportion = " width='600' height='370' ";
					$blogimg = $proportion.$newsImg;
				}else{
					$blogimg="src=\"../ls_admin/images/blog.jpg\"";
				}
	
				$blogimg = "<a href=\"blog".$suffix_str2.$news_rows['ID'].".html\"><img ".$blogimg." /></a>";
				$blogtime = date('m-d-y',strtotime($news_rows['newsDate']));
				$blogtitle = "<a href=\"blog".$suffix_str2.$news_rows['ID'].".html\">".$news_rows['newsTitle']."</a>";
				$blogtext = $news_rows['newsTitle'];
				

				$blogindexstr = "";
				
				if($blog_i <= $blog_index_num){
					$blogindexstr = str_replace("{ls_blogimg}",$blogimg,$blogarr);
					$blogindexstr = str_replace("{ls_blogtime}",$blogtime,$blogindexstr);
					$blogindexstr = str_replace("{ls_blogtitle}",$blogtitle,$blogindexstr);
					$blogindexstr = str_replace("{ls_blogtext}",$blogtext,$blogindexstr);
					
					$blogindex .= $blogindexstr;
				}
			}
			$blog123 = str_replace("<ls_foreach>".$blogarr."</ls_foreach>", $blogindex, $cate_val);
			$blog22 .= $blog123;
	  	}
	  	//$blogcontent = str_replace("<ls_blogcate>".$val."</ls_blogcate>", $blog22, $blogcontent);
		$blogcontent = $blog22;
	}
	return $blogcontent;
}

//返回大类名称以及对应大类链接，如大类下有小类链接到大类下第一个小类上
function get_pro_cate($id){
	$opendb=new mydb();
	require('char_set.php');
	require('constant.php');
	$p_cate_sql="select * from ls_products where midcateName is null and subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 order by Num asc";
	$p_cate_query=$opendb->query($p_cate_sql);
	//$s_p_cate="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
	$p_num=mysqli_num_rows($p_cate_query);
	
	$s_p_cate="";
	$x = $p_num;
	$y = 0;
	while($p_cate_rows=mysqli_fetch_assoc($p_cate_query))
	{
	  $y++;
	  $p_midcate_sql="select * from ls_products where cateName is null and subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 and midcateID=".$p_cate_rows['ID']." order by Num asc";
	  $p_midcate_query=$opendb->query($p_midcate_sql);
	  $p_midcate_num=mysqli_num_rows($p_midcate_query);
	  $rows2=mysqli_fetch_assoc($p_midcate_query);
	  
	  if($p_midcate_num==0)//大类
	  {

		  $s_p_cate.="<li><a href='../".$p_cate_rows['cateFolders']."/".$p_cate_rows['cateFolders'].".html'> ".$p_cate_rows['cateName']."</a></li>";
		// $s_p_cate.="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
	  } 
	  else//大类中类
	  {
		//$s_p_cate.="&nbsp;<img src='../Templates/".$templates_var."/images/cate.gif' border='0'> \n";  //大类引导图
		$detailsfile="../".$p_cate_rows['cateFolders']."/".$p_cate_rows['cateFolders'].".html";
		$detailsfile2="../".$templates_var."1/catedetail.html";
		if(file_exists($detailsfile2))
		{$s_p_cate.="\n<li><a href='".$detailsfile."'> ".$p_cate_rows['cateName']."</a><ul>";}
		else
		{
			$s_p_cate.="\n<li><a href='../".$p_cate_rows['cateFolders']."/".$rows2['midcateFolders']."/".$rows2['midcateFolders'].".html' onclick=\"turnit(".$p_cate_rows['ID'].",".$p_cate_rows['ID'].");this.href=this.href+'?menuId='+".$p_cate_rows['ID']."+'&cate='+".$p_cate_rows['ID'].";\" > ".$p_cate_rows['cateName']."</a></li>";
		}
	  }//if($p_midcate_num==0)//dalei
	
	}
	$s_p_cate.="";
	//echo $s_p_cate;
	$s_p1_cate=str_replace("../","",$s_p_cate);//cate
	$s_p2_cate=str_replace("../","../",$s_p_cate);//pro2_cate
	$s_p3_cate=str_replace("../","../../",$s_p_cate);//pro3_cate
	$s_p4_cate=str_replace("../","../../../",$s_p_cate);//pro4_cate
	if($id == 0){
		return $s_p1_cate;
	}elseif($id == 1){
		return $s_p_cate;
	}elseif($id == 2){
		return $s_p2_cate;
	}elseif($id == 3){
		return $s_p3_cate;
	}elseif($id == 4){
		return $s_p4_cate;
	}

}

// get_catepics 首页多类产品列表，每类一行图片
function get_allcatepics()
{
		require_once('inc/conn.php');
		$opendb=new mydb();
			$s_catepics="";
		$catepics_sql="select * from ls_products where branchID=0 and midcateName is null and subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 order by Num asc";
		$catepics_query=$opendb->query($catepics_sql);
		//$s_catepics="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		$s_catepics.="<ul class=\"catepics_list\">";
		while($catepics_rows=mysqli_fetch_assoc($catepics_query))
		{
		  $pro_midcate_sql="select * from ls_products where branchID=0 and cateName is null and subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 and midcateID=".$catepics_rows['ID']." order by Num asc";
		  $pro_midcate_query=$opendb->query($pro_midcate_sql);
		  $pro_midcate_num=mysqli_num_rows($pro_midcate_query);
	  
		  if($pro_midcate_num==0)//大类
		  {
			if($catepics_rows['ID']=="")continue; //没有跳过循环
			$s_catepics.=get_product_cate_pics($catepics_rows['ID'],$catepics_rows['cateFolders']).$catepics_rows['cateName'];
		  } 
		  else//大类中类
		  {
			//$s_catepics.="&nbsp;<img src='../Templates/".$templates_var."/images/cate.gif' border='0'> \n";  //大类引导图
			$detailsfile="../".$catepics_rows['cateFolders']."/index.html"; //indexdetails.html
			if(file_exists($detailsfile))
			{$s_catepics.=" <dt><a href='".$detailsfile."'>".$catepics_rows['cateName']."</a></dt>\r\n";}
			else
			{
				//$s_catepics.="<li id=\"catepics_list_li_title\"> <strong>".$catepics_rows['cateName']."</strong></li> \r\n";	
			}

		
			while($pro_midcate_rows=mysqli_fetch_assoc($pro_midcate_query))
			{
				$pro_subcate_sql="select * from ls_products where branchID=0 and midcateName is null and cateName is null and cateFolders is null and catePagePic is null and catePagePicWidth is null and catePagePicHeight is null and cateBrief is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 and subcateID=".$pro_midcate_rows['ID']." order by Num asc";
				$pro_subcate_query=$opendb->query($pro_subcate_sql);
				$pro_subcate_num=mysqli_num_rows($pro_subcate_query); 

				//$s_catepics.="<div class=\"midcate_list\">"; //中类菜单样式
	
				if($pro_subcate_num==0)//没小类
				{
					if($pro_midcate_rows['ID']=="")continue; //没有跳过循环
					$s_catepics.=get_product_cate_pics($pro_midcate_rows['ID'],$catepics_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']).$pro_midcate_rows['midcateName']; //$catepics_rows['cateName'].$pro_midcate_rows['midcateName']
				}
				else//有小类
				{
					//$s_catepics.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n"; //中类引导图
					$detailsfile="../".$catepics_rows['cateFolders']."/".$pro_midcate_rows['midcateName']."/index.html"; //indexdetails.html
					if(file_exists($detailsfile))
					{$s_catepics.="<a href='".$detailsfile."'>".$pro_midcate_rows['midcateName']."</a>\r\n";}
					else
					{
						//$s_catepics.="<li id=\"catepics_list_li_title\">  <strong>".$pro_midcate_rows['midcateName']."</strong></li> \r\n";			
					}
					//$s_catepics.="<div class=\"subcate_list\">";//小类菜单样式
					while($pro_subcate_rows=mysqli_fetch_assoc($pro_subcate_query))		//小类生成
					{
						if($pro_subcate_rows['ID']=="")continue; //没有跳过循环
						$s_catepics.=get_product_cate_pics($pro_subcate_rows['ID'],$catepics_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/".$pro_subcate_rows['subcateFolders']).$pro_subcate_rows['subcateName']; //$catepics_rows['cateName'].$pro_midcate_rows['midcateName'].$pro_subcate_rows['subcateName']
					}
					$s_catepics.=" \n\r\n"; 
				} 
			} //while($pro_midcate_rows=mysqli_fetch_assoc($pro_midcate_query))
			$s_catepics.="  \r\n";
		  }//if($pro_midcate_num==0)//大类
		}
	$s_catepics.="</ul>\r\n ";
	$allcatepics=str_replace("../","",$s_catepics);//cate

	//$allcatepics=$s_catepics;
	return $allcatepics;
}

/*
------------------------------------------------------
参数：
$tagVar  //英文tag变量
$enTag   //标签
$TIFd  //表名原表DI字段变量
$_SESSION['addtranschange'] 统计变量
返回： tagVar语种翻译
程序功能：将某文件标签tag 替换成 字符串内容
------------------------------------------------------
*/

function ifchangetrans($id,$enTag,$changetable,$lang,$langVar)
{
	/* 记录多语种需要更新内容 seo TKD， */
		require_once('inc/conn.php');

		$opendb=new mydb();
		require('char_set.php');


		$products_sql="select * from ls_transchange where TIFd='".$changetable.$id."' and enTag='".$enTag."' ";
		$products_query=$opendb->query($products_sql);
		$products_num=mysqli_num_rows($products_query);
		if($products_num==0){
			$products_sql="INSERT INTO `ls_transchange` (`TIFd`, `enTag`, `ifTrans`,   `".$lang."`) 
                 VALUES ('".$changetable.$id."','".$enTag."',  1 , '".$langVar."'); ";		
			$products_query=$opendb->query($products_sql);
		}
		else
		{
			$products_sql="update ls_transchange set 	ifTrans=1, 	".$lang."='".$langVar."' where TIFd='".$changetable.$id."' and 	enTag='".$enTag."'   ";
			$products_query=$opendb->query($products_sql);

		}

	 
}
/*
------------------------------------------------------
参数：
$tagVar  //英文tag变量
$enTag   //标签
$TIFd  //表名原表DI字段变量
$_SESSION['addtranschange'] 统计变量
返回： tagVar语种翻译
程序功能：将某文件标签tag 替换成 字符串内容
------------------------------------------------------
*/
function tagTrans($tagVar,$enTag,$TIFd="")
{
	if($tagVar=="") return $tagVar;
	$hashlen=300; //超过300 记录hansh md4
	$hashstr=hash("MD4", $tagVar);
	$opendb=new mydb();
	require('char_set.php');
	require('constant.php');
	$tagTrans_sql="SELECT * FROM `ls_transchange` WHERE `enTag`='".$enTag."'  and `hashstr`='".$hashstr."' ";
	$tagTrans_query=$opendb->query($tagTrans_sql);
	$tagTrans_num=mysqli_num_rows($tagTrans_query);
	$tagVar=htmlspecialchars($tagVar, ENT_QUOTES) ;
	if($tagTrans_num==1)
	{
		return $tagVar; ;
	}
	else
	{
		$tagTrans_sql="SELECT * FROM `ls_transchange` WHERE `enTag`='".$enTag."'  and `TIFd`='".$TIFd."'  and `hashstr`!='".$hashstr."' ";
		$tagTrans_query=$opendb->query($tagTrans_sql);
		$tagTrans_num=mysqli_num_rows($tagTrans_query);
	 
	 if($tagTrans_num==1)
		{
		 
			$trans_sql="update ls_transchange  set   tagVar ='".$tagVar."',hashstr ='".$hashstr."', ifenTag =1 where TIFd='".$TIFd."' and `enTag`='".$enTag."' and `date`='".date("Y-m-d H:i:s")."'   ";
			
			$trans_query=$opendb->query($trans_sql); //增加、更新新的语种
			if($trans_query) $transResult=true;
			 $_SESSION['addtranschange']+=1;  //增加transchange条数
		} 
		else
		{
			$trans_sql="insert into ls_transchange   (enTag, tagVar ,TIFd,hashstr,date ) value ('".$enTag."','".$tagVar."','".$TIFd."','".$hashstr."','". date("Y-m-d H:i:s")."'   ) ";
			$trans_query=$opendb->query($trans_sql); //增加翻译结果
			if($trans_query) $transResult=true;
		
		}  
	}
	 
	return $tagVar;

}

function ifNeedTrans($filename,$translate,$gallaryPage=false)
{
	$ifTrans=1; //1 代表需要翻译，需要覆盖
	If(file_exists($filename))
	{
		$fp = fopen ($filename,"r");
		$content = fread ($fp,filesize ($filename));  //
		$simuFlag="<font color='#F00'>".$translate."</font>"; //模拟翻译标志
		//if(strpos($content,$simuFlag)===false) $ifTrans=0;
		if(filesize ($filename)>1) $ifTrans=0;  //模拟翻译不覆盖
		
	}
	else
	{	
		if($gallaryPage)$_SESSION['lastBlankFile']=$filename;  //记录上一个为空的相册页文件，为产品相册页2次写入
	}
	return $ifTrans;	
}

// 翻译整篇并写入文件
function translateApp($newscontent,$filename,$target="zh-CN"){
	require_once("simple_html_dom.php"); //加载simple_html_dom.php文件
	global $count_num,$translate_key,$simuTransLow,$mutiLangDomianFlag,$translate_name,$sleepSecond, $delayTrigSecond,$delayTrigByte,$delayTrigTimes,$transSplitLen;  //constant
  
	$api_key =$translate_key ;

	$newscontent = str_replace("src=\"../../../", "src=\"", $newscontent);
	$newscontent = str_replace("src='../../../", "src='", $newscontent);
	$newscontent = str_replace("src=\"../../", "src=\"", $newscontent);
	$newscontent = str_replace("src='../../", "src='", $newscontent);
	$newscontent = str_replace("src=\"../", "src=\"", $newscontent);
	$newscontent = str_replace("src='../", "src='", $newscontent);
	$newscontent = str_replace("src=\"", "src=\"".$mutiLangDomianFlag, $newscontent);  //双引号的图片
	$newscontent = str_replace("src='", "src='".$mutiLangDomianFlag, $newscontent);  //单引号的图片
	$newscontent = str_replace("_src=\"url('", "_src=\"url('".$mutiLangDomianFlag, $newscontent);  //li 背景图片 _src="url('
	$newscontent = str_replace("onClick=\"this.src='", "onClick=\"this.src='".$mutiLangDomianFlag, $newscontent);  //code.php   
	$newscontent = str_replace("href=\"favicon.ico", "href=\"".$mutiLangDomianFlag."/favicon.ico", $newscontent); 
	$newscontent1=$newscontent;
	$html1=new simple_html_dom();//new simple_html_dom对象 
	$html1->load($newscontent1); //加载html
	foreach($html1->find('link[type=text/css]') as $e) 
	{
		$newhref=str_replace( '../',"",$e->href);
		$newscontent = str_replace($e->href, $mutiLangDomianFlag.$newhref, $newscontent);  
		// echo $newhref."<br/>";
	}
	
	foreach($html1->find('script[type=text/javascript]') as $e) 
	{
		$newhref=str_replace( '../',"",$e->src);
		$newscontent = str_replace($e->src, $mutiLangDomianFlag.$newhref, $newscontent);  // 直接使用 $html1 值会报错
		// echo $newhref."<br/>";
	}
	foreach($html1->find('form') as $e){ 
		$newhref=$e->action;
		$newscontent = str_replace($newhref,$mutiLangDomianFlag.$newhref, $newscontent);  

	}

	$html1->clear();  
	 
	$folder_name = $target;
	$r_name = deep_in_array($folder_name, $translate_name);
	$translateFile = "../".$r_name['folder_name'];
	$newscontent = str_replace("src='".$mutiLangDomianFlag."http", "src='http", $newscontent);  //单引号的图片 外网地址换回来
	$newscontent = str_replace("src=\"".$mutiLangDomianFlag."http", "src=\"http", $newscontent);  //单引号的图片

	$translate_str = $newscontent;
	$p = "%<translate>(.*?)</translate>%si";    //正则表达式
	preg_match_all($p, $newscontent, $arr);
	$temarr = $arr[1];
	//var_dump(count($temarr));exit;
	$source="en";
	$targets = $target;
						//echo $api_key."===".$out_val."===".$target."===".$source;
						//exit;

	foreach($temarr as $val){
		if(strlen($val)>$transSplitLen){
			
			//如果翻译的内容大于$transSplitLen，则进行分段
			foreach(subpart($val, $transSplitLen, "utf-8") as $out_val){
				//$count_num ++;
				//echo "<h4 style='color:#00F'>".$count_num."</h4>";
				$_SESSION['transTotal']+=strlen($out_val);
				$obj = translate($api_key,$out_val,$target,$source);
				
				if($obj != null)
				{
					
				if(isset($obj['error']))
				{
                                    $ie=1;
				    while(isset($obj['error']))
                                    {
					if($obj['error']['message']=='User Rate Limit Exceeded')
                                          {
                                                if($ie>5)   {echo $obj['error']['message']."$ie 次 exit"; exit;}
                                               echo "<br/>本次翻译持续".round($_SESSION['estimationSeconds'],1)."秒，本次翻译".$_SESSION['estimationBytes']."字节，请求次数".$_SESSION['estimationTimes']."，暂停".($sleepSecond+$ie+2)."秒-2, $ie 次<br/>";
						sleep($sleepSecond+$ie+2);
		                                ob_flush();
		                                flush();
                                                $obj = translate($api_key,$val,$target,$source);

                                             }
                                            else
                                            {
  
                                                echo "Error is: ".$obj['error']['message']." , $ie 次<br/>";
		                                ob_flush();
		                                flush();
                                                 if($ie>5)   {echo $obj['error']['message']."$ie 次 exit"; exit;}
                                             }
                                       $ie++;
                                    }
				}
				if(!isset($obj['error']))
				 
				{
						//echo $obj['data']['translations'][0]['translatedText']." ";
						$translate_val = $obj['data']['translations'][0]['translatedText']."";
						
						
						$translate_str = str_replace($out_val, $translate_val, $translate_str);
						
						if(isset($obj['data']['translations'][0]['detectedSourceLanguage'])) //this is set if only source is not available.
							echo "Detecte Source Languge : ".$obj['data']['translations'][0]['detectedSourceLanguage']." ";
					}
				}
				else
					echo "Error ";
			}
		}else{
			//$count_num ++;
			//echo "<h4 style='color:#00F'>".$count_num."</h4>";
				$_SESSION['transTotal']+=strlen($val);
				$obj = translate($api_key,$val,$target,$source);
				
			if($obj != null)
			{
				
				if(isset($obj['error']))
				{
                                    $ie=1;
				    while(isset($obj['error']))
                                    {
					if($obj['error']['message']=='User Rate Limit Exceeded')
                                          {
                                                if($ie>5)   {echo $obj['error']['message']."$ie 次 exit"; exit;}
                                               echo "<br/>本次翻译持续".round($_SESSION['estimationSeconds'],1)."秒，本次翻译".$_SESSION['estimationBytes']."字节，请求次数".$_SESSION['estimationTimes']."，暂停".($sleepSecond+$ie+2)."秒-2, $ie 次<br/>";
						sleep($sleepSecond+$ie+2);
		                                ob_flush();
		                                flush();
                                                $obj = translate($api_key,$val,$target,$source);

                                             }
                                            else
                                            {
                                                echo "Error is: ".$obj['error']['message']." , $ie 次<br/>";
		                                ob_flush();
		                                flush();
                                                 if($ie>5)   {echo $obj['error']['message']."$ie 次 exit"; exit;}
                                             }
                                              $ie++;
                                    }
				}
				if(!isset($obj['error']))
				 
				{
					
					//echo $obj['data']['translations'][0]['translatedText']." ";
					$translate_val = $obj['data']['translations'][0]['translatedText']."";
					//var_dump($translate_val);echo "<br/>";
					$translate_str = str_replace("<translate>".$val."</translate>", $translate_val, $translate_str);
					//$translate_str = str_replace("<translate>".$val."</translate>", $val."<font color='#F00'>".$target."</font>", $translate_str);
						//if(isset($obj['data']['translations'][0]['detectedSourceLanguage'])) //this is set if only source is not available.
						//echo "Detecte Source Languge : ".$obj['data']['translations'][0]['detectedSourceLanguage']." ";
				}
			}
			else
			
				echo "Error ";
		}
		
	}
	if (is_file ($filename)){
		 @unlink ($filename); //若文件已存在，则删除
	}
	$handle = fopen ($filename,"w"); //打开文件指针，
		//检查文件是否被创建且可写 
	if(!is_writable ($filename)){ 
		 echo "<script>alert('文件：".$filename."不可写，请检查其属性后重试！');history.go(-1);</script>";
	}

	if(!fwrite ($handle,$translate_str)){  //将信息写入文件
		return false;
	}else{
		return true;
		echo $filename."  ok, 已翻译".$_SESSION['transTotal']."字符  ";
		 ob_flush();
		flush();
 
	}
	fclose($handle);
}
//GOOGLE 文字段落翻译基础功能，模拟翻译，查询块表、慢表
function translate($api_key,$text,$target,$source=false)
{
		global   $simuTransLow,$flagFastSlow,$simuTransCons,$sleepSecond, $delayTrigSecond,$delayTrigByte,$delayTrigTimes;
		$_SESSION['simuTrans']=$simuTransCons;
	 	 //  constant $simuTransLow,$flagFastSlow; $simuTransLow低级模拟翻译 ~fr~ 分割，ls_syscode, function translat
		 
		 // $flagFastSlow; 小于这个字符数，加入快表，ls_syscode, function translat



	  if($_SESSION['simuTrans']==1)  //如果是模拟翻译
	  {
		  $obj['data']['translations'][0]['translatedText']=$text."<font color='#F00'>".$target."</font>";
		   
	  }
	  else
	  {
			$transFastStr=transfast($text,$target); //查快表，词组表
			if(!$transFastStr)
			{
				
				$transSlowStr=transslow($text,$target); //查慢表，标题文章表
				if(!$transSlowStr)
				{
					
					$url = 'https://translation.googleapis.com/language/translate/v2?key=' . $api_key . '&q=' . rawurlencode($text);
					$url .= '&target='.$target;
					if($source)
					$url .= '&source='.$source;
					if(!$simuTransLow) //低级模拟翻译
					{
					   // 耗时的处理过程 100秒100K，1000次
					  if(  $_SESSION['estimationSeconds'] >= $delayTrigSecond && ( $_SESSION['estimationBytes']>$delayTrigByte ||$_SESSION['estimationTimes']>$delayTrigTimes ))
					  {
									
						echo "<br/>本次翻译持续".round($_SESSION['estimationSeconds'],1)."秒，本次翻译".$_SESSION['estimationBytes']."字节，请求次数".$_SESSION['estimationTimes']."，暂停".$sleepSecond."秒-3<br/>";
						sleep($sleepSecond);
						
									$_SESSION['estimationSeconds']  -= $sleepSecond;  //持续大于60秒,减去延迟时间，看次数，字节数插入耗时
									$_SESSION['estimationTimes']  -= $sleepSecond; //1秒1次
									$_SESSION['estimationBytes']-= $sleepSecond*800; //1秒800字节

					   }
                                                   
                        $thisSeconds=getmicrotime();

						$ch = curl_init($url);
						curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
						curl_setopt($ch, CURLOPT_TIMEOUT,1200);
						$response = curl_exec($ch);
						curl_close($ch);


						$obj =json_decode($response,true); //true converts stdClass to associative array.
						if (!isset($obj['error'])){  //翻译成功
							$thisBytes=strlen( $obj['data']['translations'][0]['translatedText']);
							$thisSeconds=getmicrotime()- $thisSeconds;
							$_SESSION['totalBytes']+= $thisBytes;
							$_SESSION['estimationBytes']+= $thisBytes;
							$_SESSION['totalSeconds']+= $thisSeconds;
							$_SESSION['estimationSeconds']  += $thisSeconds;
							$_SESSION['estimationTimes']  += 1;  
							$_SESSION['Times']+=1;


						    if(strlen($text)<$flagFastSlow) //增加快表内容
						    {addtransfast($text,$target,$obj['data']['translations'][0]['translatedText'],"menu");}
						    else
						    {addtransslow($text,$target,$obj['data']['translations'][0]['translatedText'],"menu");}
  						}
                                               


					}
					else
					{
						
						$obj['data']['translations'][0]['translatedText']=$text."~".$target."~";
					}
						//var_dump($obj);exit;
				}
				else
				{
					
					 $obj['data']['translations'][0]['translatedText']=$transSlowStr;
				}
			}
			else
			{
				
				 $obj['data']['translations'][0]['translatedText']=$transFastStr;
			}
	}	
		return $obj;
}
/*
------------------------------------------------------
参数：
$text  //翻译文本
$target  //目标语言
$source  //源语言
程序功能：查询快表：单词短语翻译表，常用单词信息表
------------------------------------------------------
*/
function transfast($text,$target,$source=false,$ignorecase=true)
{
    $text=htmlspecialchars($text, ENT_QUOTES); //处理html定界符和引号
	require_once('inc/conn.php');
	$opendb=new mydb();
	$trans_sql="select * from ls_transfast where en='".$text."' ";
 	if($ignorecase)$trans_sql="select * from ls_transfast where lower(en)='".strtolower($text)."' "; //默认忽略大小写
	$trans_query=$opendb->query($trans_sql);
	$transNum=mysqli_num_rows($trans_query);
	$trans_rows=mysqli_fetch_assoc($trans_query);
	$transText=($trans_rows[$target]==""?false:htmlspecialchars_decode($trans_rows[$target], ENT_QUOTES));
	
	if($transNum!=0)
	{
		$trans_sql="update ls_transfast set queryTotal=queryTotal+1 where ID=".$trans_rows['ID']." ";
		$trans_query=$opendb->query($trans_sql); //查询计数增加
	}
	
	If($transText){
		$_SESSION['transfast']+=1;  //快表条数
		$_SESSION['transfastTotal']+=($transText?strlen($transText):0);  //快表字数
	}
	
	
	return $transText;

}

/*
------------------------------------------------------
参数：
$text  //翻译源文本
$target  //目标语言
$transtr  //翻译结果
程序功能：新增快表项目：单词短语翻译对
------------------------------------------------------
*/
function addtransfast($text,$target,$transtr,$cate="menu")
{
    $text=htmlspecialchars($text, ENT_QUOTES); //处理html定界符和引号
    $transtr=htmlspecialchars($transtr, ENT_QUOTES); //处理html定界符和引号
	require_once('inc/conn.php');
	$opendb=new mydb();
 
	$trans_sql="select * from ls_transfast where en='".$text."' ";
	$trans_query=$opendb->query($trans_sql);
	$transNum=mysqli_num_rows($trans_query);
	$trans_rows=mysqli_fetch_assoc($trans_query);
	$transResult=false;
	//echo  "==text:".$text."--target:".$target."--transtr:".$transtr."<br/>";
	 if(trim($text)=="")return;
	$openck=new cktb();
	if($openck->checkfield(  "ls_transfast",$target,"ALTER TABLE  `ls_transfast` ADD  `".$target."` VARCHAR( 256 ) NOT NULL AFTER  `queryTotal` ,ADD INDEX (  `".$target."` )"))$ls_msg = $ls_msg .$openck->ls_msg;
	
	
	if($transNum==0)
	{
		$trans_sql="insert into ls_transfast   (en,".$target.",cate) value ('".$text."','".$transtr."','".$cate."' ) ";
		$trans_query=$opendb->query($trans_sql); //增加新的翻译内容
		if($trans_query) $transResult=true;
	}
	else
	{
		$trans_sql="update ls_transfast  set ".$target."='".$transtr."',cate='".$cate."' where ID=".$trans_rows['ID']." ";
		$trans_query=$opendb->query($trans_sql); //增加、更新新的语种
		if($trans_query) $transResult=true;
		$_SESSION['addtransfast']+=1;  // 增加块表次数
		$_SESSION['addtransfastTotal']+=($transText?strlen($transText):0);  // 增加快表字节数
	}
	return $transResult;

}

/*
------------------------------------------------------
参数：
$text  //翻译文本
$target  //目标语言
$source  //源语言
$enTableName  //对应英文表名
$enID  //en原表 ID号
$enField  //en原表 字段

程序功能：查询慢表翻译，本站长句翻译信息对照表
------------------------------------------------------
*/
function transslow($text,$target,$enTableName="",$enID="",$enField="",$source=false)
{
    $text=htmlspecialchars($text, ENT_QUOTES); //处理html定界符和引号
	require_once('inc/conn.php');
	$opendb=new mydb();
	$trans_sql="select * from ls_transslow where en='".$text."' ";
	$trans_query=$opendb->query($trans_sql);
	$transNum=mysqli_num_rows($trans_query);
	$trans_rows=mysqli_fetch_assoc($trans_query);
	$transText=($trans_rows[$target]==""?false:htmlspecialchars_decode($trans_rows[$target], ENT_QUOTES));
	
	if($transNum!=0)
	{
		$trans_sql="update ls_transslow set queryTotal=queryTotal+1 where ID=".$trans_rows['ID']." ";
		$trans_query=$opendb->query($trans_sql); //查询计数增加
	}
	
	If($transText){
		$_SESSION['transslow']+=1;  //慢表条数
		$_SESSION['transslowTotal']+=($transText?strlen($transText):0);  //慢表字数 
	}

	return $transText;


}

/*
------------------------------------------------------
参数：
$text  //翻译源文本
$target  //目标语言
$transtr  //翻译结果

程序功能：新增慢表项，本站长句翻译信息对照表
------------------------------------------------------
*/
function addtransslow($text,$target,$transtr,$cate="menu")
{
    $text=htmlspecialchars($text, ENT_QUOTES); //处理html定界符和引号
    $transtr=htmlspecialchars($transtr, ENT_QUOTES); //处理html定界符和引号
	require_once('inc/conn.php');
	$opendb=new mydb();
	$trans_sql="select * from ls_transslow where en='".$text."' ";
	$trans_query=$opendb->query($trans_sql);
	$transNum=mysqli_num_rows($trans_query);
	$trans_rows=mysqli_fetch_assoc($trans_query);
	$transResult=false;
	
	$openck=new cktb();
	if($openck->checkfield(  "ls_transslow",$target,"ALTER TABLE  `ls_transslow` ADD  `".$target."` LONGTEXT NOT NULL   AFTER  `enText`"))$ls_msg = $ls_msg .$openck->ls_msg;	
	
	if($transNum==0)
	{
		$trans_sql="insert into ls_transslow   (en,".$target.",cate) value ('".$text."','".$transtr."','".$cate."' ) ";
		$trans_query=$opendb->query($trans_sql); //增加翻译结果
		if($trans_query) $transResult=true;
	}
	else
	{
		$trans_sql="update ls_transslow  set ".$target."='".$transtr."',cate='".$cate."' where ID=".$trans_rows['ID']." ";
		$trans_query=$opendb->query($trans_sql); //增加、更新新的语种
		if($trans_query) $transResult=true;
		 $_SESSION['addtransslow']+=1;  //增加慢表条数
		$_SESSION['addtransslowTotal']+=($transText?strlen($transText):0);  //增加慢表字数 
	}
	return $transResult;

}


/*
------------------------------------------------------
参数：
$tableName  //生成表名
程序功能检查快慢表是否存在，不存在创建
------------------------------------------------------
*/

function ckfastslow($tableName)
{
	$openck=new cktb();
	
	if($tableName=="ls_transslow"){
	  if($openck->checktable("ls_transslow","CREATE TABLE IF NOT EXISTS `ls_transslow` (
	  `ID` int(4) NOT NULL AUTO_INCREMENT,
	  `requirement` text,
	  `name` varchar(100) DEFAULT NULL,
	  `company` varchar(200) DEFAULT NULL,
	  `tel` varchar(100) DEFAULT NULL,
	  `email` varchar(150) DEFAULT NULL,
	  `date` varchar(200) DEFAULT NULL,
	  `path` varchar(1000) DEFAULT NULL,
	  `address` varchar(500) DEFAULT NULL,
	  `fax` varchar(100) DEFAULT NULL,
	  `http` varchar(100) DEFAULT NULL,
	  `proID` int(4) DEFAULT NULL,
	  `proID` varchar(500) DEFAULT NULL,
	  `ip` varchar(50) DEFAULT NULL,
	  `explorer` varchar(100) DEFAULT NULL,
	  `home` varchar(300) DEFAULT NULL,
	  `system` varchar(50) DEFAULT NULL,
	  `enable` int(1) DEFAULT '1',
	  `cateNameID` int(4) DEFAULT NULL,
	  PRIMARY KEY (`ID`)
	) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;"))	
	$ls_msg = $ls_msg .$openck->ls_msg;	
	}
	
	if($tableName=="ls_transfast"){
  		if($openck->checktable("ls_transfast","CREATE TABLE IF NOT EXISTS `ls_transfast` (
  `ID` int(5) NOT NULL,
  `cate` varchar(16) NOT NULL,
  `en` varchar(256) NOT NULL,
  `queryTotal` int(8) NOT NULL COMMENT '查询次数',
  `fr` varchar(256) NOT NULL,
  `de` varchar(256) NOT NULL,
  `it` varchar(256) NOT NULL,
  `ru` varchar(256) NOT NULL,
  `pt` varchar(256) NOT NULL,
  `es` varchar(256) NOT NULL,
  `ae` varchar(256) NOT NULL,
  `ja` varchar(256) NOT NULL,
  `ko` varchar(256) NOT NULL,
  `in` varchar(256) NOT NULL,
  `ar` longtext NOT NULL,
  `nl` varchar(255) NOT NULL,
  `fa` varchar(255) NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=163 DEFAULT CHARSET=utf8;"))	
	$ls_msg = $ls_msg .$openck->ls_msg;	


	$insertsql1="INSERT INTO `ls_transfast` (`ID`, `cate`, `en`, `queryTotal`, `fr`, `de`, `it`, `ru`, `pt`, `es`, `ae`, `ja`, `ko`, `in`, `ar`, `nl`, `fa`) VALUES
(4, 'menu', 'About Us', 8726, 'À propos de nous', 'Über uns', 'Riguardo a noi', 'О нас', 'Sobre nós', 'Sobre nosotros', '', '私たちに関しては', '회사 소개', '', 'معلومات عنا', 'Over ons', 'دربارهی ما'),
(5, 'menu', 'About Dake', 4006, '', 'Über Dake', 'A proposito di Dake', 'О Даке', 'Sobre Dake', 'Acerca de Dake', '', 'Dakeについて', 'Dake 회원', '', 'حول ديك', 'Over Dake', ''),
(6, 'menu', 'Company Team', 4928, '', 'Unternehmensteam', 'Team Aziendale', 'Команда компании', 'Equipe da Empresa', 'Equipo de la empresa', '', '会社のチーム', '회사 팀', '', 'فريق الشركة', 'Bedrijfspan', ''),
(7, 'menu', 'Products', 10906, 'Des produits', 'Produkte', 'Prodotti', 'Продукты', 'Produtos', 'Productos', '', '製品', '제작품', '', 'منتجات', 'producten', 'محصولات'),
(11, 'menu', 'News', 9415, 'Nouvelles', 'Nachrichten', 'notizia', 'Новости', 'Notícia', 'Noticias', '', 'ニュース', '뉴스', '', 'أخبار', 'Nieuws', 'اخبار'),
(12, 'menu', 'Factory', 5076, '', 'Fabrik', 'Fabbrica', 'завод', 'Fábrica', 'Fábrica', '', '工場', '공장', '', 'مصنع', 'Fabriek', ''),
(13, 'menu', 'Factory Scene', 4069, '', 'Fabrik Szene', 'Scena di fabbrica', 'Фабричная сцена', 'Cena de Fábrica', 'Escena de la fábrica', '', '工場のシーン', '공장 장면', '', 'مشهد المصنع', 'Fabrieksscène', ''),
(14, 'menu', 'Diagram', 4982, '', 'Diagramm', 'Diagramma', 'схема', 'Diagrama', 'Diagrama', '', '図', '도표', '', 'رسم بياني', 'Diagram', ''),
(15, 'menu', 'Base', 4920, '', 'Base', 'Base', 'База', 'Base', 'Base', '', 'ベース', '베이스', '', 'قاعدة', 'Baseren', ''),
(16, 'menu', 'Certificates', 5331, '', 'Zertifikate', 'certificati', 'Сертификаты', 'Certificados', 'Certificados', '', '証明書', '인증서', '', 'شهادات', 'certificaten', ''),
(17, 'menu', 'Blog', 6525, 'Blog', 'Blog', 'blog', 'Блог', 'Blog', 'Blog', '', 'ブログ', '블로그', '', 'مدونة', 'blog', 'وبلاگ'),
(18, 'menu', 'Contact Us', 8380, 'Contactez nous', 'Kontaktiere uns', 'Contattaci', 'Свяжитесь с нами', 'Contate-Nos', 'Contáctenos', '', 'お問い合わせ', '연락처', '', 'اتصل بنا', 'Neem contact met ons op', 'تماس با ما'),
(19, 'menu', 'Manager', 4903, '', 'Manager', 'Manager', 'Менеджер', 'Gerente', 'Gerente', '', 'マネージャー', '매니저', '', 'مدير', 'Manager', ''),
(20, 'menu', 'Branches', 4890, '', 'Geäst', 'filiali', 'ветви', 'Ramos', 'Ramas', '', '支店', '지점들', '', 'الفروع', 'branches', ''),
(21, 'menu', 'QUALITY ', 13, '', 'QUALITÄT', 'QUALITÀ', 'КАЧЕСТВЕННЫЙ', 'QUALIDADE', 'CALIDAD', '', '品質', '품질', '', 'جودة', 'KWALITEIT', ''),
(23, 'menu', 'Our Advantages', 13, '', 'Unsere Vorteile', 'I nostri vantaggi', 'Наши преимущества', 'Nossas vantagens', 'Nuestras ventajas', '', '私たちの利点', '우리의 장점', '', 'إيجابياتنا', 'Onze voordelen', ''),
(24, 'menu', 'Strict Control', 13, '', 'Strenge Kontrolle', 'Controllo rigoroso', 'Строгий контроль', 'Controle estrito', 'Control estricto', '', '厳格な管理', '엄격한 통제', '', 'رقابة صارمة', 'Strenge controle', ''),
(25, 'menu', 'More+', 73, '', 'Mehr +', 'Altro +', 'Подробнее +', 'Mais +', 'Más +', '', 'その他+', '기타 +', '', 'أكثر +', 'meer +', 'بیشتر +'),
(26, 'menu', 'Q&C', 0, '', 'Fragen und Antworten', '', '', '', '', '', '', '', '', '', '', ''),
(27, 'menu', 'Learn More', 13, '', 'Erfahren Sie mehr', 'Per saperne di più', 'Выучить больше', 'Saber mais', 'Aprende más', '', 'もっと詳しく知る', '더 알아보기', '', 'أعرف أكثر', 'Kom meer te weten', ''),
(28, 'menu', 'Mobile Web', 2875, 'Web mobile', 'Mobile Web', 'Mobile Web', 'Мобильная сеть', 'Web móvel', 'Web Móvil', '', 'モバイルウェブ', '모바일 웹', '', 'ويب الجوال', 'Mobiel Web', 'وب موبایل'),
(29, 'menu', 'Tel', 9175, '', 'Tel', 'Tel', 'телефон', 'Telefone', 'Tel', '', '電話番号', '전화', '', 'الهاتف', 'Tel', ''),
(30, 'menu', 'Fax', 1951, '', 'Fax', 'Fax', 'факс', 'Fax', 'Fax', '', 'ファックス', '팩스', '', 'فاكس', 'Fax', ''),
(31, 'menu', 'E-mail', 3925, '', 'Email', 'E-mail', 'Эл. почта', 'O email', 'Email', '', 'Eメール', '이메일', '', 'البريد الإلكتروني', 'E-mail', 'پست الکترونیک'),
(32, 'menu', 'Website', 1950, '', 'Webseite', 'Sito web', 'Веб-сайт', 'Local na rede Internet', 'Sitio web', '', 'ウェブサイト', '웹 사이트', '', 'موقع الكتروني', 'Website', ''),
(33, 'menu', 'Add', 1950, '', 'Hinzufügen', 'Inserisci', 'Добавить', 'Adicionar', 'Añadir', '', '追加', '더하다', '', 'إضافة', 'Toevoegen', ''),
(34, 'menu', 'Sign Up', 2407, '', 'Anmelden', 'Registrazione', 'Зарегистрироваться', 'Inscrever-se', 'Regístrate', '', 'サインアップ', '가입하기', '', 'سجل', 'Aanmelden', ''),
(35, 'menu', 'Name', 7223, '', 'Name', 'Nome', 'имя', 'Nome', 'Nombre', '', '名', '이름', '', 'اسم', 'Naam', ''),
(36, 'menu', 'Email', 7223, '', 'Email', 'E-mail', 'Эл. адрес', 'O email', 'Email', '', 'Eメール', '이메일', '', 'البريد الإلكتروني', 'E-mail', ''),
(37, 'menu', 'Message', 7261, 'Message', 'Nachricht', 'Messaggio', 'Сообщение', 'mensagem', 'Mensaje', '', 'メッセージ', '메시지', '', 'رسالة', 'Bericht', ''),
(38, 'menu', 'Links', 2269, '', 'Links', 'link', 'связи', 'Links', 'Campo de golf', '', 'リンク', '모래밭', '', 'الروابط', 'Links', 'لینک ها'),
(39, 'menu', 'Skype', 3900, '', 'Skype', 'Skype', 'Skype', 'Skype', 'Skype', '', 'Skype', 'Skype', '', 'سكايب', 'Skype', ''),
(40, 'menu', 'Back To The Top', 1949, '', 'Zurück an die Spitze', 'Torna alla parte superiore', 'Перейти к началу страницы', 'Voltar ao topo', 'Volver a la cima', '', 'トップに戻る', '위로 가기', '', 'العودة إلى الصدارة', 'Terug naar de top', ''),
(41, 'menu', 'Top', 1949, '', 'Oben', 'Superiore', 'верхний', 'Topo', 'Parte superior', '', '上', '상단', '', 'أعلى', 'Top', ''),
(42, 'menu', 'Next', 3336, 'Prochain', 'Nächster', 'Il prossimo', 'следующий', 'Próximo', 'Siguiente', '', '次', '다음 것', '', 'التالى', 'volgende', ''),
(43, 'menu', 'Previous', 3323, 'précédent', 'Bisherige', 'Precedente', 'предыдущий', 'Anterior', 'Anterior', '', '前', '너무 이른', '', 'سابق', 'voorgaand', ''),
(44, 'menu', 'Home', 10835, 'Accueil', 'Zuhause', 'Casa', 'Главная', 'Casa', 'Casa', '', 'ホーム', '집', '', 'الصفحة الرئيسية', 'Huis', 'خانه'),
(45, 'menu', '', 13157, '', '', '', '', '', '', '', '', '', '', '', '', ''),
(46, 'menu', 'Fruit', 244, 'Fruit', 'Frucht', 'Frutta', 'Фрукты', 'Fruta', 'Fruta', '', 'フルーツ', '과일', '', 'فاكهة', 'Fruit', ''),
(47, 'menu', 'Blog Category', 318, 'Catégorie Blog', 'Blog Kategorie', 'Categoria Blog', 'Категория блога', 'Categoria Blog', 'Categoría del blog', '', 'ブログカテゴリ', '블로그 카테고리', '', 'فئة المدونة', 'Blog categorie', 'دسته بندی وبلاگ'),
(50, 'menu', 'Share', 318, 'Partager', 'Aktie', 'Condividere', 'Поделиться', 'Compartilhar', 'Compartir', '', 'シェア', '몫', '', 'شارك', 'Delen', 'اشتراک گذاری'),
(67, 'menu', 'Search', 524, 'Chercher', 'Suche', 'Ricerca', 'Поиск', 'Pesquisa', 'Buscar', '', 'サーチ', '수색', '', 'بحث', 'Zoeken', 'جستجو کردن'),
(68, 'menu', 'Feedback', 39, 'Retour d&amp;#39;information', 'Feedback', 'Risposta', 'Обратная связь', 'Comentários', 'Realimentación', '', 'フィードバック', '피드백', '', 'ردود الفعل', 'terugkoppeling', 'بازخورد'),
(69, 'menu', 'Q&amp;C', 12, 'Q &amp;amp; C', 'Fragen und Antworten', 'Q &amp;amp; C', 'Q &amp;amp; С', 'Q &amp;amp; C', 'Preguntas y respuestas', '', 'Q＆C', 'Q &amp;amp; C', '', 'Q &amp;amp; C', 'Q &amp;amp; C', ''),
(70, 'menu', 'Company History', 1, 'Histoire de l&amp;#39;entreprise', '', 'storia dell&amp;#39;azienda', '', '', '', '', '', '', '', '', '', ''),
(71, 'menu', 'How to Find Us', 26, 'Comment nous trouver', 'So finden Sie uns', 'Come trovarci', 'Как нас найти', 'Como nos encontrar', 'Como encontrarnos', '', '私たちを見つける方法', '우리를 찾는 방법', '', 'كيف تجدنا', 'Hoe ons te vinden', 'راه تماس با ما - چطور ما را پیدا کنید'),
(73, 'menu', 'Contact  Us', 1046, '', 'Kontaktiere uns', 'Contattaci', 'Свяжитесь с нами', 'Contate-Nos', 'Contáctenos', '', 'お問い合わせ', '연락처', '', 'اتصل بنا', 'Neem contact met ons op', ''),
(76, 'menu', 'Video', 39, '', 'Video', 'Video', 'видео', 'Vídeo', 'Vídeo', '', 'ビデオ', '비디오', '', '', 'Video', ''),
(78, 'menu', 'Our Story', 19, '', 'Unsere Geschichte', 'La nostra storia', 'Наша история', 'Nossa história', 'Nuestra historia', '', '私たちの物語', '우리의 이야기', '', '', 'Ons verhaal', ''),
(79, 'menu', 'Factory Scence', 913, 'Factory Scence', 'Fabrik Scence', 'Scence di fabbrica', 'Заводской', 'Factory Scence', 'Fábrica Scence', '', 'ファクトリー・スケール', '공장 규모', '', 'مصنع سسينس', '', ''),
(80, 'menu', 'Branch', 47, 'Branche', 'Ast', 'Ramo', 'Филиал', 'Ramo', 'Rama', '', 'ブランチ', '분기', '', 'فرع شجرة', 'Tak', ''),
(82, 'menu', 'Workshop', 2, '', '', '', '', '', '', '', '', '', '', 'ورشة عمل', '', ''),
(84, 'menu', 'Certificate', 1562, 'Certificat', 'Zertifikat', '', '', 'Certificado', 'Certificado', '', '', '', '', '', '', ''),
(85, 'menu', 'Contact', 2454, 'Contact', 'Kontakt', '', 'контакт', 'Contato', 'Contacto', '', '接触', '접촉', '', 'اتصل', '', 'تماس'),
(86, 'menu', 'Quality Control', 1589, 'Contrôle de qualité', 'Qualitätskontrolle', '', '', 'Controle de qualidade', 'Control de calidad', '', '', '', '', '', '', ''),
(87, 'menu', 'Services', 2642, 'Prestations de service', 'Dienstleistungen', '', 'Сервисы', 'Serviços', 'Servicios', '', 'サービス', '서비스', '', 'خدمات', '', 'خدمات'),
(89, 'menu', ' Products', 375, 'Des produits', 'Produkte', '', '', 'Produtos', 'Productos', '', '', '', '', '', '', ''),
(90, 'menu', 'Plant', 754, 'Plante', 'Pflanze', '', '', 'Plantar', 'Planta', '', '', '', '', '', '', ''),
(92, 'menu', 'Name:', 86, 'Prénom:', 'Name:', '', 'Имя:', 'Nome:', 'Nombre:', '', '名：', '이름:', '', 'اسم:', '', 'نام:'),
(93, 'menu', 'Company Name:', 29, 'Nom de la compagnie:', 'Name der Firma:', '', 'Название компании:', 'Nome da empresa:', 'Nombre de empresa:', '', '会社名：', '회사 이름:', '', 'اسم الشركة:', '', 'نام شرکت:'),
(94, 'menu', 'E-mail:', 29, 'Email:', 'Email:', '', 'Эл. адрес:', 'O email:', 'Email:', '', 'Eメール：', '이메일:', '', 'البريد الإلكتروني:', '', 'پست الکترونیک:'),
(95, 'menu', 'Web:', 29, 'Web:', 'Web:', '', 'веб-сайт:', 'Rede:', 'Web:', '', 'ウェブ：', '편물:', '', 'على شبكة الإنترنت:', '', 'وب:'),
(96, 'menu', 'Message:', 89, 'Message:', 'Nachricht:', '', 'Сообщение:', 'Mensagem:', 'Mensaje:', '', 'メッセージ：', '메시지:', '', 'رسالة:', '', 'پیام:'),
(97, 'menu', 'Verification:', 29, 'Vérification:', 'Überprüfung:', '', 'Проверка:', 'Verificação:', 'Verificación:', '', '検証：', '확인:', '', 'التحقق:', '', 'تایید:'),
(98, 'menu', 'Submit', 29, 'Soumettre', 'einreichen', '', 'Отправить', 'Enviar', 'Enviar', '', '提出する', '제출', '', 'عرض', '', 'ارسال'),
(99, 'menu', 'Reset ', 14, 'Réinitialiser', 'Reset', '', '', 'Restabelecer', 'Reiniciar', '', '', '', '', '', '', ''),
(100, 'menu', 'About &amp;quot;', 14, 'Sur &amp;quot;', 'Über &amp;quot;', '', '', 'Sobre &amp;quot;', 'Acerca de &amp;quot;', '', '', '', '', '', '', ''),
(101, 'menu', ' search results', 14, 'Résultats de la recherche', 'Suchergebnisse', '', '', 'Procurar Resultados', 'Resultados de la búsqueda', '', '', '', '', '', '', ''),
(102, 'menu', 'ABOUT&amp;nbsp;US', 8, 'À PROPOS DE NOUS', 'ÜBER UNS', '', '', 'SOBRE NÓS', 'SOBRE NOSOTROS', '', '', '', '', '', '', ''),
(103, 'menu', 'Latest News', 8, 'Dernières nouvelles', 'Neuesten Nachrichten', '', '', 'Últimas notícias', 'Últimas noticias', '', '', '', '', '', '', ''),
(104, 'menu', 'Tel:', 69, 'Tel:', 'Tel:', '', 'Тел:', 'Tel:', 'Tel:', '', 'Tel：', '전화 :', '', 'الهاتف:', '', 'تلفن:'),
(105, 'menu', 'Email:', 56, 'Email:', 'Email:', '', '', 'O email:', 'Email:', '', '', '', '', '', '', ''),
(106, 'menu', 'Country:', 56, 'Pays:', 'Land:', '', '', 'País:', 'País:', '', '', '', '', '', '', ''),
(107, 'menu', 'product', 12, 'produit', 'Produkt', '', '', 'produtos', 'producto', '', '', '', '', '', '', ''),
(108, 'menu', 'Product Name: ', 2, 'Nom du produit:', 'Produktname:', '', '', '', 'Nombre del producto:', '', '', '', '', '', '', ''),
(109, 'menu', 'Exp. &amp; Imp.', 977, 'Exp. &amp;amp; Imp.', '', '', 'Exp. &amp;amp; Imp.', '', 'Exp. &amp;amp; Imp.', '', 'Exp。 ＆Imp。', '특급. &amp;amp; Imp.', '', 'إكسب. &amp;amp; إمب.', '', 'Exp &amp;amp; صادرات'),
(110, 'menu', 'Who We Are', 20, '', '', '', 'Кто мы', '', 'Quienes somos', '', '私たちは誰ですか', '우리는 누구인가?', '', 'من نحن', '', 'ما که هستیم'),
(111, 'menu', '(More...)', 20, '', '', '', '(Больше...)', '', '(Más...)', '', '（もっと...）', '(더...)', '', '(أكثر من...)', '', '(بیش...)'),
(112, 'menu', 'Recent Projects', 20, '', '', '', 'Недавние Проекты', '', 'proyectos recientes', '', '最近のプロジェクト', '최근 프로젝트', '', 'مشاريع حديثه', '', 'پروژههای اخیر')
  " ;
  
  	$insertsql2="INSERT INTO `ls_transfastbs` (`ID`, `cate`, `en`, `queryTotal`, `fr`, `de`, `it`, `ru`, `pt`, `es`, `ae`, `ja`, `ko`, `in`, `ar`, `nl`, `fa`) VALUES  (113, 'menu', 'FAQ', 974, 'FAQ', '', '', 'Вопросы-Ответы', '', 'Preguntas más frecuentes', '', 'よくある質問', '자주하는 질문', '', 'التعليمات', '', 'سوالات متداول'),
(116, 'menu', 'Why Us', 20, '', '', '', 'Почему нас', '', 'Porque nosotros', '', 'なんで私達なの', '', '', 'لماذا نحن', '', 'چرا ما'),
(117, 'menu', 'Market Ranking', 20, '', '', '', 'Рыночный рейтинг', '', 'Ranking de mercado', '', '市場ランキング', '', '', 'ترتيب السوق', '', 'رتبه بندی بازار'),
(118, 'menu', 'Overview ', 20, '', '', '', 'обзор', '', 'Visión de conjunto', '', '概要', '', '', 'نظرة عامة', '', 'بررسی اجمالی'),
(120, 'menu', 'Mg plant', 2503, 'Mg Plant', '', '', 'Mg Plant', '', 'Planta de Mg', '', 'Mgプラント', 'Mg 공장', '', 'نبات المغنيسيوم', '', 'گیاه Mg'),
(122, 'menu', 'Whatsapp', 20, '', '', '', 'Whatsapp', '', 'Whatsapp', '', 'Whatsapp', '', '', 'ال WhatsApp', '', 'واتساپ'),
(124, 'menu', 'Organization', 1044, 'Organisation', '', '', 'организация', '', 'Organización', '', '組織', '조직', '', 'منظمة', '', 'سازمان'),
(125, 'menu', 'Sustainability', 1044, 'Durabilité', '', '', 'устойчивость', '', 'Sostenibilidad', '', 'サステナビリティ', '지속 가능성', '', 'الاستدامة', '', 'پایداری'),
(126, 'menu', 'Tech Innovation', 1044, 'Innovation technologique', '', '', 'Техническая инновация', '', 'Innovación tecnológica', '', '技術革新', '기술 혁신', '', 'الابتكار التكنولوجي', '', 'نوآوری فناوری'),
(127, 'menu', 'Equipment', 1044, 'Équipement', '', '', 'Оборудование', '', 'Equipo', '', '装置', '장비', '', 'الرجعية', '', 'تجهیزات'),
(129, 'menu', 'Contact Info', 951, 'Informations de contact', '', '', 'Контактная информация', '', 'Datos de contacto', '', '連絡先情報', '연락처 정보', '', 'معلومات الاتصال', '', 'اطلاعات تماس'),
(130, 'menu', 'Messages', 939, 'Messages', '', '', 'Сообщения', '', 'Mensajes', '', 'メッセージ', '메시지', '', 'رسائل', '', 'پیام ها'),
(131, 'menu', 'Work With Us', 981, 'Travaille avec nous', '', '', 'Работать с нами', '', 'Trabaja con nosotros', '', '私たちと働く', '우리와 함께 일하십시오', '', 'اعمل معنا', '', 'با ما همکاری کنید'),
(132, 'menu', 'Mobile Contact', 908, 'Contact mobile', '', '', 'Мобильный контакт', '', 'Contacto móvil', '', 'モバイル連絡先', '모바일 연락처', '', 'الاتصال بالجوال', '', 'تماس با تلفن همراه'),
(133, 'menu', 'Product List', 923, 'Liste de produits', '', '', 'Список продуктов', '', 'Lista de productos', '', '製品リスト', '상품 목록', '', 'قائمة المنتجات', '', 'لیست محصولات'),
(135, 'menu', 'Description', 327, 'La description', '', '', 'Описание', '', 'Descripción', '', '説明', '기술', '', 'وصف', '', 'شرح'),
(136, 'menu', '&gt;Products', 14, '', '', '', '&amp;gt; Продукты', '', '&amp;gt; Productos', '', '&amp;gt;製品', '&amp;gt; 제품', '', '&amp;gt; المنتجات', '', '&amp;gt; محصولات'),
(137, 'menu', 'sendmail', 27, '', '', '', 'Отправить письмо', '', 'enviar correo', '', 'sendmail', '메일을 보내다', '', 'ارسل بريد', '', 'ارسال ایمیل'),
(139, 'menu', 'search results', 13, '', '', '', 'результаты поиска', '', 'Resultados de la búsqueda', '', 'の検索結果', '검색 결과', '', 'نتائج البحث', '', 'نتایج جستجو'),
(140, 'menu', ' Article', 13, '', '', '', 'Статья', '', 'Artículo', '', '記事', '조', '', 'مقالة - سلعة', '', 'مقاله'),
(141, 'menu', 'Leave A Message', 25, '', '', '', 'Оставить сообщение', '', 'Deja un mensaje', '', '伝言を残す', '메시지 남기기', '', 'اترك رسالة', '', 'یک پیام بگذار'),
(142, 'menu', ' Your Name:', 12, '', '', '', 'Ваше имя:', '', 'Tu nombre:', '', 'あなたの名前：', '귀하의 성함 :', '', 'اسمك:', '', 'اسم شما:'),
(143, 'menu', ' E-mail:', 12, '', '', '', 'Эл. адрес:', '', 'Email:', '', 'Eメール：', '이메일:', '', 'البريد الإلكتروني:', '', 'پست الکترونیک:'),
(144, 'menu', 'Send', 12, '', '', '', 'послать', '', 'Enviar', '', '送信', '보내다', '', 'إرسال', '', 'ارسال'),
(145, 'menu', 'Vision', 14, '', '', '', 'видение', '', 'Visión', '', 'ビジョン', '시력', '', 'رؤية', '', 'چشم انداز'),
(147, 'menu', ' Messages ', 11, '', '', '', 'Сообщения', '', 'Mensajes', '', 'メッセージ', '', '', 'رسائل', '', 'پیام ها'),
(148, 'menu', 'FAQs', 20, '', '', '', 'Вопросы и ответы', '', 'Preguntas frecuentes', '', 'よくある質問', 'FAQs', '', 'أسئلة وأجوبة', '', 'سوالات متداول'),
(149, 'menu', 'Negotiable', 10, '', '', '', 'оборотный', '', 'Negociable', '', '交渉可能な', '협상 가능한', '', 'قابل للتفاوض', '', 'قابل مذاکره است'),
(150, 'menu', 'Company Blog', 121, '', '', '', 'Блог компании', '', 'Blog de la empresa', '', '会社のブログ', '회사 블로그', '', 'مدونة الشركة', '', 'وبلاگ شرکت'),
(151, 'menu', 'Technology Blog', 101, '', '', '', 'Технологический блог', '', 'Blog de tecnología', '', 'テクノロジーブログ', '기술 블로그', '', 'مدونة التكنولوجيا', '', 'وبلاگ فناوری'),
(152, 'menu', 'Customer Blog', 111, '', '', '', 'Блог клиента', '', 'Blog del cliente', '', 'カスタマーブログ', '고객 블로그', '', 'مدونة العملاء', '', 'وبلاگ مشتری'),
(153, 'menu', 'Business Blog', 102, '', '', '', 'Бизнес-блог', '', 'Blog empresarial', '', 'ビジネスブログ', '비즈니스 블로그', '', 'مدونة الأعمال', '', 'وبلاگ تجاری'),
(154, 'menu', 'As vice', 9, '', '', '', 'Как недостаток', '', 'Como el vicio', '', '副として', '악덕으로', '', 'كنائب', '', 'به عنوان معاون'),
(161, 'menu', 'Business-Blog', 10, '', '', '', 'Бизнес-блог', '', 'Business-Blog', '', 'ビジネスブログ', '비즈니스 블로그', '', 'الأعمال مدونة', '', 'وبلاگ کسب و کار')";

	require_once('inc/conn.php');
	$opendb=new mydb();
	$trans_query=$opendb->query($insertsql1);
	$trans_query=$opendb->query($insertsql2);
}
}

//英文文章分段，分隔时可以截取完整单词与<>符号的标签，翻译函数中用到
function subpart($cont, $len, $charset,$endflag=""){
	$end = 0;
	//$j=0;
	$contlen = strlen($cont);
	$cont=urldecode($cont);
	//echo $contlen."<br />".$cont;   //总长度
	for ($i=0; $i<=$contlen;){
		//  echo "起始的位置".$i."end1:".$end."--len".$len."<br>" ;  //起始的位置
		$end1=$end ;
		$end = strrpos(substr($cont, 0, $end+$len), " ");
		$end2 = strrpos(substr($cont, 0, $end1+$len), "&nbsp;");  //&nbsp; 代替空格
		// echo ($end+$len);
		if($end2>$end) $end=$end2;

		// echo "<br>结束的位置".$end."len".$len."<br>".$cont ;    //结束的位置
		$thisstr1=substr($cont, 0, $end);
		$lt = strrpos($thisstr1, '<');  if($lt==0)$lt = strrpos($thisstr1, '&lt;'); 
		$gt = strrpos($thisstr1, ">") ; if($gt==0)$gt = strrpos($thisstr1, '&gt;'); 
		// echo "<br><br>[:".$thisstr1.":]".$lt."==". $gt." <br/><br/><br/>";
		$end=$gt+3;
		if($lt > $gt){
			$end =$lt ;
			// echo "最终结束的位置：".$end."&nbsp;"; 
		}
		//  echo "小号：".$lt."&nbsp;";
		//  echo "大号：".$gt."&nbsp".$end. "--<br/><br/>";
		$len_num = $end - $i;
		// echo "截取的长度".$len_num."<br />";   //截取的长度
		$thisstr= substr($cont, $i, $len_num);
 		//echo $thisstr1."<br/><br/>";
 		if($endflag!=""){
			$endflagpos=strrpos( $thisstr,$endflag );
			if($endendflagpos!=0){ 
				$len_numflag= $endflagpos;
				$thisstr= substr($thisstr, 0, $len_numflag);
				$end =$i+$len_numflag;
			}
		}
		 $contarr[] = $thisstr; 
		
		$i = $end;
		if($end+$len > $contlen){ break;}
	}
	$thissub=substr($cont, $i, $len);
	//echo $thissub."<br/><br/><br/><br/>";
	$contarr[] = $thissub;
	return $contarr;
}



//记录代码运行时间  
function getmicrotime()
{
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

/*
* ============================== 截取含有 html标签的字符串 =========================
* @param (string) $str   待截取字符串
* @param (int)  $lenth  截取长度
* @param (string) $repalce 超出的内容用$repalce替换之（该参数可以为带有html标签的字符串）
* @param (string) $anchor 截取锚点，如果截取过程中遇到这个标记锚点就截至该锚点处
* @return (string) $result 返回值
* @demo  $res = cut_html_str($str, 256, '...'); //截取256个长度，其余部分用'...'替换
* ===============================================================================
*/
function cut_html_str($str, $lenth, $replace='', $anchor='<!-- break -->'){ 
    $_lenth = mb_strlen($str, "utf-8"); // 统计字符串长度（中、英文都算一个字符）
    if($_lenth <= $lenth){
        return $str;    // 传入的字符串长度小于截取长度，原样返回
    }
    $strlen_var = strlen($str);     // 统计字符串长度（UTF8编码下-中文算3个字符，英文算一个字符）
    if(strpos($str, '<') === false){ 
        return mb_substr($str, 0, $lenth);  // 不包含 html 标签 ，直接截取
    } 
    if($e = strpos($str, $anchor)){ 
        return mb_substr($str, 0, $e);  // 包含截断标志，优先
    } 
    $html_tag = 0;  // html 代码标记 
    $result = '';   // 摘要字符串
    $html_array = array('left' => array(), 'right' => array()); //记录截取后字符串内出现的 html 标签，开始=>left,结束=>right
    /*
    * 如字符串为：<h3><p><b>a</b></h3>，假设p未闭合，数组则为：array('left'=>array('h3','p','b'), 'right'=>'b','h3');
    * 仅补全 html 标签，<?php <% 等其它语言标记，会产生不可预知结果
    */
    for($i = 0; $i < $strlen_var; ++$i) { 
        if(!$lenth) break;  // 遍历完之后跳出
        $current_var = substr($str, $i, 1); // 当前字符
        if($current_var == '<'){ // html 代码开始 
            $html_tag = 1; 
            $html_array_str = ''; 
        }else if($html_tag == 1){ // 一段 html 代码结束 
            if($current_var == '>'){ 
                $html_array_str = trim($html_array_str); //去除首尾空格，如 <br / > < img src="" / > 等可能出现首尾空格
                if(substr($html_array_str, -1) != '/'){ //判断最后一个字符是否为 /，若是，则标签已闭合，不记录
                    // 判断第一个字符是否 /，若是，则放在 right 单元 
                    $f = substr($html_array_str, 0, 1); 
                    if($f == '/'){ 
                        $html_array['right'][] = str_replace('/', '', $html_array_str); // 去掉 '/' 
                    }else if($f != '?'){ // 若是?，则为 PHP 代码，跳过
                        // 若有半角空格，以空格分割，第一个单元为 html 标签。如：<h2 class="a"> <p class="a"> 
                        if(strpos($html_array_str, ' ') !== false){ 
                        // 分割成2个单元，可能有多个空格，如：<h2 class="" id=""> 
                        $html_array['left'][] = strtolower(current(explode(' ', $html_array_str, 2))); 
                        }else{ 
                        //若没有空格，整个字符串为 html 标签，如：<b> <p> 等，统一转换为小写
                        $html_array['left'][] = strtolower($html_array_str); 
                        } 
                    } 
                } 
                $html_array_str = ''; // 字符串重置
                $html_tag = 0; 
            }else{ 
                $html_array_str .= $current_var; //将< >之间的字符组成一个字符串,用于提取 html 标签
            } 
        }else{ 
            --$lenth; // 非 html 代码才记数
        } 
        $ord_var_c = ord($st[$i]); 
        switch (true) { 
            case (($ord_var_c & 0xE0) == 0xC0): // 2 字节 
                $result .= substr($str, $i, 2); 
                $i += 1; break; 
            case (($ord_var_c & 0xF0) == 0xE0): // 3 字节
                $result .= substr($str, $i, 3); 
                $i += 2; break; 
            case (($ord_var_c & 0xF8) == 0xF0): // 4 字节
                $result .= substr($str, $i, 4); 
                $i += 3; break; 
            case (($ord_var_c & 0xFC) == 0xF8): // 5 字节 
                $result .= substr($str, $i, 5); 
                $i += 4; break; 
            case (($ord_var_c & 0xFE) == 0xFC): // 6 字节
                $result .= substr($str, $i, 6); 
                $i += 5; break; 
            default: // 1 字节 
                $result .= $current_var; 
        } 
    } 
    if($html_array['left']){ //比对左右 html 标签，不足则补全
        $html_array['left'] = array_reverse($html_array['left']); //翻转left数组，补充的顺序应与 html 出现的顺序相反
        foreach($html_array['left'] as $index => $tag){ 
            $key = array_search($tag, $html_array['right']); // 判断该标签是否出现在 right 中
            if($key !== false){ // 出现，从 right 中删除该单元
                unset($html_array['right'][$key]); 
            }else{ // 没有出现，需要补全 
                $result .= '</'.$tag.'>'; 
            } 
        } 
    } 
    return $result.$replace; 
}

/** 
*对内容中的关键词添加链接 
*只处理第一次出现的关键词，对已有链接的关键不会再加链接，支持中英文 
*$content:string 原字符串 
*$keyword:string  关键词 
*$link:string,链接 
*/ 
function internal_keyword_link($content,$keyword,$link){
    //排除图片中的关键词 
    $content = preg_replace( '|(<img[^>]*?)('.$keyword.')([^>]*?>)|U', '$1%&&&&&%$3', $content);
	if(preg_match("/[\x7f-\xff]/", $keyword)){
		$regEx = '/(?!((<.*?)|(<a.*?)))('.$keyword.')(?!(([^<>]*?)>)|([^>]*?<\/a>))/si';
	}else{
		$regEx = '/(?!((<.*?)|(<a.*?)))(\b'.$keyword.'\b)(?!(([^<>]*?)>)|([^>]*?<\/a>))/si';
	}
	//$link = str_replace('../','',$link);
    $url="<a href='".$link."' class=\"internal\">".$keyword."</a>";  //添加带有internal标记的内链
    $content = preg_replace($regEx,$url,$content,-1);
    //还原图片中的关键词
    $content=str_replace('%&&&&&%',$keyword,$content);
	
    return $content;
}

/*对原来有内链关键词去掉链接*/
function clear_keyword_link($content,$keyword){
	//$regEx = '~<a.*?class="internal"[\s\S]*?</a>~';  //去掉带有internal标记的内链
    $regEx = '/<a[^>]+>('.$keyword.')[^>]+a>/';
    $content = preg_replace($regEx,$keyword,$content,-1);
    return $content;
}

/** 十六进制颜色 转 RGB */
function rgbToHex($hexColor) {
	$color = str_replace('#', '', $hexColor);
	if (strlen($color) > 3) {
		$rgb = array(
			'r' => hexdec(substr($color, 0, 2)),
			'g' => hexdec(substr($color, 2, 2)),
			'b' => hexdec(substr($color, 4, 2))
		);
	} else {
		$color = $hexColor;
		$r = substr($color, 0, 1) . substr($color, 0, 1);
		$g = substr($color, 1, 1) . substr($color, 1, 1);
		$b = substr($color, 2, 1) . substr($color, 2, 1);
		$rgb = array(
			'r' => hexdec($r),
			'g' => hexdec($g),
			'b' => hexdec($b)
		);
	}
	return $rgb;
}

/* 正则图片添加alt,title 标记
function addAltTitle($alt,$title,$str){
	$preg = "/<img.*?src=[\"|\'](.*?)[\"|\'].*?>/";
	$img = '<img src="$1" alt="'.$alt.'"title="'.$title.'">';
	return preg_replace($preg,$img,$str);
}*/
function addAltTitle($alt,$title,$str){
	 
	 $_SESSION['alt111']=$alt;
	 $_SESSION['title111']=$title;

 
    return preg_replace_callback( "/(<img.*?src=[\"|\'].*?[\"|\'].*?>)/",'callbackAddAltTitle',$str);
}

//addAltTitle 正则替换函数的 回调函数
function callbackAddAltTitle( $str1){
	$str2=$str1[1];
	$alt111=$_SESSION['alt111'];
	$title111=$_SESSION['title111'];

	 if(!preg_match ("/alt=[\"|\']/",$str2))
	 {$str2 =	str_replace("/>", 'alt="'.$alt111.'" />',$str2);}
	 else
	 {$str2 =	preg_replace("/alt=[\"|\']s*[\"|\']/", 'alt="'.$alt111.'"',$str2);}

	  if(!preg_match ("/title=[\"|\']/",$str2))

	 {$str2 =	str_replace("/>",  'title="'.$title111.'"  />',$str2);}
	 else
	 { $str2 =	preg_replace("/title=[\"|\']s*[\"|\']/", 'title="'.$title111.'"',$str2);}
    return ( $str2 );
}

// 没有标签的增加翻译标签
function transtag($file1,$file2)
{
 	global  $totalfile,$totalstr;
	require_once('inc/ls_syscode_ml.php');
	if(file_exists($file1)) 
	{
		 transtreatfile( $file1,$file2)	;
  	}
	return true;
}

function notranstag($file1,$file2)
{
	$file2= array("html","htm","js","php"); 
	$file3= array("ls_admin","images","css","inc","widget","vplayer","ueditor","styles","scripts","phpqrcode","qr","login-img","kindeditor-4.1.10","player","linkedin","img","font-awesome","code","bootstrap","backupdb","ls_mantain","mail","motif","revolvingpics","Templates","Templates1","video","update",".htaccess","update"); // 跳过文件夹
	
	if(in_array($file1,$file3)){return false;}

	if(in_array(getfileext($file1),$file2) )
	{return true;}
	else
	{
		return false;}
}
//


//mp4 视频将 <embed 换成<video mp4      
function videomp4($content ){   
				$vstart=stripos($content,"<embed ");
				if($vstart===false) return $content;
				$mp4pos=stripos($content,'.mp4',$vstart);
				$vsend=stripos($content,'/>',$vstart);
				if($mp4pos>$vstart&&$mp4pos<$vsend){$i++;}else return $content;  //控制返回
				
				$vend=$flvpos+strlen('type="video/flv"/>');
				$vsubstr=substr($content,$vstart,$vend-$vstart);
				$vsubstr1=substr($content,0,$vstart);  // 前半部分
				$vsubstr2=substr($content,$vend);   // 后半部分
				
				 
				$vfstart=stripos($vsubstr,'<source src="')+strlen('<source src="');
				$vfend=stripos($vsubstr,'.flv') ;
				$vfile=substr($vsubstr,$vfstart,$vfend-$vfstart-1);  //视频文件
}

function	deployvideo1($videostr,$i=1){  //uedit  上传视频 适合 flv 视频
			
				$vstart=stripos($videostr,"<video ");
				if($vstart===false) return $videostr;
				$flvpos=stripos($videostr,'type="video/flv"/>');
				if($i<=6&&$flvpos!==false){$i++;}else return $videostr;  //控制返回
				
				$vend=$flvpos+strlen('type="video/flv"/>');
				$vsubstr=substr($videostr,$vstart,$vend-$vstart);
				$vsubstr1=substr($videostr,0,$vstart);  // 前半部分
				$vsubstr2=substr($videostr,$vend);   // 后半部分
				
				 
				$vfstart=stripos($vsubstr,'<source src="')+strlen('<source src="');
				$vfend=stripos($vsubstr,'.flv') ;
				$vfile=substr($vsubstr,$vfstart,$vfend-$vfstart-1);  //视频文件
				//mecfocus.com/player/flvplayer.swf"
				$vstrstart=strpos($_SERVER["HTTP_REFERER"],$_SERVER['SERVER_NAME'])+strlen($_SERVER['SERVER_NAME']);
				$vstrlen=  strpos($_SERVER["HTTP_REFERER"],'ls_admin' )-$vstrstart-1;
				$vstr=substr($_SERVER["HTTP_REFERER"],$vstrstart,$vstrlen); 
				$vnew='
				<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> 
     	<li>
			<div id="player_box1"></div></li>
			<script type="text/javascript">
        var s1 = new SWFObject("'.$vstr.'/player/flvplayer.swf","single","450","300","10");
        s1.addParam("allowfullscreen","true");
        s1.addParam("wmode","transparent");
        s1.addVariable("file","'.$vfile.'");
        s1.addVariable("image","'.$vstr.'/video/cover.jpg");
        s1.addVariable("width","450");
        s1.addVariable("height","300");
        s1.write("player_box1");
    </script>
       </div>
';
	return ($vstart===false?$videostr:deployvideo($vsubstr1.$vnew.$vsubstr2,$i));
}

/*翻译模板*/
function transtpl($target,$wrtpl=true,$dirName="../Templates1"){
	global   $manualTrans,$mantplstr;
	//include_once("constant.php");
	if(file_exists($dirName) && $handle=opendir($dirName)){
		while(false!==($item = readdir($handle))){
			if($item!= "." && $item != ".."){
				if(file_exists($dirName.'/'.$item) && is_dir($dirName.'/'.$item)){
					echo " $dirName/$item 是文件夹! <br/>";
				}else{
					if($manualTrans){
						 transfile($item,$target,$wrtpl,$dirName);
						//if(strpos($mantplstr,$thisstr)===false) $mantplstr  .=$thisstr; //聚合 翻译串
					}
					else
					{
						if(transfile($item,$target,$wrtpl,$dirName)){
						}
					}
				}
			}
		}
		closedir( $handle);
	}
	//return $transstr;
}

// 翻译并写入文件 —— 通过谷歌在线翻译
function transfile($filename,$target="zh-CN",$wrtpl=true,$dirName){
	//require_once("simple_html_dom.php"); //加载simple_html_dom.php文件
	global   $manualTrans,$count_num,$translate_key,$simuTransLow,$mutiLangDomianFlag,$translate_name,$sleepSecond, $delayTrigSecond,$delayTrigByte,$delayTrigTimes,$transSplitLen,$mantplstr;  //constant
	$source="en";
 
	$api_key =$translate_key ;
	$scrFile=$dirName."/".$filename;
	//echo $scrFile."==".$target;

	if($manualTrans){  //手工翻译语种模板
		$scrFile=str_replace("../","../".$target."/", $scrFile) ;
		echo $scrFile."<br/>";
	}
	$fp = fopen($scrFile,"r");
	$newscontent  = fread($fp,filesize ($scrFile));
		 
	$folder_name = $target;
	$r_name = deep_in_array($folder_name, $translate_name);
	//$translateFile = "../".$r_name['folder_name']  ;
	$translateFile = "../".$target  ;
	if(!is_dir($translateFile )) mkdir($translateFile);
	$translateFile = $translateFile."/Templates1/";
	if(!is_dir($translateFile )) mkdir($translateFile); // 创建文件夹
	$translateFile = $translateFile.$filename;
	$translate_str = $newscontent;
	$p = "%<translate>(.*?)</translate>%si";    //正则表达式
	preg_match_all($p, $newscontent, $arr);
	$temarr = $arr[1];
	$targets = $target;

	foreach($temarr as $val){
		//$val1=trim($val);
		$var1len=strlen($val);
		
		if( strpos($val,"{")==0 && strrpos($val,"}")==$var1len-1) continue; // 标签退出
		$v1=strpos($val,"{");
		$v2=strpos($val,"}");
		if($v1>=0  && $v2>1 && $v2>$v1) continue;
 		if($manualTrans){   
			$val=str_replace("</translate>","",$val);
			$val=str_replace("<translate>","",$val);
			if(strpos($mantplstr,"999\r\n".$val)===false)$mantplstr.="999\r\n".$val."\r\n"; 
			//echo $val."<br/>";
		}
			  if(strlen($val)>$transSplitLen){
				  
				  //如果翻译的内容大于$transSplitLen，则进行分段
				  foreach(subpart($val, $transSplitLen, "utf-8") as $out_val){
					  //$count_num ++;
					  //echo "<h4 style='color:#00F'>".$count_num."</h4>";
					  $_SESSION['transTotal']+=strlen($out_val);
					  $obj = translate2($api_key,$out_val,$target,$source);
					  if($obj != null)
					  {
								  
						  if(isset($obj['error']))
						  {
							  if(isset($obj['data']['translations'][0]['detectedSourceLanguage'])) //this is set if only source is not available.
							  {
								  echo "Detecte Source Languge : ".$obj['data']['translations'][0]['detectedSourceLanguage']." ";
							  }
							  else
							  {	echo "Error  in translate online long word:<br/> $out_val <br/>";}
						  }
						  else
						  {
			  
							  $translate_val = $obj['data']['translations'][0]['translatedText']."";
							  $translate_str = str_replace($out_val, $translate_val, $translate_str);	
							  
						  }
			  
					  }
					  
				  }
				}
				else
				{
					  $_SESSION['transTotal']+=strlen($val);
					  $obj = translate2($api_key,$val,$target,$source);
					  //var_dump($obj );exit;
					  if($obj != null)
					  {
						  if(isset($obj['error']))
						  {
							   
							  if(isset($obj['data']['translations'][0]['detectedSourceLanguage'])) //this is set if only source is not available.
							  {
								  echo "Detecte Source Languge : ".$obj['data']['translations'][0]['detectedSourceLanguage']." ";
							  }
							  else
							  {	echo "Error in translate online short word : $val <br/>";}
						  }
						  else
						  {
								  $translate_val = $obj['data']['translations'][0]['translatedText']."";
								  //echo "<br/><br/><br/><translate>".$val."</translate><br/>".$translate_val;
								  $translate_str = str_replace("<translate>".$val."</translate>", $translate_val, $translate_str);
						  }
	  
					  }
			  }//if(strlen($val)>$transSplitLen){
/*		}  //if($manualTrans){  //手工翻译
*/	} //foreach($temarr as $val){
		
	if($wrtpl){ // 确定 后 写入模板
		$filename=$translateFile;
		//echo $filename."-目标 <br/>".$translate_str; exit;
		if (is_file ($filename)){
			 @unlink ($filename); //若文件已存在，则删除
		}
		$handle = fopen ($filename,"w"); //打开文件指针，
			//检查文件是否被创建且可写 
		if(!is_writable ($filename)){ 
			 echo "<script>alert('文件：".$filename."不可写，请检查其属性后重试！');history.go(-1);</script>";
		}
		if(!fwrite ($handle,$translate_str)){  //将信息写入文件
			echo $filename."  翻译 error";
			return false;
		}else{
			echo $filename."  ok, 已翻译".$_SESSION['transTotal']."字符 <br/> ";
			return true;
		}
	}
	fclose($handle);
}

//每个语种数据库写入同样一行内容
function insertmdb($sql)
{
	include("constant.php");
	include("conn.php");
	include("conn_var.php");
	$transa=explode(",",$transFlags);
	foreach($transa as $lang){
		$lang=trim($lang);
		$opendb2=new mydb($dbname."_".$lang);
		$query = $opendb2->query($sql);
		if($query) return true; else return false;
	}
}

//GOOGLE 在线翻译 文字段落翻译基础功能，无模拟翻译，查询块表、不查慢表
function translate2($api_key,$text,$target,$source=false)
{
		global   $manualTrans,$simuTransLow,$flagFastSlow,$simuTransCons,$sleepSecond, $delayTrigSecond,$delayTrigByte,$delayTrigTimes;
		$_SESSION['simuTrans']=$simuTransCons;

			$transFastStr=transfast($text,$target); //查快表，词组表
			if($manualTrans && !$transFastStr){
				$transFastStr=" [$target ERROR] ";
				//addtransfast($text,$target,$transFastStr,"menu"); // ERROR 增加到块表
			}
			// echo $text."==".$target; //exit;
			if(!$transFastStr )
			{
                        $thisSeconds=getmicrotime();
						$response = googleonlinetrans($text,$target); //翻译
						//echo $response ."==".$text; exit;
						
 						$obj =json_decode($response,true); //true converts stdClass to associative array.
						if (!isset($obj['error'])){  //翻译成功
							$thisBytes=strlen( $obj['data']['translations'][0]['translatedText']);
							$thisSeconds=getmicrotime()- $thisSeconds;
							$_SESSION['totalBytes']+= $thisBytes;
							$_SESSION['estimationBytes']+= $thisBytes;
							$_SESSION['totalSeconds']+= $thisSeconds;
							$_SESSION['estimationSeconds']  += $thisSeconds;
							$_SESSION['estimationTimes']  += 1;  
							$_SESSION['Times']+=1;


						    if(strlen($text)<$flagFastSlow) //增加快表内容
						    {addtransfast($text,$target,$obj['data']['translations'][0]['translatedText'],"menu");}
  						}
                                              
				
			}
			else
			{
				 $obj['data']['translations'][0]['translatedText']=$transFastStr;
				// echo $transFastStr." fast ok<br/>";
			}
		  return $obj;

}


/*翻译内容 $target 目标语言 $mod 不起作用*/
function transdt($target,$mod="all" ){
	global   $manualTrans,$mantplstr,$headlang;
	include_once('conn.php');

	$mantplstr=""; //手工翻译拼合串
	$headlang="";
	$opendb=new mydb();
	$myck=new cktb();

	$skiptitle=array("ID","Num","enable" ,"hsyear mobile", "email", "qq", "skype", "facebook", "tel", "linkedin", "twitter", "googleplus", "wechat", "menuLink", "static_tpl", "singlepage_name", "videoFile", "name", "post", "mobile", "functionName", "inMenu" ); // 与这些关键字相同的字段跳过  
	
	$skipinclude=array("ID","Num","enable","pic","path","Folders","width", "length", "date", "datetime", "clicks", "suffStr", "url", "specName", "specValue","Pic","Folder","PicPath","ItemNo","PicPath" , "reserve"); // 包含这些关键字的字段跳过 

	$skiptable=array("ls_admin","ls_agentcates","ls_agents","ls_branch","ls_config","ls_mobiconfig","ls_fetchpass","ls_instruction","ls_log","ls_right","ls_statistics","ls_tips","ls_transchange","ls_transfast","ls_transslow","ls_writefiles","ls_ver", "ls_mobiconfig", "ls_b2b_type", "ls_change","ls_comments","ls_config","ls_fetchpass","ls_functioncode","ls_mantain","ls_motif","ls_promote_en","ls_provincecity","ls_pro_feedback","ls_replace","ls_role", "ls_select_id", "ls_shop", "ls_tags", "ls_users", "ls_watermark", "partimages",   "ls_functioncates", "ls_menu", "ls_productsbak", "ls_prospec", "ls_transfast1"); // 
	
			$title_sql = "select * from ls_config";
			$title_query = $opendb->query($title_sql);
			$pro_value = mysqli_fetch_assoc($title_query);
		 
			$headlang.="999\r\n"."ls_config+companyName+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['companyName']."\r\n";   
			
			$headlang.="999\r\n"."ls_config+siteKeywords+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['siteKeywords']."\r\n";   
	
			$headlang.="999\r\n"."ls_config+siteDescription+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['siteDescription']."\r\n";  
	
			$headlang.="999\r\n"."ls_config+aboutus+1"."\r\n"; 		
			$langpathstr=str_replace('src="../../ls_admin','src="../ls_admin',$pro_value['aboutus']); //text 字段路径多语下加 ../
			$langpathstr=str_replace('src="../ls_admin','src="../../ls_admin',$langpathstr);
			$mantplstr.="999\r\n".$langpathstr."\r\n";  
	
			$headlang.="999\r\n"."ls_config+notice+1"."\r\n";  		
			$langpathstr=str_replace('src="../../ls_admin','src="../ls_admin',$pro_value['notice']); //text 字段路径多语下加 ../
			$langpathstr=str_replace('src="../ls_admin','src="../../ls_admin',$langpathstr);
			$mantplstr.="999\r\n".$langpathstr."\r\n";  
			
		 
		
 			$title_sql = "select * from ls_mobiconfig";
			$title_query = $opendb->query($title_sql);
			$pro_value = mysqli_fetch_assoc($title_query);
	 
			$headlang.="999\r\n"."ls_mobiconfig+companyName+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['companyName']."\r\n";   
			
			$headlang.="999\r\n"."ls_mobiconfig+siteKeywords+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['siteKeywords']."\r\n";   
	
			$headlang.="999\r\n"."ls_mobiconfig+siteDescription+1"."\r\n"; 		
			$mantplstr.="999\r\n".$pro_value['siteDescription']."\r\n";  
	
			$headlang.="999\r\n"."ls_mobiconfig+aboutus+1"."\r\n"; 		
			$langpathstr=str_replace('src="../../ls_admin','src="../ls_admin',$pro_value['aboutus']); //text 字段路径多语下加 ../
			$langpathstr=str_replace('src="../ls_admin','src="../../ls_admin',$langpathstr);
			$mantplstr.="999\r\n".$langpathstr."\r\n";  

		$i=0;
		$sqltable="show table status  ";
			$querytable=$opendb->query($sqltable);
			while($rowstable=mysqli_fetch_assoc($querytable))
		  	{				
				$tablename=trim($rowstable['Name']);
				 if($tablename=="")return;
				if(!strin($tablename,$skiptable))
				{
				  $pro_sql = "select * from ".$tablename;
				  $pro_query = $opendb->query($pro_sql);
				  while($pro_value = mysqli_fetch_array($pro_query)){
					  
					  if($myck->issetfield($tablename,"transflag"&& $updateTrans))
					  	if($myck->valueidfield($tablename,"transflag",$pro_value['ID'])==1)
							{echo $tablename." id: ".$pro_value['ID']." skipped. <br/>";continue ;}
					  // 如果只翻译更新的，而且本行已已翻译，跳过
					  $i++;
					  $sqlcolumns   ="show columns in  ".$tablename." "; 
					  $querycolumns   = $opendb->query($sqlcolumns); 
					  $ls_msg1="表".$tablename.":<br/>";
					  $ls_msg2="";

					  while($rowscolumns=mysqli_fetch_assoc($querycolumns))
		  				{		
							
							$fieldname=$rowscolumns['Field'];
							 //echo $tablename.$pro_value['ID'].$rowscolumns['Field']."<br/>";
							if($fieldname=="")continue;

							if(strpos($rowscolumns['Type'],"char") ===false && strpos($rowscolumns['Type'],"text") ===false)continue;
							
								if(!strin($fieldname,$skiptitle) &&!strinclude($fieldname,$skipinclude) )
								{
									//echo $ls_msg1.$fieldname.":".$rowscolumns['Type'];
									if($manualTrans){  //手工翻译
										if($pro_value[$fieldname]!=""){
											$headlang.="999\r\n". $tablename."+".$fieldname."+".$pro_value['ID']."\r\n"; 
											if(!(strpos($pro_value[$fieldname],"999\r\n"))) "<br/>999\r\n 已存在<br/>";
											if(!(strpos($pro_value[$fieldname],"999"))) "<br/>999 已存在<br/>";
											
											$langpathstr=str_replace('src="../../ls_admin','src="../ls_admin',$pro_value[$fieldname]);
											$langpathstr=str_replace('src="../ls_admin','src="../../ls_admin',$langpathstr); //text 字段路径多语下加 ../					
											// include("_inc_transdtclear.php");  // 替换内容文件

											$mantplstr.="999\r\n".$langpathstr."\r\n";  }  // $pro_value[$fieldname] char text 值
									}
								 
								}
						}
					}
					if( $ls_msg2==""){}  else {
						$ls_msg.= $ls_msg1.$ls_msg2."<br/>";
						//$ls_msg.= $ls_msg1.$ls_msg2."<br/><br/>";
					}
				}
				 
			}
			// 	echo  $mantplstr."11";
			if($ls_msg=="")$ls_msg="没有翻译任何表，任何字段"; else $ls_msg.=" 翻译完成！";
}

/*
$str 翻译字符串
$obj 目标语言
谷歌在线翻译
*/
function googleonlinetrans($str,$obj="zh-CN",$src="en"){
	$str=rawurlencode($str);
	$url='https://translate.google.cn/?sl='.$src.'&tl='.$obj.'&text='.$str.'#'.$src.'/'.$obj.'/'.$str.'';
	@set_time_limit(0);
	$html = "";
	$ch = curl_init();
	
	//var_dump($ch);
	$user_agent = "Mozilla/4.0";
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
	curl_setopt($ch, CURLOPT_HEADER,0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//禁止调用时就输出获取到的数据
	curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
	curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
	curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
	curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1");
	curl_setopt($ch, CURLOPT_PROXYPORT, "25378");  //http://127.0.0.1:25378/echo-pac?t=6262500 代理
	$html = curl_exec($ch);
	 echo $html."++ $str <br/>";
	if(curl_errno($ch))$html = "";
	curl_close($ch);
	
	if(!empty($html)){
		$x=explode("';var ctr, h;tld='",$html);
		$x=explode("TRANSLATED_TEXT='",$x[0]);
		
		return   ggdecode($x[1]);
	}else{
		return false;
	}
}
 
/*翻译内容 $target 目标语言 */
function transdt1($target,$mod="all" ){
	global   $manualTrans;
	include_once('conn.php');
	$opendb=new mydb();

	$mantplstr=""; //手工翻译拼合串
	switch($mod){
	
		case "all":
		case "all_products":
		case "products":
	//	var_dump($manualTrans);



 			$pro_sql = "select * from ls_products    ";
			$pro_query = $opendb->query($pro_sql);
			while($pro_value = mysqli_fetch_array($pro_query)){

				$replacedir_sql=sprintf("update ls_products set productSpecification=%s, characteristics=%s, advantages=%s, parameters=%s, cateBrief=%s, cateDetail=%s, midcateBrief=%s, midcateDetail=%s, subcateBrief=%s, subcateDetail=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$pro_value['productSpecification'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['characteristics'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['advantages'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['parameters'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['cateBrief'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['cateDetail'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['midcateBrief'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['midcateDetail'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['subcateBrief'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['subcateDetail'], $target),"text"),
						GetSQLValueString($pro_value['ID'],"int")
					);
				if($manualTrans){  //手工翻译
								 

					if($pro_value['productSpecification']!=""){$headlang="[{[".base64_encode("ls_products+productSpecification+".$pro_value['ID'])."]}]";			$mantplstr.=$headlang.$pro_value['productSpecification'];  }					
					if($pro_value['characteristics']!=""){$headlang="[{[".base64_encode("ls_products+characteristics+".$pro_value['ID'])."]}]";			$mantplstr.=$headlang.$pro_value['characteristics'];}
					if($pro_value['advantages']!=""){$headlang="[{[".base64_encode("ls_products+advantages+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['advantages'];}
					if($pro_value['parameters']!=""){$headlang="[{[".base64_encode("ls_products+parameters+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['parameters'];}
					if($pro_value['cateBrief']!=""){$headlang="[{[".base64_encode("ls_products+cateBrief+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['cateBrief'];}
					if($pro_value['midcateBrief']!=""){$headlang="[{[".base64_encode("ls_products+midcateBrief+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['midcateBrief'];}
					if($pro_value['cateDetail']!=""){$headlang="[{[".base64_encode("ls_products+cateDetail+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['cateDetail'];}
					if($pro_value['midcateDetail']!=""){$headlang="[{[".base64_encode("ls_products+midcateDetail+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['midcateDetail'];}
					if($pro_value['subcateDetail']!=""){$headlang="[{[".base64_encode("ls_products+subcateDetail+".$pro_value['ID'])."]}]";					$mantplstr.=$headlang.$pro_value['subcateDetail'];}
					
				}else{
					$replacedir_query=$opendb->query($replacedir_sql);
				}
			}
				 //echo $mantplstr."==="; exit;

 			$pro_sql = "select * from ls_propic  order by Num ";
			$pro_query = $opendb->query($pro_sql);
			while($pro_value = mysqli_fetch_array($pro_query)){
				$replacedir_sql=sprintf("update ls_products set picName  =%s, proTitle=%s  where id=%s",
						GetSQLValueString(translate2($translate_key,$pro_value['picName'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$pro_value['proTitle'], $target),"text"),
                        GetSQLValueString($pro_value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "singlepage":
		
			$singlepages_sql = "select * from ls_singlepages  order by Num ";
			$singlepages_query = $opendb->query($singlepages_sql);
			while($value = mysqli_fetch_array($singlepages_query)){
				$replacedir_sql=sprintf("update ls_singlepages set pageText=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['pageText'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //singlepage内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "news":

			$news_sql = "select * from ls_news  order by Num ";
			$news_query = $opendb->query($news_sql);
			while($value = mysqli_fetch_array($news_query)){
				$replacedir_sql=sprintf("update   ls_news   set newsText=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['newsText'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //news内容翻译
			}
			
		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "aboutus":
			
			$about_sql="select * from ls_information where inMenu='aboutus' order by ID";
			$about_query=$opendb->query($about_sql);
			$about_row=mysqli_fetch_array($about_query);
			$replacedir_sql=sprintf("update   ls_information  set content=%s where inMenu='aboutus' ",
					GetSQLValueString(translate2($translate_key,$about_row['content'], $target),"text")
				);
			$replacedir_query=$opendb->query($replacedir_sql);  //aboutus内容翻译
			

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "workshop":

			$workshop_sql = "select * from ls_workshop  order by Num ";
			$workshop_query = $opendb->query($workshop_sql);
			while($value = mysqli_fetch_array($workshop_query)){
				$replacedir_sql=sprintf("update   ls_workshop   set workshopText=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['workshopText'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //workshop内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "certificate":

			$certificate_sql = "select * from ls_certificate  order by Num ";
			$certificate_query = $opendb->query($certificate_sql);
			while($value = mysqli_fetch_array($certificate_query)){
				$replacedir_sql=sprintf("update   ls_certificate   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //certificate内容翻译
			}
			

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "qualitycontrol":

			$qualitycontrol_sql = "select * from ls_qualitycontrol  order by Num ";
			$qualitycontrol_query = $opendb->query($qualitycontrol_sql);
			while($value = mysqli_fetch_array($qualitycontrol_query)){
				$replacedir_sql=sprintf("update   ls_qualitycontrol   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //qualitycontrol内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "packing":


			$packing_sql = "select * from ls_packing  order by Num ";
			$packing_query = $opendb->query($packing_sql);
			while($value = mysqli_fetch_array($packing_query)){
				$replacedir_sql=sprintf("update   ls_packing   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //packing内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "rd":


			$rd_sql = "select * from ls_rd  order by Num ";
			$rd_query = $opendb->query($rd_sql);
			while($value = mysqli_fetch_array($rd_query)){
				$replacedir_sql=sprintf("update   ls_rd   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //rd内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		
		case "brand":
			$brand_sql = "select * from ls_brand  order by Num ";
			$brand_query = $opendb->query($brand_sql);
			while($value = mysqli_fetch_array($brand_query)){
				$replacedir_sql=sprintf("update   ls_brand   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //brand内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		
		case "faq":
			$brand_sql = "select * from ls_problem  order by Num ";
			$brand_query = $opendb->query($brand_sql);
			while($value = mysqli_fetch_array($brand_query)){
				$replacedir_sql=sprintf("update   ls_brand   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //brand内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		
		case "download":
			$brand_sql = "select * from ls_download  order by Num ";
			$brand_query = $opendb->query($brand_sql);
			while($value = mysqli_fetch_array($brand_query)){
				$replacedir_sql=sprintf("update   ls_brand   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //brand内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		
		case "history":
			$brand_sql = "select * from ls_download  order by Num ";
			$brand_query = $opendb->query($brand_sql);
			while($value = mysqli_fetch_array($brand_query)){
				$replacedir_sql=sprintf("update   ls_brand   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //brand内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		case "video":

			$brand_sql = "select * from ls_video  order by Num ";
			$brand_query = $opendb->query($brand_sql);
			while($value = mysqli_fetch_array($brand_query)){
				$replacedir_sql=sprintf("update   ls_brand   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //brand内容翻译
			}

		if($ls!="all" && $ls!="all_products"){
		//生成全部页面，不包括产品页，否则break 
			break;
		}
		
		case "management":
			$management_sql = "select * from ls_management  order by Num ";
			$management_query = $opendb->query($management_sql);
			while($value = mysqli_fetch_array($management_query)){
				$replacedir_sql=sprintf("update   ls_management   set Text=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['Text'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //management内容翻译
			}

		
	 	default:
			$article_sql = "select * from ls_article  order by Num ";
			$article_query = $opendb->query($article_sql);
			while($value = mysqli_fetch_array($article_query)){
				$replacedir_sql=sprintf("update  ls_article  set articleText=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['articleText'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //article内容翻译
		
			}
			
			$functioncates_sql = "select * from ls_functioncates  order by Num ";
			$functioncates_query = $opendb->query($functioncates_sql);
			while($value = mysqli_fetch_array($functioncates_query)){
				$replacedir_sql=sprintf("update   ls_functioncates   set brief=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['brief'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //functioncates内容翻译
			}

			$notice_sql="select * from ls_information where inMenu='notice' order by ID";
			$notice_query=$opendb->query($notice_sql);
			$notice_row=mysqli_fetch_array($notice_query);
			$replacedir_sql=sprintf("update   ls_information  set content=%s where inMenu='notice' ",
					GetSQLValueString(translate2($translate_key,$notice_row['content'], $target),"text")
				);
			$replacedir_query=$opendb->query($replacedir_sql);  //notice内容翻译
			
			$menu_sql = "select * from ls_menu  order by menuNum ";
			$menu_query = $opendb->query($menu_sql);
			while($value = mysqli_fetch_array($menu_query)){
				$replacedir_sql=sprintf("update   ls_menu   set description=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['description'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //menu内容翻译
			}

			$menu_sql = "select * from ls_links   order by linkNum ";
			$menu_query = $opendb->query($menu_sql);
			while($value = mysqli_fetch_array($menu_query)){
				$replacedir_sql=sprintf("update   ls_menu   set inTitle  =%s,   inKeywords   =%s,   inDescription   =%s,  menuName  =%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['inTitle'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$value['inKeywords'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$value['inDescription'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$value['menuName'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //menu内容翻译
			}

			$menu_sql = "select * from ls_banword  ";
			$menu_query = $opendb->query($menu_sql);
			while($value = mysqli_fetch_array($menu_query)){
				$replacedir_sql=sprintf("update   ls_banword   set banword=%s where id=%s",
						GetSQLValueString(translate2($translate_key,$value['banword'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //menu内容翻译
			}
			
			$menu_sql = "select * from ls_internal   order by Num ";
			$menu_query = $opendb->query($menu_sql);
			while($value = mysqli_fetch_array($menu_query)){
				$replacedir_sql=sprintf("update   ls_internal   set title =%s  where id=%s",
						GetSQLValueString(translate2($translate_key,$value['title'], $target),"text"),
						GetSQLValueString(translate2($translate_key,$value['memo'], $target),"text"),
						GetSQLValueString($value['ID'],"int")
					);
				$replacedir_query=$opendb->query($replacedir_sql);  //menu内容翻译
			}			

	} //switch
}

?>