ASP template and HTML file code.

Source: Internet
Author: User
Tags servervariables

Select case request ("action ")
'Put it in the library first, and then generate the page
'Add start ---------------------------------------------------------------------------------
Case "add"
Title = request ("title ")
Content = request ("content ")
Moban = request ("moban ")
Class_id = request ("class_id ")
Class_name = request ("class_name ")
Class_big = request ("class_big ")
ZZ = request ("ZZ ")
From = request ("from ")
Up = request ("up ")
PIC = request ("pic ")
Picurl = request ("Images ")
Addtime = now ()
Hits = request ("hits ")
Fname = makefilename (addtime)
Addtime = now ()
If title = "" and content = "" then
Response. Write "<SCRIPT> history. Go (-1) </SCRIPT>"
Else
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * from article where (ID = NULL )"
Rs. Open SQL, Conn, 1, 3
Rs. addnew
RS ("title") = title
RS ("content") = content
RS ("moban_id") = moban
RS ("class_id") = class_id
RS ("class_name") = class_name
RS ("class_big") = class_big
RS ("pic") = PIC
RS ("picurl") = picurl
RS ("addtime") = addtime
RS ("ZZ") = ZZ
RS ("from") = from
RS ("hits") = hits
RS ("up") = up
Rs. Update

Moban_id = RS ("moban_id ")
Title = RS ("title ")
Content = txt (RS ("content "))
Addtime = RS ("addtime ")
Addtime = formatdatetime (addtime, 1)
Fileid = RS ("ID ")
Fname = fname & filetype
RS ("fname") = fname
RS ("oktime") = addtime
Rs. Update
Rs. Close

'Page generation program starts
SQL = "select * From moban where id =" & moban_id & "" 'moban is a number and a template ID
Rs. Open SQL, Conn, 1, 1
Okweb = RS ("content ")
'Replace the related fields in the template
Okweb = Replace (okweb, "$ nnso_title", title) 'Article Title
Okweb = Replace (okweb, "$ nnso_content", content) 'Article content
Okweb = Replace (okweb, "$ nnso_addtime", addtime) 'input time
Okweb = Replace (okweb, "$ nnso_from", from) 'source of the article
Okweb = Replace (okweb, "$ nnso_class_big", class_big )'
Okweb = Replace (okweb, "$ nnso_class_name", class_name) 'Class Name
Okweb = Replace (okweb, "$ nnso_path", class_id) 'location, path
Okweb = Replace (okweb, "$ nnso_zz", ZZ) 'author
Okweb = Replace (okweb, "$ nnso_id", fileid) 'ID of the comment
'Start generating
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Filepath = server. mappath ("../html/") & (class_id ))
Set F = FSO. createtextfile (filepath & "/" & fname)
F. writeline okweb
F. Close
'Page generation program ended

'Add logs
IPS = request. servervariables ("remote_addr ")
SJ = now
Conn. execute "insert into log (username, action, IP, SJ) values ('Post add', '[" & Title & "] added successfully ', '"& IPS &"', '"& SJ &"')"
End if
Rs. Close
Set rs = nothing
Conn. Close
Set conn = nothing
Response. Redirect "article. asp? Class_id = "& class_id &""
'Add ended ---------------------------------------------------------------------------------

