<?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
	
	//左侧产品类别 Start
	// public.php	
	//左侧产品类别 End
	
	//产品页面左侧产品类别 Start
	// public.php
	//左侧产品页面产品类别 End
	
	$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;
	
	$inf_sql="select * from ls_information where inMenu = 'aboutus' order by ID";	
	$inf_query=$opendb->query($inf_sql);
	$inf_row=mysql_fetch_array($inf_query);
	
	$lenght_sql="select * from ls_functioncode where codeID = 'aboutLenght' order by ID";	
	$lenght_query=$opendb->query($lenght_sql);
	$lenght_row=mysql_fetch_array($lenght_query);

	$allabout_m = str_replace("href=\"../", "href=\"", $inf_row['content']);
	
	switch($ls){
		
//移动终端页面生成
case "all_m":
 
   case "index_m":  //生成 index
   		$index_path="../".$mobi_templates_var."/index.html";	//模板地址
		$ls_title=$mobi_row['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_m=mb_substr($inf_row['homeAbout'],0,$lenght_row['code'],'utf-8').((strlen($inf_row['content'])>$lenght_row['code'])?" <a href=\"aboutus.html\">(More...)</a>":"");
		$ls_about=$about_m ;			//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, 9; ";
	$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."/".trim(str_replace(substr($products_rows['productPic'],-4),"",$products_rows['productPic'])).".html";
		
		switch($homehrefStytle){
			case "prohref":
				$homehref = $profile."/".clearFolder(strtolower(pathProName($products_rows['productName'])))."-".$products_rows['ID'].".html";
			break;
			
			case "classhref":
				$homehref = $profile."/".getproductpath($products_rows['productID']).".html";
			break;
		}
		
		$homepro.="<div class=\"col-xs-4\"><div class=\"thumbnail\"><div class=\"img-pic\"><a href=\"".$homehref."\"><img src=\"../".$prosrc."\"  border=\"0\" alt=\"".$products_rows['productName']."\" title=\"".$products_rows['productName']."\" ></a></div><div class=\"caption pro-name\"><a href=\"".$homehref."\">".$products_rows['productName']."</a></div>
			</div>
		</div>";
		$count++;
	}

	//首页产品展示 End
		$ls_homepro=$homepro;
		$ls_propage="";
		$mainpart=$allabout;
		$mainpartsubject="index_m";
		$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);

	 	 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_m;		//About us
		$ls_foot=$foot;		//底部信息
		
		$ls_propage="";
		$mainpart=$allabout_m;
		$mainpartsubject="aboutus_m";
		$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
		if($ls!="all_m" && $ls!="all_products")
 {break;}	
	
	//case""
	
	 case "technology_m":  //生成 About us
		$index_path="../".$mobi_templates_var."/technology.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/technology.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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
		if($ls!="all_m" && $ls!="all_products")
 {break;}	
	
	//case""
	
	case "news_m": //生成手机新闻 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
	createFolder("../m/".$newsshowFolders_m);
	$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里面
		$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
		
		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><span>(".$news_rows['newsDate'].")</span><a href=\"".$newsshowFolders_m."/news".$suffix_str2.$news_rows['ID'].".html\">".$news_rows['newsTitle']."</a></li>";
			
			$index_newspath="../".$mobi_templates_var."/newsshow".$suffix_str2.".html";		//模板地址
			if(file_exists($index_newspath)){
				$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="../".$mobi_templates_var."/newsshow".$suffix_str2.".html";		//模板地址
				$ls_title = $news_rows['title'];				//title
				$ls_keywords=$news_rows['keywords'];			//Keywords
				$ls_description=$news_rows['description'];	//Description
				$ls_cate=$pro_cate;
				$ls_s_cate=$s_pro_cate;								//左侧产品类别;
				$ls_s_news = $ls_h1_news;
				$ls_p_cate=$s_p_cate;								//左侧产品类别;
				$ls_f_cate=get_pro_cate(1);
				$ls_motif=$s_m2_cate;
				$ls_menu=$menu_pro;									//主菜单
				$ls_newstitle=$newstitle ;							//新闻标题
				$ls_newstext=str_replace("src=\"../", "src=\"../../", $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_p_cate}",$ls_p_cate,$newscontent);
				$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
				$newscontent = str_replace("{ls_f_cate}",$ls_f_cate,$newscontent);
				$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
				$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
				$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
				$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
				$ls_facebook_twitter_share = $facebook_twitter_share;
				$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
				
				$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li style='text-transform : capitalize;'><a href=\"../news".$suffix_str2.".html\">".$suffix_str2."</a></li>";
				$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$newscontent);
				
				$newscontent = str_replace("{ls_news}",$ls_s_news,$newscontent);
				
				$newscontent = str_replace("{ls_newstime}",$ls_newstime,$newscontent);
				$newscontent = str_replace("{ls_newid}",$ls_newid,$newscontent);
				$newscontent = str_replace("{ls_click_n}",$ls_click_n,$newscontent);
				
				$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
				$newscontent = str_replace("{ls_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_news",$catenews['cateName'],"news",$suffix_str2,true);
				$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{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="../m/".$newsshowFolders_m."/news".$cate_rows["cate"].$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);
			}else{
				echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";	
			}
					
		}
		
	//end for , all pages
	
