<?php
// $ls="all" 生成全部，不包含产品页； $ls!="all_products" 生成全部，包含产品页；
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/admin.css" rel="stylesheet" type="text/css">
<title>无标题文档</title>
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
  <tr>
    <td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong><a href="" onclick="history.go(0);">模板管理</a></strong></font></div></td>
  </tr>
  <tr>
    <td height="213" valign="top" bgcolor="#dee7ff"><br />
      <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
        <tr bgcolor="#B9DAFF">
          <td style="padding-left:10px;" >
<?php
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/public.php'); //main menu & left menu
	require_once('inc/ls_syscode.php');
	require_once('inc/ls_m_syscode.php');
	
	$ls=$_GET['ls'];
	$cateid=$_GET['cateid'];
	$cateFolders=$_GET['cateFolders'];
	$midcateid=$_GET['midcateid'];
	$midcateFolders=$_GET['midcateFolders'];
	$subcateid=$_GET['subcateid'];
	$subcateFolders=$_GET['subcateFolders'];
	$menuListscateid=$_GET['menuListscateid'];	//global ver in ls_syscode
	//主菜单 start
	// public.php
	//主菜单 end
	
// 获得某类下第一个产品的记录 for get_allcatepics
function get_product_class_rows($classpro_rowsID)
{
			require_once('inc/conn.php');
			$opendb=new mydb();
			require_once('inc/char_set.php');

			$product_class_sql="select * from ls_products where branchID=0 and productID=".$classpro_rowsID." and AdditionalAttributesClassPro&1   order by Num ASC";	//定义 AdditionalAttributesClassPro 属性
			$product_class_query=$opendb->query($product_class_sql);
		  	$product_class_num=mysql_num_rows($product_class_query);
			if($product_class_num>=1) //已定义classpro 展示产品
			{
				$product_class_rows=mysql_fetch_assoc($product_class_query);
			}
			else  //未定义classpro 展示产品，直接选一个
			{
				$product_class_sql="select * from ls_products where  branchID=0 and productID=".$classpro_rowsID." and enable=1  order by ID desc";
				$product_class_query=$opendb->query($product_class_sql);
		  		$product_class_num=mysql_num_rows($product_class_query);
				if($product_class_num>=1) //已定义classpro 展示产品
				{
					$product_class_rows=mysql_fetch_assoc($product_class_query);
				}
			}
			return $product_class_rows;
}
	
// 获得某类下所有产品的图片及连接
function get_product_cate_pics($catepics_rowsID,$thisfolder)
{
			$s_catepics="";
			require_once('inc/conn.php');
			$opendb=new mydb();
			require_once('inc/char_set.php');
			global $ls_catepicsPicW;

				$catepics_sql="select * from ls_products where branchID=0 and  productID=".$catepics_rowsID." and enable=1  order by ID desc";
				$catepics_query=$opendb->query($catepics_sql);
		  		$catepics_num=mysql_num_rows($catepics_query);
				if($catepics_num>=1) //已定义catepics 展示产品
				{
					while($catepics_rows=mysql_fetch_assoc($catepics_query))
					{
						$catepics_piclink=getpiclink($catepics_rows['ID'],$catepics_rows['productPic']); //
						//echo $catepics_rows['ID']."--".$catepics_piclink['picsrc']; // /thumbnails/1361107436.jpg  带/
			
						$s_catepics.="<li class=\"class_dt\"><a href=\"../".$thisfolder.$catepics_piclink['piclink']."\"><img src='../".$thisfolder.$catepics_piclink['picsrc']."' width='".$ls_catepicsPicW."' border='0'></a> </li> \r\n";	//每类产品一行
						//echo $s_catepics;
						
					}
				}
				else
				{
					//$s_catepics="No products in cate ".$catepics_rowsID;
				}

			return $s_catepics;
}

// get_catepics 首页多类产品列表，每类一行图片
function get_allcatepics()
{
		require_once('inc/conn.php');
		$opendb=new mydb();
		require_once('inc/char_set.php');
		$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=mysql_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=mysql_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']."/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=mysql_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=mysql_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']."/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=mysql_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=mysql_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;
}
	//左侧产品类别 Start
	// public.php	
	//左侧产品类别 End
	
	//产品页面左侧产品类别 Start
	// public.php
	//左侧产品页面产品类别 End
	
	
	
	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$config_row=mysql_fetch_array($tem_query);
	//print_r($row);exit;
	$templates_var = $config_row['templates'];
	
	$mobi_tem_sql="select * from ls_mobiconfig order by ID";	
	$mobi_tem_query=$opendb->query($mobi_tem_sql);
	$mobi_row=mysql_fetch_array($mobi_tem_query);
	$mobi_templates_var = $mobi_templates;

	//首页新闻列表 Start
	$sort='';
	if($newsSort=="ID") {
		$sort = "ID";
	}else if($newsSort=="Num"){
		$sort = "Num";
	}else{
		$sort = "ID";
	}
	$news_sql="select * from ls_news order by $sort desc limit 0,".$newsNum."";
	$news_query=$opendb->query($news_sql);
	//equire_once('inc/char_set.php');

	$i=1;
	while($news_rows=mysql_fetch_assoc($news_query)){
		$news.="<li><a href=\"".$newsshowFolders."/news".$news_rows['ID'].".html\">".$news_rows['newsTitle']." </a>";
		$news.="</li>";
		$i++;
	}
	//首页新闻列表 End
	
	//首页常见问题列表 Start
	$sort='';
	if($newsSort=="ID") {
		$sort = "ID";
	}else if($newsSort=="Num"){
		$sort = "Num";
	}else{
		$sort = "ID";
	}
	$problem_sql="select * from ls_problem order by $sort desc limit 0,".$newsNum."";	
	$problem_query=$opendb->query($problem_sql);
	//equire_once('inc/char_set.php');

	$i=1;
	while($problem_rows=mysql_fetch_assoc($problem_query)){
		$problem.="<li><a href=\"".$problemshowFolders."/problem".$problem_rows['ID'].".html\">".$problem_rows['problemTitle']."  (".$problem_rows['problemDate'].")</a>";
		$problem.="</li>";
		$i++;
	}
	//首页常见问题列表 End
	
//类产品展示 Start, selectPic 或者默认 后台每类选择图片 文字水命并排序
	
if($ls_classproType=="selectPic" || $ls_classproType=="")
{

	$products_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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributesClassPro&1 and enable=1";
	$products_sql.=" order by NoClassPro asc";
	$products_query=$opendb->query($products_sql);
	$classpro="";
	while($products_rows=mysql_fetch_assoc($products_query)){
					
		if(hassameclass($products_rows['productID'])){
			continue;
		}
		
		$p_id = $products_rows['productID'];
		$sql2 = "select * from ls_products where ID = ".$p_id." ";
		$products_query2=$opendb->query($sql2);
		
		$catename_query = mysql_fetch_assoc($products_query2);
		if(!$catename_query['subcateName']){
			if(!$catename_query['midcateName']){
				//只有大类
				$class_name = $catename_query['cateName'];
			}else{
				//有大类、有中类
				//获得关于中类的记录
				$search_catename2 = "SELECT * FROM ls_products WHERE ID={$catename_query[midcateID]}";
				$catename_query2 = mysql_fetch_assoc($opendb->query($search_catename2));
				
				$class_name = $catename_query['midcateName'];
			}
		}else{
			//有大类、有中类、有小类
			//获得关于中类的记录
			$search_catename2 = "SELECT * FROM ls_products WHERE ID={$catename_query[subcateID]}";
			$catename_query2 = mysql_fetch_assoc($opendb->query($search_catename2));
			
			//获得关于大类的记录
			$search_catename3 = "SELECT * FROM ls_products WHERE ID={$catename_query2[midcateID]}";
			$catename_query3 = mysql_fetch_assoc($opendb->query($search_catename3));
			
			$class_name = $catename_query['subcateName'];
		}
		
		
		$profile=getproductfolder($products_rows['productID']);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
	//$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html"; 原来类产品链接
		$prolink=$profile."/index.html";//类分类的链接
		$classpro.="<li><a href=\"".$prolink."\" ><img src=\"".$prosrc."\" width=\"188\" height=\"188\" border=\"0\" alt=\"".$class_name."\" title=\"".$class_name."\"></a><span>".$class_name."</span></li>";
	}		
}	
	
	//类产品展示 End
	
	//类产品展示 Start
	//默认 $ls_classproType="picIntro" 或空 是图片列表
	if($ls_classproType=="pic" )
	{
		$products_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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributesClassPro&1 and enable=1";
		$products_sql.=" order by NoClassPro asc";
		$products_query=$opendb->query($products_sql);
		$classpro="";
		while($products_rows=mysql_fetch_assoc($products_query)){
					
			if(hassameclass($products_rows['productID'])){
			continue;
			}
		
			$p_id = $products_rows['productID'];
			$sql2 = "select * from ls_products where ID = ".$p_id." ";
			$products_query2=$opendb->query($sql2);
			$products_rows2=mysql_fetch_assoc($products_query2);
			
			$class_name = "";
			if($products_rows2['cateBrief'] != null){
				$class_name = $products_rows2['cateName'];
			}elseif($products_rows2['midcateBrief'] != null){
				$class_name = $products_rows2['midcateName'];
			}elseif($products_rows2['subcateBrief'] != null){
				$class_name = $products_rows2['subcateName'];
			}
			
			$pro_i++;
			$profile=getproductfolder($products_rows['productID']);
			$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
					//$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html"; 原来类产品链接
			$prolink=$profile."/index.html";//类分类的链接
			$classpro.="<li><a href=\"".$prolink."\" ><img src=\"".$prosrc."\" width=\"188\" height=\"188\" border=\"0\" alt=\"".$class_name."\" title=\"".$class_name."\"></a><span>".$class_name."</span></li>";
		}		
	}
	
