Dede Source code Interpretation (1)--index.php

Source: Internet
Author: User
Tags php class

Just learning PHP, the feeling of weaving dream cms is very good, like learning, record their own learning experience!

  I am a novice, PHP is not to understand, wrong place, welcome to criticize, greatly appreciated!

  Let's start with the analysis of the Dream portal. index.php, first paste code, line by row analysis

1<?PHP2 /**3 * @version $Id: index.php 1 9:23 2010-11-11 Tianya $4 * @package Dedecms.site5 * @copyright Copyright (c) 2007-2010, Desdev, Inc.6 * @license http://help.dedecms.com/usersguide/license.html7 * @link http://www.dedecms.com8  */
  
/**
* First sentence if statement first look at the data under the common.inc.php file exists, does not exist then jumps to the Dede
* Install page, stop executing the following code
*common.inc.php file should be Dede when installing the database configuration file, the content is the database connection information
* Includes host name ($cfg _dbhost), database name ($cfg _dbname), username ($cfg _dbuser), with
* User password ($cfg _dbpwd), table prefix setting ($cfg _dbprefix) and database using encoding format ($cfg _db_language)
*/
9 if(!file_exists(dirname(__file__).‘ /data/common.inc.php '))Ten { One Header(' location:install/index.php '); A Exit(); - }

  
  isset ($_get[' Upcache ')  is a GET request, do not know the specific role, I want to know to tell me a bit
  //!  File_exists (' index.html ')  to determine if the index.html file exists
The general meaning is that if the request to update the page or the index.html file does not exist, regenerate it - //automatically generate HTML version the if(isset($_get[' Upcache ']) || !file_exists(' index.html ')) - {
Introduce the common.inc.php file under include, which defines many of the system's constants about the directory
Do a security check, such as work, template directory processing, the introduction of database processing classes and so on - require_once(dirname(__file__) . "/include/common.inc.php");
    
Introduces the arc.partview.class.php class file under Include, sets the template file to parse, and invokes the parse template and
Ways to save HTML files
Dedeinc is a constant defined in the include common.inc.php file , which refers to the Include directory - require_onceDedeinc. " /arc.partview.class.php ";
    
Assigning the global variable _arclistenv to index + $GLOBALS[' _arclistenv '] = ' index ';

Get a record from the #@__homepageset table
#@__ will replace the set table prefix
- $row=$dsql->getone ("Select * from ' #@__homepageset '");

///**
  *  template directory rules
  *
  * @param      string  $tmpdir   Template Catalog
  * @return     string
  * br> * function Mftemplet ($tmpdir)
* {
   *   $tmpdir = Str_replace ("{style}", $GLOBALS [' cfg_df_s Tyle '], $tmpdir);
    * $tmpdir = preg_replace ("/\/{1,}/", "/", $tmpdir);
    * return $tmpdir;
* } The
* probably sees from the function that the contents of the Templet from the table should be {style} and/replace with the actual path, saved in $row [' Templet ']
* / +     $row[' templet '] = Mftemplet ($row[' Templet ']);

Instantiate the Partview class A $PV=NewPartview ();

Call Settemplet to load the template, internally invoke the parse template method at $PV->settemplet ($cfg _basedir.$cfg _templets_dir. "/" .$row[' Templet ']);

View this $row [' Showmod '] exists no, does not exist and is created and assigned a value of 0 - $row[' showmod '] =isset($row[' Showmod '])?$row[' Showmod ']: 0;

$row [' showmod '] if equal to 1 is saved as a index.html file and loaded index.html, otherwise the parsed template string is output directly - if($row[' showmod '] = = 1) - { - $PV->savetohtml (dirname(__file__).‘ /index.html '); - include(dirname(__file__).‘ /index.html '); in Exit(); -}Else { to $PV-Display ();// Direct Output parse template string + Exit(); - } the } * Else $ {
    //Jump to index.html Panax Notoginseng Header(' http/1.1 301 Moved permanently '); - Header(' Location:index.html '); the } +?>

Many still do not know, depressed!

  

  

Dede Source code Interpretation (1)--index.php

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.