'Modify start ---------------------------------------------------------------------------------
Case "Mod"
'Step 1: delete files in the directory
Fileid = request ("ID ")
Class_id = request ("class_id ")
Fname = request ("fname ")
Filepath = server. mappath ("../html/") & (class_id) & "/" & fname
Set FSO = Createobject ("scripting. FileSystemObject ")
FSO. deletefile (filepath)
Set FSO = nothing
On Error resume next
'Delete the files in the directory first, and then delete the records in the database. Otherwise, the query will fail.
Title = request ("title ")
Content = request ("content ")
Moban = request ("moban ")
Class_id = request ("class_id ")
Class_name = request ("class_name ")
Class_big = request ("class_big ")
ZZ = request ("ZZ ")
From = request ("from ")
Up = request ("up ")
PIC = request ("pic ")
Picurl = request ("Images ")
Hits = request ("hits ")
If title = "" and content = "" then
Response. Write "<SCRIPT> history. Go (-1) </SCRIPT>"
Else
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * from article where id =" + fileid
Rs. Open SQL, Conn, 1, 3
RS ("title") = title
RS ("content") = content
RS ("moban_id") = moban
RS ("class_id") = class_id
RS ("class_name") = class_name
RS ("class_big") = class_big
RS ("pic") = PIC
RS ("picurl") = picurl
RS ("ZZ") = ZZ
RS ("from") = from
RS ("hits") = hits
RS ("up") = up
Rs. Update

Moban_id = moban
Title = txt (RS ("title "))
Content = txt (RS ("content "))
Addtime = RS ("addtime ")
Addtime = formatdatetime (addtime, 1)
Fileid = RS ("ID ")
Rs. Close

'Page generation program starts
SQL = "select * From moban where id =" & moban_id & "" 'moban is a number and a template ID
Rs. Open SQL, Conn, 1, 1
Okweb = RS ("content ")
'Replace the related fields in the template
Okweb = Replace (okweb, "$ nnso_title", title) 'Article Title
Okweb = Replace (okweb, "$ nnso_content", content) 'Article content
Okweb = Replace (okweb, "$ nnso_addtime", addtime) 'input time
Okweb = Replace (okweb, "$ nnso_from", from) 'source of the article
Okweb = Replace (okweb, "$ nnso_path", class_id) 'location, path
Okweb = Replace (okweb, "$ nnso_class_big", class_big )'
Okweb = Replace (okweb, "$ nnso_class_name", class_name) 'Class Name
Okweb = Replace (okweb, "$ nnso_zz", ZZ) 'author
Okweb = Replace (okweb, "$ nnso_id", fileid) 'ID of the comment
'Start generating
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Filepath = server. mappath ("../html/") & (class_id ))
Set F = FSO. createtextfile (filepath & "/" & fname)
F. writeline okweb
F. Close
'Add logs
IPS = request. servervariables ("remote_addr ")
SJ = now
Conn. execute "insert into log (username, action, IP, SJ) values ('Article modify', '" & fname & "-modified successfully','" & IPS &"', '"& SJ &"')"
End if
Rs. Close
Set rs = nothing
Conn. Close
Set conn = nothing
Response. Redirect "article. asp? Class_id = "& class_id &""

'Page generation program ended
'Modification ended --------------------------------------------------------------------------------

'Delete start --------------------------------------------------------------------------------
Case "Del"
ArticleID = request ("ID ")
Class_id = request ("class_id ")
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select ID, class_id, fname from article where id =" + ArticleID
Rs. Open SQL, Conn, 1, 3
Fname = RS ("fname ")
Class_id = RS ("class_id ")
Rs. Close
Set rs = nothing

'Delete the articles in the directory
Filepath = request. servervariables ("appl_physical_path") & ("html/") & (class_id) & "/" & fname
Set FSO = Createobject ("scripting. FileSystemObject ")
FSO. deletefile (filepath)
Set FSO = nothing
'Delete the files in the directory first, and then delete the records in the database. Otherwise, the query will fail.
Conn.exe cute ("delete from article where id =" & ArticleID &"")
'Add logs
IPS = request. servervariables ("remote_addr ")
SJ = now
Conn. execute "insert into log (username, action, IP, SJ) values ('Article delete', '" & fname & "-deleted successfully', '" & IPS &"', '"& SJ &"')"
Conn. Close
Set conn = nothing
'Redirection return
Response. Redirect "article. asp? Class_id = "& class_id &""
'Deletion ended --------------------------------------------------------------------------------

End select

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.