$index_path="../".$mobi_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_m";
		$filename = "../m/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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
	}//end of while all news cats
}
		echo "共有".$mynum."条新闻。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
	 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "faq_m": //生成手机新闻 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
	createFolder("../m/".$faqshowFolders_m);
	$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里面
		$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
		$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);
		
		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("faq".$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><span>(".$news_rows['newsDate'].")</span><a href=\"".$faqshowFolders_m."/faq".$suffix_str2.$news_rows['ID'].".html\">".$news_rows['newsTitle']."</a></li>";
			
			$index_newspath="../".$mobi_templates_var."/faqshow".$suffix_str2.".html";		//模板地址
			if(file_exists($index_newspath)){
				$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="../".$mobi_templates_var."/faqshow".$suffix_str2.".html";		//模板地址
				$ls_title = $news_rows['title'];				//title
				$ls_keywords=$news_rows['keywords'];			//Keywords
				$ls_description=$news_rows['description'];	//Description
				$ls_cate=$pro_cate;
				$ls_s_cate=$s_pro_cate;								//左侧产品类别;
				$ls_s_news = $ls_h1_news;
				$ls_p_cate=$s_p_cate;								//左侧产品类别;
				$ls_f_cate=get_pro_cate(1);
				$ls_motif=$s_m2_cate;
				$ls_menu=$menu_pro;									//主菜单
				$ls_newstitle=$newstitle ;							//新闻标题
				$ls_newstext=str_replace("src=\"../", "src=\"../../", $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_p_cate}",$ls_p_cate,$newscontent);
				$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
				$newscontent = str_replace("{ls_f_cate}",$ls_f_cate,$newscontent);
				$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
				$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
				$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
				$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
				$ls_facebook_twitter_share = $facebook_twitter_share;
				$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
				
				$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li style='text-transform : capitalize;'><a href=\"../faq".$suffix_str2.".html\">FAQs</a></li>";
				$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$newscontent);
				$newscontent = str_replace("{ls_news}",$ls_s_news,$newscontent);
				$newscontent = str_replace("{ls_newstime}",$ls_newstime,$newscontent);
				$newscontent = str_replace("{ls_newid}",$ls_newid,$newscontent);
				$newscontent = str_replace("{ls_click_n}",$ls_click_n,$newscontent);
				$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
				$newscontent = str_replace("{ls_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_news",$catenews['cateName'],"faq",$suffix_str2,true);
				$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_news",$catenews['cateName'],"faq",$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="../m/".$faqshowFolders_m."/faq".$cate_rows["cate"].$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);
			}else{
				echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";	
			}
		}
	//end for , all pages
