<%@ codepage ="936" %>
<%charset="gb2312"%>
<%Session.CodePage=936%>
<!--#include file="admin.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="../Inc/articleCHAR.INC"-->

<%
owner=Trim(Request("owner"))
If owner="" Then
  Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select top 1 owner from about where ntype=1 order by owner desc"
  rs.open sql,conn,1,1
  If Not (rs.bof And rs.eof) Then owner=rs(0)
  rs.close
  Set rs=nothing
  If owner<>"" Then 
	owner=owner+1
  Else
    owner=0
  End if
end If

if Request.QueryString("no")="eshop" then

title=Trim(Request("title"))
content=Request("content")
If title="" Then
response.write "SORRY <br>"
response.write "请输入信息的标题!!<a href=""javascript:history.go(-1)"">返回重输</a>"
response.end
end if
If content="" Then
response.write "SORRY <br>"
response.write "内容不能为空!!<a href=""javascript:history.go(-1)"">返回重输</a>"
response.end
end if

UploadFiles=trim(request.form("UploadFiles"))
if left(trim(UploadFiles),1)="|" then UploadFiles=right(UploadFiles,len(UploadFiles)-1)
'***************************************
'删除无用的上传文件
if  UploadFiles<>"" then
	dim fso,strRubbishFile
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	if instr(UploadFiles,"|")>1 then
		dim arrUploadFiles,intTemp
		arrUploadFiles=split(UploadFiles,"|")
		UploadFiles=""
		for intTemp=0 to ubound(arrUploadFiles)
			if instr(Content,arrUploadFiles(intTemp))<=0 then
				strRubbishFile=server.MapPath("../" & arrUploadFiles(intTemp))
				if fso.FileExists(strRubbishFile) then
					fso.DeleteFile(strRubbishFile)
					response.write "<br><li>" & arrUploadFiles(intTemp) & "在文章中没有用到，所以已经被删除！</li>"
				end if
			else
				if intTemp=0 then
					UploadFiles=arrUploadFiles(intTemp)
				else
					UploadFiles=UploadFiles & "|" & arrUploadFiles(intTemp)
				end if
			end if
		next
	else
		if instr(Content,UploadFiles)<=0 then
			strRubbishFile=server.MapPath("../" & UploadFiles)
			if fso.FileExists(strRubbishFile) then
				fso.DeleteFile(strRubbishFile)
				response.write "<br><li>" & UploadFiles & "在文章中没有用到，所以已经被删除！</li>"
			end if
			UploadFiles=""
		end if
	end if
	set fso=nothing
end If
'结束
'***************************************

Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from About "
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("UploadFiles")=UploadFiles
rs("owner")=owner
rs("ntype")=1
rs("html")=0
rs.update
rs.close
response.redirect "About_Manage.asp"
end if
%>
<script>
function CheckForm()
{
  if (document.myform.title.value=="")
  {
    alert("文章标题不能为空！");
	document.myform.title.focus();
	return false;
  }
  if (editor.getHTML()=="")
  {
    alert("文章内容不能为空！");
	editor.shuziren_editor.focus();
	return false;
  }
  myform.submit();    
}
function loadForm()
{
  editor.shuziren_editor.document.body.innerHTML=document.myform.Content.value;
  return true
}
</script>
<!-- #include file="Inc/Head.asp" -->
<body onLoad="javascipt:setTimeout('loadForm()',300);">
<div align=center>
<TABLE class=tableBorder1 style="WIDTH: 100%" cellSpacing=0 cellPadding=3 
align=center border=0>
  <TBODY>
  <TR>
    <TD height=50></TD></TR></TBODY></TABLE>
<TABLE class=tableBorder cellSpacing=0 cellPadding=0 width="85%" align=center border=0>
	<tr> 
	  <TH align=left height=23 class="tableHeaderText">
	    <div align="center"><font color=white>添加关于我们</font></div>
	  </TH>
	</tr>
	<tr> 
		<form method="post" name="myform" action="About_Add.asp?no=eshop">
		<td>
		<div align="center"> 
 	       <table width="100%" border="0" cellspacing="2" cellpadding="0">
			  <tr> 
				<td width="8%" height="25" bgcolor="#C0C0C0"> <div align="center">标&nbsp;&nbsp;题</div></td>
				<td width="62%" bgcolor="#C0C0C0"><input type="text" name="title" maxlength="80" size="45"> <font color=red>*</font>　　　　　　　　　［标 <font color=red>*</font> 的为必填项］</td>
			  </tr>
			  <tr> 
				<td height="25" bgcolor="#C0C0C0"><div align="center">内&nbsp;&nbsp;容<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>*</font></div></td>
				<td height="25" bgcolor="#C0C0C0">
				<input name="UploadFiles" type="hidden" id="UploadFiles">
				<textarea name="Content" style="display:none"></textarea>
				  <iframe id="editor" src="../edit/hy_html/edit.asp?id=Content&source=1" frameborder="0" scrolling="no" width="620" height="350"></iframe>
				</td>
			  </tr>
			  <tr> 
			    <td height=5 colspan="2" bgcolor=#C0C0C0></td>
			  </tr>
			  <tr> 
				<td width="8%" height="25" bgcolor="#C0C0C0"> <div align="center">排&nbsp;&nbsp;序</div></td>
				<td width="62%" bgcolor="#C0C0C0"><input type="text" name="owner" maxlength="80" size="15" value="<%=owner%>"></td>
			  </tr>
			  <tr> 
			  <td colspan="2" bgcolor=#C0C0C0><div align="center"> 
				  <input type="button" onclick="javascript:CheckForm();" value=" 添 加 "name="cmdok">
					&nbsp;
					<input type="reset" value=" 从来 ">
					&nbsp;
					<input type="button" onclick="history.go(-1);" value=" 返回 ">
				  </div></td>
			  </tr>
			  <tr> 
			    <td height=5 colspan="2" bgcolor=#C0C0C0></td>
			  </tr>
			</table>
           </div>
		   </td>
		   </form>
        </tr>
      </table>
      <br>
      <br>
    </td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
</div>
