To deal with stingy space service providers, everyone used to think of using linked data tables to store larger databases. Now let me tell you another method: use the code of one forum to run two forum programs. This can circumvent those space service regulations that do not allow two sets of forum programs to be set up in one space on the grounds that the server CPU usage is too high.
1. Prepare the database. Most of the mainstream ASP forum programs on the Internet (such as Dongwang Forum 6.1) are based on Access databases. All forum posts, user information, forum settings, etc. are stored in a database file. We need to prepare two forum database files, and then let the forum program open different database files according to different conditions.
Upload the local forum to the server, then prepare two databases named bbs1.mdb and bbs2.mdb (in order to ensure the security of the forum, the file names can be changed to be more complicated), and upload them to the server's /abc/bbs/ data/ directory. The database can either use the existing forum or the forum's initial database.
2. Determination conditions There are many conditions used to determine entry into the forum, such as the visitor's IP address, operating system, time of accessing the forum, etc. Here the author uses the URL address submitted by the visitor.
A forum may have two different addresses, such as "www.cpcw.com" and "WWW.CPCW.COM". Although the two URLs point to the computer newspaper website, in the view of VbScript they are two different ASCII Strings because uppercase and lowercase letters are recognized as different characters. Therefore, two addresses with different upper and lower case can be used as judgment conditions.
Request.ServerVariables is an ASP built-in object for obtaining environment variables. The value of the code Request.ServerVariables("SCRIPT_NAME") is the path of the currently executed ASP page. For example, when accessing http://www.scat.com/aBc/test.asp (note the 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/bbs . In fact, you can use this method to open more than two forums, because from the perspective of permutation and combination, there can be 2 to the n power of uppercase and lowercase combinations of a URL of length n!
3. Modify the forum program. For the convenience of programming, most of the ASP forum programs now have the code to open the database object separated and placed in conn.asp. Other pages access the database by referencing this file. This provides convenience for our next operations.
Open conn.asp with a text editor and find the following code:
Dim Db
'For free users, please modify the local database address for the first time...
DB="datadvbbs6.mdb"
The program defines the variable Db , the relative address of the database is assigned to this string variable. The value of this variable will be used later when the program opens the database object.
We change these lines to:
Dim Db
Dim Whichbbs
Whichbbs =Request.ServerVariables("SCRIPT_NAME ")
if left(Whichbbs, 4)="/ABC" then 'Use the left function to intercept the string of required length for verification
Db= "/data/bbs1.mdb"
else
Db="/data/bbs2.mdb"
end if
The meaning of this code is to assign the address submitted by the visitor to the Whichbbs variable. Since the second half of the URL address changes when a visitor is active in the forum, only the first 4 digits of Whichbbs are used for comparison with the string "/ABC". If the two strings are the same, Db is assigned the value "/data/bbs1.mdb"; otherwise, Db is assigned the value "/data/bbs2.mdb". Then the database corresponding to Db will be opened. If the address submitted by the visitor is http://asp2.6to23.com/ABC , the forum system opens the database of bbs1.mdb and allows the visitor to enter the forum in bbs1.mdb; otherwise, it opens bbs2.mdb and enters bbs2.mdb. in the forum.
In this way, you can set up more than one forum in one space, and the server resource usage is much smaller than setting up two independent forum systems separately.
This method can also be extended:
1. Apply to other ASP programs involving database operations, such as news systems, download systems, message boards, counters, etc.
2. Use the visitor's IP address as the judgment condition (Request.ServerVariables("REMOTE_ADDR")) to create a disguised and more covert IP filtering, so that unwelcome people are unknowingly isolated from the real forum. .
3. Use other information as judgment criteria according to your own needs to create your own personalized and colorful forum.