// $ls_classproType="picIntro" 是图片文字列表
if($ls_classproType=="picIntro")
	{
		$s_classpro="";
		$classpro_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";
		$classpro_query=$opendb->query($classpro_sql);
		//$s_classpro="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		$s_classpro.="<ul class=\"classpro_list\">";
		while($classpro_rows=mysql_fetch_assoc($classpro_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=".$classpro_rows['ID']." order by Num asc";
		  $pro_midcate_query=$opendb->query($pro_midcate_sql);
		  $pro_midcate_num=mysql_num_rows($pro_midcate_query);
	  
		  if($pro_midcate_num==0)//大类
		  {
		//$s_classpro.="&nbsp;<img src='../Templates/images/cate.gif' border='0'> \n";
		//$s_classpro.="\n<dt>".$classpro_rows['cateName']."</dt>";
			////
			if($classpro_rows['ID']=="")continue; //没有跳过循环
			$product_class_rows=get_product_class_rows($classpro_rows['ID']);
			$product_class_piclink=getpiclink($product_class_rows['ID'],$product_class_rows['productPic']); //
			//echo $classpro_rows['ID']."--".$product_class_piclink['picsrc']; // /thumbnails/1361107436.jpg  带/
			
			if($product_class_piclink['picsrc'] == null){
				$s_classpro.="<li class=\"class_dt\"><a href=\"../".$classpro_rows['cateFolders']."/index.html\"><img src='ls_admin/images/NoPictures_en.jpg' width='".$ls_classproPicW."' border='0'></a> <a id='classpro_list_a2' href=\"../".$classpro_rows['cateFolders']."/index.html\"><strong>".$classpro_rows['cateName']."</strong></a></li> \r\n";	
			}else{
				$s_classpro.="<li class=\"class_dt\"><a href=\"../".$classpro_rows['cateFolders']."/index.html\"><img src='../".$classpro_rows['cateFolders'].$product_class_piclink['picsrc']."' width='".$ls_classproPicW."' border='0'></a> <a id='classpro_list_a2' href=\"../".$classpro_rows['cateFolders']."/index.html\"><strong>".$classpro_rows['cateName']."</strong></a></li> \r\n";	
			}

			// $s_classpro.="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		  } 
		  else//大类中类
		  {
			//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/cate.gif' border='0'> \n";  //大类引导图
			$detailsfile="../".$classpro_rows['cateFolders']."/indexdetails.html";
			if(file_exists($detailsfile))
			{$s_classpro.=" <dt><a href='".$detailsfile."'>".$classpro_rows['cateName']."</a></dt>\r\n";}
			else
			{
				if($classpro_rows['ID']=="")continue; //没有跳过循环

				$product_class_rows=get_product_class_rows($classpro_rows['ID']);
				$product_class_piclink=getpiclink($product_class_rows['ID'],$product_class_rows['productPic']);
				//echo $product_class_piclink['picsrc'];
			
				//$s_classpro.="<li id=\"classpro_list_li_title\"> <strong>".$classpro_rows['cateName']."</strong></li> \r\n";	
				//有图：
				//$s_classpro.="<li class=\"class_dt\"><img src='../".$classpro_rows['cateFolders'].$product_class_piclink['picsrc']."' width='".$ls_classproPicW."' border='0'> <strong>".$classpro_rows['cateName']."</strong></li> \r\n";	
			}

				//$s_classpro.=" <li class=\"class_dt\"><img src='../".$templates_var."/images/006.gif' width='12' border='0'> <strong>".$classpro_rows['cateName']."</strong><ul>\r\n";}
		
				//？ 不应该有$s_classpro.="\n <div class=\"cate_list\">\n";
				while($pro_midcate_rows=mysql_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=mysql_num_rows($pro_subcate_query); 

				//$s_classpro.="<div class=\"midcate_list\">"; //中类菜单样式
	
					if($pro_subcate_num==0)//没小类
					{
						if($pro_midcate_rows['ID']=="")continue; //没有跳过循环

						$product_class_rows=get_product_class_rows($pro_midcate_rows['ID']);
						$product_class_piclink=getpiclink($product_class_rows['ID'],$product_class_rows['productPic']);
						
						if($product_class_piclink['picsrc'] == null){
							$s_classpro.="<li class=\"class_dt\"> <a href='../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders']."/index.html'><img src='ls_admin/images/NoPictures_en.jpg' width='".$ls_classproPicW."' border='0'></a>  <a id='classpro_list_a2' href='../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders']."/index.html'><strong>".$pro_midcate_rows['midcateName']."</strong></a></li> \r\n";
						}else{
							$s_classpro.="<li class=\"class_dt\"> <a href='../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders']."/index.html'><img src='../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders'].$product_class_piclink['picsrc']."' width='".$ls_classproPicW."' border='0'></a>  <a id='classpro_list_a2' href='../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders']."/index.html'><strong>".$pro_midcate_rows['midcateName']."</strong></a></li> \r\n";
						}

					//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n";  //中类引导图
				//	$s_classpro.="<li><img src='Templates1/images/name_prefix.gif' border='0'> <a href='../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/index.html'>".$pro_midcate_rows['midcateName']."</a></li>\r\n";
					}
					else//有小类
					{
					//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n"; //中类引导图
						$detailsfile="../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateName']."/indexdetails.html";
						if(file_exists($detailsfile))
						{$s_classpro.="<a href='".$detailsfile."'>".$pro_midcate_rows['midcateName']."</a>\r\n";}
						else
						{
							if($pro_midcate_rows['ID']=="")continue; //没有跳过循环
							$product_class_rows=get_product_class_rows($pro_midcate_rows['ID']);
							$product_class_piclink=getpiclink($product_class_rows['ID'],$product_class_rows['productPic']);
				
							//$s_classpro.="<li id=\"classpro_list_li_title\">  <strong>".$pro_midcate_rows['midcateName']."</strong></li> \r\n";			
							//有图：
							//$s_classpro.="<li class=\"class_dt\"><img src='../".$classpro_rows['cateFolders'] .$pro_midcate_rows['midcateFolders'].$product_class_piclink['picsrc']."' width='".$ls_classproPicW."' border='0'>  <strong>".$pro_midcate_rows['midcateName']."</strong></li> \r\n";			

					//$s_classpro.="\n<dd><a href='javascript:void(0)'>".$pro_midcate_rows['midcateName']."</a>\n<ul>\r\n";
					
						}
				//$s_classpro.="<div class=\"subcate_list\">";//小类菜单样式
						while($pro_subcate_rows=mysql_fetch_assoc($pro_subcate_query))		//小类生成
						 {
					
							if($pro_subcate_rows['ID']=="")continue; //没有跳过循环
							$product_class_rows=get_product_class_rows($pro_subcate_rows['ID']);
							$product_class_piclink=getpiclink($product_class_rows['ID'],$product_class_rows['productPic']);
							
							if($product_class_piclink['picsrc'] == null){
								$s_classpro.="<li class=\"class_dt\"><a href=\"../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders'] ."/".$pro_subcate_rows['subcateFolders']."/index.html\" ><img src='ls_admin/images/NoPictures_en.jpg' width='".$ls_classproPicW."' border='0'></a>  <strong><a id='classpro_list_a2' href=\"../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders'] ."/".$pro_subcate_rows['subcateFolders']."/index.html\" >".$pro_subcate_rows['subcateName']."</a></strong></li>  \r\n";
							}else{
								$s_classpro.="<li class=\"class_dt\"><a href=\"../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders'] ."/".$pro_subcate_rows['subcateFolders']."/index.html\" ><img src='../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/".$pro_subcate_rows['subcateFolders'].$product_class_piclink['picsrc']."' width='".$ls_classproPicW."' border='0'></a>  <strong><a id='classpro_list_a2' href=\"../".$classpro_rows['cateFolders'] ."/".$pro_midcate_rows['midcateFolders'] ."/".$pro_subcate_rows['subcateFolders']."/index.html\" >".$pro_subcate_rows['subcateName']."</a></strong></li>  \r\n";
							}

					//$s_classpro.="<li><a href=\"../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/".$pro_subcate_rows['subcateFolders']."/index.html\" >".$pro_subcate_rows['subcateName']."</a></li>\r\n";
						 }
						$s_classpro.=" \n\r\n"; 
					} 
			}
			$s_classpro.="  \r\n";
		  }//if($pro_midcate_num==0)//dalei
	
		}
		$s_classpro.="</ul>\r\n ";
		$classpro=str_replace("../","",$s_classpro);//cate

	}

	// $ls_classproType="cateList" 产品分类展开列表
	if($ls_classproType=="cateList"  )
	{	
		$s_classpro="";
		$classpro_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";
		$classpro_query=$opendb->query($classpro_sql);
		//$s_classpro="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		$s_classpro.="<ul class=\"ls_classpro\">";
		while($classpro_rows=mysql_fetch_assoc($classpro_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=".$classpro_rows['ID']." order by Num asc";
		  $pro_midcate_query=$opendb->query($pro_midcate_sql);
		  $pro_midcate_num=mysql_num_rows($pro_midcate_query);
	  
		  if($pro_midcate_num==0)//大类
		  {
		//$s_classpro.="&nbsp;<img src='../Templates/images/cate.gif' border='0'> \n";
		//$s_classpro.="\n<dt>".$classpro_rows['cateName']."</dt>";
		
			$s_classpro.="<li><img src='../".$templates_var."/images/name_prefix.gif' border='0'> <a href='../".$classpro_rows['cateFolders']."/index.html'>".$classpro_rows['cateName']."</a></li><ul> \r\n";
			// $s_classpro.="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		  } 
		  else//大类中类
		  {
			//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/cate.gif' border='0'> \n";  //大类引导图
			$detailsfile="../".$classpro_rows['cateFolders']."/indexdetails.html";
			if(file_exists($detailsfile))
			{ 	$s_classpro.=" <dt><a href='".$detailsfile."'>".$classpro_rows['cateName']."</a></dt>\r\n";}
			else
			{	$s_classpro.=" <li><img src='../".$templates_var."/images/name_prefix.gif' border='0'> <a href='javascript:void(0)'>".$classpro_rows['cateName']."</a><ul>\r\n";}
		
			//？ 不应该有$s_classpro.="\n <div class=\"cate_list\">\n";
				while($pro_midcate_rows=mysql_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=mysql_num_rows($pro_subcate_query); 

				//$s_classpro.="<div class=\"midcate_list\">"; //中类菜单样式
	
					if($pro_subcate_num==0)//没小类
					{
					//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n";  //中类引导图
						$s_classpro.="<li><a href='../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/index.html'>".$pro_midcate_rows['midcateName']."</a></li>\r\n";
					}
					else//有小类
					{
					//$s_classpro.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n"; //中类引导图
						$detailsfile="../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateName']."/indexdetails.html";
						if(file_exists($detailsfile))
						{$s_classpro.="<a href='".$detailsfile."'>".$pro_midcate_rows['midcateName']."</a>\r\n";}
						else
						{$s_classpro.="\n<dd><a href='javascript:void(0)'>".$pro_midcate_rows['midcateName']."</a>\n<ul>\r\n";}
					//$s_classpro.="<div class=\"subcate_list\">";//小类菜单样式
						while($pro_subcate_rows=mysql_fetch_assoc($pro_subcate_query))		//小类生成
						{
							$s_classpro.="<li><a href=\"../".$classpro_rows['cateFolders']."/".$pro_midcate_rows['midcateFolders']."/".$pro_subcate_rows['subcateFolders']."/index.html\" >".$pro_subcate_rows['subcateName']."</a></li>\r\n";
						 }
					$s_classpro.="</ul>\n</dd>\r\n"; 
					}
				}
				$s_classpro.="</ul></li>\r\n";
			  }//if($pro_midcate_num==0)//dalei
	
		}
		$s_classpro.="</ul>\r\n ";
		//echo $s_classpro;
		$classpro=str_replace("../","",$s_classpro);//cate
	}
	//类产品展示 End
	
	
	//首页产品展示 Start
	$products_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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributes&1 and enable=1";
	$products_sql.=" order by No asc ";
	$products_query=$opendb->query($products_sql);
	$homepro="";
	$count=1;
	while($products_rows=mysql_fetch_assoc($products_query)){
		if(hassameclass($products_rows['productID'])){
			continue;
		}
		$pro_i++;
		$profile=getproductfolder($products_rows['productID']);
		
		$hotprofilenamearray = explode("/", strrev($profile));
		$hotprofilename = strrev($hotprofilenamearray[0]);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
		$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";
		
		$homepro.="<li><a href=\"".$profile."/".getproductpath($products_rows['productID']).".html?menuId=".$products_rows['productID']."\" target=\"_blank\" ><img src=\"".$prosrc."\"  border=\"0\" alt=\"".$products_rows['productName']."\" title=\"".$products_rows['productItemNo']."\" class='homepro' ></a><span><a href=\"".$profile."/".getproductpath($products_rows['productID']).".html?menuId=".$products_rows['productID']."\" target=\"_blank\" class='pn' title='".$products_rows['productItemNo']."'>".$products_rows['productItemNo']."</a></span></li>";
		$count++;
	}
	//首页产品展示 End

	//热点产品展示 Start
	$products_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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributes&2 and enable=1";
	$products_sql.=" order by Num asc";
	$products_query=$opendb->query($products_sql);
	$hotpro="";
	while($products_rows=mysql_fetch_assoc($products_query)){
		if(hassameclass($products_rows['productID'])){
			continue;
		}
		$pro_i++;
		$profile=getproductfolder($products_rows['productID']);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
		$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";


		$hotpro.="<div class=\"proall\">";
		$hotpro.="<div class=\"proPic\" >";
		$hotpro.="<a href=\"".$prolink."\" target=\"_blank\"><img src=\"".$prosrc."\" border=\"0\" alt=\"".$products_rows['productName']."\" /></a>";
		$hotpro.="</div>";
		$hotpro.="<div class=\"proItem\" ><a href=\"".$prolink."\" target=\"_blank\">".$products_rows['productName']."</a></div>";
		$hotpro.="<div class=\"proItem\" ><a href=\"".$prolink."\" target=\"_blank\">".$products_rows['productItemNo']."</a></div>";
		$hotpro.="</div>";
		
	}
	//热点产品展示 End

	//主题图
	$motif_sql="select * from ls_motif where enable=1 order by Num desc ";
	$motif_query=$opendb->query($motif_sql);
	
	$s_motif_cate.="
		<ul class=\"slides_container\">";
	while($motif_rows=mysql_fetch_assoc($motif_query))
	{
		$s_motif_cate.="
			<li _src=\"url(../".$MotifFolders."/".$BigFoldersProducts."/".$motif_rows['motifPic'].")\" style=\"background:#dddddd center 0 no-repeat;\"><a target=\"_blank\" href=\"javascript:void(0)\"></a></li>";
	}
	$s_motif_cate.="
		</ul>\n ";
	
	$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
	
	//主题图 End


	//新产品展示 Start 2011-2-22 修正 img标签 结束错误
	$products_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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributes&4 and enable=1";
	$products_sql.=" order by Num asc ";
	$products_query=$opendb->query($products_sql);
	$newpro="";
	while($products_rows=mysql_fetch_assoc($products_query)){
		if(hassameclass($products_rows['productID'])){
			continue;
		}
		$pro_i++;
		$profile=getproductfolder($products_rows['productID']);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
		$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";


		$newpro.="<div class=\"proall\">";
		$newpro.="<div class=\"proPic\" >";
		$newpro.="<a href=\"".$prolink."\" target=\"_blank\"><img src=\"".$prosrc."\" border=\"0\" alt=\"".$products_rows['productName']."\" /></a>";
		$newpro.="</div>";
		$newpro.="<div class=\"proItem\" ><a href=\"".$prolink."\" target=\"_blank\">".$products_rows['productName']."</a></div>";
		$newpro.="<div class=\"proItem\" ><a href=\"".$prolink."\" target=\"_blank\">".$products_rows['productItemNo']."</a></div>";
		$newpro.="</div>";
		
	}																		
	//新产品展示 End
	
	
	$about=mb_substr($config_rows['aboutus'],0,$config_rows['aboutLenght'],'utf-8').((strlen($config_rows['aboutus'])>$config_rows['aboutLenght'])?" <a href=\"aboutus.html\">(More...)</a>":"");
	$allabout=$config_rows['aboutus'];
	
	$file_welcome="../".$templates_var."/welcome.html";	//模板地址
	$ls_title=$config_rows['companyName'];					//title
	$ls_keywords=$config_rows['siteKeywords'];				//Keywords
	$ls_description=$config_rows['siteDescription'];		//Description
	
	if(file_exists($file_welcome)){
		$fp = fopen($file_welcome,"r");
		$procontent  = fread($fp,filesize($file_welcome));
		$procontent  = str_replace("../","/",$procontent);
		$procontent  = str_replace("{ls_title}",$ls_title,$procontent);
		$procontent  = str_replace("{ls_keywords}",$ls_keywords,$procontent);
		$procontent  = str_replace("{ls_description}",$ls_description,$procontent);
		$procontent  = str_replace("{ls_s_cate}",$s_cate,$procontent);
		$procontent  = str_replace("{ls_site_cate}",$site_cate1,$procontent);

		$profilename="../welcome.html";
		if (is_file ($profilename)){ 
			@unlink ($profilename); //若文件已存在，则删除
		}
		$handle   = fopen($profilename,"w"); //打开文件指针，
		/*
		　检查文件是否被创建且可写
		*/
		if (!is_writable ($profilename)){ 
			echo "文件：".$profilename."不可写，请检查其属性后重试！";
		}
		if (!fwrite ($handle,$procontent)){  //将信息写入文件
			echo "".$profilename."失败！";
		}else{
			echo "生成 <a href='".$profilename."'>".$profilename."</a><br>";
		}
		fclose ($handle); //关闭指针
		//die ("创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a>");
		fclose ($fp);
	}
	
	switch($ls){
		case "all_products": //生成全部页面，包括产品页，否则break	
		case "products":  //生成产品页 products
			//echo "<h1>".$ls."</h1>";
			$menuListscateidall=0;
			/*$cate_sql="select * from ls_products where midcateID is null 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";*/
			//查找大类的SQL语句
			$cate_sql = 'SELECT * FROM `ls_products` WHERE cateName IS NOT NULL';
			$cate_query=$opendb->query($cate_sql);
			while($cate_rows=mysql_fetch_assoc($cate_query)){
				if($_GET['productsall']=="ok"){
					$cateid=$cate_rows['ID'];
					$menuListscateid=0;
				}
				$products_sql_p="select * from ls_products where branchID=0 and midcateID 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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null ";
				//大类
				if( $cateid!="" && $midcateid=="" && $subcateid=="" ){
					//大类下有中类
					//echo "<h1>".$cateid."</h1>";
					$sqlstr1="SELECT `ID` FROM `ls_products` WHERE midcateID=".$cateid;
					$query1=$opendb->query($sqlstr1);
					$mynum1=mysql_num_rows($query1);
					if($mynum1!=0){
						//有中类
						$DetailPage=1;
						writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);// write 所有大枝类的details
						$DetailPage=0; //reset flag
			
						$menuListscateidall++;
						if($_GET['productsall']=="ok"){$menuListscateid=$menuListscateidall;}		// if it is all products set $menuListscateid
						while($myrows1=mysql_fetch_assoc($query1)){
							$sqlstr2="select ID from ls_products where subcateID =".$myrows1['ID']." ";
							$query2=$opendb->query($sqlstr2);
							$mynum2=mysql_num_rows($query2);
							if($mynum2!=0){
								//有小类
								$midcateid=$myrows1['ID'];
								$mid_id = $midcateid;
								$DetailPage=1;
								writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);// write 所有中枝类的details
								$DetailPage=0; //reset flag
			
								while($myrows2=mysql_fetch_assoc($query2)){
									$productID=" productID=".$myrows2['ID'];
									$products_sql=$products_sql_p." and ".$productID;
									$subcateid=$myrows2['ID'];
									$midcateid = $mid_id;
									writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
									$midcateid="";
									$subcateid="";
								}
							}
							else{
								//没有小类
								$productID=" productID=".$myrows1['ID'];
								$products_sql=$products_sql_p." and ".$productID;
								$midcateid=$myrows1['ID'];
								writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
								$midcateid="";
							}
						}
					}
					else{
						$products_sql=$products_sql_p." and productID=".$cateid;
						writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
					}
				}
			
				
				//中类
				if($cateid!="" && $midcateid!="" && $subcateid==""){
					//中类下有小类
					$sqlstr="select ID from ls_products where subcateID =".$midcateid." ";
					$query1=$opendb->query($sqlstr);
					$mynum=mysql_num_rows($query1);
					if($mynum!=0){
						while($myrows=mysql_fetch_assoc($query1)){
								$productID=" productID=".$myrows['ID'];
								$products_sql=$products_sql_p." and ".$productID;
								$subcateid=$myrows['ID'];
								writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
								$subcateid="";
						}
					}
					else{
						//中类下没有小类
						$products_sql=$products_sql_p." and productID=".$midcateid;
						writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
			
					}
				}
				//小类
				if($cateid!="" && $midcateid!=""&& $subcateid!=""){
					$products_sql=$products_sql_p." and productID=".$subcateid;
					writeProPageIndex($products_sql,$cateid,$midcateid,$subcateid);
				}
				//echo 	$products_sql;
				echo "生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=products\"><u>返回</u></a><br/>
				---------------------------------------------------------------------------------------------------<br/><br/><br/>";																				
				if($_GET['productsall']=="ok")//不生成全部产品就执行一次循环退出
				{}
				else
				{break;}
			}// end of cate while
			if($ls!="all_products"){
				//生成全部页面，不包括产品页，否则break 
				break;
			}

		case "all":						//生成全部页面，不包括产品页
		case "nomenufiles":				//生成首页
			$ls_cate=$cate;				//左侧产品类别
			$ls_menu=$menu;				//主菜单
			$ls_classpro=$classpro;			//类别产品
			$ls_motif=$s_m_cate;
			$ls_hotpro=$hotpro;			//功能页面热点产品
			$ls_newpro=$newpro;			//功能页面新产品
			// $ls_title, $ls_keywords, $ls_description from public
			$ls_foot=$foot;				//底部信息
			$ls_site_cate = $site_cate;
			foreach($generalCreateFiles as $createdfile){
				$index_path="../".$templates_var."/";//模板目录
				$mainpartsubject=$createdfile;
				$filename="../".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	
			echo "生成member 目录下文件--------------------<br />";
			foreach($generalCreateFilesMembers as $createdfile){			//生成member 下文件
				$subFolder=true;		//设置子目录 替换../../ 为 ../
				$index_path="../".$templates_var."/";//模板目录
				$mainpartsubject="createdfile";
				$filename="../member/".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
			$subFolder=false;
				
			echo "生成agent 目录下文件--------------------<br />";
			foreach($generalCreateFilesAgents as $createdfile ) {			//生成agent 下文件
				$subFolder=true;
				$index_path="../".$templates_var."/";//模板目录
				$mainpartsubject="createdfile";
				$filename="../agent/".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
			$subFolder=false;
			if($ls!="all" && $ls!="all_products"){
				//生成全部页面，不包括产品页，否则break 
				break;
			}

     //生成单页
    case "singlepage":
		$sql = "select * from ls_singlepages where enable=1";
		$list = $opendb->allRows($sql);
		
		foreach($list as $v){
			$tpl = '../'.$templates_var."/".$v['static_tpl'];
			if(file_exists($tpl)){
				$arr = explode('.',$v['singlepage_name']);
				if($arr[1]=='html'){
					$ls_s_cate = $s_cate;				//左侧产品类别
					$ls_menu=$menu;				//主菜单
					$ls_classpro=$classpro;			//类别产品
					$ls_motif=$s_m_cate;
					$ls_hotpro=$hotpro;			//功能页面热点产品
					$ls_newpro=$newpro;			//功能页面新产品
					// $ls_title, $ls_keywords, $ls_description from public
					$ls_foot=$foot;				//底部信息
					$ls_site_cate = $site_cate;
					global $ls_about,$ls_news,$ls_homepro,$ls_newpro,$ls_classpro,$ls_hotpro,$ls_designby,$ls_news,$ls_link,$ls_s_cate,$ls_newsdongtai,$ls_newsgonggao,$ls_newstieshi,$ls_revo,$ls_allcatepics,$ls_site_cate,$facebook_twitter,$facebook_twitter_share;

					$handle = fopen($tpl,'r');
					$content = fread($handle,filesize ($tpl));
					$content = str_replace("{ls_title}",$ls_title,$content);
					$content = str_replace("../","./",$content);
					$content = str_replace("{ls_keywords}",$ls_keywords,$content);
					$content = str_replace("{ls_description}",$ls_description,$content);
					$content = str_replace("{ls_menu}",$ls_menu,$content);
					$content = str_replace("{ls_s_cate}",$ls_s_cate,$content);
					$content = str_replace("{ls_motif}",$ls_motif,$content);
					$content = str_replace("{ls_m_news}",$ls_m_news,$content);
					$content = str_replace("{ls_link}",$ls_link,$content);
					$content = str_replace("{ls_about}",$ls_about,$content);
					
					$content = str_replace("{ls_site_cate}",$ls_site_cate,$content);
					$content = str_replace("{ls_weibo}",$ls_facebook_twitter,$content);
					$content = str_replace("{weiboshare}",$facebook_twitter_share,$content);
					
					$content = str_replace("{ls_news}",$ls_news,$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_designby}",$ls_designby,$content);
					$content = str_replace("{ls_cate}",$ls_cate,$content);
					$content = str_replace("{ls_foot}",$ls_foot,$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("{singlepage_title}",$v['pageTitle'],$content);
					$content = str_replace("{singlepage_content}",$v['pageText'],$content);
					fclose($handle);
					
					$handle = fopen('../'.$v['singlepage_name'],'w+');
					if (!is_writable ('../'.$v['singlepage_name']))
					{ 
						echo "文件："."../".$v['singlepage_name']."不可写，请检查其属性后重试！";
					}else{
						if(fwrite($handle,$content)){
							echo "<p>生成 <a href='../".$v['singlepage_name']."'>../".$v['singlepage_name']."</a>成功</p>";	
							fclose ($handle);
						}	
					}
				}else{
					echo "生成的".$v['singlepage_name']."文件格式错误";	
				}
				
			}else{
				echo "<p>模版文件".$tpl."不存在，生成".$v['singlepage_name']."失败</p>";	
			}
		}
		if($ls!="all" && $ls!="all_products"){
			//生成全部页面，不包括产品页，否则break 
			break;
		}

	case "index":  //生成首页
		$index_path="../".$templates_var."/index.html";//首页模板地址
		$ls_cate=$cate;				//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;				//主菜单
		$ls_about=$about ;			//globle 首页About us 
		$ls_news=$news;				//globle 首页News
		$ls_problem=$problem;				//globle 首页problem
		$ls_revo=$revo;
		$ls_homepro=$homepro;			//globle 首页Hot products
		// $ls_title, $ls_keywords, $ls_description from public
		$ls_allcatepics=get_allcatepics();
		$ls_foot=$foot;				//底部信息
		
		$mainpartsubject="index";
		$filename="../index.html";
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
	
		if($ls_news!=""){	
			$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=mysql_num_rows($result_cate);
	 //$catenews = mysql_fetch_assoc($result_cate);
	$i_news=1;
	// 遍历所有分类 cate, 按分类生成 相关分类的news index.php，如 index_all.html, index_tieshi.html
	// 分页显示，以及全部新闻内容页 newsshow.html
	while(true)
	
	{
	  if($num_cate==0)
	  {
		 $news_sql2="select * from ls_news where enable=1 order by Num,newsDate desc ";
		 $suffix_str="_all";
	  }
	  else
	  {
		 $catenews = mysql_fetch_assoc($result_cate);
		 $news_sql2="select * from ls_news where enable=1 and cate='".$catenews['cateName']."' order by Num,newsDate desc ";
 		 $suffix_str=$catenews['suffStr'];

	  }
	  
	$result=$opendb->query($news_sql2);
	$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
	$onepage = $PageNumNews; 
		//共有页数
	$allpages = ceil($mynum/$onepage);
		
	//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
	//页码计算  在ls_syscode里面
	$propage=getPages("news".$suffix_str.".html",$allpages);
	//页码计算

	for ($i=0; $i< $allpages; $i++){ 
		$newslist="";
		if ($i == 0){ 
	 		$indexpath = "news".$suffix_str.".html";
		}else{ 
	   		$indexpath = "news".$suffix_str.$i.".html";
		}
		$start = $i * $onepage;

		 //查询产品
		 
		$news_sql=$news_sql2." limit ".$start.",".$onepage." ";
		$news_query=$opendb->query($news_sql2);
		while($news_rows=mysql_fetch_assoc($news_query)){
			$newslist.="<div style=\"padding-left:15px; padding-top:10px;\"><img src='Templates/images/news.gif' border='0'> <a href=\"".$newsshowFolders."/news".$news_rows['ID'].".html\">".$news_rows['newsTitle']."  </a>";
			$newslist.="<div class=\"xuxian\"></div></div>";
					
			$newstitle=$news_rows['newsTitle'];
			$newstext=$news_rows['newsText'];
			$ls_newstime = $news_rows['newsDate'];
			$ls_newid = $news_rows['ID'];
			$ls_click_n = $news_rows['clickNum'];
			createFolder("../".$newsshowFolders);
					
			$index_newspath="../".$templates_var."/newsshow.html";											//模板地址
			$ls_title=$config_rows['companyName'];				//title
			$ls_keywords=$config_rows['siteKeywords'];										//Keywords
			$ls_description=$config_rows['siteDescription'];							//Description
			$ls_cate=$pro_cate;
			$ls_s_cate=$s_cate;																						//左侧产品类别;
			$ls_motif=$s_pro_cate;
			$ls_menu=$menu_pro;																						//主菜单
			$ls_newstitle=$newstitle ;																		//新闻标题
			$ls_newstext=$newstext;
			$ls_revo=$pro_revo;
			$ls_url="../";							//链接		
			$ls_foot=$foot;																								//底部信息
					
			$fp = fopen ($index_newspath,"r");
			$newscontent = fread ($fp,filesize ($index_newspath));
			$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_cate}",$ls_cate,$newscontent);
			$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
			$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
			$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
			$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
			$newscontent = str_replace("{ls_newstext}",$ls_newstext,$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_url}../../",$newscontent);
			$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
//new
			$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
			$newscontent = str_replace("{ls_newsall}",$ls_newsall2,$newscontent);
			$newscontent = str_replace("{ls_newstieshi}",$ls_newstieshi2,$newscontent);

			$newscontent = str_replace("{ls_url}",$ls_url,$newscontent);
			$newscontent = str_replace("{ls_foot}",$ls_foot,$newscontent);	
			$newscontent = str_replace("{ls_revo}",$ls_revo,$newscontent);	
			
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_nextlink}',$newscontent,"ls_news",$catenews['cateName'],"news",$suffix_str2,true);
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_previouslink}',$newscontent,"ls_news",$catenews['cateName'],"news",$suffix_str2,true);
			//echo $newscontent;
			
					
			$filename="../".$newsshowFolders."/news".$news_rows['ID'].".html";
			
			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,$newscontent))
		 	{  //将信息写入文件
			  	echo "<script>alert('生成文件".$filename."失败！');history.go(-1);</script>";
			 } 
			fclose ($handle); //关闭指针
			 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
			fclose ($fp);
					
		}		
  		echo "共有".$mynum."条新闻。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
	}//end for , all pages
		if($num_cate==0 || $i_news==$num_cate)		//没有新闻分类 循环一遍退出， 如有新闻分类 循环所有分类
		{break;}
		else
		{
			$i_news++;
		}
	
	}	
  		
	}//
		
 if($ls!="all" && $ls!="all_products")//生成全部页面，不包括产品页，否则break 
 {break;}
 	
   case "aboutus":  //生成 About us
  
		$index_path="../".$templates_var."/aboutus.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		$ls_cate=$s_cate;			//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;		//主菜单
		$ls_allabout=$allabout ;		//About us
		$ls_foot=$foot;		//底部信息
		
		$ls_propage="";
		$mainpart=$allabout;
		$mainpartsubject="aboutus";
		$filename="../aboutus.html";
		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,$ls_cate,$ls_addprolink,$ls_addnewprolink,$newstag);
	 	 if($ls!="all" && $ls!="all_products")
 {break;}	
 
	case "feedback":  //生成 feedback
		
		$index_path="../".$templates_var."/feedback.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
			//$ls_cate=$pro_cate;																						//左侧产品类别
			//$ls_menu=$menu_pro;																						//主菜单
		$ls_cate=$s_cate;				//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;	//主菜单
		$ls_feedback=$config_rows['feedback'] ;//feedback
		$ls_feedbackemail=$config_rows['email'] ;//E-Mail
		$ls_foot=$foot;	//底部信息
		
		$ls_propage="";
		$mainpart=$ls_feedback ;
		$mainpartsubject="feedback";
		$filename = "../feedback.html"; 
		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,$ls_cate,$ls_addprolink,$ls_addnewprolink,$newstag);

	 	 if($ls!="all" && $ls!="all_products")
 {break;}	
	 
	 case "contactus":  //生成 contact us
			
		$contactus.="Address:".$config_rows['address']."<br>\n";
		$contactus.="Tel:".$config_rows['tel']."<br>\n";
		$contactus.="Fax:".$config_rows['fax']."<br>\n";
		$contactus.="E-Mail:<a href=\"mailto:".$config_rows['email']."\">".$config_rows['email']."</a><br>\n";
		$contactus.="MSN:<a href=\"mailto:".$config_rows['MSN']."\">".$config_rows['MSN']."</a><br>\n";
		$contactus.="URL:<a href=\"http://".$config_rows['website']."\">".$config_rows['website']."</a><br>\n";
		$contactus.=$ContactAttach; //联系我们的附件文字： google地图， 地区环境
		
		$contactus = $config_rows['contact'];
		
		$index_path="../".$templates_var."/contact.html";//模板地址
		$ls_title=$config_rows['companyName'];	//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		//$ls_cate=$pro_cate;																						//左侧产品类别
		//$ls_menu=$menu_pro;																						//主菜单
		$ls_cate=$s_cate;	//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;	//主菜单
		$ls_contactus=$contactus ;//contact us
		$ls_foot=$foot;//底部信息
		
		$ls_propage="";
		$ls_feedbackemail="";
		$mainpart=$contactus ;
		$mainpartsubject="contactus";
		$filename = "../contact.html"; 
		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,$ls_cate,$ls_addprolink,$ls_addnewprolink,$newstag);
	 	 if($ls!="all" && $ls!="all_products")
 {break;}	



	case "news": //生成新闻 News
	$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=mysql_num_rows($result_cate);
	 //$catenews = mysql_fetch_assoc($result_cate);
	$i_news=1;
	// 遍历所有分类 cate, 按分类生成 相关分类的news index.php，如 index_all.html, index_tieshi.html
	// 分页显示，以及全部新闻内容页 newsshow.html
	
	$sort='';	
	while($catenews = mysql_fetch_assoc($result_cate))
	{
		 //$mido = "<h3>".$catenews['cateName']."</h3>";
		 $news_sql2="select * from ls_news where enable=1 and cate='".$catenews['cateName']."' order by Num desc ";
 		 $suffix_str2=$catenews['suffStr'];
		 
		 $result=$opendb->query($news_sql2);
		$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
		$onepage = $PageNumNews;
			//共有页数
		$allpages = ceil($mynum/$onepage);
			
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
		//页码计算  在ls_syscode里面
		
		for ($i=0; $i<= $allpages; $i++){
			$newslist="";
			$suffix_str=$suffix_str2;
			if($i == 0)
			{
				$suffix_str = $suffix_str;
			} 
			else 
			{
				$suffix_str = $suffix_str."-".$i;
			}
			$start = $i * $onepage;
			$propage=getPagess("news".$catenews['suffStr'].".html",$allpages,$i+1);	
			
			//查询产品
			$news_sql=$news_sql2." limit ".$start.",".$onepage." ";
			
		$mido = "";
		$news_query=$opendb->query($news_sql);
		while($news_rows=mysql_fetch_assoc($news_query))
		{
			$mido.="<li><a href=\"".$newsshowFolders."/news".$suffix_str2.$news_rows['ID'].".html\">".$news_rows['newsTitle']."</a></li>";
			
			$newstag=$news_rows['cate'];
			$newstitle=$news_rows['newsTitle'];
			$newstext=$news_rows['newsText'];
			$ls_newstime = $news_rows['newsDate'];
			$ls_newid = $news_rows['ID'];
			$ls_click_n = $news_rows['clickNum'];
			createFolder("../".$newsshowFolders);
			
			$index_newspath="../".$templates_var."/newsshow".$suffix_str2.".html";		//模板地址
			$ls_title=$news_rows['newsTitle']." - ".$config_rows['companyName'];				//title
			$ls_keywords=$config_rows['siteKeywords'];			//Keywords
			$ls_description=$config_rows['siteDescription'];	//Description
			$ls_cate=$pro_cate;
			$ls_s_cate=$s_pro_cate;								//左侧产品类别;
			$ls_motif=$s_m2_cate;
			$ls_menu=$menu_pro;									//主菜单
			$ls_newstitle=$newstitle ;							//新闻标题
			$ls_newstext=$newstext;
			$ls_url="../";										//链接		
			$ls_foot=$foot;										//底部信息
			
			$fp	   = fopen ($index_newspath,"r");
			$newscontent = fread ($fp,filesize ($index_newspath));
			$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_cate}",$ls_cate,$newscontent);
			$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
			
			$ls_d_cate = str_replace("class=\"dropdown\"","",$ls_s_cate);
			$ls_d_cate = str_replace("class=\"sub-menu\"","",$ls_d_cate);
			
			$newscontent  = str_replace("{ls_d_cate}",$ls_d_cate,$newscontent);
			
			$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
			$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
			$ls_facebook_twitter = $facebook_twitter;
			$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newstext}",$ls_newstext,$newscontent);
			$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
//new
			$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
			$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链接
			
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_nextlink}',$newscontent,"ls_news",$catenews['cateName'],"news",$suffix_str2,true);
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_previouslink}',$newscontent,"ls_news",$catenews['cateName'],"news",$suffix_str2,true);
			
			$newscontent = str_replace("{newstag}",$newstag,$newscontent);
			if($suffix_str == "_dongtai"){
				$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
				$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
			}
					
			$filename="../".$newsshowFolders."/news".$suffix_str2.$news_rows['ID'].".html";
			
			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,$newscontent)){  //将信息写入文件
			  	echo "'生成文件".$filename."失败！";
			 } 
			fclose ($handle); //关闭指针
			 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
			fclose ($fp);
					
		}
	//end for , all pages
	
