杭州神话信息技术有限公司

标题: 源代码注释...适合新学PHP之人..函数注释...记事狗结构分解 [打印本页]

作者: winken520    时间: 2010-11-6 11:08:01     标题: 源代码注释...适合新学PHP之人..函数注释...记事狗结构分解

为了方便大家进行修改自己的站.,.也方便我自己学习PHP..所以进行源代码参详,...先放出index.php


  1. <?php
  2. /*******************************************************************
  3. *[JishiGou] (C)2005 - 2010 Cenwor Inc.
  4. *
  5. * This is NOT a freeware, use is subject to license terms
  6. *
  7. * @Filename master.mod.php $
  8. *
  9. * @Author http://www.jishigou.net $
  10. *
  11. * @Date 2010-09-02 10:14:03 $
  12. *******************************************************************/
  13. error_reporting(E_ALL ^ E_NOTICE);//显示错误
  14. @ini_set("arg_seperator.output", "&amp;");//当启用自动在URL中添加PHPSESSID变量时所使用的分隔符,用于分隔PHPSESSID和原有的变量。
  15. @set_magic_quotes_runtime(0);//开启当遇到反斜杆、单引号,将会自动加上一个反斜杆
  16. @header('Content-Type: text/html; charset=gbk');//送出 HTTP 协议的标头到浏览器
  17. $time_start = microtime_float();
  18. define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());//定义一个常量。

  19. define('DEBUG',false);
  20. define('ROOT_PATH',dirname(__FILE__) . '/');//返回当前文件路径的 路径部分
  21. define('RELATIVE_ROOT_PATH','./');//总路径

  22. class initialize//定义类
  23. {

  24. function init()//建立函数
  25. {
  26.   $config=array();//建立数组
  27.     require(ROOT_PATH . 'setting/settings.php');//导入文件
  28.   
  29.     if($config['install_lock_time'] < 1)
  30.   {
  31.    if (!is_file(ROOT_PATH . 'install/install.lock') && is_file(ROOT_PATH . 'install.php'))
  32.    {
  33.     die("<a href='./install.php'>请点此进行系统的安装</a>");//判断是否安装了,如果没安装,就结束下边PHP
  34.    }
  35.   }
  36.   
  37.     if ($config['upgrade_lock_time'] > 0)
  38.   {   
  39.    if(($config['upgrade_lock_time'] + 180 > time()) || (is_file(ROOT_PATH . 'cache/upgrade.lock') && filemtime(ROOT_PATH . 'cache/upgrade.lock')+600>time())) {
  40.     die('系统升级中,请稍候……');//filemtime获取文件修改时间
  41.    }
  42.   }
  43.   
  44.     if ($config['site_closed'])
  45.   {
  46.    if ('login'!=$_GET['mod'] && @$site_enable_msg=file_get_contents('./cache/site_enable.php')) //file_get_contents读入文件内容为字符串
  47.    {
  48.     die($site_enable_msg);//判断是否网站关闭,是就终止运行下边的PHP
  49.    }
  50.   }
  51.   
  52.     require(ROOT_PATH . 'setting/constants.php');//UC连接功能
  53.   
  54.     if ($config['rewrite_enable']) //如果REWRITE开启
  55.   {
  56.    include(ROOT_PATH . 'include/rewrite.php');//导入文件
  57.   }
  58.   
  59.     if($config['robot_enable']) //机器人设置
  60.   {
  61.    include(ROOT_PATH . 'setting/robot.php');
  62.   }
  63.   
  64.     if($config['ad_enable']) //广告设置
  65.   {
  66.    include(ROOT_PATH . 'setting/ad.php');
  67.   }
  68.   
  69.     require_once(ROOT_PATH . 'include/function/global.func.php');//导入全局函数  
  70.     require_once(ROOT_PATH . 'modules/master.mod.php');//基本设置,如标题,IP禁止
  71.     require_once(ROOT_PATH . 'modules/' . $this->SetEvent($config['default_module']) . '.mod.php');//调用类SETEVENT的CONFIG函数来对URL提交的MOD数据进行跳转到各页面
  72.   if($_GET)
  73.   {
  74.    $_GET  = daddslashes($_GET, 1, TRUE);//对GET传的数据进行反斜杠处理
  75.   }
  76.   if($_POST)
  77.   {
  78.    $_POST  = daddslashes($_POST, 1, TRUE);//对POST的数据进行处理
  79.   }
  80.   $moduleobject = new ModuleObject($config);
  81.   if(DEBUG===true) $moduleobject->DatabaseHandler->Debug();//判断是否开启错误提示
  82. }

  83. function SetEvent($default='topic')
  84. {
  85.   $modss = array('topic'=>1,'pm'=>1,'login'=>1,'member'=>1,'profile'=>1,'tag'=>1,'get_password'=>1,'report'=>1,'url'=>1,'share'=>1,'other'=>1,);//给数组加内容
  86.   
  87.   $mod = (isset($_POST['mod']) ? $_POST['mod'] : $_GET['mod']);//如果POST变量存在,或者POST提交的表单的MOD有内容,那么就采用POST处理,不然就用GET处理
  88.   
  89.     if(!isset($modss[$mod])) //如果变量的值不存在MODSS数组里,就执行下边
  90.   {
  91.    if($mod)
  92.    {
  93.     $_POST['mod_original'] = $_GET['mod_original'] = $mod;
  94.    }
  95.    
  96.    $mod = ($default ? $default : 'index');//如果DEFAULT存在,就采用默认的,不然设置为INDEX
  97.   }
  98.   
  99.   $_POST['mod'] = $_GET['mod'] = $mod;
  100.   
  101.   Return $mod;
  102. }
  103. }
  104. ob_start("my_output");//开启缓存输出
  105. $init=new initialize;
  106. $init->init();//运行类INITIALIZE里的INIT()函数
  107. unset($init);//释放变量
  108. ob_end_flush();//结束OB—START
  109. //检查GZIP的输出
  110. function my_output(&$buffer,$mode=5)
  111. {
  112. $modss = array('share'=>1);
  113. if(GZIP===true && function_exists('ob_gzhandler') && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && !isset($modss[$_GET['mod']])) {
  114.   $buffer=ob_gzhandler($buffer,$mode);
  115. }
  116. return $buffer;
  117. }
  118. //PHP的运行时间
  119. function microtime_float()
  120. {
  121. list($usec, $sec) = explode(" ", microtime());
  122. return ((float)$usec + (float)$sec);
  123. }
  124. ?>
复制代码

作者: winken520    时间: 2010-11-6 11:10:08

留个位置发布下边的
作者: yuechuan    时间: 2010-12-1 21:16:58

非常不错!
作者: sanpir    时间: 2010-12-1 21:23:12

应该把所有的都给分享一下,呵呵!




欢迎光临 杭州神话信息技术有限公司 (http://cenwor.com/) Powered by Discuz! X2