Setting up multiple forums with a set of forum procedures

Source: Internet
Author: User
Tags mdb database prepare servervariables access database
To deal with the stingy space service providers, previously we thought of using linked datasheet method to store a larger database. Now let's tell you another way: Run two forum programs with a forum code. This can be bypassed by the server CPU occupancy rate is too large for the reason that no space to set up two forum procedures in space service provisions.

I. Preparation of the database
The Online Mainstream ASP forum program (such as Dynamic Network Forum 6.1) is mostly based on Access database. All the forum posts, user information, forum settings, etc. are stored in a database file. We need to prepare two forum database files, then let the forum program open different database files according to different conditions.

Upload the local machine forum to the server, and then prepare two databases named Bbs1.mdb and Bbs2.mdb (to ensure the security of the forum, the filename can be changed a bit more complex) and uploaded to the server's/abc/bbs/data/directory. The database can either use an existing forum or use the initial database of the forum.

Ii. Conditions of Judgment
There are a lot of criteria for deciding to enter a forum, such as the IP address of the visitor, the operating system, the time to access the forum, etc. Here I use the URL address submitted by the caller.

A forum is likely to have two different addresses, such as "www.cpcw.com" and "WWW.CPCW.COM", two of which are pointing to a computer site, but in VBScript they are two different ASCII strings because uppercase and lowercase letters are considered different characters. Therefore, the case of different two addresses can be made to determine the conditions.

Request.ServerVariables is an ASP built-in object that obtains environment variables. The value of the Code request.servervariables ("Script_name") is the path to the currently executing ASP page. For example, access to http://www.scat.com/aBc/test.asp(note case!) ), the value of Request.ServerVariables ("Script_name") is: "/abc/test.asp".

We stipulate that the addresses of the two forums are Http://www.scat.com/ABC/bbs and Http://www.scat.com/abc/bbsrespectively. In fact, you can open more than two forums in this way, because from the point of view of permutations and combinations, the case combination of a URL of length n can be 2 of n Times Square species!

III. revision of the forum procedure
Now most of the ASP forum programs for programming convenience, the code to open the database objects are independent out of the conn.asp, other pages are referenced by referencing this file to access the database. This provides the convenience for our next operation.

Open conn.asp with a text editor and locate the following code:

Dim Db

' For the first time, please modify our database address ...

db= "\data\dvbbs6.mdb"

The program defines the DB variable, and the relative address of the database is assigned to the string variable. The value of this variable is used later when the program opens the database object.

Let's change these lines to:

Dim Db

Dim Whichbbs

Whichbbs =request.servervariables ("Script_name")

If left (whichbbs,4) = "/ABC" Then ' uses a left-hand function to intercept a string that requires length to validate

db= "/data/bbs1.mdb"

Else

db= "/data/bbs2.mdb"

End If

The meaning of this code is to assign the address that the visitor submits to the Whichbbs variable. Because the second half of the URL address changes when the visitor is active in the forum, the first 4 digits of the Whichbbs are compared with the string "/ABC". If the two strings are the same, the DB is assigned "/data/bbs1.mdb", otherwise the DB is assigned "/data/bbs2.mdb". The DB corresponding database will then open. The address submitted by the visitor if it is Http://asp2.6to23.com/ABC, The forum system opens the Bbs1.mdb database, lets the visitor enter the Bbs1.mdb forum, otherwise opens the Bbs2.mdb, enters the Bbs2.mdb forum.

In this way, you can set up more than one forum in a space, and the server's resource consumption than the separate two sets of independent forum system method is much smaller.

This method can also be extended:

1. Apply to other ASP programs related to database operation, such as news system, downloading system, message board, counter and so on.

2. Use the visitor IP address to make the decision condition (Request.ServerVariables ("REMOTE_ADDR")), make disguised, more covert IP filter, let the unpopular person unknowingly be isolated in the real forum.

3. According to their own needs, using other information to determine conditions, to create your rich personality, colorful forum.



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.