<?php
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$ls_msg="关于我们";
	
	$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);
	
	$aboutus=$_POST['aboutus'];
	$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=mysql_fetch_assoc($in_query)){
		$aboutus = internal_keyword_link($aboutus, $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'], $aboutus);//内链
	$aboutus = editorPath($_SERVER['PHP_SELF'], $aboutus);//图片
	
	$homeAbout = editorPath('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], $homeAbout);//内链
	$homeAbout = editorPath($_SERVER['PHP_SELF'], $homeAbout);//图片
	
	$aTitle=$_POST['newsTitle'];
	$aKeywords=$_POST['newsKeywords'];
	$aDescription=$_POST['newsDescription'];
	
	$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=mysql_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=mysql_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="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','',$select_rows['siteDescription']);?>';
						$('#newsDescription').val(newsDescription.substr(0, 267).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" bgcolor="#6396d6">
			<tr>
				<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>关于我们</strong></font></div>
				</td>
			</tr>
			<tr>
				<td height="743" align="center" valign="middle" bgcolor="#dee7ff"><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;</td>
						</tr>
					</table>
                    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
                      <tr>
                        <td width="65%">
                        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
					  <tr bgcolor="#B9DAFF"> 
						<td height="25" align="center" ><b>首页Aboutus栏目</b></td>
					  </tr>
					  <tr> 
						<td>
	<textarea name="homeAbout" id="homeAbout" style="width:100%;height:240px;visibility:hidden;"><?php echo htmlspecialchars($htmlDatahomeAbout); ?></textarea>
						</td>
					  </tr>
                      <tr>
                      </tr>
					</table>
                        </td>
                        <td width="35%" valign="top">
                        	<table border="0" width="100%" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
                    	<tr bgcolor="#B9DAFF">
							<td height="25" colspan="8"><span style="float:right;"><input 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, 267).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
	}else{
		return false;
	}"/></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 bgcolor="#f4f4f4" align="right" >标题<br /> Title</td>
						    <td bgcolor="#f4f4f4"  ><textarea name="newsTitle" id="newsTitle" cols="65" rows="4"><?php echo $inTitle;?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" align="right" >关键字<br /> Keywords</td>
						    <td  bgcolor="#f4f4f4"  ><textarea name="newsKeywords" id="newsKeywords" cols="65" rows="4"><?php echo $inKeywords;?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" align="right">描述<br /> Description</td>
						    <td bgcolor="#f4f4f4"  ><textarea name="newsDescription" id="newsDescription" cols="65" rows="6" ><?php echo $inDescription;?></textarea></td>
					      </tr>
					    </table>
                        </td>
                      </tr>
                      <tr bgcolor="#B9DAFF">
                        <td colspan="2" height="37" align="center"><input type="submit" value="保存" onclick="if($('#newsTitle').val().length <= 0){
						$('#newsTitle').val('<?=$companyName?>');
						$('#newsKeywords').val('<?=$siteKeywords?>');
						$('#newsDescription').val('<?=$siteDescription?>');
					}" />
&nbsp;
<label>
  <input type="reset" name="button3" id="button3" value="重置" />
</label></td>
                      </tr>
                      <tr bgcolor="">
                        <td colspan="2" height="24" align="center">&nbsp;</td>
                      </tr>
                      <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="保存" />
&nbsp;
<input type="reset" name="button2" id="button2" value="重置" />
                        <br />
                        <br />
                      	</label></td>
                      </tr>
                    </table>
				</form>
				 <br />
				</td>
		  </tr>
		</table>
	</body>
</html>

