Pagecooker Code Reading Notes

Source: Internet
Author: User

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

  • You can operate on $ SQL objects, such as $ entry = $ SQL-> queryrowsarray ("select * from entry where id = ". intval ($ _ Get ['id']);
  • $ SQL object in global. php $ SQL = init_primary_database ();
  • Init_primary_database is actually creating a database object. Look at init. php.
    If (function_exists ('mysqli _ connect '))
    {

    Require_once (cookery_framework_dir. 'lib/class_mysqli.php ');
    }
    Else
    {

    Require_once (cookery_framework_dir. 'lib/class_mysql.php ');
    }

    Class_mysqli.php and class_mysql.php are two different database implementations. Select the appropriate one here.

 

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.

 

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.