$index_path="../".$mobi_templates_var."/faq".$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="faq_m";
		$filename = "../m/faq".$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
	}//end of while all news cats
}
		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_m";
		$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_cate0,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);

		}
	  		
	  	echo "共有".$mynum."条下载。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		 if($ls!="all" && $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 = $PageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("workshop.html",$allpages);
			
			$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);

			//根据页码生成文件名
			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;		//当前页码
				}
				
				$ls_p_cate=$s_p_cate;	//左侧产品类别;
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<div class=\"row pro_list masonry-container\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="<div class=\"col-xs-4 item\">
							<div class=\"thumbnail\">
								<div class=\"img-pic2\">
							  <a href=\"".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\" class=\"c-img\"><img src=\"../".$WorkShopFolders."/".$SmallFoldersProducts."/".$news_rows['workshopPic']."\" alt=\"".$news_rows['Title']."\" /></a>
							  </div>
							  <div class=\"caption pro-name\">
								<a href=\"".$WorkShopFolders."/workshop-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\">".$news_rows['Title']."</a>
							  </div>
							</div>
						  </div>";
					
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$WorkShopFolders."/".$BigFoldersProducts."/".$news_rows['workshopPic']."\" class=\"img-responsive\"  ondragstart=\"return false;\"/></center>";
					$newstext = str_replace("src=\"../", "src=\"../../", $news_rows['workshopText']);
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$WorkShopFolders);
					
					$index_newspath="../".$mobi_templates_var."/workshopshow.html";		//模板地址
					if(file_exists($index_newspath)){
						$ls_title=$news_rows['newsTitle'];				//title
						$ls_keywords=$news_rows['newsKeywords'];			//Keywords
						$ls_description=$news_rows['newsDescription'];	//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_p_cate}",$ls_p_cate,$newscontent);
						$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
						$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
						$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
						$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
						$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
						$ls_facebook_twitter_share = $facebook_twitter_share;
						$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
						
						$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li><a href=\"../workshop.html\">workshop</a></li>";
						$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$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);
					}else{
						echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";
					}
				}
				$list.="</div>";
				
				//页码计算
				$propage=getPagess("workshop.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/workshop.html";				//车间模板地址
				$ls_title=$news_rows3['inTitle'];												//title
				$ls_keywords=$news_rows3['inKeywords'];										//Keywords
				$ls_description=$news_rows3['inDescription'];							//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_m";
				$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
	  		
	  		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": //生成包装(Packing)
			$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 = $PageNum; 
			//共有页数
			$allpages = ceil($mynum/$onepage);

			echo "共有".$mynum."个产品。可以生成".$allpages."页.每页".$onepage."个<br>";
			
			//页码计算
			//$propage=getPages("certificate.html",$allpages);
			
			$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);

			//根据页码生成文件名
			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;		//当前页码
				}
				
				$ls_p_cate=$s_p_cate;	//左侧产品类别;
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<div class=\"row pro_list masonry-container\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="<div class=\"col-xs-4 item\">
							<div class=\"thumbnail\">
								<div class=\"img-pic2\">
							  <a href=\"".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\" class=\"c-img\"><img src=\"../".$CertificateFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" alt=\"".$news_rows['Title']."\" /></a>
							  </div>
							  <div class=\"caption pro-name\">
								<a href=\"".$CertificateFolders."/certificate-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\">".$news_rows['Title']."</a>
							  </div>
							</div>
						  </div>";
					
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$CertificateFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" class=\"img-responsive\"  ondragstart=\"return false;\"/></center>";
					$newstext = str_replace("src=\"../", "src=\"../../", $news_rows['Text']);
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$CertificateFolders);
					
					$index_newspath="../".$mobi_templates_var."/certificateshow.html";		//模板地址
					if(file_exists($index_newspath)){
						$ls_title=$news_rows['newsTitle'];				//title
						$ls_keywords=$news_rows['newsKeywords'];			//Keywords
						$ls_description=$news_rows['newsDescription'];	//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_p_cate}",$ls_p_cate,$newscontent);
						$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
						$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
						$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
						$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
						$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
						$ls_facebook_twitter_share = $facebook_twitter_share;
						$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
						
						$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li><a href=\"../certificate.html\">certificate</a></li>";
						$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$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);
					}else{
						echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";
					}
				}
				$list.="</div>";
				
				//页码计算
				$propage=getPagess("certificate.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/certificate.html";				//车间模板地址
				$ls_title=$news_rows3['inTitle'];												//title
				$ls_keywords=$news_rows3['inKeywords'];										//Keywords
				$ls_description=$news_rows3['inDescription'];							//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="certificate_m";
				$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "qualitycontrol_m": //生成质量(Quality)
			$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);
			
			$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);

			//根据页码生成文件名
			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;		//当前页码
				}
				
				$ls_p_cate=$s_p_cate;	//左侧产品类别;
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<div class=\"row pro_list masonry-container\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="<div class=\"col-xs-4 item\">
							<div class=\"thumbnail\">
								<div class=\"img-pic2\">
							  <a href=\"".$qualitycontrolFolders."/quality-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\" class=\"c-img\"><img src=\"../".$qualitycontrolFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" alt=\"".$news_rows['Title']."\" /></a>
							  </div>
							  <div class=\"caption pro-name\">
								<a href=\"".$qualitycontrolFolders."/quality-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\">".$news_rows['Title']."</a>
							  </div>
							</div>
						  </div>";
					
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$qualitycontrolFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" class=\"img-responsive\"  ondragstart=\"return false;\"/></center>";
					$newstext = str_replace("src=\"../", "src=\"../../", $news_rows['Text']);
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$qualitycontrolFolders);
					
					$index_newspath="../".$mobi_templates_var."/qualityshow.html";		//模板地址
					if(file_exists($index_newspath)){
						$ls_title=$news_rows['newsTitle'];				//title
						$ls_keywords=$news_rows['newsKeywords'];			//Keywords
						$ls_description=$news_rows['newsDescription'];	//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_p_cate}",$ls_p_cate,$newscontent);
						$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
						$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
						$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
						$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
						$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
						$ls_facebook_twitter_share = $facebook_twitter_share;
						$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
						
						$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li><a href=\"../quality.html\">quality</a></li>";
						$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$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="../m/".$qualitycontrolFolders."/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);
					}else{
						echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";
					}
				}
				$list.="</div>";
				
				//页码计算
				$propage=getPagess("quality.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/quality.html";				//车间模板地址
				$ls_title=$news_rows3['inTitle'];												//title
				$ls_keywords=$news_rows3['inKeywords'];										//Keywords
				$ls_description=$news_rows3['inDescription'];							//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="quality_m";
				$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
	  		
	  		echo "共有".$mynum."条。总共生成".$allpages."页。<br>生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！<a href=\"temp.php?ls=other\"><u>返回</u></a><br/><br/>";
		
		 if($ls!="all_m" && $ls!="all_products")
 {break;}
 
 case "packing_m": //生成包装(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);
			
			$facebook_twitter = str_replace("YOUR-FACEBOOK",$row['facebook'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-TWITTER",$row['twitter'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-LINKEDIN",$row['linkedin'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-GOOGLE",$row['google'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-PINTEREST",$row['pinterest'],$facebook_twitter);
			$facebook_twitter = str_replace("YOUR-YOUTUBE",$row['youtube'],$facebook_twitter);

			//根据页码生成文件名
			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;		//当前页码
				}
				
				$ls_p_cate=$s_p_cate;	//左侧产品类别;
		 		//查询产品
				$news_sql2.=" limit ".$start.",".$onepage." ";
				$news_query=$opendb->query($news_sql2);
				$list="<div class=\"row pro_list masonry-container\">";
				while($news_rows=mysql_fetch_assoc($news_query)){
					$list.="<div class=\"col-xs-4 item\">
							<div class=\"thumbnail\">
								<div class=\"img-pic2\">
							  <a href=\"".$packingFolders."/packing-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\" class=\"c-img\"><img src=\"../".$packingFolders."/".$SmallFoldersProducts."/".$news_rows['Pic']."\" alt=\"".$news_rows['Title']."\" /></a>
							  </div>
							  <div class=\"caption pro-name\">
								<a href=\"".$packingFolders."/packing-page".$news_rows['ID'].".html\"  title=\"".$news_rows['Title']."\">".$news_rows['Title']."</a>
							  </div>
							</div>
						  </div>";
					
					$newstitle=$news_rows['Title'];
					$newimg = "<center><img src=\"../../".$packingFolders."/".$BigFoldersProducts."/".$news_rows['Pic']."\" class=\"img-responsive\"  ondragstart=\"return false;\"/></center>";
					$newstext = str_replace("src=\"../", "src=\"../../", $news_rows['Text']);
					$ls_newid = $news_rows['ID'];
					createFolder("../m/".$packingFolders);
					
					$index_newspath="../".$mobi_templates_var."/packingshow.html";		//模板地址
					if(file_exists($index_newspath)){
						$ls_title=$news_rows['newsTitle'];				//title
						$ls_keywords=$news_rows['newsKeywords'];			//Keywords
						$ls_description=$news_rows['newsDescription'];	//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_p_cate}",$ls_p_cate,$newscontent);
						$newscontent = str_replace("{ls_m_cate}",$p_m_cate1,$newscontent);
						$newscontent = str_replace("{ls_motif}",$ls_motif,$newscontent);
						$newscontent = str_replace("{ls_propage}",$ls_propage,$newscontent);
						$ls_facebook_twitter = str_replace("../", "../../",$facebook_twitter);
						$newscontent = str_replace("{ls_weibo}",$ls_facebook_twitter,$newscontent);
						$ls_facebook_twitter_share = $facebook_twitter_share;
						$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
						
						$ls_indicatebar = "<li><a href=\"../index.html\">Home</a></li>
								   <li><a href=\"../packing.html\">packing</a></li>";
						$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$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_packing",$catenews['cateName'],"packing",$suffix_str2,false);
						$newscontent = circleNavigationLinkNews($news_rows['ID'],'F','{ls_previouslink}',$newscontent,"ls_packing",$catenews['cateName'],"packing",$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/".$packingFolders."/packing-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);
					}else{
						echo "<p>模版文件".$index_newspath."不存在，请设计好模板后重新生成。</p>";
					}
				}
				$list.="</div>";
				
				//页码计算
				$propage=getPagess("packing.html",$allpages,$ls_current_page);
				
				$index_path="../".$mobi_templates_var."/packing.html";				//车间模板地址
				$ls_title=$news_rows3['inTitle'];												//title
				$ls_keywords=$news_rows3['inKeywords'];										//Keywords
				$ls_description=$news_rows3['inDescription'];							//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_m";
				$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
	  		
	  		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地图， 地区环境
		
		$information_sql="select * from ls_information where inMenu='contact' ";
		$information_query=$opendb->query($information_sql);
		$information_rows=mysql_fetch_assoc($information_query);
		
		$ls_title=$information_rows['inTitle'];//title
		$ls_keywords=$information_rows['inKeywords'];	//Keywords
		$ls_description=$information_rows['inDescription'];//Description
		
		$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 = str_replace("href=\"../", "href=\"", $information_rows['content']);//contact us
		$ls_foot=$foot;//底部信息
		
		$ls_propage="";
		$ls_feedbackemail="";
		$mainpart=$ls_contactus;
		$mainpartsubject="contactus_m";
		$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
	 	 if($ls!="all_m" && $ls_m!="all_products")
 {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_m";
				$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,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
	
			echo "生成member 目录下文件--------------------<br />";
			foreach($generalCreateFilesMembers as $createdfile){			//生成member 下文件
				$subFolder=true;		//设置子目录 替换../../ 为 ../
				$index_path="../".$mobi_templates_var."/";//模板目录
				$mainpartsubject="createdfile_m";
				$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_motif,$ls_menu,$ls_foot,
$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
			$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_motif,$ls_menu,$ls_foot,
$filename,$mainpart,$ls_introduction,$mainpartsubject,$ls_feedbackemail,$ls_propage,$s_cate,$s_p1_cate,$languages0,$ls_addprolink,$ls_addnewprolink,$newstag,$translate);
			}
			$subFolder=false;
			if($ls!="all" && $ls!="all_products"){
				//生成全部页面，不包括作品页，否则break 
				break;
			}
 
 		//生成手机产品页
		case "all_products_m": //生成全部页面，包括产品页，否则break	
		case "products_m":  //生成产品页 products
			
			$pro_pic_sql="SELECT * FROM `ls_products` WHERE `cateName` IS NOT NULL and catePic !='' order by Num";
			$pro_pic_query=$opendb->query($pro_pic_sql);
			
			$ls_pro = "<div class=\"row pro_list\">";
			while($pro_pic_rows=mysql_fetch_assoc($pro_pic_query)){
				$ls_pro .= "<div class=\"col-xs-4\"><div class=\"thumbnail\"><div class=\"img-pic\"><a href=\"".$pro_pic_rows['cateFolders']."/".$pro_pic_rows['cateFolders'].".html\"><img src=\"../".$pro_pic_rows['cateFolders']."/".$pro_pic_rows['catePic']."\" name=\"imgs\" alt=\"".$pro_pic_rows['midcateName']."\" /></a></div><div class=\"caption pro-name\"><a href=\"".$pro_pic_rows['cateFolders']."/".$pro_pic_rows['cateFolders'].".html\">".$pro_pic_rows['cateName']."</a></div></div></div>";
			}
			$ls_pro .= "</div>";

			$index_newspath="../".$mobi_templates_var."/prolist.html";		//模板地址
			$ls_title = $config_row['companyName'];				//title
			$ls_keywords=$config_row['siteKeywords'];			//Keywords
			$ls_description=$config_row['siteDescription'];	//Description
			$ls_cate=$pro_cate;
			$ls_s_cate=$s_pro_cate;								//左侧产品类别;
			$ls_s_news = $ls_h1_news;
			$ls_p_cate=$s_p_cate;								//左侧产品类别;
			$ls_f_cate=get_pro_cate(1);
			$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("../","",$newscontent);
			$newscontent = str_replace("{ls_title}",$ls_title,$newscontent);
			$newscontent = str_replace("{ls_keywords}",$ls_keywords,$newscontent);
			$newscontent = str_replace("{ls_description}",$ls_description,$newscontent);
			$newscontent = str_replace("{ls_menu}",$ls_menu,$newscontent);
			$newscontent = str_replace("{ls_cate}",$ls_cate,$newscontent);
			$newscontent = str_replace("{ls_s_cate}",$ls_s_cate,$newscontent);
			$newscontent = str_replace("{ls_pro}",$ls_pro,$newscontent);
			$newscontent = str_replace("{ls_p_cate}",$ls_p_cate,$newscontent);
			$newscontent = str_replace("{ls_f_cate}",$ls_f_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);
			$ls_facebook_twitter_share = $facebook_twitter_share;
			$newscontent = str_replace("{ls_weiboshare}",$ls_facebook_twitter_share,$newscontent);
			
			$ls_indicatebar = "<li><a href=\"index.html\">Home</a></li>
                               <li style='text-transform : capitalize;'>Products</li>";
			$newscontent = str_replace("{ls_indicatebar}",$ls_indicatebar,$newscontent);
			$newscontent = str_replace("{ls_news}",$ls_s_news,$newscontent);
			$newscontent = str_replace("{ls_newstime}",$ls_newstime,$newscontent);
			$newscontent = str_replace("{ls_newid}",$ls_newid,$newscontent);
			$newscontent = str_replace("{ls_click_n}",$ls_click_n,$newscontent);
			$newscontent = str_replace("{ls_newstitle}",$ls_newstitle,$newscontent);
			$newscontent = str_replace("{ls_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链接
			$filename="../m/prolist.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);
			
			//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_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);
							$mynum2=mysql_num_rows($query2);
							if($mynum2!=0){
								//有小类
								$midcateid=$myrows1['ID'];
								$mid_id = $midcateid;
								$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'];
									$midcateid = $mid_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);
					$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']=="ok")//不生成全部产品就执行一次循环退出
				{}
				else
				{break;}
			}// end of cate while
			if($ls!="all_products"){
				//生成全部页面，不包括产品页，否则break 
				break;
			}
}
?></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
