<!--#include file="../conn.asp"-->
<!--#include file="inc/admin_config.asp"-->
<!--#include file="inc/top.asp"-->
<%
If Cint(AdminGroup(4))=1   or Cint(Request.Cookies("IsSuper"))=1 then
else
Response.Redirect("Default.asp")
Response.End()
End If


response.Write("<table border=0 align=center cellpadding=3 cellspacing=1 class=tablecolor>")
response.Write("<tr><td height=25 align=center class=banner>新闻 添加/修改</td></tr></table>")
select case request("action")
case "saveabout"
call saveabout()
case else
call normal()
end select
sub normal()
dim id,wt_title,wt_images,wt_content,wt_grade,wt_description
dim wt_Author,wt_CopyFrom,wt_Editor,wt_sortId,wt_keywords,wt_addtime
id=request.QueryString("id")
if id<>"" then
dim rs
set rs=conn.execute("select * from wd_news  where wt_id="&clng(id))
if rs.bof and rs.eof then
response.Write("<script>alert('没有此信息');history.go(-1);</script>")
response.End()
end if
wt_title=rs("wt_title")
wt_content=rs("wt_Content")
wt_grade=rs("wt_grade")
wt_description=rs("wt_description")
wt_images=rs("wt_images")
wt_Author=rs("wt_Author")
wt_CopyFrom=rs("wt_CopyFrom")
wt_Editor=rs("wt_Editor")
wt_sortId=rs("wt_sortId")
wt_keywords=rs("wt_keywords")
wt_addtime=rs("wt_addtime")
rs.close
set rs=nothing
end if
response.Write("<table border='0' align='center' cellpadding='3' cellspacing='1' class='tablecolor'>") &vbCrLf
response.Write("<form action=""?action=saveabout"" method=""POST"" name=""frmAnnounce"" onSubmit=""return checkdata()"" > ")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>所属类别：</strong></td><td class='tablebody'><select name=wt_sortId id=wt_sortId><option value=''>-----</option>")
	  dim  srs
	  set srs=server.CreateObject("adodb.recordset")
 	  srs.open "select * from wd_news_sort  ",conn,1,1
	  do while not srs.eof
response.Write("<option value='"&srs("wt_id")&"'")
if  cstr(request("wt_sortId"))=cstr(srs("wt_id")) then response.Write(" selected ")
response.Write(">"&srs("wt_title")&"</option>")
	  srs.movenext
	  loop
 	  srs.close
 	  set srs=nothing
