www.gusucode.com > 公寓出租网站整站源码 1.0程序 > admin/News_save.asp
<!--#include file="conn.asp"--> <!--#include file="admin.asp"--> <!--#include file="../Inc/Config.asp"--> <!--#include file="../Inc/Ubbcode.asp"--> <!--#include file="Inc/Function.asp"--> <% ID=Request.Form("ID") Title=Trim(request.form("Title")) BigClassName=trim(request.form("BigClassName")) SmallClassName=trim(request.form("SmallClassName")) Content=trim(request.form("Content")) User=Trim(request.form("User")) FirstImageName=trim(request.form("DefaultPicUrl")) AddDate=trim(request.form("AddDate")) Ok=Trim(request.form("Ok")) Infotime=trim(request.form("Infotime")) Hits=trim(request.form("Hits")) Action=trim(request("Action")) if BigClassName="" then founderr=true errmsg=errmsg+"<li>未指定新闻所属大类</li>" end if if Title="" then founderr=true errmsg="<li>新闻标题不能为空</li>" end if if Content="" then founderr=true errmsg=errmsg+"<li>新闻内容不能为空</li>" end if if founderr=false then Title=dvhtmlencode(Title) if Infotime<>"" and IsDate(Infotime)=true then Infotime=CDate(Infotime) else Infotime=now() end if if Hits<>"" then Hits=CLng(Hits) else Hits=0 end if set rs=server.createobject("adodb.recordset") select case Action case "Add" sql="select * from News where (id is null)" rs.open sql,conn,1,3 rs.addnew call SaveData() rs.update rs.close set rs=nothing response.redirect "News_Manage.asp" case "Modify" if ID<>"" then sql="select * from News where id="&ID rs.open sql,conn,1,3 if not (rs.bof and rs.eof) then call SaveData() rs.update rs.close set rs=nothing response.redirect "News_Manage.asp" else founderr=true errmsg=errmsg+"<li>找不到此新闻,可能已经被删除。</li>" call WriteErrMsg() end if else founderr=true errmsg=errmsg+"<li>不能确定ID的值</li>" call WriteErrMsg() end if Case else founderr=true errmsg=errmsg+"<li>没有选定参数</li>" call WriteErrMsg() end select call CloseConn() else WriteErrMsg end if %> <% sub SaveData() rs("Title")=Title rs("Content")=Content rs("AddDate")=AddDate rs("User")=User rs("BigClassName")=BigClassName rs("SmallClassName")=SmallClassName rs("Infotime")=Infotime rs("Hits")=Hits if Ok="yes" then rs("Ok")=True else rs("Ok")=False end if '*************************************** '删除无用的上传文件 if ObjInstalled=True and 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 and arrUploadFiles(intTemp)<>FirstImageName 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 and UploadFiles<>FirstImageName 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 '结束 '*************************************** rs("FirstImageName")=FirstImageName end sub %>