$index_path="../".$templates_var."/news".$suffix_str2.".html";												  //模板地址
		$ls_title=$config_rows['companyName'];												//title
		$ls_keywords=$config_rows['siteKeywords'];										//Keywords
		$ls_description=$config_rows['siteDescription'];							//Description
		$ls_cate=$cate;																								//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;																								//主菜单
		$ls_newslist=$mido ;																			//新闻news 列表
		$ls_propage=$propage;																					//新闻分页页码
		$ls_foot=$foot;																								//底部信息
		
		$ls_feedbackemail="";
		$mainpart=$ls_newslist ;
		$mainpartsubject="news";
		$filename = "../news".$suffix_str.".html";
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
	}//end of while all news cats
}
		echo "共有".$mynum."条新闻。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
	 if($ls!="all" && $ls!="all_products")
 {break;}
 
 case "problem": //生成常见问题 Problem

	$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=mysql_num_rows($result_cate);
	 //$catenews = mysql_fetch_assoc($result_cate);
	$i_news=1;
	// 遍历所有分类 cate, 按分类生成 相关分类的news index.php，如 index_all.html, index_tieshi.html
	// 分页显示，以及全部新闻内容页 newsshow.html
	$sort='';
	if($newsSort=="ID"){
		$sort = "ID";
	}else if($newsSort=="Num"){
		$sort = "Num";
	}else{
		$sort = "ID";
		}
	$alllist = '';
	while($catenews = mysql_fetch_assoc($result_cate)){
		//echo "<h1>".$catenews['ID']."</h1>";
	  
		 $news_sql2="select * from ls_problem where enable=1 and cate='".$catenews['ID']."' order by $sort desc ";
 		 $suffix_str=$catenews['suffStr'];
	  
	  
	 $result=$opendb->query($news_sql2);
		 //查询产品
		 
		
		$news_query=$opendb->query($news_sql2);
		$newslist = '<h3>'.$catenews['cateName'].'</h3>';
		while($news_rows=mysql_fetch_assoc($news_query))
		{
			$newslist.="<div style=\"padding-left:15px; padding-top:10px;\">&bull; <a href=\"".$problemshowFolders."/problem".$suffix_str.$news_rows['ID'].".html\">".$news_rows['problemTitle']." &nbsp; (".substr($news_rows['problemDate'],-5).")</a></div>";
			
			
			$tag_sql="select * from ls_functioncates where ID=".$news_rows['cate']." order by $sort desc ";
			$tag_query=$opendb->query($tag_sql);
			$tag_rows=mysql_fetch_assoc($tag_query);
			$newstag=$tag_rows['cateName'];
			
			$newstitle=$news_rows['problemTitle'];
			$newstext=$news_rows['problemText'];
			createFolder("../".$problemshowFolders);
					
			$index_newspath="../".$templates_var."/problemshow".$suffix_str2.".html";		//模板地址
			$ls_title=$config_rows['companyName'];				//title
			$ls_keywords=$config_rows['siteKeywords'];			//Keywords
			$ls_description=$config_rows['siteDescription'];	//Description
			$ls_cate=$pro_cate;
			$ls_s_cate=$s_pro_cate;								//左侧产品类别;
			$ls_motif=$s_m2_cate;
			$ls_menu=$menu_pro;									//主菜单
			$ls_newstitle=$newstitle ;							//新闻标题
			$ls_newstext=$newstext;
			$ls_url="../";										//链接		
			$ls_foot=$foot;										//底部信息
					
			$fp	= fopen ($index_newspath,"r");
			$newscontent = fread ($fp,filesize ($index_newspath));
			$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_cate}",$ls_cate,$newscontent);
			$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
			$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
			$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
			$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
			$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
			$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
//new
			$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
			$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链接
			
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_previouslink}',$newscontent,"ls_problem",$catenews['ID'],"problem",$suffix_str2,true);
			$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_nextlink}',$newscontent,"ls_problem",$catenews['ID'],"problem",$suffix_str2,true);
			
			$newscontent = str_replace("{newstag}",$newstag,$newscontent);
			if($suffix_str == "_dongtai"){
				$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
				$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
			}
					
			$filename="../".$problemshowFolders."/problem".$suffix_str.$news_rows['ID'].".html";
			
			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,$newscontent))
		 	{  //将信息写入文件
			  	echo "生成文件".$filename."失败！";
			 } 
			fclose ($handle); //关闭指针
			 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
			fclose ($fp);
					
		}
		$alllist .=$newslist."<br /><br />";		
		
	}//end for , all pages
		$index_path="../".$templates_var."/problem".$suffix_str2.".html";												  //模板地址
		$ls_title=$config_rows['companyName'];												//title
		$ls_keywords=$config_rows['siteKeywords'];										//Keywords
		$ls_description=$config_rows['siteDescription'];							//Description
		$ls_cate=$cate;																								//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;																								//主菜单
		$ls_newslist=$alllist ;																			//新闻news 列表
		$ls_propage=$propage;																					//新闻分页页码
		$ls_foot=$foot;																								//底部信息
			
		$ls_feedbackemail="";
		$mainpart=$ls_newslist ;
		$mainpartsubject="problem";
		$filename = "../problem".$suffix_str.".html"; 
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
  		echo "共有".$mynum."条新闻。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
	
	//end of while all news cats

	 if($ls!="all" && $ls!="all_products")
 {break;}
	 
	case "download": //生成下载
		
		$news_sql2="select * from ls_download where enable=1 order by ID desc ";
	  	$result=$opendb->query($news_sql2);
		$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
		$onepage = $PageNumDowbloads; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			$propage=getPages("download.html",$allpages);
			//页码计算
			
		for ($i=0; $i<= $allpages; $i++)
		{ 
			if ($i == 0)
			{ 
			$indexpath = "download.html";
		  	} 
		  	else 
		  	{ 
				$indexpath = "download-".$i.".html";
		  	}
			 $start = $i * $onepage;
			 $downlist="";
		 //查询产品
		 
		 $news_sql=$news_sql2. " limit ".$start.",".$onepage." ";
		// echo $news_sql;
			 $news_query=$opendb->query($news_sql);
	
			 while($news_rows=mysql_fetch_assoc($news_query))
			{
					$down_size = round($news_rows['downloadSize']/1000);
					if($down_size > 1048576){
						$size = sprintf("%.2f", $value1['downloadSize']/1048576)."MB";
					}else{
						$size = $down_size."KB";
					}
					$downlist.="<li><span style=\"float:right;\">".$size."</span><a href=\"".$downloadFolders."/".$news_rows['downloadName']."\" onclick='$.download_times(".$news_rows['ID'].")' title=\"Size:".$size."\">".$news_rows['downloadTitle']."</a></li>";
				}
				$index_path="../".$templates_var."/download.html";		  //模板地址
				$ls_title=$config_rows['companyName'];				//title
				$ls_keywords=$config_rows['siteKeywords'];			//Keywords
				$ls_description=$config_rows['siteDescription'];	//Description
				$ls_cate=$cate;																								//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;																								//主菜单
				$ls_downlist=$downlist ;																			//新闻news 列表
				$ls_propage=$propage;																					//新闻分页页码
				$ls_foot=$foot;																								//底部信息
				
		$ls_feedbackemail="";
		$mainpart=$ls_downlist;
		$mainpartsubject="download";
		$filename = "../".$indexpath;
		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,$ls_addprolink,$ls_addnewprolink,$newstag);

		}
	
	  		
	  	echo "共有".$mynum."条下载。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
	case "management": //生成管理团队(Management)
			
		$news_sql2="select * from ls_management where enable=1 order by Num desc ";
	  $result=$opendb->query($news_sql);
		$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
		$onepage = $PageNum; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			$propage=getPages("management.html",$allpages);
			//页码计算
			
			for ($i=0; $i<= $allpages; $i++)
			{ 
			if ($i == 0)
			{ 
			$indexpath = "management.html";
		  } 
		  else 
		  { 
			$indexpath = "management".$i.".html";
		  }
		 $start = $i * $onepage;
		 //查询产品
		 
		 $news_sql=$news_sql2." limit ".$start.",".$onepage." ";
			 $news_query=$opendb->query($news_sql);
	
			 while($news_rows=mysql_fetch_assoc($news_query))
				{
					$list.="
					<div style=\"border-bottom:1px solid #ccc; margin-left:20px;width:98%;\">
						<div style=\"float:left;padding-left:20px;padding-right:20px;\">
							<a href=\"".$WorkShopFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" target=\"_blank\">
							<img src=\"".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\"></a>
						</div>
						<div style=\"float:left;\">
							".$news_rows['Text']."
						</div>
					</div>
					";
				}
				$index_path="../".$templates_var."/management.html";										//模板地址
				$ls_title=$config_rows['companyName'];												//title
				$ls_keywords=$config_rows['siteKeywords'];										//Keywords
				$ls_description=$config_rows['siteDescription'];							//Description
				$ls_cate=$cate;																								//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;																								//主菜单
				$ls_list=$list ;																			//新闻news 列表
				$ls_propage=$propage;																					//新闻分页页码
				$ls_foot=$foot;																								//底部信息
				
		$ls_feedbackemail="";
		$mainpart=$ls_list;
		$mainpartsubject="management";
		$filename = "../management.html"; 
		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,$ls_addprolink,$ls_addnewprolink,$newstag);

				}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
		case "workshop": //生成车间图片(Workshop)
		
			$news_sql3="select * from ls_menu where menuName='workshop'";
			$news_query3=$opendb->query($news_sql3);
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_workshop where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $WorkshopPageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("workshop.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_workshop where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "workshop.html";
		 		}else{ 
					$indexpath = "workshop-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html\" title=\"{$news_rows['workshopTitle']}\" >
						<img src=\"".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['workshopPic']."\" border=\"0\" >
						</a><a href=\"".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html\" title=\"{$news_rows['workshopTitle']}\" class='pn' >".$news_rows['workshopTitle']."</a></li>";
						
					$newstitle=$news_rows['workshopTitle'];
					$newimg = "<center><img src=\"../".$WorkShopFolders."/".$BigFoldersProducts."/".$news_rows['workshopPic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['workshopText'];
					$ls_newid = $news_rows['ID'];
					createFolder("../".$WorkShopFolders);
					
					$index_newspath="../".$templates_var."/workshopshow.html";		//模板地址
					$ls_title=$news_rows['workshopTitle']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					
					$ls_d_cate = str_replace("class=\"dropdown\"","",$ls_s_cate);
					$ls_d_cate = str_replace("class=\"sub-menu\"","",$ls_d_cate);
					
					$newscontent  = str_replace("{ls_d_cate}",$ls_d_cate,$newscontent);
					
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_workshop",$catenews['cateName'],"workshop",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_workshop",$catenews['cateName'],"workshop",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
							
				
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("workshop.html",$allpages,$ls_current_page);
				
				$index_path="../".$templates_var."/workshop.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$cate;											//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="workshop";
				$filename = "../{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
		case "video": //生成车间图片(Workshop)
		
			$news_sql3="select * from ls_menu where menuName='video'";
			$news_query3=$opendb->query($news_sql3);
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_video where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("workshop.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_video where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "video.html";
		 		}else{ 
					$indexpath = "video".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<ul class=\"p_list\">";
				
				if("192.168.2.20"==$_SERVER["SERVER_ADDR"] || "pmf.lanscend.cn"==$_SERVER['HTTP_HOST']){
					$url=explode("/", $_SERVER["REQUEST_URI"]);
					$path = "/".$url[1];
				}else{
					$url="";
				}
				while($news_rows=mysql_fetch_assoc($news_query)){
					if($news_rows['code']==NULL){
						$list.="<li><embed src='".$path."/video/".$news_rows['videoFile']."' type='application/x-shockwave-flash' width='".$news_rows['videoW']."' height='".$news_rows['videoH']."' quality='high' />".$news_rows['videoName']."</li>";
					}else{
						$list .= "<li>".$news_rows['code']."<br />".$news_rows['videoName']."</li>";
					}
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("video.html",$allpages,$ls_current_page);
				
				$index_path="../".$templates_var."/video.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$cate;											//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="video";
				$filename = "../{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
			case "qualitycontrol": //生成管理团队(Management)
			
			$news_sql3="select * from ls_menu where menuName='Quality'";
			$news_query3=$opendb->query($news_sql3);
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
			
			$news_sql2="select * from ls_qualitycontrol where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("quality.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){ 
				$news_sql2="select * from ls_qualitycontrol where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "quality.html";
		 		}else{ 
					$indexpath = "quality-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}
				
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$QualitycateFolders."/quality-page".$news_rows['ID'].".html\" title=\"{$news_rows['Title']}\">
						<img src=\"".$QualitycateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
						</a><span><a href=\"".$QualitycateFolders."/quality-page".$news_rows['ID'].".html\" title=\"{$news_rows['Title']}\"  class='pn'>".$news_rows['Title']."</a></span></li>";
						
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../".$QualitycateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../".$WorkShopFolders);
					
					$index_newspath="../".$templates_var."/qualityshow.html";		//模板地址
					$ls_title=$news_rows['Title']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					
					$ls_d_cate = str_replace("class=\"dropdown\"","",$ls_s_cate);
					$ls_d_cate = str_replace("class=\"sub-menu\"","",$ls_d_cate);
					
					$newscontent  = str_replace("{ls_d_cate}",$ls_d_cate,$newscontent);
					
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_qualitycontrol",$catenews['cateName'],"quality",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_qualitycontrol",$catenews['cateName'],"quality",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../".$QualitycateFolders."/quality-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("quality.html",$allpages,$ls_current_page);
				
				$index_path="../".$templates_var."/quality.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$cate;											//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="qualitycontrol";
				$filename = "../{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
		
	case "rd": //生成研发(R&D)
		
		$news_sql3="select * from ls_menu where menuName='Research&Development'";
		$news_query3=$opendb->query($news_sql3);
		$news_rows3=mysql_fetch_assoc($news_query3);
		$introduction = $news_rows3['description'];
			
		$news_sql2="select * from ls_rd where enable=1 order by Num desc ";
	  $result=$opendb->query($news_sql2);
		$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
		$onepage = $PageNum; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			$propage=getPages("rd.html",$allpages);
			//页码计算
			
			for ($i=0; $i< $allpages; $i++)
			{ 
			if ($i == 0)
			{ 
			$indexpath = "rd.html";
		  } 
		  else 
		  { 
			$indexpath = "rd".$i.".html";
		  }

		 $start = $i * $onepage;
		 //查询产品
		     $news_sql=$news_sql2." limit ".$start.",".$onepage." ";
			 $news_query=$opendb->query($news_sql);
	         $list="<ul class=\"list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$rdFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" target=\"_blank\" title=\"".$news_rows['Text']."\" $('.list').lightBox();>
							<img src=\"".$rdFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><br /><span>".$news_rows['Text']."</span></li>";
				}
				$list.="</ul>";
				
				$index_path="../".$templates_var."/rd.html";										//模板地址
				$ls_title=$config_rows['companyName'];												//title
				$ls_keywords=$config_rows['siteKeywords'];										//Keywords
				$ls_description=$config_rows['siteDescription'];							//Description
				$ls_cate=$cate;																								//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;																								//主菜单
				$ls_list=$list ;																			//新闻news 列表
				$ls_introduction=$introduction;                           //简介
				$ls_propage=$propage;																					//新闻分页页码
				$ls_foot=$foot;																								//底部信息
				
		$ls_feedbackemail="";
		$mainpart=$ls_list;
		$mainpartsubject="rd";
		$filename = "../rd.html"; 
		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,$ls_addprolink,$ls_addnewprolink,$newstag);

				}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
	case "certificate": //生成证书(Certificate)
		$news_sql3="select * from ls_menu where menuName='Certificate'";
		$news_query3=$opendb->query($news_sql3);
		$news_rows3=mysql_fetch_assoc($news_query3);
		$introduction = $news_rows3['description'];
		
		$news_sql2="select * from ls_certificate where enable=1 order by Num desc ";
		$result=$opendb->query($news_sql2);
		$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
		$onepage = $CertificatePageNum; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
		//页码计算
		//$propage=getPages("certificate.html",$allpages);
		//页码计算
		for ($i=0; $i<= $allpages; $i++){
			$news_sql2="select * from ls_certificate where enable=1 order by Num desc ";
			if ($i == 0){ 
				$indexpath = "certificate.html";
			}else{ 
				$indexpath = "certificate-".$i.".html";
			}
			$start = $i * $onepage;
			
			if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
			}
			
			//查询产品
		 
			$news_sql=$news_sql2." limit ".$start.",".$onepage." ";
			$news_query=$opendb->query($news_sql);
			$list = "<ul class=\"p_list\">";
			while($news_rows=mysql_fetch_assoc($news_query)){
				$list.="<li><a href=\"".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\">
					<img src=\"".$CertificateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\" title=\"".$news_rows['Title']."\">
					</a><span><a href=\"".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\" class='pn'>".$news_rows['Title']."</a></span></li>";
					
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../".$CertificateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../".$WorkShopFolders);
					
					$index_newspath="../".$templates_var."/certificateshow.html";		//模板地址
					$ls_title=$news_rows['workshopTitle']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					
					$ls_d_cate = str_replace("class=\"dropdown\"","",$ls_s_cate);
					$ls_d_cate = str_replace("class=\"sub-menu\"","",$ls_d_cate);
					
					$newscontent  = str_replace("{ls_d_cate}",$ls_d_cate,$newscontent);
					
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_certificate",$catenews['cateName'],"certificate",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_certificate",$catenews['cateName'],"certificate",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../".$CertificateFolders."/certificate-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
			}
			$list.="</ul>";
			
			//页码计算
			$propage=getPagess("certificate.html",$allpages,$ls_current_page);
			
			$index_path="../".$templates_var."/certificate.html";//模板地址
			$ls_title=$config_rows['companyName'];		//title
			$ls_keywords=$config_rows['siteKeywords'];	//Keywords
			$ls_description=$config_rows['siteDescription'];//Description
			$ls_cate=$cate;									//左侧产品类别
			$ls_motif=$s_m_cate;
			$ls_menu=$menu;									//主菜单
			$ls_list=$list ;								//新闻news 列表
			$ls_introduction=$introduction;                           //简介
			$ls_propage=$propage;							//新闻分页页码
			$ls_foot=$foot;									//底部信息
			$ls_feedbackemail="";
			$mainpart=$ls_list;
			$mainpartsubject="certificate";
			$filename = "../{$indexpath}";		
			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,$ls_addprolink,$ls_addnewprolink,$newstag);
		}
	  	echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		if($ls!="all" && $ls!="all_products"){break;}
		
		
		case "packing": //生成包装(Packing)
			$news_sql3="select * from ls_menu where menuName='Packing'";
			$news_query3=$opendb->query($news_sql3);
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_packing where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("packing.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){ 
				$news_sql2="select * from ls_packing where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "packing.html";
		 		}else{ 
					$indexpath = "packing".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}
				
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$WorkShopFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" target=\"_blank\" title=\"{$news_rows['Text']}\" $('.p_list').lightBox();>
							<img src=\"".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><br /><span>".$news_rows['Text']."</span></li>";
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("packing.html",$allpages,$ls_current_page);
				
				$index_path="../".$templates_var."/packing.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$cate;											//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="packing";
				$filename = "../{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
		
		
		case "brand": //生成品牌(Brand)
			
		$news_sql3="select * from ls_menu where menuName='brand'";
			$news_query3=$opendb->query($news_sql3);
			mysql_query("set names utf8");
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_brand where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			mysql_query("set names utf8");
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $brandPageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("quality.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_brand where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "brand.html";
		 		}else{ 
					$indexpath = "brand-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				mysql_query("set names utf8");
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$brandFolders."/brand-page".$news_rows['ID'].".html\" title=\"{$news_rows['Title']}\" $('.p_list').lightBox();>
							<img src=\"".$brandFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><span>".$news_rows['Title']."</span></li>";
							
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../".$brandFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$brandFolders);
					
					$index_newspath="../".$templates_var."/brandshow.html";		//模板地址
					$ls_title=$news_rows['Title']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_brand",$catenews['cateName'],"brand",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_brand",$catenews['cateName'],"brand",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../".$brandFolders."/brand-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("brand.html",$allpages,$ls_current_page);
				
				$index_path="../".$templates_var."/brand.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$ls_m_cate;			//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="brand";
				$filename = "../{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}


//移动终端页面生成
case "all_m":
 
   case "index_m":  //生成 index
   		$index_path="../".$mobi_templates_var."/index.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		$ls_cate=$p_m_cate;			//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;		//主菜单
		$about=mb_substr($config_rows['aboutus'],0,$config_rows['aboutLenght'],'utf-8').((strlen($config_rows['aboutus'])>$config_rows['aboutLenght'])?" <a href=\"aboutus.html\">(More...)</a>":"");
		$ls_about=$about ;			//globle 首页About us 
		$ls_allabout=$allabout;		//About us
		$ls_foot=$foot;		//底部信息
		
		//首页产品展示 Start
	$products_sql="select * from ls_products where 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 subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and AdditionalAttributes&1 and enable=1";
	$products_sql.=" order by No asc limit 0, 6; ";
	$products_query=$opendb->query($products_sql);
	mysql_query("SET NAMES utf8");
	$homepro="";
	$count=1;
	while($products_rows=mysql_fetch_assoc($products_query)){
		if(hassameclass($products_rows['productID'])){
			continue;
		}
		$pro_i++;
		$profile=getproductfolder($products_rows['productID']);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
		$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";
		
		$homepro.="<li><a href=\"../m/".$profile."/".getproductpath($products_rows['productID']).".html\"><img src=\"../".$prosrc."\"  border=\"0\" alt=\"".$products_rows['productName']."\" title=\"".$products_rows['productName']."\" ></a><a href=\"".$profile."/".getproductpath($products_rows['productID']).".html\" class='pn'>".$products_rows['productName']."</a></li>";
		$count++;
	}

	//首页产品展示 End
	
	//首页证书展示 Start
		$products_sql="select * from ls_certificate where enable=1 ";
		$products_sql.=" order by Num asc limit 0, 3";
		$products_query=$opendb->query($products_sql);
		$homecer="";
		$count=1;
		while($news_rows=mysql_fetch_assoc($products_query)){
			$homecer.="<li><a href=\"../m/".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\" src=\"{$news_rows['Title']}\" title=\"".$news_rows['Title']."\"><img src=\"../certificate/images/".$news_rows['Pic']."\" border=\"0\"></a><span><a href=\"../certificate/images/".$news_rows['Pic']."\" src=\"{$news_rows['Title']}\" title=\"".$news_rows['Title']."\" class='pn' >".$news_rows['Title']."</a></span></li>";
			$count++;
		}
	//首页证书展示 End
	
		$ls_homecer=$homecer;
		$ls_homepro=$homepro;
		$ls_propage="";
		$mainpart=$allabout;
		$mainpartsubject="index";
		$filename="../m/index.html";
		
		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,$ls_addprolink,$ls_addnewprolink,$newstag);

	 	 if($ls!="all_m" && $ls!="all_products")
 {break;}	


   case "aboutus_m":  //生成 About us
		$index_path="../".$mobi_templates_var."/aboutus.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		$ls_cate=$p_m_cate;			//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;		//主菜单
		$ls_allabout=$allabout ;		//About us
		$ls_foot=$foot;		//底部信息
		
		$ls_propage="";
		$mainpart=$allabout;
		$mainpartsubject="aboutus";
		$filename="../m/aboutus.html";
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
		if($ls!="all_m" && $ls!="all_products")
 {break;}	

	case "feedback_m":  //生成 feedback
		
		$index_path="../".$mobi_templates_var."/feedback.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
			//$ls_cate=$pro_cate;																						//左侧产品类别
			//$ls_menu=$menu_pro;																						//主菜单
		$ls_cate=$s_cate;				//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;	//主菜单
		$ls_feedback=$config_rows['feedback'] ;//feedback
		$ls_feedbackemail=$config_rows['email'] ;//E-Mail
		$ls_foot=$foot;	//底部信息
		
		$ls_propage="";
		$mainpart=$ls_feedback ;
		$mainpartsubject="feedback";
		$filename = "../m/feedback.html"; 
		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,$ls_cate,$ls_addprolink,$ls_addnewprolink,$newstag);

	 	 if($ls!="all_m" && $ls!="all_products")
 {break;}
	
	 case "technology_m":  //生成 About us
		$index_path="../".$mobi_templates_var."/jishu.html";	//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		$ls_cate=$p_m_cate;			//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;		//主菜单
		$ls_allabout=$alltechnology;		//About us
		$ls_foot=$foot;		//底部信息
		
		$ls_propage="";
		$mainpart=$ls_allabout;
		$mainpartsubject="technology";
		$filename="../m/jishu.html";
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
		if($ls!="all_m" && $ls!="all_products")
 {break;}	
	
	//case""
	
	case "news_m":  //生成 news
	
		$cate_sql2 = "SELECT * FROM ls_news WHERE enable=1 group by cate";
		$cate_query2=$opendb->query($cate_sql2);
		mysql_query("set names utf8");
		$cate_num2 = mysql_num_rows($cate_query2);
		
		createFolder("../".$newsshowFolders_m);
		
		while($cate_rows=mysql_fetch_assoc($cate_query2)){
	   
			//从数据库取出新闻，形成$news_m标签
			$news_sql2="select * from ls_news where enable=1 and cate='".$cate_rows["cate"]."' order by ID desc";
			$news_query=$opendb->query($news_sql2);
			mysql_query("set names utf8");
			$mynum = mysql_num_rows($news_query);//总产品数
			
			$news_cate_sql="select * from ls_functioncates where enable=1 and cateName='".$cate_rows["cate"]."' order by ID desc";
			$news_cate_query=$opendb->query($news_cate_sql);
			$news_cate_rows=mysql_fetch_assoc($news_cate_query);
			
			$suffix_str2 = $news_cate_rows['suffStr'];
			
			$onepage = $PageNum_m;
			//共有页数
			$allpages = ceil($mynum/$onepage);
			
			//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			//页码计算
				
			for ($i=0; $i< $allpages; $i++)
			{ 
				$newslist="";
				if ($i == 0)
				{ 
					$indexpath = "../m/news".$suffix_str2.".html";
				} 
				else 
				{ 
					$indexpath = "../m/news".$suffix_str2."-".$i.".html";
				}
				$start = $i * $onepage;
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}
				$propage=getPagess("news".$suffix_str2.".html",$allpages,$ls_current_page);	
				 //查询产品
				 
				$news_sql=$news_sql2." limit ".$start.",".$onepage." ";
				

				$news_query=$opendb->query($news_sql);
				mysql_query("set names utf8");
				$ls_m_news='';
				while($news_rows=mysql_fetch_assoc($news_query)){
						$ls_m_news .="<li><a href='newspage_m/news".$suffix_str2."".$news_rows['ID'].".html'>
							<dt>".$news_rows['newsTitle']."</dt>
							<dd>".substr(strip_tags($news_rows['newsText']),0,150)."</dd>
							</a>
						</li>";

					//echo "<pre>".$ls_m_news;	
					
					$news_m_title=$news_rows['newsTitle'];
					$news_m_text=$news_rows['newsText'];
					$news_m_time=$news_rows['newsDate'];
					
					createFolder("../".$newsshowFolders);
					
					$index_newspath="../".$mobi_templates_var."/newsshow".$suffix_str2.".html";											//模板地址
					$ls_title=$config_rows['companyName'];												//title
					$ls_keywords=$config_rows['siteKeywords'];										//Keywords
					$ls_description=$config_rows['siteDescription'];
					$ls_m_logo = $mobi_row['logo'];							//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;																						//左侧产品类别;
					$ls_motif=$s_pro_cate;
					$ls_menu=$menu_pro;	
					$ls_m_time = $news_m_time;																				//主菜单
					$ls_newstitle=$newstitle;																		//新闻标题
					$news_m_text=$news_m_text;
					
					$ls_url="../";							//链接		
					//底部信息
					
					$fp = fopen ($index_newspath,"r");
					
					$newscontent_m = fread ($fp,filesize($index_newspath));
					$newscontent_m = str_replace("{ls_newstitle}",$news_m_title,$newscontent_m);
					$newscontent_m = str_replace("{ls_title}",$news_m_title,$newscontent_m);
					$newscontent_m = str_replace("{ls_m_logo}",$ls_m_logo,$newscontent_m);
					$newscontent_m = str_replace("{ls_m_time}",$ls_m_time,$newscontent_m);
					
					$ls_m_cate = str_replace("display:none","",$ls_s_cate);
					$newscontent_m = str_replace("{ls_m_cate}",$ls_m_cate,$newscontent_m);
					
					$newscontent_m = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent_m);
					$newscontent_m = str_replace("{ls_addprolink}",$ls_addprolink,$newscontent_m);	//指向主菜单中的Products链接
					$newscontent_m = str_replace("{ls_addnewprolink}",$ls_addnewprolink,$newscontent_m);	//指向主菜单中的NewProducts链接
					$newscontent_m = str_replace("{ls_newstext}",$news_m_text,$newscontent_m);
				
					//var_dump($newscontent_m);exit;
					
					$newscontent_m = circleNavigationLinkNews($news_rows['ID'],'F','{ls_nextlink}',$newscontent_m,"ls_news",$news_cate_rows['cateName'],"news",$suffix_str2,true);
					$newscontent_m = circleNavigationLinkNews($news_rows['ID'],'B','{ls_previouslink}',$newscontent_m,"ls_news",$news_cate_rows['cateName'],"news",$suffix_str2,true);
					
							
					$filename="../".$newsshowFolders_m."/news".$cate_rows["cate"].$news_rows['ID'].".html";
					
					if (is_file ($filename))
					{ 
						 @unlink ($filename); //若文件已存在，则删除
					}
					
				   $handle   = fopen ($filename,"w"); //打开文件指针，
				   //var_dump($handle);exit;
						/*
						检查文件是否被创建且可写
						 */ 
							 
					if (!is_writable ($filename))
					{ 
						 echo "<script>alert('文件：".$filename."不可写，请检查其属性后重试！');history.go(-1);</script>";
					 }
					if (!fwrite ($handle,$newscontent_m))
					{  //将信息写入文件
						echo "<script>alert('生成文件".$filename."失败！');history.go(-1);</script>";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
							
				}   
			$index_path="../".$mobi_templates_var."/news".$cate_rows["cate"].".html";	//模板地址
			$ls_title=$config_rows['companyName'];//title
			$ls_keywords=$config_rows['siteKeywords'];	//Keywords
			$ls_description=$config_rows['siteDescription'];//Description
			$ls_cate=$ls_m_cate;			//左侧产品类别
			$ls_motif=$s_m_cate;
			$ls_menu=$menu;		//主菜单
					//About us
			$ls_foot=$foot;		//底部信息
			
			$ls_propage=$propage;
			$mainpart= $ls_m_news;
			$mainpartsubject="news";
			$filename = $indexpath;
			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,$ls_addprolink,$ls_addnewprolink,$newstag);
	
			}
		}
	echo "共有".$mynum."条新闻。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
	
	if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "workshop_m": //生成车间图片(Workshop)
		
			$news_sql3="select * from ls_menu where menuName='workshop'";
			$news_query3=$opendb->query($news_sql3);
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_workshop where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $WorkshopPageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("workshop.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_workshop where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "workshop.html";
		 		}else{ 
					$indexpath = "workshop-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<ul class=\"store_con\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html\" title=\"{$news_rows['workshopTitle']}\" >
						<img src=\"../".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['workshopPic']."\" border=\"0\" >
						</a><span>".$news_rows['workshopTitle']."</span></li>";
						
					$newstitle=$news_rows['workshopTitle'];
					$newimg = "<center><img src=\"../../".$WorkShopFolders."/".$BigFoldersProducts."/".$news_rows['workshopPic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['workshopText'];
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$WorkShopFolders);
					
					$index_newspath="../".$mobi_templates_var."/workshopshow.html";		//模板地址
					$ls_title=$news_rows['workshopTitle']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_workshop",$catenews['cateName'],"workshop",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_workshop",$catenews['cateName'],"workshop",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../m/".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
							
				
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("workshop.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/workshop.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$cate;											//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="workshop";
				$filename = "../m/{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}	
 
 case "quality_m": //生成车间图片(Workshop)
		
			$news_sql3="select * from ls_menu where menuName='quality'";
			$news_query3=$opendb->query($news_sql3);
			mysql_query("set names utf8");
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_qualitycontrol where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			mysql_query("set names utf8");
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum_m; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("quality.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_qualitycontrol where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "quality.html";
		 		}else{ 
					$indexpath = "quality-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				mysql_query("set names utf8");
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$QualitycateFolders."/quality-page".$news_rows['ID'].".html\" title=\"{$news_rows['Title']}\" $('.p_list').lightBox();>
							<img src=\"../".$QualitycateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><span>".$news_rows['Title']."</span></li>";
							
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$QualitycateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$QualitycateFolders);
					
					$index_newspath="../".$mobi_templates_var."/qualityshow.html";		//模板地址
					$ls_title=$news_rows['Title']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_qualitycontrol",$catenews['cateName'],"qualitycontrol",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_qualitycontrol",$catenews['cateName'],"qualitycontrol",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../m/".$QualitycateFolders."/quality-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("quality.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/quality.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$ls_m_cate;			//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="certificate";
				$filename = "../m/{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "certificate_m": //生成车间图片(Workshop)
		
			$news_sql3="select * from ls_menu where menuName='certificate'";
			$news_query3=$opendb->query($news_sql3);
			mysql_query("set names utf8");
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_certificate where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			mysql_query("set names utf8");
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum_m; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("certificate.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_certificate where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "certificate.html";
		 		}else{ 
					$indexpath = "certificate-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				mysql_query("set names utf8");
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\"  title=\"{$news_rows['Title']}\" >
							<img src=\"../".$CertificateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><span>".$news_rows['Title']."</span></li>";
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$CertificateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$CertificateFolders);
					
					$index_newspath="../".$mobi_templates_var."/certificateshow.html";		//模板地址
					$ls_title=$news_rows['workshopTitle']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_certificate",$catenews['cateName'],"certificate",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_certificate",$catenews['cateName'],"certificate",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../m/".$CertificateFolders."/certificate-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("certificate.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/certificate.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$ls_m_cate;			//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="certificate";
				$filename = "../m/{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "brand_m": //生成品牌(Brand)
			
		$news_sql3="select * from ls_menu where menuName='brand'";
			$news_query3=$opendb->query($news_sql3);
			mysql_query("set names utf8");
			$news_rows3=mysql_fetch_assoc($news_query3);
			$introduction = $news_rows3['description'];
		
			$news_sql2="select * from ls_brand where enable=1 order by Num desc ";
	 		$result=$opendb->query($news_sql2);
			mysql_query("set names utf8");
			$mynum = mysql_num_rows($result);//总产品数
			// 每页数量
			$onepage = $PageNum_m; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("quality.html",$allpages);

			//根据页码生成文件名
			for ($i=0; $i<= $allpages; $i++){
				$news_sql2="select * from ls_brand where enable=1 order by Num desc ";
				if ($i == 0){ 
					$indexpath = "brand.html";
		 		}else{ 
					$indexpath = "brand-".$i.".html";
		 		}
				$start = $i * $onepage;
				
				if($allpages!=1){
					$ls_current_page=$i+1;		//当前页码
				}

		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				mysql_query("set names utf8");
				$list="<ul class=\"p_list\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="
					<li><a href=\"".$brandFolders."/brand-page".$news_rows['ID'].".html\" title=\"{$news_rows['Title']}\" $('.p_list').lightBox();>
							<img src=\"../".$brandFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
							</a><span>".$news_rows['Title']."</span></li>";
							
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$brandFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" ondragstart=\"return false;\"/></center>";
					$newstext = $news_rows['Text'];
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$brandFolders);
					
					$index_newspath="../".$mobi_templates_var."/brandshow.html";		//模板地址
					$ls_title=$news_rows['Title']." - ".$config_rows['companyName'];				//title
					$ls_keywords=$config_rows['siteKeywords'];			//Keywords
					$ls_description=$config_rows['siteDescription'];	//Description
					$ls_cate=$pro_cate;
					$ls_s_cate=$s_pro_cate;								//左侧产品类别;
					$ls_motif=$s_m2_cate;
					$ls_menu=$menu_pro;									//主菜单
					$ls_newstitle=$newstitle ;							//新闻标题
					$ls_newimg=$newimg;
					$ls_newstext=$newstext;
					$ls_url="../";										//链接		
					$ls_foot=$foot;										//底部信息
					
					$fp	   = fopen ($index_newspath,"r");
					$newscontent = fread ($fp,filesize ($index_newspath));
					$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_cate}",$ls_cate,$newscontent);
					$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
					$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
					$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
					$ls_facebook_twitter = $facebook_twitter;
					$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$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_newimg}",$ls_newimg,$newscontent);
					
					$newscontent = str_replace("{ls_newstext}",$ls_newstext,$newscontent);
					$newscontent = str_replace("{ls_newsdongtai}",$ls_newsdongtai2,$newscontent);		//子目录下新闻
		//new
					$newscontent = str_replace("{ls_newsgonggao}",$ls_newsgonggao2,$newscontent);
					$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链接
					
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'B','{ls_nextlink}',$newscontent,"ls_brand",$catenews['cateName'],"brand",$suffix_str2,false);
					$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_brand",$catenews['cateName'],"brand",$suffix_str2,false);
					
					$newscontent = str_replace("{newstag}",$newstag,$newscontent);
					if($suffix_str == "_dongtai"){
						$newscontent = str_replace("<li id=\"current\"><a href=\"../news.html\">","<li><a href=\"../news.html\">",$newscontent);
						$newscontent = str_replace("<li><a href=\"../technology.html\">","<li id=\"current\"><a href=\"../technology.html\">",$newscontent);
					}
							
					$filename="../m/".$brandFolders."/brand-page".$news_rows['ID'].".html";
					
					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,$newscontent)){  //将信息写入文件
						echo "'生成文件".$filename."失败！";
					 } 
					fclose ($handle); //关闭指针
					 //echo "创建<a href='".$filename."'>".$filename."</a>成功！<a href=\"temp.php?ls=normal\"><u>返回</u></a><br/><br/>";
					fclose ($fp);
				}
				$list.="</ul>";
				
				//页码计算
				$propage=getPagess("brand.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/brand.html";				//车间模板地址
				$ls_title=$config_rows['companyName'];					//title
				$ls_keywords=$config_rows['siteKeywords'];				//Keywords
				$ls_description=$config_rows['siteDescription'];		//Description
				$ls_cate=$ls_m_cate;			//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;											//主菜单
				$ls_list=$list ;										//车间图片列表
				$ls_introduction=$introduction;                           //车间简介
				$ls_propage=$propage;									//车间分页页码
				$ls_foot=$foot;											//底部信息
				
				$ls_feedbackemail="";
				$mainpart=$ls_list;
				$mainpartsubject="brand";
				$filename = "../m/{$indexpath}";
				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,$ls_addprolink,$ls_addnewprolink,$newstag);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "download_m": //生成下载
		
		$news_sql2="select * from ls_download where enable=1 order by ID desc ";
	  	$result=$opendb->query($news_sql2);
		$mynum = mysql_num_rows($result);//总产品数
		// 每页数量
		$onepage = $PageNumDowbloads; 
		//共有页数
		$allpages = ceil($mynum/$onepage);
		
		//echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			$propage=getPages("download.html",$allpages);
			//页码计算
			
		for ($i=0; $i<= $allpages; $i++)
		{ 
			if ($i == 0)
			{ 
			$indexpath = "download.html";
		  	} 
		  	else 
		  	{ 
				$indexpath = "download-".$i.".html";
		  	}
			 $start = $i * $onepage;
			 $downlist="";
		 //查询产品
		 
		 $news_sql=$news_sql2. " limit ".$start.",".$onepage." ";
		// echo $news_sql;
			 $news_query=$opendb->query($news_sql);
	
			 while($news_rows=mysql_fetch_assoc($news_query))
			{
					$down_size = round($news_rows['downloadSize']/1000);
					if($down_size > 1048576){
						$size = sprintf("%.2f", $value1['downloadSize']/1048576)."MB";
					}else{
						$size = $down_size."KB";
					}
					$downlist.="<li><span style=\"float:right;\">".$size."</span><a href=\"../".$downloadFolders."/".$news_rows['downloadName']."\" onclick='$.download_times(".$news_rows['ID'].")' title=\"Size:".$size."\">".$news_rows['downloadTitle']."</a></li>";
				}
				$index_path="../".$mobi_templates_var."/download.html";		  //模板地址
				$ls_title=$config_rows['companyName'];				//title
				$ls_keywords=$config_rows['siteKeywords'];			//Keywords
				$ls_description=$config_rows['siteDescription'];	//Description
				$ls_cate=$cate;																								//左侧产品类别
				$ls_motif=$s_m_cate;
				$ls_menu=$menu;																								//主菜单
				$ls_downlist=$downlist ;																			//新闻news 列表
				$ls_propage=$propage;																					//新闻分页页码
				$ls_foot=$foot;																								//底部信息
				
		$ls_feedbackemail="";
		$mainpart=$ls_downlist;
		$mainpartsubject="download";
		$filename = "../m/".$indexpath;
		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,$ls_addprolink,$ls_addnewprolink,$newstag);

		}
	
	  		
	  	echo "共有".$mynum."条下载。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		if($ls!="all_m" && $ls!="all_products")
 {break;}	
 
  case "contact_m":  //生成 contact us
			
		$contactus.="Address:".$row['address']."<br>\n";
		$contactus.="Tel:<a class='zzp-tel ui-link' href='tel:".$row['tel']."'>".$row['tel']."</a>".$row['tel']."<br>\n";
		$contactus.="Fax:".$row['fax']."<br>\n";
		$contactus.="E-Mail:<a href=\"mailto:".$row['email']."\">".$row['email']."</a><br>\n";
		$contactus.="MSN:<a href=\"mailto:".$row['MSN']."\">".$row['MSN']."</a><br>\n";
		$contactus.="URL:<a href=\"http://".$row['website']."\">".$row['website']."</a><br>\n";
		$contactus.=$ContactAttach_m; //联系我们的附件文字： google地图， 地区环境
		
		
		$index_path="../".$mobi_templates_var."/contact.html";//模板地址
		$ls_title=$config_rows['companyName'];//title
		$ls_keywords=$config_rows['siteKeywords'];	//Keywords
		$ls_description=$config_rows['siteDescription'];//Description
		//$ls_cate=$pro_cate;																						//左侧产品类别
		//$ls_menu=$menu_pro;																						//主菜单
		$ls_cate=$p_m_cate;	//左侧产品类别
		$ls_motif=$s_m_cate;
		$ls_menu=$menu;	//主菜单
		$ls_contactus=$contactus ;//contact us
		$ls_foot=$foot;//底部信息
		
		$ls_propage="";
		$ls_feedbackemail="";
		$mainpart=$contactus ;
		$mainpartsubject="contactus";
		$filename = "../m/contact.html"; 
		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,$ls_addprolink,$ls_addnewprolink,$newstag);
	 	 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 //生成单页
    case "singlepage_m":
		$sql = "select * from ls_singlepages where enable=1";
		$list = $opendb->allRows($sql);
		
		foreach($list as $v){
			$tpl = '../'.$mobi_templates_var."/".$v['static_tpl'];
			if(file_exists($tpl)){
				$arr = explode('.',$v['singlepage_name']);
				if($arr[1]=='html'){
					$ls_s_cate = $s_cate;				//左侧产品类别
					$ls_menu=$menu;				//主菜单
					$ls_classpro=$classpro;			//类别产品
					$ls_motif=$s_m_cate;
					$ls_hotpro=$hotpro;			//功能页面热点产品
					$ls_newpro=$newpro;			//功能页面新产品
					// $ls_title, $ls_keywords, $ls_description from public
					$ls_foot=$foot;				//底部信息
					$ls_site_cate = $site_cate;
					global $ls_about,$ls_news,$ls_homepro,$ls_newpro,$ls_classpro,$ls_hotpro,$ls_designby,$ls_news,$ls_link,$ls_s_cate,$ls_newsdongtai,$ls_newsgonggao,$ls_newstieshi,$ls_revo,$ls_allcatepics,$ls_site_cate,$facebook_twitter,$facebook_twitter_share;

					$handle = fopen($tpl,'r');
					$content = fread($handle,filesize ($tpl));
					$content = str_replace("{ls_title}",$ls_title,$content);
					$content = str_replace("../","./",$content);
					$content = str_replace("{ls_keywords}",$ls_keywords,$content);
					$content = str_replace("{ls_description}",$ls_description,$content);
					$content = str_replace("{ls_menu}",$ls_menu,$content);
					$content = str_replace("{ls_s_cate}",$ls_s_cate,$content);
					$content = str_replace("{ls_motif}",$ls_motif,$content);
					$content = str_replace("{ls_m_news}",$ls_m_news,$content);
					$content = str_replace("{ls_link}",$ls_link,$content);
					$content = str_replace("{ls_about}",$ls_about,$content);
					
					$content = str_replace("{ls_site_cate}",$ls_site_cate,$content);
					$content = str_replace("{ls_weibo}",$ls_facebook_twitter,$content);
					$content = str_replace("{weiboshare}",$facebook_twitter_share,$content);
					
					$content = str_replace("{ls_news}",$ls_news,$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_designby}",$ls_designby,$content);
					$content = str_replace("{ls_cate}",$ls_cate,$content);
					$content = str_replace("{ls_foot}",$ls_foot,$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("{singlepage_title}",$v['pageTitle'],$content);
					$content = str_replace("{singlepage_content}",$v['pageText'],$content);
					fclose($handle);
					
					$handle = fopen('../m/'.$v['singlepage_name'],'w+');
					if (!is_writable ('../m/'.$v['singlepage_name']))
					{ 
						echo "文件："."../m/".$v['singlepage_name']."不可写，请检查其属性后重试！";
					}else{
						if(fwrite($handle,$content)){
							echo "<p>生成 <a href='../m/".$v['singlepage_name']."'>../m/".$v['singlepage_name']."</a>成功</p>";	
							fclose ($handle);
						}	
					}
				}else{
					echo "生成的".$v['singlepage_name']."文件格式错误";	
				}
				
			}else{
				echo "<p>模版文件".$tpl."不存在，生成".$v['singlepage_name']."失败</p>";	
			}
		}
		if($ls!="all_m" && $ls!="all_products"){
			//生成全部页面，不包括产品页，否则break 
			break;
		}
 
 		case "nomenufiles_m":				//生成首页
			$ls_cate=$p_m_cate;	//左侧产品类别
			$ls_menu=$menu;				//主菜单
			$ls_classpro=$classpro;			//类别作品
			$ls_hotpro=$hotpro;			//功能页面热点作品
			$ls_newpro=$newpro;			//功能页面新作品
			$ls_title=$config_rows['companyName'];												//title
			$ls_keywords=$config_rows['siteKeywords'];										//Keywords
			$ls_description=$config_rows['siteDescription'];
			// $ls_title, $ls_keywords, $ls_description from public
			$ls_foot=$foot;				//底部信息
			$ls_site_cate = $site_cate;
			foreach($m_generalCreateFiles as $createdfile){
				$index_path="../".$mobi_templates_var."/";//模板目录
				$mainpartsubject=$createdfile;
				$filename="../m/".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				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,$ls_addprolink,$ls_addnewprolink,$newstag,$ls_hot_behalf);
			}
	
			echo "生成member 目录下文件--------------------<br />";
			foreach($generalCreateFilesMembers as $createdfile){			//生成member 下文件
				$subFolder=true;		//设置子目录 替换../../ 为 ../
				$index_path="../".$mobi_templates_var."/";//模板目录
				$mainpartsubject="createdfile";
				$filename="../member/".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink,$newstag,$ls_hot_behalf);
			}
			$subFolder=false;
				
			echo "生成agent 目录下文件--------------------<br />";
			foreach($generalCreateFilesAgents as $createdfile ) {			//生成agent 下文件
				$subFolder=true;
				$index_path="../".$mobi_templates_var."/";//模板目录
				$mainpartsubject="createdfile";
				$filename="../agent/".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_introduction="";
				$ls_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink,$newstag,$ls_hot_behalf);
			}
			$subFolder=false;
			if($ls!="all_m" && $ls!="all_products")
 {break;}	
 
 		//生成手机产品页
 		case "products_m":  
			$menuListscateidall=0;
			/*$cate_sql="select * from ls_products where midcateID is null 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";*/
			//查找大类的SQL语句
			$cate_sql = 'SELECT * FROM `ls_products` WHERE cateName IS NOT NULL';
			$cate_query=$opendb->query($cate_sql);
			mysql_query("set names utf8");
			while($cate_rows=mysql_fetch_assoc($cate_query)){
				if($_GET['productsall']=="ok"||$ls == 'products_m'){
					$cateid=$cate_rows['ID'];
					$menuListscateid=0;
				}
				$products_sql_p="select * from ls_products where midcateID is null and cateName is null and cateFolders is null and   subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null ";
				//大类
					
				if( $cateid!="" && $midcateid=="" && $subcateid=="" ){
					//大类下有中类
					//echo "<h1>".$cateid."</h1>";
					$sqlstr1="SELECT `ID` FROM `ls_products` WHERE midcateID=".$cateid;
					$query1=$opendb->query($sqlstr1);
					mysql_query("set names utf8");
					$mynum1=mysql_num_rows($query1);
					if($mynum1!=0){
						//有中类
						$DetailPage=1;
						
						writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);// write 所有大枝类的details
						$DetailPage=0; //reset flag
			
						$menuListscateidall++;
						if($_GET['productsall']=="ok"){$menuListscateid=$menuListscateidall;}		// if it is all products set $menuListscateid
						while($myrows1=mysql_fetch_assoc($query1)){
							$sqlstr2="select ID from ls_products where subcateID =".$myrows1['ID']." ";
							$query2=$opendb->query($sqlstr2);
							mysql_query("set names utf8");
							$mynum2=mysql_num_rows($query2);
							if($mynum2!=0){
								//有小类
								$midcateid=$myrows1['ID'];
								$DetailPage=1;
								writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);// write 所有中枝类的details
								$DetailPage=0; //reset flag
			
								while($myrows2=mysql_fetch_assoc($query2)){
									$productID=" productID=".$myrows2['ID'];
									$products_sql=$products_sql_p." and ".$productID;
									$subcateid=$myrows2['ID'];
									writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
									$midcateid="";
									$subcateid="";
								}
							}
							else{
								//没有小类
									
								$productID=" productID=".$myrows1['ID'];
								$products_sql=$products_sql_p." and ".$productID;
								$midcateid=$myrows1['ID'];
								writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
								$midcateid="";
							}
						}
					}
					else{
						$products_sql=$products_sql_p." and productID=".$cateid;
						writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
					}
				}
			
				
				//中类
				if($cateid!="" && $midcateid!="" && $subcateid==""){
					//中类下有小类
					$sqlstr="select ID from ls_products where subcateID =".$midcateid." ";
					$query1=$opendb->query($sqlstr);
					mysql_query("set names utf8");
					$mynum=mysql_num_rows($query1);
					if($mynum!=0){
						while($myrows=mysql_fetch_assoc($query1)){
								$productID=" productID=".$myrows['ID'];
								$products_sql=$products_sql_p." and ".$productID;
								$subcateid=$myrows['ID'];
								writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
								$subcateid="";
						}
					}
					else{
						//中类下没有小类
						$products_sql=$products_sql_p." and productID=".$midcateid;
						writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
			
					}
				}
				//小类
				if($cateid!="" && $midcateid!=""&& $subcateid!=""){
					$products_sql=$products_sql_p." and productID=".$subcateid;
					writeProPageIndex_m($products_sql,$cateid,$midcateid,$subcateid);
				}
				//echo 	$products_sql;
				echo "生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=products\"><u>返回</u></a><br/>
				---------------------------------------------------------------------------------------------------<br/><br/><br/>";	
				if($_GET['productsall']!=''){
					if($_GET['productsall']=="ok")//不生成全部产品就执行一次循环退出
					{}
					else
					{break;}
				}
			}// end of cate while
			if($ls!="all_products" && $ls!='product_m'){
				//生成全部页面，不包括产品页，否则break 
				break;
			}
}
?></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
