<?php
	require_once('_approot.php');	

	$ls_msg="关于我们";
	
	$lenght_sql="select * from ls_functioncode where codeID = 'aboutLenght' order by ID";	
	$lenght_query=$opendb->query($lenght_sql);
	$lenght_row=mysqli_fetch_array($lenght_query);
	
	$aTitle=clearname($_POST['newsTitle']);
	$aKeywords=clearname($_POST['newsKeywords']);
	$aDescription=clearname($_POST['newsDescription']);
	
	$aboutus=  $_POST['aboutus']; 
	$homeAbout=$_POST['homeAbout'];
	
	$aboutus=editorprocess($aboutus,$_SERVER['PHP_SELF'],$aTitle,$aTitle);
	$homeAbout=editorprocess($homeAbout,$_SERVER['PHP_SELF'],$aTitle,$aTitle);
	
/*	$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)){
		$aboutus = internal_keyword_link($aboutus, $in_rows['title'], $in_rows['url']);
		$homeAbout=  internal_keyword_link($homeAbout, $in_rows['title'], $in_rows['url']);

	}
	
	if($aboutus != "" && strlen(trim($_POST['homeAbout']))<=30){
		$homeAbout=cut_html_str($aboutus,$lenght_row['code']);
	}else{
		//$homeAbout=$_POST['homeAbout'];
	}
	//编辑器中的内链与图片转换成相对路径
	$aboutus = editorPath('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], clearname($aboutus ));//内链
	$aboutus = editorPath($_SERVER['PHP_SELF'], $aboutus);//图片
	
	$homeAbout = editorPath('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], clearname($homeAbout));//内链
	$homeAbout = editorPath($_SERVER['PHP_SELF'], $homeAbout);//图片
*/	
	
	$ls=$_POST['ls'];
	switch($ls)
	{
		case "insert":
			$update_sql=sprintf("update ls_information set inTitle=%s, inKeywords=%s, inDescription=%s, content=%s, homeAbout=%s where inMenu=%s " ,
							GetSQLValueString($aTitle, "text"),
							GetSQLValueString($aKeywords, "text"),
							GetSQLValueString($aDescription, "text"),
							GetSQLValueString($aboutus, "text"),
							GetSQLValueString($homeAbout, "text"),
							GetSQLValueString("aboutus", "text")
							);
			if($update_query=$opendb->query($update_sql)){
				$ls_msg="修改操作成功！";
			}else{
				$ls_msg="修改操作失败！";
			}
			
			break;
	}
	//如果标题为空，默认取ls_config表中的数据
	$select_sql="select * from ls_config ";
	$select_query=$opendb->query($select_sql);
	$select_rows=mysqli_fetch_assoc($select_query);
	$companyName = $select_rows['companyName'];
	$siteKeywords = $select_rows['siteKeywords'];
	$siteDescription = $select_rows['siteDescription'];
	
	$information_sql="select * from ls_information where inMenu='aboutus' ";
	$information_query=$opendb->query($information_sql);
	$information_rows=mysqli_fetch_assoc($information_query);
	$htmlData = $information_rows['content'];
	$htmlDatahomeAbout = $information_rows['homeAbout'];
	
	$inTitle = $information_rows['inTitle'];
	$inKeywords = $information_rows['inKeywords'];
	$inDescription = $information_rows['inDescription'];
	
