用文本+ASP打造新聞發布系統(四)新聞刪除/新聞刪除

來源:互聯網
上載者:User
<!--#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 "沒有新聞內容"
     myread2.close
     Response.End
end if

     mytext2=myread2.readall
     myread2.close
     dim listarray,i,h,count,sf,title
      listarray=split(mytext2,"|")     '#########讀取記錄並以#分割成listarray數組
      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說明上傳了圖片,刪除新聞圖片和該列表記錄
                if ubound(sf)=6 then
                 myfso.deletefile(server.MapPath ("./images/"&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("刪除成功");
  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 "沒有該新聞"
    Response.End
    end if
    
    set myfso=createobject("scripting.filesystemobject")
    set myread=myfso.opentextfile(server.mappath("./news_content/



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.