<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      用文本+ASP打造新聞公布系統(5)新聞更改

      [摘要]‘#######news_update.asp<!--#include file="news_session.asp"--> <SCRIPT ID=client...
      ‘#######news_update.asp
      <!--#include file="news_session.asp"-->

      <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
      <!--

      function client_onblur(ii) {
      server=eval("form1.server"+ii)
      if(server.value==""){
      client=eval("form1.client"+ii)
      clientvalue=client.value+""
      varlen=clientvalue.length
      a=clientvalue.lastIndexOf('\\')
      clientvalue=clientvalue.substring(a+1)
      //alert(clientvalue);
      server.value=clientvalue
      }
      }
      function form1_onsubmit() {
      for(i=1;i<1;i++){
      client=eval("form1.client"+i)
      server=eval("form1.server"+i)
      if(client.value!="" && server.value==""){alert("上傳后的文件名不能空!");server.focus();return false}
      }
      }

      //-->
      </SCRIPT>
      <% dim myid
      myid=Request.QueryString ("id")
      if len(myid)=0 then
      Response.Write "沒有該新聞"
      Response.End
      end if

      dim myfso,myread,mytext,newscontent
      '#######打開對應的新聞內容文件,并讀取用變量存儲
      set myfso=createobject("scripting.filesystemobject")
      if myfso.FileExists (server.mappath("./news_content/"&myid&".txt")) then
      set myread=myfso.opentextfile(server.mappath("./news_content/"&myid&".txt"),1,0)

      newscontent=myread.readall
      myread.close
      newscontent=replace(newscontent,"<br>",chr(13))
      newscontent=replace(newscontent," "," ")
      newscontent=replace(newscontent," ",chr(32))
      newscontent=replace(newscontent,"'' ",chr(34))

      else
      Response.Write "該新聞已被刪除"
      Response.End
      end if

      dim mytext2,myread2 '#######打開新聞列表文件
      set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
      if myread2.atendofstream then
      Response.Write "沒有新聞內容"
      Response.End
      end if

      mytext2=myread2.readall
      dim listarray
      listarray=split(mytext2," ") '#########讀取記錄并以#分割成listarray數組
      dim count,sf,i,title,src
      count=ubound(listarray)
      for i=0 to count '###########根據ID找到該新聞并用變量存儲給新聞的標題
      sf=split(listarray(i),",")
      if right(sf(0),7)=right(myid,7) then
      title=sf(1)
      src=sf(3)
      exit for
      end if
      next


      %>

      <head>
      <style>
      td {font-size:9pt}
      INPUT.buttonface {
      BACKGROUND-COLOR: #0079F2; BORDER-BOTTOM: #333333 1px outset; BORDER-LEFT: #333333 1px outset; BORDER-RIGHT: #ffffff 1px outset; BORDER-TOP: #ffffff 1px inset; COLOR: black; FONT-SIZE: 9pta { color: #000000; text-decoration: none}

      .text {font-size:11pt}
      INPUT.buttonface2 {
      BACKGROUND-COLOR: #EDF0F5; COLOR: black; FONT-SIZE: 9pta { color: #000000; text-decoration: none}
      a:hover { color: white; text-decoration: underline overline; background: #007EBB}
      .text {font-size:11pt}

      </style>
      </head>

      <body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0>

      <form method="POST" action="news_updateing.asp" name="form1" enctype="multipart/form-data" onsubmit="return form1_onsubmit()">
      <div align="left">

      <table border="1" width="752" height="240" cellspacing="0" cellpadding="0">
      <tr>
      <td colspan="2" height="12" align="center" width="800" style="font-size:12pt"><strong>新聞發布系統后臺管理--新聞修改</strong></td>
      </tr>
      <tr>
      <td width="119" height="12" style="font-size:9pt">新聞標題</td>
      <td width="675" height="12">
      <input type="text" name="newtitle" size="94" value="<%=title%>" class="buttonface2 ">
      </td>
      </tr>
      <tr>
      <td width="119" height="213" style="font-size:9pt">
      新<br>
      聞<br>
      內<br>
      容</td>
      <td width="675" height="213">
      <textarea rows="14" name="newcontent" cols="93" style="BACKGROUND-COLOR: #EDF0F5"><%=newscontent%></textarea>
      <br>
      </td>
      </tr>
      <tr>
      <td width="119" height="4" style="font-size:9pt">新聞來源</td>
      <td width="675" height="4">
      <input type=text name="newssrc" value="<%=src%>" size="93" class="buttonface2 ">
      </td>
      </tr>
      <tr>
      <td width="119" height="5" style="font-size:9pt">圖片上傳</td>
      <td width="675" height="5"> <input type="file" name="client1" size="20" readonly LANGUAGE=javascript onblur="return client_onblur(1)" ></td>
      </tr>
      </table>
      </div>
      <p>
      <input type="submit" value="確認" name="B1" style="font-size: 10pt; color: #000000; " class="buttonface">
      <input type="reset" value="全部重寫" name="B2" style="font-size:10pt;color:#000000;" class="buttonface">
      <input type="button" value="帳號修改" onclick="location.href='admin/news_chadmin.asp'" name="B2" style="font-size:10pt;color:#000000;" class="buttonface">
      <input type="button" value="新聞添加" onclick="location.href='news_add.asp'" name="B2" style="font-size:10pt;color:#000000;" class="buttonface"></p>
      <input type=hidden name="myid" value="<%=myid%>">
      <INPUT type="hidden" name="server1">
      <input type="hidden" name="mysession" value="mysession">
      </form>

      ##########
      news_updating.asp
      <!--#include file="news_session.asp"-->
      <!--#include file="upload.inc"-->
      <%
      'Fields("xxx").Name 取得Form中xxx(Form Object)的名字
      'Fields("xxx").FilePath 如果是file Object 取得文件的完整路徑
      'Fields("xxx").FileName 如果是file Object 取得文件名
      'Fields("xxx").ContentType 如果是file Object 取得文件的類型
      'Fields("xxx").Length 取得Form中xxx(Form Object)的數據長度
      'Fields("xxx").Value 取得Form中xxx(Form Object)的數據內容
      Dim FormData,FormSize,gnote,bnote,notes,binlen,binstr
      FormSize=Request.TotalBytes
      FormData=Request.BinaryRead(FormSize)
      Set Fields = GetUpload(FormData)

      '############判斷輸入錯誤
      dim mytitle,content,src,id,mysession
      mysession=Fields("newtitle").value
      if len(mysession)=0 then
      Response.Write "非法登陸或超時間,請重新登陸"
      Response.End
      end if

      mytitle=Fields("newtitle").value
      mytitle=replace(mytitle," "," ")
      mytitle=replace(mytitle,"<br>","")

      content=Fields("newcontent").value

      src=Fields("newssrc").value
      src=replace(src," "," ")
      src=replace(src,"<br>","")
      id=trim(right(Fields("myid").value,12))

      if len(mytitle)=0 then
      Response.Write "<script>"
      Response.Write "alert('出錯!新聞標題不能為空!');"
      Response.Write"location.href=history.go(-1);"
      Response.Write "</script>"
      end if

      if len(content)=0 then
      Response.Write "<script>"
      Response.Write "alert('出錯!新聞內容不能為空!');"
      Response.Write"location.href=history.go(-1);"
      Response.Write "</script>"
      end if

      if len(src)=0 then
      Response.Write "<script>"
      Response.Write "alert('出錯!新聞來源不能為空!');"
      Response.Write"location.href=history.go(-1);"
      Response.Write "</script>"

      end if

      '##########################圖片更該功能的實現
      newfile="client1"
      If Fields(newfile).FileName<>"" Then
      set file_0=Server.CreateObject("Scripting.FileSystemObject")
      dim contextname
      contextname=right(Fields("client1").FileName,4)
      imageid=id&contextname

      if contextname<>".gif" and contextname<>".jpg" then '#########判斷上傳文件格式
      Response.Write "<script>"
      Response.Write "alert('出錯!上傳文件格式不對 只能為jpg/gif圖片格式!');"
      Response.Write"location.href=history.go(-1);"
      Response.Write "</script>"
      end if

      file_name=Server.MapPath("./images/"&imageid&"")

      '#####################################如果原來有圖片文件主名為id的則刪除該圖片
      if file_0.fileexists(server.MapPath ("./images/"&id&".gif")) then
      Set f3 = file_0.GetFile(server.MapPath ("./images/"&id&".gif"))
      f3.Delete

      end if
      if file_0.fileexists(server.MapPath ("./images/"&id&".jpg")) then
      Set f3 = file_0.GetFile(server.MapPath ("./images/"&id&".jpg"))
      f3.Delete
      end if
      '########################################寫入圖片

      set outstream=file_0.openTextFile(file_name,8,-1)
      binstr=Fields("client1").Value

      binlen=1
      varlen=lenb(binstr)
      for i=1 to varlen
      clow = MidB(binstr,i,1)
      If AscB(clow) = 255 then
      outstream.write chr(255)
      binlen=binlen+1
      if (i mod 2)=0 then
      notes=gnote
      exit for
      end if
      elseif AscB(clow) > 128 then
      clow1=MidB(binstr,i+1,1)
      if AscB(clow1) <64 or AscB(clow1) =127 or AscB(clow1) = 255 then
      binlen=binlen+1
      'if (binlen mod 2)=0 then
      binlen=binlen+1
      outstream.write Chr(AscW(ChrB(128)&clow))
      'end if
      notes=bnote
      exit for
      else
      outstream.write Chr(AscW(clow1&clow))
      binlen=binlen+2
      i=i+1
      if (i mod 2)=0 then
      notes=gnote
      exit for
      end if
      end if
      else
      outstream.write chr(AscB(clow))
      binlen=binlen+1
      if (i mod 2)=0 then
      notes=gnote
      exit for
      end if
      end if
      next
      outstream.close
      set outstream=file_0.OpenTextFile(file_name,8,false,-1)
      outstream.write midb(Fields(newfile).Value,binlen)
      outstream.close
      if notes=bnote then notes=notes&(binlen-1)&"字節處。"

      End If

      '######################################

      dim myfso,mywrite '#######修改新聞詳細內容
      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
      set mywrite=myfso.createtextfile(server.mappath("./news_content/"&id&".txt"),-1,0)
      mywrite.write content


      dim mytext2,myread2 '#########修改新聞的標題來源
      set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
      mytext2=myread2.readall
      dim listarray,i,h,count,sf
      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
      sf(1)=mytitle
      sf(3)=src

      '#######為6說明上傳了圖片,存儲新的數組實現查看記錄點擊次數加1
      if ubound(sf)=6 then
      If Fields(newfile).FileName<>"" Then
      sf(6)=imageid
      end if
      listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)&","&sf(6)
      else
      listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)
      end if
      '##################
      exit for
      end if

      next


      function htmlencode2(str) '#############字符處理函數
      dim result
      dim l
      l=len(str)
      result=""
      dim i
      for i = 1 to l
      select case mid(str,i,1)

      case chr(34)
      result=result+"''"
      case "&"
      result=result+"&"
      case chr(13)
      result=result+"<br>"
      case " "
      result=result+" "
      case chr(9)
      result=result+" "
      case chr(32)
      if i+1<=l and i-1>0 then
      if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
      result=result+" "
      else
      result=result+" "
      end if
      else
      result=result+" "
      end if
      case else
      result=result+mid(str,i,1)
      end select
      next
      htmlencode2=result
      end function
      '##########################
      dim k,mytext,mappath
      mappath=server.mappath("./")
      set mytext=myfso.createtextfile(mappath&"\new_list.asp",-1,0)

      for i=0 to ubound(listarray)' ##########把所有數據重新寫入文件
      if i=ubound(listarray) then
      mytext.write htmlencode2(listarray(i))
      else
      mytext.write htmlencode2(listarray(i)&" ")
      end if
      next
      %>
      <script language="javascript">
      alert("更改成功");
      window.location=("news_admin1.asp");
      </script>





      日韩精品一区二区三区高清