Z-blog Classification label total Station static scheme

Source: Internet
Author: User
Tags date auth exit html page modify trim

Z-blog has already realized the homepage and the article page static, may generate the HTML file, but the system classification page, tags tags page, the archive page and the author page all did not achieve the static, this article will tell a very simple scheme, can automatically generate each category page, Archive pages and tags for static HTML pages so that users can migrate the Web site to a host that does not support ASP, such as Apache.

Z-blog's category pages, tags tags pages, archive pages, and author pages are called catalog.asp, so modify this file to automatically generate an HTML file for that page when the user invokes the file. If a visitor reads this file repeatedly, a static file can be used directly at the beginning of the file for a certain period of time to conserve system resources.

The way to do this is to first create a directory cat under the root and then use the editor to open the catalog.asp file in the Z-blog root and add the following code at the beginning of the file:

Dim objFSO
Dim objfile
Dim strFileName
Dim Strfiletime
Dim Isbuildfile
If Request.QueryString ("Cate") <> "" Then
If Request.QueryString ("page") <> "then
strFileName = "Cate" + "_" + request.querystring ("cate") + "_" + request.querystring ("page") + ". html"
Else
strFileName = "Cate" + "_" + request.querystring ("cate") + ". html"
End If
ElseIf request.querystring ("tags") <> "" Then
If Request.QueryString ("page") <> "then
strFileName = "tags" + "_" + request.querystring ("tags") + "_" + request.querystring ("page") + ". html"
Else
strFileName = "tags" + "_" + request.querystring ("tags") + ". html"
End If
ElseIf request.querystring ("auth") <> "" Then
If Request.QueryString ("page") <> "then
strFileName = "Auth" + "_" + request.querystring ("auth") + "_" + request.querystring ("page") + ". html"
Else
strFileName = "Auth" + "_" + request.querystring ("auth") + ". html"
End If
ElseIf request.querystring ("date") <> "" Then
If Request.QueryString ("page") <> "then
strFileName = "Date" + "_" + request.querystring ("date") + "_" + request.querystring ("page") + ". html"
Else
strFileName = "Date" + "_" + request.querystring ("date") + ". html"
End If
ElseIf request.querystring ("page") <> "" Then
strFileName = "Default" + "_" + request.querystring ("page") + ". html"
Else
strFileName = "default_1" + ". html"
End If
Isbuildfile = False
Set objFSO = CreateObject ("Scripting.FileSystemObject")
If objfso.fileexists (Server.MapPath (strFileName)) Then
Set objfile = Objfso.getfile (Server.MapPath (strFileName))
Strfiletime = objfile.datelastmodified
Set objfile = Nothing
If DateDiff ("H", Strfiletime,now ()) > 1 Then
Isbuildfile = True
Else
Server.Transfer strFileName
Response.End
End If
Else
Isbuildfile = True
End If
Set objFSO = Nothing

Locate the Response.Write artlist.html line and add the following code to it:

If Isbuildfile Then
Artlist.filename=strfilename
Artlist.directory= "Cat"
Artlist.save
End If

In this way, the system automatically generates static HTML files for all dynamic pages, and does not duplicate the generation within 1 hours, and automatically loads static HTML files to save system resources if there are calls.

After this processing, z-blog of all categories and tags can be generated static HTML page.

After the static, you can put Z-blog all the station on the Php+apache host. The specific method is to configure the Apache host to use the PHP method to parse the ASP, and then edit catalog.asp this file, modify its code to be as follows:

if (Isset ($_get[' Cate ')) {
if (Isset ($_get[' page ')) {
$strFileName = "Cate_". Strip_tags (Stripslashes (Trim ($_get[' cate '))). " _ ". Strip_tags (stripslashes ($_get[' page ')).". HTML ";
} else {
$strFileName = "Cate_". Strip_tags (Stripslashes (Trim ($_get[' cate '))). ". HTML ";
}
else if (isset ($_get[' tags '))} {
if (Isset ($_get[' page ')) {
$strFileName = "Tags_". Strip_tags (Stripslashes (Trim ($_get[' tags ')). " _ ". Strip_tags (stripslashes ($_get[' page ')).". HTML ";
} else {
$strFileName = "Tags_". Strip_tags (Stripslashes (Trim ($_get[' tags '))). HTML ";
}
else if (isset ($_get[' auth '))} {
if (Isset ($_get[' page ')) {
$strFileName = "Auth_". Strip_tags (Stripslashes (Trim ($_get[' auth '))). " _ ". Strip_tags (stripslashes ($_get[' page ')).". HTML ";
} else {
$strFileName = "Auth_". Strip_tags (Stripslashes (Trim ($_get[' auth '))). ". HTML ";
}
else if (isset ($_get[' Date ')) {
if (Isset ($_get[' page ')) {
$strFileName = "Date_". Strip_tags stripslashes (Trim ($_get[' Date ')). " _ ". Strip_tags (stripslashes ($_get[' page ')).". HTML ";
} else {
$strFileName = "Date_". Strip_tags stripslashes (Trim ($_get[' Date ')). ". HTML ";
}
else if (isset ($_get[' page ')) {
$strFileName = "Default_". Strip_tags (Stripslashes (Trim ($_get[' page ')). ". HTML ";
} else {
$strFileName = ". /default.html ";
}
Define ("Html_file", DirName (__file__). " /". $strFileName);
if (file_exists (html_file)) {
Echo (file_get_contents (html_file));
Exit (0);
} else {
Exit (0);
}



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.