<?php
	require_once('_approot.php');	
	$addcatestr=substr(str_replace(",","' or cateName='",$defaultmenu),1)."' ";
	$selectfunctionName=str_replace("'","''",urldecode($_GET['selectfunctionName'])); 
	if($cateName=="") $tplin=true; else $tplin=(strpos($defaultmenu,(string)$cateName)===false);	
	//var_dump($tplin,$cateName);

	$searchproductName=($_POST['searchproductName']==""?$_GET['searchproductName']:$_POST['searchproductName']);
	if($searchproductName!="") $ls_msg="包含 $searchproductName 的类别 ";
	if($_POST['gopage']!=""){$gopage =(ctype_digit($_POST['gopage'])?$_POST['gopage']:1);}
	if($gopage!="") $ls_msg="第 $gopage 页的类别 ";

	$modiid=$_POST['modiid'];
	$dispFunctionName="菜单";
	$functionName=str_replace("'","''",trim($_POST['functionName']));
	$functionName2=str_replace("'","''",trim($_POST['functionName2']));
	$cateName=str_replace("'","''",trim($_POST['cateName']));
	$cateName2=str_replace("'","''",trim($_POST['cateName2']));
	if($_GET['cateName']!="")
		{$cateName=$_GET['cateName'];} 
	$typeurl = trim($_POST['typeurl']);
	$folder = clearFolder(trim(strtolower($_POST['folder'])));
	$createpage = $_POST['createpage'];
	$flag = $_POST['flag'];
	$headerurl = $_POST['headerurl'];
	$brief=trim($_POST['brief']);
	$brief = editorPath('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], $brief);//内链
	$brief = editorPath($_SERVER['PHP_SELF'], $brief);//图片

	
	$detail=trim($_POST['detail']);
	$detail = editorPath('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], $detail);//内链
	$detail = editorPath($_SERVER['PHP_SELF'], $detail);//图片
	
	$in_sql="SELECT * FROM ls_internal where enable=1 order by Num asc"; //count the error by searchtype
	$in_query=$opendb->query($in_sql);
	while ($in_rows=mysqli_fetch_assoc($in_query)){
		$detail = internal_keyword_link($detail, $in_rows['title'], $in_rows['url']);
		$brief = internal_keyword_link($brief, $in_rows['title'], $in_rows['url']);
	}

	$brief = addAltTitle( $cateName!=""?$cateName:$functionName, $functionName."，".$cateName, $brief);  //图片添加alt,title
	
	$briefmodi=$_POST['briefmodi'];
	$briefmodi = addAltTitle( $cateName!=""?$cateName:$functionName, $functionName."，".$cateName, $briefmodi);  //图片添加alt,title
	$detail = addAltTitle( $cateName!=""?$cateName:$functionName, $functionName."，".$cateName, $detail);  //图片添加alt,title
 
	$detailmodi=$_POST['detailmodi'];
	$detailmodi = addAltTitle( $cateName!=""?$cateName:$functionName, $functionName."，".$cateName, $detailmodi);  //图片添加alt,title
	
	$suffStr=trim($_POST['suffStr']);
	$hotLines=trim($_POST['hotLines']);
	$hotWords=trim($_POST['hotWords']);
	$newstype=trim($_POST['newstype']);
	$oldfunctionName=str_replace("'","''",$_POST['oldfunctionName']);
	$oldcateName=str_replace("'","''",$_POST['oldcateName']);
	
	$Num=$_POST['Num'];
	$inMenu=$_POST['inMenu']; 
	
	$newsTitle=trim($_POST['newsTitle']);
	$newsKeywords=trim($_POST['newsKeywords']);
	$newsDescription=trim($_POST['newsDescription']);
	
	if($newsTitle==""){
		$newsTitle= ($cateName==""?$functionName:$cateName)." - ".$mycompanyName ;
	
		$newsKeywords=($cateName==""?$functionName:$cateName);
		$newsDescription=( $briefmodi==""?$newsKeywords:trim(substr(strip_tags($briefmodi),0,260)));
	}
	
	if ($_GET['ls_msg']=="")
	{
		$ls_msg.=$functionName."管理操作。";
	}	
	else
	{
		$ls_msg.=$_GET['ls_msg'];	
	}
		$ls=$_GET['ls'];
		$id=$_GET['id'];
	switch ($ls)
	{
	 	case "unenable":
			$unenable_sql="update ls_functioncates set enable=0 where id=".$id." ";
			//echo $unenable_sql;
			$unenable_query=$opendb->query($unenable_sql);
			$ls_msg="不显示操作成功！";
			break;
		case "enable":
			$enable_sql="update ls_functioncates set enable=1 where id=".$id." ";
			//echo $enable_sql;
			$enable_query=$opendb->query($enable_sql);
			$ls_msg="显示操作成功！";
			break;
		case "del":
			$select_sql2="select * from ls_functioncates  where ID=".$id."";
			$select_query2=$opendb->query($select_sql2);
			$rows2=mysqli_fetch_assoc($select_query2);
			$numar=funccatearnum($rows2['functionName'],$rows2['cateName']);
			if($numar==0){
				$del_sql="delete from ls_functioncates where ID=".$id."";
				//echo $del_sql;
				$del_query=$opendb->query($del_sql);
				$ls_msg="删除操作成功！";
				$tpl=$rows2['typeurl'];
				$tplshow=str_replace(".","show.",$tpl);
				if(file_exists("../Templates1/".$tpl)) 
					if(!unlink("../Templates1/".$tpl)) $ls_msg.=$tpl."模板删除错误! "; else $ls_msg.=$tpl."模板已删除! ";//复制模板
				if(file_exists("../Templates1/".$tplshow)) 
					if(!unlink("../Templates1/".$tplshow)) $ls_msg.=$tplshow."模板删除错误! "; else $ls_msg.=$tplshow."模板已删除! ";//复制模板
				$folder="../".$rows2['folder'];
				if(rmdir($folder)) $ls_msg.=$folder."已删除! ";	
				
				writelog($_SERVER['PHP_SELF'],"delete column(function) ","ID: ".$id);
			}else{
				$ls_msg.="当前分类下有 ".$numar." 条文章，请先删除这些，再删除此分类。";	
			}
			break;
			
		case "insert":
			$select_sql2="select * from ls_functioncates  where  cateName='".$cateName."'  and functionName='".$functionName."' ";
			if($cateName=="") $select_sql2="select * from ls_functioncates  where cateName is NULL and functionName='".$functionName."' ";
			$select_query2=$opendb->query($select_sql2);
			$select_rows2_num=mysqli_num_rows($select_query2); //总数
			
			$select_sql21="select * from ls_functioncates  where  typeurl='".$typeurl."'    ";
			$select_query21=$opendb->query($select_sql21);
			$select_rows21_num=mysqli_num_rows($select_query21); //总数
			if($select_rows2_num==0 && $select_rows21_num==0)
			{
				
				$folder=$folder!=""?$folder:clearFolder(trim(strtolower($functionName))); //建文件夹
				$folder= $lang == "en"? $folder:pathProName($folder); //中文
				if(!file_exists("../".$folder)) createFolder("../".$folder);
				$folder2=clearFolder(trim(strtolower($cateName)));
				$folder2= $lang == "en"? $folder2:pathProName($folder2); //中文
				if(!file_exists("../".$folder2)&& $folder2!="") createFolder("../".$folder2);
				$folder=$folder2!=""?$folder2:$folder;
				
				$insert_sql=sprintf("insert into ls_functioncates (fTitle, fKeywords, fDescription, cateName, brief, detail,suffStr, hotLines, hotWords, functionName, typeurl,newstype,createpage,date,folder,Num) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
						GetSQLValueString($newsTitle,"text"),
						GetSQLValueString($newsKeywords,"text"),
						GetSQLValueString($newsDescription,"text"),
						GetSQLValueString($cateName,"text"),
						GetSQLValueString($brief,"text"),
						GetSQLValueString($detail,"text"),
						GetSQLValueString($suffStr,"text"),
						GetSQLValueString($hotLines,"text"),
						GetSQLValueString($hotWords,"text"),
						GetSQLValueString($functionName,"text"),
						GetSQLValueString($typeurl, "text"),
						GetSQLValueString($newstype, "text"),
						GetSQLValueString(1, "int"),
						GetSQLValueString(date('y-m-d H:m:s'), "date"),
						GetSQLValueString($folder, "text"),
						GetSQLValueString($Num, "int")
						);
				
				//echo $insert_sql."--1--"; exit;
				$insert_query=$opendb->query($insert_sql);
				$tpl=$typeurl;
				$tplshow=str_replace(".","show.",$typeurl);
				$ls_msg="添加操作成功！";
				
				if(!file_exists("../Templates1/".$tpl) && $tplarcate && $tplin) //允许中类模板，不是默认的，模板不存在
					if(!copy("../Templates1/article.html","../Templates1/".$tpl)) $ls_msg.=$tpl."复制模板错误!";//复制模板
					else $ls_msg.=$tpl."模板已复制。";
				else $ls_msg.= $tpl."模板已存在。".($tplarcate?$tpl."使用大类模板。":"");
				
				if(!file_exists("../Templates1/".$tplshow)&& $tplarcate && $tplin) 
					if(!copy("../Templates1/articleshow.html","../Templates1/".$tplshow)) $ls_msg.=$tplshow."复制模板错误!";//复制模板
					else $ls_msg.=$tplshow."模板已复制。";
				else $ls_msg.= $tplshow."模板已存在。".($tplarcate?$tplshow."或使用大类模板。":"");

				
				writelog($_SERVER['PHP_SELF'],"add column(function) ","cateName: ".$cateName." functionName: ".$functionName);
			}
			else
			{ $ls_msg= $select_rows2_num==0?"链接已存在！":"分类已存在！";}
			break;
			
	case "modi":
			if(!file_exists("../".$folder)&& $folder!=""){ createFolder("../".$folder);$ls_msg.="../".$folder." 目录已填加。";}  

			
			$modi_sql=sprintf("update ls_functioncates set cateName=%s, fTitle=%s, fKeywords=%s, fDescription=%s, Num=%s, suffStr=%s, hotLines=%s, hotWords=%s, brief=%s, detail=%s, typeurl=%s, inMenu=%s, newstype=%s,createpage=%s,date=%s,folder=%s,flag=%s,headerurl=%s  where id=%s",
						GetSQLValueString($cateName,"text"),
						GetSQLValueString($newsTitle,"text"),
						GetSQLValueString($newsKeywords,"text"),
						GetSQLValueString($newsDescription,"text"),
						GetSQLValueString($Num,"int"),
						GetSQLValueString($suffStr,"text"),
						GetSQLValueString($hotLines,"text"),
						GetSQLValueString($hotWords,"text"),
						GetSQLValueString($briefmodi,"text"),
						GetSQLValueString($detailmodi,"text"),
						GetSQLValueString($typeurl,"text"),
						GetSQLValueString($inMenu,"int"),
						GetSQLValueString($newstype,"int"),
						GetSQLValueString($createpage,"int"),
						GetSQLValueString(date('y-m-d H:m:s'), "date"),
						GetSQLValueString($folder,"text"),
						GetSQLValueString($flag,"text"),
						GetSQLValueString($headerurl,"text"),
						GetSQLValueString($modiid,"int") 
						);
			$modi_query=$opendb->query($modi_sql);
			
			//全部分类
			$modi_sql="update ls_functioncates set functionName='".$functionName."'  where functionName='".$oldfunctionName."' ";
			//echo $modi_sql;
			$modi_query=$opendb->query($modi_sql);
			//全部子类
			$modi_sql="update ls_functioncates set cateName='".$cateName."'  where cateName='".$oldcateName."' and functionName='".$functionName."'";
			//		echo $modi_sql_article;
			$modi_query=$opendb->query($modi_sql);
			//文章分类
			$modi_sql_article="update ls_article set functionName='".$functionName."'  where functionName='".$oldfunctionName."' ";
			//		echo $modi_sql_article;
			$modi_query=$opendb->query($modi_sql_article);
			//文章子类			
			$modi_sql_article="update ls_article set  cateName='".$cateName."'  where cateName='".$oldcateName."'  and functionName='".$functionName."'";
			//		echo $modi_sql_article;
			$modi_query=$opendb->query($modi_sql_article);

			$tpl=$typeurl;
			$tplshow=str_replace(".","show.",$typeurl);
 
			if(!file_exists("../Templates1/".$tpl) && $tplarcate && $tplin) 
				if(!copy("../Templates1/article.html","../Templates1/".$tpl)) $ls_msg.=$tpl."复制模板错误。";//复制模板
				else $ls_msg.=$tpl."模板已复制。";
			else $ls_msg.=$tplarcate?$tpl."模板已存在。":$tpl."使用大类模板。"; 
			
			if(!file_exists("../Templates1/".$tplshow) && $tplarcate && $tplin) 
				if(!copy("../Templates1/articleshow.html","../Templates1/".$tplshow)) $ls_msg.=$tplshow."复制模板错误。";//复制模板
				else $ls_msg.=$tplshow."模板已复制。";
			else $ls_msg.=$tplarcate?$tplshow."模板已存在。":$tplshow."使用大类模板。";


			writelog($_SERVER['PHP_SELF'],"modify column(function) "."cateName: ".$cateName." functionName: ".$functionName,"ID: ".$modiid);
			$ls_msg。="修改操作成功！";
			break;
	}
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysqli_fetch_assoc($title_query);
?>
<!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">
        <script language="JavaScript" src="js/jquery.min.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
	</head>
    
<script>
	function caiji(a){
			
	}


</script>
<link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
	<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
	<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
	<script>
   // 修改 brief 的 KindEditor 初始化在secBoard
		
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="briefmodi"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterBlur: function(){
					this.sync();
					if($('#functionName').val().length >= 0){
						$('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}
				},
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
		
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="detailmodi"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterBlur: function(){
					this.sync();
					if($('#functionName').val().length >= 0){
						$('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}
				},
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});

		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="brief"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterBlur: function(){
					this.sync();
					if($('#functionName').val().length >= 0){
						$('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}
				},
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
		
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="detail"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterBlur: function(){
					this.sync();
					if($('#functionName').val().length >= 0){
						$('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}
				},
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});

</script>
 <body>
	<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#3c8dbc">
<tr>
				<td height="31" background=""><div align="center"><font color="#ffffff"><strong>
			    菜单、栏目
				管理</strong></font></div>
</td>
			</tr>
			<tr>
				<td height="879" valign="top" bgcolor="#f0f0ee"><br />
				  <table width="98%" border="0" align="center">
				  <tr>
				    <td width="97%" >提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
				    <td width="3%" ><a href="#add">添加</a></td>
			      </tr>
				  </table>
				  <?php
					// 获取当前页数
					if( isset($_GET['page']) ){
					   $page = intval( $_GET['page'] );
					}
					else{
					   $page = 1;
					}
					// 每页数量
					$PageSize = 12;
					
					// 获取总数据量
					/********************************************************************************/
			if($searchproductName!="") $searhprostr=" and (	functionName like '%".$searchproductName."%' or brief like '%".$searchproductName."%' or 	detail like '%".$searchproductName."%' or date like '%".$searchproductName."%' or cateName like '%".$searchproductName."%' or subCateName like '%".$searchproductName."%'  ) ";   	
						
		  if($selectfunctionName=="")
		  {	$sql="select * from ls_functioncates where  functionName!='singlePages'   ";	} //functionName!='新闻分类' and functionName!='博客分类'  and functionName!='常见问题'  and
		  else
		  {
		  	$sql="select * from ls_functioncates where functionName='".$selectfunctionName."'  ";	
		  } 
		  
		  if($selectfunctionName=="1")
		  {	
		  	$sql="select * from ls_functioncates where ( cateName='' or cateName is NULL  ".$addcatestr." ) and ( subCateName='' or subCateName is NULL )    ";												
		  }						
		  $sql.=$searhprostr; //搜索
		  $result=$opendb->query( $sql ); 
													
													/********************************************************************************/
		  // 获取总数据量
		  
		  $row = mysqli_num_rows($result);
		  $amount = $row;
		  
		  // 记算总共有多少页
		  if( $amount ){
			 if( $amount < $PageSize ){ $page_count = 1; }			   //如果总数据量小于$PageSize，那么只有一页
			 if( $amount % $PageSize ){								  //取总数据量除以每页数的余数
				 $page_count = (int)($amount / $PageSize) + 1;		   //如果有余数，则页数等于总数据量除以每页数的结果取整再加一
			 }else{
				 $page_count = $amount / $PageSize;					  //如果没有余数，则页数等于总数据量除以每页数的结果
			 }
		  }
		  else{
			 $page_count = 0;
		  }
		  
		  // 翻页链接
		  $page_string = '';
			  
		  if( $page == 1 ){
			 $page_string .= '首页 | 上一页 |';
		  }
		  else{
			 $page_string .= '<a href=?page=1&selectfunctionName='.urlencode($selectfunctionName).'&searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">首页</font></u></a> | <a href=?page='.($page-1).'&selectfunctionName='.urlencode($selectfunctionName).'&searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">上一页</font></u></a> | ';
		  }
		  if( ($page == $page_count) || ($page_count == 0) ){
			 $page_string .= ' 下一页 | 尾页';
		  }
		  else{
			 $page_string .= ' <a href=?page='.($page+1).'&selectfunctionName='.urlencode($selectfunctionName).'&searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">下一页</font></u></a> | <a href=?page='.$page_count.'&selectfunctionName='.urlencode($selectfunctionName).'&searchproductName='.$searchproductName.'><u><font color=\"#0000FF\">尾页</font></u></a>';
		  }
			   $page_string .= " &nbsp;&nbsp;页次：<font color='#FF0000'><b>".$page."</b></font>/<b>".$page_count."</b>页";
			   $page_string .= " &nbsp;&nbsp;<b>".$PageSize."</b>个每页";
					?>
					
				
				<table border="0" width="98%" align="center">
<tr>
							<td width="91%"><strong>菜单项选择： </strong>
							  <?php                                                 
                  $article_sql="SELECT distinct functionName FROM ls_functioncates where enable=1 order by Num ASC ";// 
                  
                  $article_query=$opendb->query($article_sql);

                    while($news_rows2=mysqli_fetch_assoc($article_query))
                      {
						  $thisfunc1=$news_rows2['functionName'];
						  $showfunc=$thisfunc1;
						  if($thisfunc1=="博客分类")$showfunc=getlangmemu("Blog");
						  if($thisfunc1=="常见问题")$showfunc=getlangmemu("Faq");
						  if($thisfunc1=="新闻分类")$showfunc=getlangmemu("News");
						  
                          if($news_rows2['brief'] == "home"){
                              if($selectfunctionName==$thisfunc1)
                              {echo "<a href='?selectfunctionName=".urlencode($thisfunc1)."'><font  color='#549800' ><span style=\"color:#930\" >".$showfunc."</span></font></a> | ";}
                              else
                              {echo "<a href='?selectfunctionName=".urlencode($thisfunc1)."'><font  color='#549800' >".$showfunc."</font></a> | ";}
                          }else{
                              if($selectfunctionName==$thisfunc1)
                              {echo "<a href='?selectfunctionName=".urlencode($thisfunc1)."'><span style=\"color:#930\" >".$showfunc."</span></a> | ";}
                              else
                              {echo "<a href='?selectfunctionName=".urlencode($thisfunc1)."'>".$showfunc."</a> | ";}
                          }
                      }
                    ?>							  <a href='?selectcate='> 全部 </a> | <a href='?selectfunctionName=1'> 大类 </a>
</td>
                      <td width="9%" align="right">共 <b><?php echo $row; ?></b> 个</td>
					</tr>
					 </table>
			  <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#E4E4E4">
							<td width="25" height="25" align="center">选</td>
		  <td width="26" height="25" align="center">ID</td>
		  <td width="158"  align="center" ><?=$dispFunctionName?>分类（banner）</td>
		  <td width="158"  align="center" >子<?=$dispFunctionName?>分类</td>
		  <td width="126"  align="center" >链接（模板）</td>

		  <td width="192"  align="center" id="jianjie">数量 / 日期 /  简介</td>
		  <td width="38"  align="center" >标识</td>
		  <td width="38"  align="center" >列出</td>
		  <td width="38"  align="center" >图标</td>
		  <td width="38" align="center">形式</td> <!--采集-->
		  <td width="28" align="center" >排序</td>
		  <td width="28" align="center" >生成</td>
		  <td width="33" align="center" id="flag" >修改</td>
		  <td width="29" align="center">删除</td>
		  <td width="35" align="center">菜单</td>
				</tr>
		  <?php
		  
		  $functioncates_sql=$sql." order by  Num asc, ID desc limit ". ($page-1)*$PageSize .",".$PageSize." ";	
		  //echo $functioncates_sql;
		  		$functioncates_query=$opendb->query($functioncates_sql);
		  
		  		  	$i=1;
		  		  	while($functioncates_rows=mysqli_fetch_assoc($functioncates_query))
		  			 {
						$showcateName= $functioncates_rows['cateName'];
						$ifdefaultmenu= strpos($defaultmenu,$showcateName)===false? false:true;
		  		  	 ?>

                       <tbody id='ZH_<?=$functioncates_rows['ID']?>' >	
		  				<tr bgcolor='#f4f4f4'
		  		  onMouseOver=
		  		  	 	this.style.backgroundColor='#FDFDFD' 
		  		  	onMouseOut=
		  		  	 	this.style.backgroundColor='#f4f4f4' 
		  		  	>
		  		  		<td align='center'  height='34'>
		  		  			<input name='select_id<?=$i?>' type='checkbox' onclick="unselectall()" id="select_id" value='<?=$functioncates_rows['ID']?>'>
		  		  		</td>
		  		  		<td align='center'>
		  		  	<?=$functioncates_rows['ID']?>
		  		  		</td>
		  		    	<td style='padding-left:10px;' title="标题： <?=$functioncates_rows['fTitle']."\r\n\r\n描述： ".$functioncates_rows['fDescription']?>">
		  		    <?php 						  $thisfunc1=$functioncates_rows['functionName'];
						  $showfunc=$thisfunc1;
						  if($thisfunc1=="博客分类")$showfunc=getlangmemu("Blog");
						  if($thisfunc1=="常见问题")$showfunc=getlangmemu("Faq");
						  if($thisfunc1=="新闻分类")$showfunc=getlangmemu("News");
						  echo $showfunc;
					?>
		  		    	</td>
		  		    	<td style='padding-left:10px;' title="标题： <?=$functioncates_rows['fTitle']."\r\n\r\n描述： ".$functioncates_rows['fDescription']?>">
		  		    
		  		    <?=$ifdefaultmenu?"":$showcateName?> <!--<font color='green'>".$showcateName."<font>-->
		  		    	</td>
		  		    	<td style='padding-left:10px;' ><?=$functioncates_rows['typeurl']?></td>
		  		    	<td style='padding-left:10px;'>
		  		    <?=trim($selectfunctionName=="大类"?funccatearnum($functioncates_rows['functionName'],$showcateName):funccatearnum($functioncates_rows['functionName'],$showcateName))?>)
                   <?=substr( $functioncates_rows['date'],2,8)?> <br/>
		  		   <span title="<?=strip_tags($functioncates_rows['brief'])?>" style="color:#757575; font-size:10px;"> <?=mb_substr(strip_tags($functioncates_rows['brief']),0,46, 'utf-8')?>
		  		    </span>
		  		    	</td>
		  		    	<td style='padding-left:10px;'>
		  		    <?=$functioncates_rows['suffStr']?>
		  		    	</td>
		  		    	<td style='padding-left:10px;'>
		  		    <?=$functioncates_rows['hotLines']?>
		  		    	</td>
		  		    	<td style='padding-left:10px;'>
		  		    <?=$functioncates_rows['hotWords']?>
		  		    	</td>
		  		    	<td style='padding-left:10px;'>
                        <?=$functioncates_rows['newstype']?>
                        <?php 						
/*							$sql = "select * from ls_collection where enable=1 group by menu ";
							$rows = $opendb->AllRows($sql);
							foreach($rows as $v){
                            	if($v['menu']==$functioncates_rows['ID']){
		  		    				echo '<a href="savecollection.php?id='.$functioncates_rows['ID'].'" >采集</a>';
								}else{
									
								}
							}
*/						?>
		  		    	</td>
		  		    	<td align='center'><span style="padding-left:10px;">
		  		    	  <?=$functioncates_rows['Num']?>
		  		    	</span></td>
			<td align='center'><span style="padding-left:10px;">
			  <?=$functioncates_rows['createpage']?>
			</span></td>
		  		  		<td align='center'><a href='javascript:secBoard(<?=$functioncates_rows['ID']?>);$("#jianjie").text("文件夹名(一般勿改)");$("#flag").text("首页"); ' title='编辑'><img src='images/b_edit.png' border='0' /></a></td>
		  		  		<td align='center'><?php
							$article_sql="select count(*) as ctrows from ls_article where functionName ='".str_replace("'","''",$functioncates_rows['functionName'])."' and cateName='".str_replace("'","''",$showcateName)."' and subCateName='".str_replace("'","''",$functioncates_rows['subCateName'])."'  ";
							$article_query=$opendb->query($article_sql);
							$rowct = mysqli_fetch_assoc($article_query);
					   		$article_num = $rowct['ctrows'];
							$thisfunc =trim($functioncates_rows['functionName']);
							$thiscate =trim($showcateName);
							$ifdefunc= strpos( $funcreadonly,$thisfunc  );
							$ifdecate= strpos( $catereadonly,$thiscate  );
							if($article_num == 0 &&   $ifdefunc===false  ||  $ifdecate===false   ){
						 
                        if(($thisfunc!="博客分类"||$thisfunc=="博客分类"&&$thiscate!="blog")&&($thisfunc!="常见问题"||$thisfunc=="常见问题"&&$thiscate!="faq")&&($thisfunc!="新闻分类"||$thisfunc=="新闻分类"&&$thiscate!="news")){?> <a href='?id=<?=$functioncates_rows['ID']?>&ls=del&functionName=<?=$functionName?>&cateName=<?=$cateName?>&selectfunctionName=<?=$selectfunctionName?>&page=<?=$page?>&searchproductName=<?=$searchproductName?>' onclick='return ConfirmDelSubCate();' title='删除'><img src='images/b_drop.png' border='0' /></a>
                          <?php }}else{?>
                          <img src='images/b_undrop.png' border='0' title='不可删除类或者类别下面有文章，请先删除文章。' />
                          <?php }?></td>
		  		  		<td align='center'>
		  					  <?php 		  		  	  if($functioncates_rows['enable']==1)
		  		  		{
		  		  			?>
		  		  			<a href='?id=<?=$functioncates_rows['ID']?>&ls=unenable&selectcate=<?=$selectcate?>&selectfunctionName=<?=$selectfunctionName?>&page=<?=$page?>&searchproductName=<?=$searchproductName?>' title='显示'><img src='images/enable.gif' border='0'></a>
		  		  		<?php }
		  		  	  if($functioncates_rows['enable']==0)
		  		  	  	{ ?>
		  		  			<a href='?id=<?=$functioncates_rows['ID']?>&ls=enable&selectcate=<?=$selectcate?>&selectfunctionName=<?=$selectfunctionName?>&page=<?=$page?>&searchproductName=<?=$searchproductName?>' title='不显示'><img src='images/unenable.gif' border='0'></a>
                            <?php } ?>
		  		  		  		
		  		  		</td>
		  		    </tr>
	    		</tbody>
		
		<tbody id='Z_<?=$functioncates_rows['ID']?>' style='display:none;'>
		 <form name='fm_menu<?=$functioncates_rows['ID']?>' action='?ls=modi&page=<?=$page?>&functionName=<?=$functionName?>&selectfunctionName=<?=$selectfunctionName?>&searchproductName=<?=$searchproductName?>' method='post'  > 

			<tr bgcolor='#CCCCCC'>
			<td align='center'>&nbsp;
			</td>
			<td align='center'>&nbsp;
			</td>
				<td style='padding-left:5px;'>
				  <input type='text' value='<?=$functioncates_rows['functionName']?>' name='functionName' style='width:100%' class='inp' onKeyUp="this.value=this.value.replace(/&/g, '');" <?php if( !( $ifdefunc===false) )  echo "readonly" ; ?>> 
			<input type='hidden' value='<?=$functioncates_rows['functionName']?>' name='oldfunctionName' > 
		 		</td>
				<td style='padding-left:5px;'>
					<input type='text' value='<?=$showcateName?>' name='cateName' style='width:100%' class='inp' onKeyUp="this.value=this.value.replace(/&/g, '');" <?php if(!( $ifdecate===false))  echo "readonly" ; ?>>
			<input type='hidden' value='<?=$showcateName?>' name='oldcateName' > 
		 		</td>
				<td style='padding-left:5px;'><input type='text' value='<?=$functioncates_rows['typeurl']?>' name='typeurl' class='inp' style='width:100%' /></td>
				<td style='padding-left:5px;'><input type='text' value='<?=$functioncates_rows['folder']?>' name='folder' class='inp' style='width:90%' />
               
            </td>
				<td style='padding-left:5px;'>
					<input type='text' value='<?=$functioncates_rows['suffStr']?>' name='suffStr' size='6' class='inp'>
		 		</td>
				<td style='padding-left:5px;'>
					<input type='text' value='<?=$functioncates_rows['hotLines']?>' name='hotLines' size='2' class='inp' ondblclick= 'this.value=(this.value==1?0:1)'>
		 		</td>
				<td style='padding-left:5px;'><input type='text' value='<?=$functioncates_rows['hotWords']?>' name='hotWords' size='16' class='inp' /></td>
				<td style='padding-left:5px;'><input type='text' name='newstype' value='<?=$functioncates_rows['newstype']?>'  size='2' class='inp' /></td>
				<td><span style="padding-left:5px;">
				  <input type='text' value='<?=$functioncates_rows['Num']?>' name='Num' size='2' class='inp' />
				</span></td>
		  		<td><span style="padding-left:5px;">
		  		  <input type='text' value='<?=$functioncates_rows['createpage']?>' name='createpage' size='1' class='inp' ondblclick= 'this.value=(this.value==1?0:1)' />
		  		</span></td>
                <td><input type='text' value='<?=$functioncates_rows['flag']?>' name='flag' size='1' class='inp' ondblclick= 'this.value=(this.value==1?0:1)' /></td>
             <td>&nbsp;</td>
                <td><span style="padding-left:5px;">
<!--                  <input type='text' value='<?=$functioncates_rows['inMenu']?>' name='inMenu' size='2' class='inp' />
-->                </span></td>
                 
			</tr>
			<tr bgcolor='#CCCCCC'>
            	<td colspan="2">简介：</td>
              <td colspan="7" align='center'><textarea name="briefmodi"  class="inp" id="briefmodi" style="width:100%;height:180px;visibility:;" onblur="addcate.newsDescription.value=(addcate.newsDescription.value.length==0) ? this.value : addcate.newsDescription.value"><?=$functioncates_rows['brief']?>
              </textarea></td>
              <td colspan='6' rowspan="3" align='center' valign="top">
		  			<table border="0" width="100%">
						  <tr>
						    <td height="34" align="right"><input type='submit' value='确定'  onclick=' $("#jianjie").text("数量 / 日期 / 简介");$("#flag").text("修改");' />
&nbsp;
<input type='button' onclick='javascript:secBoard2(<?=$functioncates_rows['ID']?>);$("#jianjie").text("数量 / 日期 / 简介");$("#flag").text("修改");' value='放弃' /></td>
				      </tr>
						  <tr>
						    <td>标题 Title</td>
				      </tr>
						  <tr>
						    <td><input name="newsTitle" id="newsTitle" type="text" value="<?php echo $functioncates_rows['fTitle'];?>"   style="width:94%;" /></td>
					      </tr>
						  <tr>
						    <td>关键字 Keywords</td>
				      </tr>
						  <tr>
						    <td><input name="newsKeywords" id="newsKeywords" type="text" value="<?php echo $functioncates_rows['fKeywords'];?>" style="width:94%;"  /></td>
					      </tr>
						  <tr>
						    <td>描述 Description</td>
				      </tr>
						  <tr>
						    <td><textarea name="newsDescription" style="width:98%;"  rows="12" id="newsDescription" onblur="addcate.briefmodi.value=(addcate.briefmodi.value.length==0) ? this.value : addcate.briefmodi.value"><?php echo $functioncates_rows['fDescription'];?></textarea>
					        <?=$promlv>1?$seo:""?></td>
					      </tr>
                          <tr>
                            <td height="49" align="left"><span style="padding-left:;">
                              <span style="padding-left:10px;">跳转链接： </span>
                              <input name="headerurl" id="headerurl" type="text" style="width:96%;" value="<?=$functioncates_rows['headerurl']?>" size="20"  />
                            </span></td>
                      </tr>
                          <tr>
						    <td align="center"><input value='<?=$functioncates_rows['ID']?>' name='modiid' type='hidden'>
		  			<input type='submit' value='确定'> &nbsp; 
		  			<input type='button' onclick='javascript:secBoard2(<?=$functioncates_rows['ID']?>)' value='放弃'></td>
					      </tr>
					    </table>
		   	</td>
		   </tr>
			<tr bgcolor='#CCCCCC'>
			  <td colspan="2">详细：</td>
              <td colspan="7" align='center'>
			    <textarea id="detailmodi" name="detailmodi" cols="14" class="inp" style="width:100%;height:240px;visibility:;" onblur=""><?=$functioncates_rows['detail']?></textarea>
			  </td>
		   </tr>
			<tr bgcolor='#CCCCCC'>
			  <td colspan="15" align='center'>&nbsp;</td>
		   </tr>

		 </form>
		</tbody>

		  		    
		  		   <?php $i++;
		  		   }
		  		   ?>
		  		   	<tr bgcolor="#E4E4E4">
		  		    <td height='44' colspan="6" align='center'>
		  		    <?=$page_string?>
		  		    </td>
		  		    <td height='44' colspan="9" align='center'>
                     <form name="searcharticle" method="Post" action="?selectcate=<?=$selectcate?>&selectfunctionName=<?=$selectfunctionName?>" >
			  <table align="center"  cellpadding="4px;" style="width:98%;"><tr>
						<td align="right"><span style="padding-left:6px;">
			      <input type="text" name="searchproductName" size="16" maxlength="50"  value="" />
			      <input type='submit'    value="查询" style="height:24px;"    />
			      </span> <span style="padding-left:26px;">
			      <input name="gopage" id="gopage" type="text" size="3" />
			      页
<input type='submit'    value="GO"  style="height:24px;"   />
			      </span></td>
						</tr>
			      </table>
				</form>
                    </td>
		  		    </tr>
					</table>
			  <br />
			  <form action="?ls=insert&amp;selectcate=<?=$selectcate?>&amp;selectfunctionName=<?=$selectfunctionName?>&page=<?=$page?>&searchproductName=<?=$searchproductName?>" method="post" name="addcate" id="addcate" onsubmit="return checkSubmitForm('functionName','栏目');">
			    <br />
			    <table width="98%" border="0" align="center" cellpadding="5" cellspacing="0"  style=" background-color:#D9E4EA">
		          <tr>
			          <td colspan="4" align="center" ><strong><br />
		              添加菜单项<a name="add" id="add"></a></strong></td>
	              </tr>
		          <tr>
			        <td width="21%" height="48" valign="bottom" style="padding-left:3%;"><?=$dispFunctionName?>
		            ：<br />			          <input name="functionName" type="text" id="functionName" size="12" style="width:80%;" onKeyUp="addcate.newsTitle.value=addcate.newsKeywords.value=this.value;addcate.typeurl.value=this.value.toLowerCase().replace(/\s+/g,'')+'.html';this.value=this.value.replace(/&/g, '');" />
		            *</td>
			        <td width="11%" valign="bottom" >子<?=$dispFunctionName?>：
			          <label><br />
			            <input name="cateName" type="text" id="cateName" size="12" style="width:80%;" onblur="addcate.newsTitle.value=this.value+'_'+addcate.functionName.value;addcate.newsKeywords.value=this.value+','+addcate.functionName.value;" onKeyUp="addcate.typeurl.value=this.value.toLowerCase().replace(/\s+/g,'')+'.html';this.value=this.value.replace(/&/g, '');" />
</label></td>
			        <td width="30%" valign="bottom"  >链接：<label><br />
                        <input name="typeurl" type="text" value="" size="10" style="width:90%;"  />
                      <span style="padding-left:5px;">
                        <input type='hidden' value='0' name='createpage' />
                    </span></label></td>
			        <td width="38%" rowspan="3" align="left" valign="middle" ><table border="0" width="100%">
			          <tr>
			            <td width="29%">标题 Title</td>
			            <td width="71%"><input name="newsTitle" id="newsTitle2" type="text" value="" style="width:90%;" /></td>
		              </tr>
			          <tr>
			            <td>关键字 Keywords</td>
			            <td><input name="newsKeywords" id="newsKeywords2" type="text" value="" style="width:90%;" /></td>
		              </tr>
			          <tr>
			            <td height="87">描述 Description</td>
			            <td><textarea name="newsDescription" rows="4" id="newsDescription2" style="width:90%;"  onblur="addcate.brief.value=(addcate.brief.value.length==0) ? this.value : addcate.brief.value"></textarea>
		                <br />			              <?=$promlv>1?$seo:""?></td>
		              </tr>
		            </table></td>
		          </tr>
			      <tr>
                    <td width="21%" align="left" valign="middle" style="padding-left:3%;"  ><p style="">
                      <select name="select2" id="select2" style="width:82%;padding-left:18px;"  onchange="aa=this.options[this.selectedIndex].value.split(',');document.addcate.functionName.value=aa[1];document.addcate.Num.value=aa[0];"  >
                        <option value="0">请选择栏目：</option>
                        <?php 			$news_sql="SELECT distinct functionName FROM ls_functioncates  order by Num ASC";//count the error by searchtype
			$news_query=$opendb->query($news_sql);
			while($news_rows2=mysqli_fetch_assoc($news_query))
		  	{
						  $thisfunc1=$news_rows2['functionName'];
						  $showfunc=$thisfunc1;
						  if($thisfunc1=="博客分类")$showfunc="Blog";
						  if($thisfunc1=="常见问题")$showfunc="Faq";
						  if($thisfunc1=="新闻分类")$showfunc="News";

				$select_sql2="select * from ls_functioncates where functionName='".$news_rows2['functionName']."' ";
				//echo $select_sql2;
				$select_query2=$opendb->query($select_sql2);
				$select_rows2_num=mysqli_num_rows($select_query2); //总数
				
				echo "<option value='".((($select_rows2_num+1)*5)).",".$thisfunc1."'>".$showfunc."</option>";
			}//(($select_rows2_num+1)*5)

			?>
                      </select>
                    </p></td>
			        <td valign="middle" >标识：
                      <input name="suffStr" type="text" id="suffStr" value="" style="width:80%" /></td>
			        <td valign="middle" ><p>序号
			            <span style="padding-left:5px;">
			            <input type='hidden' value='0' name='Num2' />
			            </span>
		              <?php 					
						  	$select_sql2="select * from ls_functioncates where ( cateName='' or cateName is NULL ".$addcatestr." ) and ( subCateName='' or subCateName is NULL ) order by Num DESC "; 
							//echo $select_sql2;
							$select_query2=$opendb->query($select_sql2);
							$num_rows=mysqli_fetch_assoc($select_query2); //总数

						?>
                      <input name="Num" id="Num" type="text" style="width:10%" value="<?=$num_rows['Num']+5?>" size="3" maxlength="6" />
形式
  <input name="newstype" type="text" id="newstype" size="1" value="2" style="width:4%" />
  列出/首页行数
  <input name="hotLines" type="text" id="hotLines" size="1" value="0"  style="width:4%"/>
  图标
                      <input name="hotWords" type="text" id="hotWords2" size="1" value="" style="width:4%" />
	                </p></td>
		          </tr>
			      <tr>
			        <td colspan="3" align="left"  style="padding-left:30px;" >article.html、articleshow.htm 模板建好后，再添分类</td>
		          </tr>
			      <tr>
			        <td colspan="3" align="left"  style="padding-left:30px;" >简介：</td>
			        <td align="center"  style="padding-left:30px;" ><input type="submit" name="button4" id="button5" value="确定" onclick="if($('#functionName').val().length &gt; 0){
						$('#newsTitle2').val($('#cateName').val()+', '+$('#functionName').val()+' - '+'<?=$title_value['companyName']?>'); 
						$('#newsKeywords2').val($('#cateName').val()+', '+$('#functionName').val());
                        $('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/&lt;[^&gt;]+&gt;/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}"  />
  &nbsp;
  <input type="reset" name="button4" id="button6" value="重置" />
  </a></td>
		          </tr>
			      <tr>
			        <td colspan="4" align="center" ><label>
			          <textarea name="brief" id='fText' style="width:94%;height:220px;visibility:;"  onblur="addcate.newsDescription.value=(addcate.newsDescription.value.length==0) ? this.value : addcate.newsDescription.value"></textarea>
			          <?=$promlv>1?$brief_tips:""?>
			        </label></td>
		          </tr>
			      <tr>
			        <td colspan="4" align="center"  style="padding-left:30px;" ><input type="submit" name="button3" id="button3" value="确定" onclick="if($('#functionName').val().length &gt; 0){
						$('#newsTitle2').val($('#cateName').val()+', '+$('#functionName').val()+' - '+'<?=$title_value['companyName']?>'); 
						$('#newsKeywords2').val($('#cateName').val()+', '+$('#functionName').val());
                        $('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/&lt;[^&gt;]+&gt;/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}"  />
&nbsp;
<input type="reset" name="button3" id="button4" value="重置" />
</a></td>
		          </tr>
			      <tr>
			        <td colspan="4" align="left"  style="padding-left:30px;" >详细：</td>
		          </tr>
			      <tr>
			        <td colspan="4" align="center" ><label>
			          <textarea name="detail" id='detail' cols="30" style="width:94%;height:360px;visibility:;"  onblur=""></textarea>
			          <?=$promlv>1?$detail_tips:""?>
			        </label></td>
		          </tr>
                  <tr>
                    <td colspan="4" align="left"   style="padding-left:30px;line-height:1.9;"><p><br />
                    1、操作前，请确认基础模板 article.html、articleshow.html 已经建好。类别名、链接不能重复。<br />
                    2、列出：1表示主菜单列出文章标题；也表示首页热点文章的行数。<br />
                    3、图标：含有 .jpg .png按images 下图片显示，否则显示为文字。<br />
                    4、形式：列表显示方式默认是 1 标题列表， 2 图片标题简介，3 图篇标题竖排，4 日期标题简介。<br />
                    5、链接：类别下面只有1篇文章，会直接跳转到文章页面，不使用这个链接名。<br />
                    6、主题图文件名为 images 下 小写无空格大类名 + _banner.jpg<br />
                    7、大类About Us、Contact Us等菜单的子菜单分类如果为aboutus、conatctus，内容编辑会直接打开默认的关于我们和联系我们页。</p></td><!--7、非英语也不可翻译 PRODUCTS，News，Faq，Blog，Download 等菜单项。除系统保留大类名外，大类项请保持中类为空-->
                  </tr>
                  <tr>
                  <td colspan="4" rowspan="6" align="center" >
			          <input type="submit" name="button" id="button" value="确定" onClick="if($('#functionName').val().length > 0){
						$('#newsTitle2').val($('#cateName').val()+', '+$('#functionName').val()+' - '+'<?=$title_value['companyName']?>'); 
						$('#newsKeywords2').val($('#cateName').val()+', '+$('#functionName').val());
                        $('#newsDescription2').val($('#fText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
					}"  /> &nbsp; 
<input type="reset" name="button2" id="button2" value="重置" />
			          </a><br />			          <br /></td>
                    </tr>
		        </table>
			    <br />
			    </form>
<br /></td>
			</tr>
	</table>
	<br />
</body>
</html>