Pagecooker Code Reading Notes
Recently, I am doing some research on large distributed websites. I want to build a PHP Web System under Linux. I only need two systems. One is to allow uploading static images for display, the other is to have database access, because we want to make a distributed transformation in the following two aspects. I wanted to write a message board myself, but I was afraid of trouble. Later I found pagecooker and found that the code was fairly simple, read the main code.
1. Main directory structure
- Some common functions under lib
- Template is a page template file.
- Qqwry. dat under database, which is an IP database
- Other major initialization statuses, configurations, and database connection files are in the root directory.
2. Page Rendering
- All requests are processed in index. php and are processed according to the get parameter act in the URL. Taking login as an example, the current URL is http: // 192.168.5.128/MB /? Act = login. When act = login, first check whether there is $ _ post ['username']. If yes, perform user verification. Otherwise, only the logon page is displayed.
The logon page is displayed in the show_login function. These two lines are used:
$ Template = new template ('login', null, 'login ');
Eval ($ template-> parse ());
- The template class is located in class_template.php under Lib. The load function loads the corresponding Template File Based on the specified Template Name, replaces the corresponding tag, and then runs eval directly and outputs the result.
- It seems that the performance is problematic when a large number of users access it.
3. Database Access
4. In addition, the function of capturing data with Flick is also available. After capturing data, it is written to the file in JSON format and then displayed on the page.