<?php
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>模板管理</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/ls_syscode.php');
	require_once('inc/public.php'); //main menu & left menu
	

	$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
	
	
	//左侧产品类别 Start
	// public.php	
	//左侧产品类别 End
	
	//产品页面左侧产品类别 Start
	// public.php
	//左侧产品页面产品类别 End
	
	$tem_sql="select * from ls_config order by ID";	
	$tem_query=$opendb->query($tem_sql);
	$row=mysql_fetch_array($tem_query);
	$templates_var = $row['templates'];
	
	//首页新闻列表 Start
	$news_sql="select * from ls_news order by Num,newsDate 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']."  (".$news_rows['newsDate'].")</a>";
		$news.="</li>";
		$i++;
	}
	//首页新闻列表 End
	
	//首页产品展示 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 ";
	$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']);
		$prosrc=$profile."/".$SmallFoldersProducts."/".$products_rows['productPic'];
		$prolink=$profile."/".$showproductsFolders."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";
		
		$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);
		
		$homepro.="<li class=\"p_bg".$pro_i."\"><div class=\"cateName".$pro_i."\">".$products_rows2['cateName']."</div><p></p><div class=\"pro_bg".$pro_i."\"><div class=\"productsName".$pro_i."\">".$products_rows['productName']."</div><p></p><a href=\"".$prolink."\" target=\"_blank\"><img src=\"".$prosrc."\" width=\"127\" height=\"124\" border=\"0\" alt=\"".$products_rows['productName']."\" title=\"".$products_rows['productName']."\"></a><div class=\"p_spe\">Specifications: <br />". htmlspecialchars(trim($products_rows['canshu']), ENT_QUOTES)."</div></div></li>";
		$count++;
	}
	//首页产品展示 End

	//热点产品展示 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&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><img src=\"../".$MotifFolders."/".$BigFoldersProducts."/".$motif_rows['motifPic']."\" border=\"0\"></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 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=substr_cut($config_rows['aboutus'],$aboutLength)."... <a href=\"aboutus.html\">More</a>";
	$allabout=$config_rows['aboutus'];
	
	switch($ls){
		case "all_products":	
		case "products":  //生成产品页 products
			$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 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=="" ){
					//大类下有中类
					$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){
								//有小类
								$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;
									$midcateid=$myrows1['ID'];
									$subcateid=$myrows2['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_hotpro=$hotpro;			//功能页面热点产品
			$ls_newpro=$newpro;			//功能页面新产品
			// $ls_title, $ls_keywords, $ls_description from public
			$ls_foot=$foot;				//底部信息
			foreach($generalCreateFiles as $createdfile){
				$index_path="../".$templates_var."/";//模板目录
				$mainpartsubject=$createdfile;
				$filename="../".$createdfile;
				$index_path=$index_path.$createdfile;
				$mainpart="";
				$ls_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_motif,$ls_menu,$ls_foot,
	$filename,$mainpart,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
	
			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_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
			$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_feedbackemail="";
				$ls_propage="";
				writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_menu,$ls_foot,
	$filename,$mainpart,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
			$subFolder=false;
			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_revo=$revo;
		$ls_homepro=$homepro;			//globle 首页Hot products
		// $ls_title, $ls_keywords, $ls_description from public
		$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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
	
		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']."  (".substr($news_rows['newsDate'],-5).")</a>";
			$newslist.="<div class=\"xuxian\"></div></div>";
					
			$newstitle=$news_rows['newsTitle'];
			$newstext=$news_rows['newsText'];
			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_pro_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_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);	
			
			//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=$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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
	 	 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=$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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);

	 	 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地图， 地区环境
		
		$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=$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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
	 	 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
	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;\">&bull; <a href=\"".$newsshowFolders."/news".$suffix_str.$news_rows['ID'].".html\">".$news_rows['newsTitle']." &nbsp; (".substr($news_rows['newsDate'],-5).")</a></div>";
					
			$newstitle=$news_rows['newsTitle'];
			$newstext=$news_rows['newsText'];
			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_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_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链接
			
					
			$filename="../".$newsshowFolders."/news".$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 "<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="../".$templates_var."/news.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=$newslist ;																			//新闻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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
  		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++;
		}
	
	}//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))
				{
					$downlist.="<div style=\"padding-left:15px;\"><img src='Templates/images/news.gif' border='0'> <a href=\"".$downloadFolders."/".$news_rows['downloadName']."\" title=\"Size:".$news_rows['downloadSize']."KB\">".$news_rows['downloadTitle']."</a> ";
					$downlist.="<div class=\"xuxian\"></div></div>";
				}
				$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 = "../download.html"; 
		writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_motif,$ls_menu,$ls_foot,
$filename,$mainpart,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);

		}
	  		
	  	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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);

				}
	  		
	  		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_sql2="select * from ls_workshop 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_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."/".$BigFoldersProducts."/".$news_rows['workshopPic']."\" target=\"_blank\" title=\"{$news_rows['workshopText']}\" $('.p_list').lightBox();>
							<img src=\"".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['workshopPic']."\" border=\"0\">
							</a><br /><span>".$news_rows['workshopText']."</span></li>";
				}
				$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_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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
	  		
	  		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_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=\"".$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("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_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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
	  		
	  		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_sql2="select * from ls_rd 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("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);
	
			 while($news_rows=mysql_fetch_assoc($news_query))
				{
					$list.="
					<div style=\"border-bottom:1px solid #ccc; width:98%;\">
						<div style=\"float:left;padding-right:10px;\">
							<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."/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_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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);

				}
	  		
	  		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_sql2="select * from ls_certificate 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("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>";
			while($news_rows=mysql_fetch_assoc($news_query)){
				$list.="
				<li><a href=\"".$CertificateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" target=\"_blank\" src=\"{$news_rows['workshopText']}\">
					<img src=\"".$CertificateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" border=\"0\">
					</a><span>".$news_rows['Text']."</span></li>";
			}
			$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_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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
		}
	  	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_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_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,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);
			}
	  		
	  		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_sql2="select * from ls_brand 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("brand.html",$allpages);
			//页码计算
			
			for ($i=0; $i<= $allpages; $i++)
			{ 
			if ($i == 0)
			{ 
			$indexpath = "brand.html";
		  } 
		  else 
		  { 
			$indexpath = "brand".$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; width:98%;\">
						<div style=\"float:left;padding-right:10px;\">
							<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."/brand.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="brand";
		$filename = "../brand.html"; 
		writeMainMenuItemFile($index_path,$ls_title,$ls_keywords,$ls_description,$ls_cate,$ls_motif,$ls_menu,$ls_foot,
$filename,$mainpart,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$ls_addprolink,$ls_addnewprolink);

	}	  		
	
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all" && $ls!="all_products")
 {break;}
}
?></td>
				</tr>
			</table></td>
	</tr>
</table>
</body>
</html>