?>
<!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">
		<title>关于我们</title>
		<link href="css/admin.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="../themes/default/default.css" />
        <script language="JavaScript" src="js/jquery.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
     <link rel="stylesheet" href="css/style2.css" />
	<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>
		var editor12;
		KindEditor.ready(function(J) {
			    editor12 = J.create('textarea[name="homeAbout"]', {
				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();
				},
				afterCreate : function() {
					var self = this;
					J.ctrl(document, 13, function() {
						self.sync();
						J('form[name=example]')[0].submit();
					});
					J.ctrl(self.edit.doc, 13, function() {
						self.sync();
						J('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
		
		
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="aboutus"]', {
				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($('#newsTitle').val().length <= 0){
						$('#newsTitle').val('<?=$companyName?>');
						$('#newsKeywords').val('<?=$siteKeywords?>');
						var newsDescription = '<?=str_replace('\\r','',  strip_tags($select_rows['siteDescription']));?>';
						$('#newsDescription').val(newsDescription.substr(0, 155).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>
</head>
<body>
		<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1">
			<tr>
				<td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">关于我们</font></div>
				</td>
			</tr>
			<tr style="height:346px;">
				<td height="743" align="center" valign="middle"><br>
				 <form name="newsform" enctype="multipart/form-data" method="post" action="ls_about.php" >
					<input type="hidden" value="insert" name="ls">
					<table border="0" width="98%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right">&nbsp; &nbsp; &nbsp; <?php if(!(strpos($_SERVER['HTTP_REFERER'],"managearticle")===false)){ ?> <a href="managearticle.php">返回</a><?php } ?></td>
						</tr>
					</table>
                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" style="background-color: #f0f0ee;">
                      <tr>
                        <td width="65%" valign="top">
                        <table width="98%" border="0" align="center" cellpadding="3">
					  <tr bgcolor="#f0f0ee"> 
						<td height="37" align="center" ><b>首页Aboutus栏目</b></td>
					  </tr>
					  <tr> 
						<td>
	<textarea name="homeAbout" id="homeAbout" style="width:100%;height:300px;visibility:hidden;"><?php echo  htmlspecialchars_decode($htmlDatahomeAbout); ?></textarea>
						</td>
					  </tr>
                      <tr>
                      </tr>
					</table>
                        </td>
                        <td width="35%" valign="top">
                        	<table border="0" width="100%" align="center" cellpadding="3" style="padding-right:2%;">
                    	<tr bgcolor="#f0f0ee">
							<td height="37" colspan="8"><span style="float:right;"><button type="button" name="button" id="button" value="SEO"  onclick="
                            if(confirm('您确定要修改SEO设置吗？')){
                            $('#newsTitle').val('<?=$companyName?>');
						$('#newsKeywords').val('<?=$siteKeywords?>');
						var newsDescription = '<?=$siteDescription?>';
						$('#newsDescription').val(newsDescription.substr(0, 155).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
	}else{
		return false;
	}"/>SEO</button></span><b style="padding-left:180px; line-height:25px;">SEO优化</b></td>
							<?php file_exists("widget/generalpics/head.php")?include "widget/generalpics/head.php" :"" ?>
						</tr>
						  <tr>
						    <td width="23%" align="right" bgcolor="" style="padding-right:1%;">标题<br />					          Title *</td>
						    <td width="77%" bgcolor=""  ><textarea name="newsTitle" id="newsTitle" style="width:96%;"  rows="4"><?php echo $inTitle;?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="" align="right" >关键字<br /> Keywords</td>
						    <td  bgcolor=""  ><textarea name="newsKeywords" id="newsKeywords" style="width:96%;"  rows="4"><?php echo $inKeywords;?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="" align="right">描述<br />					          Description *</td>
						    <td bgcolor=""  ><textarea name="newsDescription" id="newsDescription" style="width:96%;"  rows="6" ><?php echo $inDescription;?></textarea>
						     <?=$promlv>1?$seo:""?>
                             </td>
					      </tr>
					    </table>
                        </td>
                      </tr>
                      <tr bgcolor="">
                        <td colspan="2" height="47" align="center"><button type="submit" value="保存" onclick="if($('#newsTitle').val().length <= 0){
						$('#newsTitle').val('<?=$companyName?>');
						$('#newsKeywords').val('<?=$siteKeywords?>');
						$('#newsDescription').val('<?=$siteDescription?>');
					}" />保存</button>
&nbsp;
<label>
  <button type="reset" name="button3" id="button3" value="重置" />重置</button>
</label></td>
                      </tr>
                       </table>
                       <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
                       <tr>
                        <td colspan="2" height="24" align="center">&nbsp;</td>
                      </tr>
                       </table>
                      
                    <!--  <tr bgcolor="#B9DAFF">
                        <td height="496" colspan="2" align="center"><b><br />
                        About us 页面内容</b><br />
                        <br />
<label> 
	              <textarea name="aboutus" cols="18" id="aboutus" style="width:100%;height:380px;">
							<?php 
							echo $htmlData;?>
				            </textarea>
				            <br />
<input type="submit" value="保存"style="
                            padding: 10px 25px;
background-color: #00c0ef;
border-color: #00acd6;
border-radius: 5px;
border: 1px;
color: #fff; " />
&nbsp;
<input type="reset" name="button2" id="button2" value="重置"style="
                            padding: 10px 25px;
background-color: #00c0ef;
border-color: #00acd6;
border-radius: 5px;
border: 1px;
color: #fff; " />
                        <br />
                        <br />
                      	</label></td>
                      </tr>-->
                     
                      <table width="98%;" style="background-color: #f0f0ee;">
                      <tr bgcolor="#f0f0ee"> 
						<td height="37" align="center" ><b> About us 页面内容</b></td>
					  </tr>
                      <tr>
                      <td>
                      <label> 
	              <textarea name="aboutus" cols="18" id="aboutus" style="width:100%;height:380px;">
							<?php 
							echo $htmlData;?>
				            </textarea>
                      	</label>
                        </td>
                        </tr>
                        <tr bgcolor="">
                        <td colspan="2" height="47" align="center"><button type="submit" value="保存" onclick="if($('#newsTitle').val().length <= 0){
						$('#newsTitle').val('<?=$companyName?>');
						$('#newsKeywords').val('<?=$siteKeywords?>');
						$('#newsDescription').val('<?=$siteDescription?>');
					}" />保存</button>
&nbsp;
<label>
  <button type="reset" name="button3" id="button3" value="重置"/>重置</button>
</label></td>
                      </tr>
                    </table>
				</form>
				
				</td>
		  </tr>
		</table>
	</body>
</html>