response.Write("</select></td></tr>")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>标题：</strong></td><td class='tablebody'><input name=wt_title class=FormClass value='"&wt_title&"' size=60 maxlength=60></td></tr>")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>排序：</strong></td><td class='tablebody'>")&vbCrLf
response.Write("<input onkeydown=""onlyNum();"" style=""ime-mode:Disabled; width:60px"" value="""&wt_grade&""" name=""wt_grade"">&nbsp;只允许输入数字，数字越小排列越靠前.")&vbCrLf
response.Write("</td></tr>")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>关键字：</strong></td><td class='tablebody'><input name=""wt_keywords"" class=""FormClass"" value="""&wt_keywords&""" size=60 maxlength=60> 每个关键字用“,”号格开</td></tr> ")
response.Write("<tr><td  class='tablebody'><strong>作者：</strong></td><td class='tablebody'><input name=wt_Author class=FormClass value='"&wt_Author&"' size=20 maxlength=60></td></tr>")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>来源：</strong></td><td class='tablebody'><input name=wt_CopyFrom class=FormClass value='"&wt_CopyFrom&"' size=20 maxlength=60></td></tr>")&vbCrLf
response.Write("<tr><td  class='tablebody'><strong>编辑：</strong></td><td class='tablebody'><input name=wt_Editor class=FormClass value='"&wt_Editor&"' size=20 maxlength=60></td></tr>")&vbCrLf
response.Write("<tr><td class='tablebody' style='font-weight: bold'>缩略图：</td><td class='tablebody' valign=""top"">")
response.Write "<input name='news_pic' type='text' value='"&wt_images&"' size='60' maxlength'255'>"&vbCrLf
response.Write "<input type=""button"" name=""Submit2"" style='upfile_button' value=""上传图片"" onClick=""window.open('inc/upload.asp?formname=frmAnnounce&editname=news_pic&uppath=/upfile/news&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')""> <font color=""red"">JPG格式</font>"&vbCrLf
if wt_addtime = "" then
wt_addtime=year(now())&"-"&month(now())&"-"&day(now())
end if
response.Write("<tr><td  class='tablebody'><strong>时间：</strong></td><td class='tablebody'><input name=wt_addtime class=FormClass value='"&wt_addtime&"' size=20 maxlength=60></td></tr>")&vbCrLf
response.Write "</td></tr>"&vbCrLf
response.Write("<tr><td valign='top' class='tablebody'><Strong> 简介：</Strong></td>")&vbCrLf
response.Write("<td valign='top' class='tablebody'>")&vbCrLf
response.Write("<textarea name=""wt_description"" id=""wt_description"" cols=""80""  rows=""3"">"&  wt_description  &"</textarea><br />内容不超过200字符，超过部分将自动裁减掉！")&vbCrLf
response.Write("</td></tr><tr><td valign='top' class='tablebody'  colspan=2><Strong>正文</Strong><br />")
sBasePath = Request.ServerVariables("PATH_INFO")
sBasePath = Left( sBasePath, InStrRev( sBasePath, "/_samples" ) )
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath	= sBasePath
oFCKeditor.Value	= ""&wt_content &""
oFCKeditor.Create "wt_content"
response.Write (" </td></tr> ")&vbCrLf
'记录地址，方便返回
response.Write (" <input name=comeUrl  value='"&comeUrl&"' type=""hidden"" ><input name=thisUrl  value='"&thisUrl&"' type=""hidden"" >")&vbCrLf
response.Write (" <input type='hidden' name='id' value='"&id&"'>")
response.Write (" <tr><td align='center' class='tablebody'>&nbsp;</td><td class='tablebody'> <input type=Submit value='提交' name=Submit>&nbsp;<input type=reset name=Submit2 value='重置'></td></tr>")&vbCrLf
response.Write ("</form>")&vbCrLf
response.Write ("</table>")&vbCrLf
end sub
sub saveabout()
dim wt_title,wt_images,wt_content,id,wt_grade,wt_description
dim wt_Author,wt_CopyFrom,wt_Editor,wt_sortId,wt_keywords,wt_fileUrl,wt_addtime
id=request.Form("id")
wt_title=checkStr(request.Form("wt_title"))
wt_content=checkStr(request.Form("wt_content"))
wt_description=checkStr(request.Form("wt_description"))
wt_grade=checkStr(request.Form("wt_grade"))
wt_images=checkStr(request.Form("news_pic"))
wt_Author=checkStr(request.Form("wt_Author"))
wt_CopyFrom=checkStr(request.Form("wt_CopyFrom"))
wt_Editor=checkStr(request.Form("wt_Editor"))
wt_sortId=checkStr(request.Form("wt_sortId"))
wt_keywords=checkStr(request.Form("wt_keywords"))
wt_addtime=checkStr(request.Form("wt_addtime"))
if wt_title="" then
response.Write("<script>alert('标题不能为空！') ; history.go(-1);</script>")
response.End()
end if
if wt_sortId="" then
response.Write("<script>alert('请选择分类！') ; history.go(-1);</script>")
response.End()
end if
if wt_content="" then
response.Write("<script>alert('正文不能为空！') ; history.go(-1);</script>")
response.End()
end if 
if wt_description="" then
wt_description=ScriptHtmlAll(checkStr(request.Form("wt_content")))
end if 
wt_description=left(wt_description,200)
if wt_grade="" then
wt_grade=99
end if
if wt_Author ="" then
wt_Author="admin"
end if
if wt_CopyFrom="" then
wt_CopyFrom=weburl
end if
if wt_Editor="" then
wt_Editor="admin"
end if
if wt_keywords="" then
wt_keywords = replace(checkStr(request.Form("wt_title")),"，",",")
end if
wt_keywords=replace(wt_keywords," ",",")
wt_keywords=replace(wt_keywords,"，",",")
wt_keywords = replace(wt_keywords,"、",",")
wt_keywords = replace(wt_keywords," ",",")
wt_keywords = replace(wt_keywords,"：",",")
''''处理文件地址
''''' 静态生成时需要
	'组合文件地址
	wt_fileUrl= "/news-show.asp?id="&id&""
dim ip
ip=Request.ServerVariables("HTTP_REFERER")
if id<>"" then
conn.execute("update wd_news set wt_title='"&wt_title&"',wt_content='"&wt_content&"',wt_grade="&wt_grade&",wt_description='"&wt_description&"' ,wt_images='"&wt_images&"'  ,wt_addtime='"&wt_addtime&"',wt_Editor='"&wt_Editor&"',wt_CopyFrom='"&wt_CopyFrom&"',wt_Author='"&wt_Author&"',wt_sortId="&wt_sortId&",wt_keywords='"&wt_keywords&"'  ,wt_fileUrl='"&wt_fileUrl&"'  where wt_id="&clng(id)&"")
response.Write "<li>更新成功！</li>"
response.Write "<li><strong><a href="""&request("comeUrl")&""" ><font color=red>返回</font></a></strong></li>"
response.End()
else
conn.execute("insert into wd_news(wt_title,wt_content,wt_grade,wt_description,wt_images,wt_Author,wt_CopyFrom,wt_Editor,wt_sortId,wt_keywords,wt_fileUrl,wt_addtime) values('"&wt_title&"','"&wt_content&"',"&wt_grade&",'"&wt_description&"','"&wt_images&"','"&wt_Author&"','"&wt_CopyFrom&"','"&wt_Editor&"',"&wt_sortId&",'"&wt_keywords&"','"&wt_fileUrl&"','"&wt_addtime&"' )")
response.Write "<li>添加成功！</li>"
response.Write "<li><strong><a href="""&ip&""" ><font color=red>返回</font></a></strong></li>"
response.End()
end if
end sub
%>
<%CloseConn%>
<!--#include file="inc/end.asp"-->
