Using text +asp to build press release system (iv) news deletion/News deletion

Source: Internet
Author: User
Tags exit count split
<!--#include file= "news_session.asp"-->

<%
Dim id
Id=request.querystring ("id")
Dim Myfso
Set Myfso=createobject ("Scripting.FileSystemObject")
If Myfso. FileExists (Server.MapPath ("./news_content/" &id& "TXT")) Then
Myfso. DeleteFile (Server.MapPath ("./news_content/" &id& ". txt")) ' ############ #删除新闻内容
End If

Dim mytext2,myread2
Set Myread2=myfso.opentextfile (Server.MapPath ("./new_list.asp"), 1,0)
If Myread2.atendofstream Then
Response.Write "No news content"
Myread2.close
Response.End
End If

Mytext2=myread2.readall
Myread2.close
Dim listarray,i,h,count,sf,title
Listarray=split (mytext2, "|") ' ######## #读取记录并以 # split into Listarray arrays
Count=ubound (Listarray)
For i=0 to count ' ########## #根据ID找到该新闻实现删除功能
Sf=split (Listarray (i), ",")
If Right (SF (0), 7) =right (id,7) Then
Dim thisid
Thisid=i

' ###### #为6说明上传了图片, delete the news picture and the list record
If UBound (SF) =6 Then
Myfso.deletefile (server. MapPath ("./images/" &AMP;SF (6)))
End If
Exit For
End If
Next

Dim Mytext,mappath
Mappath=server.mappath ("./")
Set Mytext=myfso.createtextfile (mappath& "\new_list.asp", -1,0)
For i=0 to Thisid-1 ' ######### #把所有数据重新写入文件
Mytext.write Listarray (i) & "|"
Next

For I=thisid+1 to UBound (Listarray)
If I=ubound (Listarray) Then
Mytext.write Listarray (i)
Exit For
Else
Mytext.write Listarray (i) & "|"
End If
Next
Mytext.close
%>
<script language= "JavaScript" >
Alert ("Delete succeeded");
Location.href = ("news_admin1.asp");
</script>
---------------
News_view.asp
<% response.expires=0
Dim myid,myfso,myread,mytext1
Myid=request.querystring ("id")

If Len (myID) =0 Then
Response.Write "No Such news"
Response.End
End If

Set Myfso=createobject ("Scripting.FileSystemObject")
Set Myread=myfso.opentextfile (Server.MapPath ("./news_content/



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.