| 
         在引导文件中,调试和session等接口处理的主要是下面代码: 
-  
 - $_debug_safe_ip = false; 
 - require PATH_LIBRARY.'/debug/lib_debug.php'; 
 - if( in_array( util::get_client_ip(), $GLOBALS['config']['safe_client_ip']) || OPEN_DEBUG === true ) 
 - { 
 -     $_debug_safe_ip = true; 
 -     ini_set('display_errors', 'On'); 
 - } 
 - else 
 - { 
 -     ini_set('display_errors', 'Off'); 
 - } 
 - set_exception_handler('handler_debug_exception'); 
 - set_error_handler('handler_debug_error', E_ALL); 
 - register_shutdown_function('handler_php_shutdown'); 
 -  
 -  
 - require CORE.'/session.php'; 
 
  
Debug程序是通过 
- set_exception_handler('handler_debug_exception'); 
 - set_error_handler('handler_debug_error', E_ALL); 
   
这里对系统的debug信息进行了接管(接口函数定义在 core/library/debug/lib_debug.php ) 
除了支持基本的调试外,也支持使用xhprof进行性能调试 
 
关于错误处理时具体方法请参考:错误处理与程序Debug方法>> 
 
core/session.php 分两种情况,一种是使用memcache的情况,仅是修改php参数,不会对session接口重写,另一种情况是使用文件hash缓存(如果单服务器运行的程序,这种模式会更稳定),接口进行了重写,考虑性能原因,默认并没有初始化缓存,如果需要使用session,还是需要用户自行在使用前用 @session_start() 初始化。。 
 
此外在 init.php 还定义了几个特殊函数: 
  
-  
 -  
 -  
 - function handler_php_shutdown() 
 - { 
 -     show_debug_error(); 
 -     log::save(); 
 -     if( defined('CLS_CACHE') ) { 
 -         cache::free(); 
 -     } 
 -     if( defined('CLS_CACHE_NATIVE') ) { 
 -         cls_cache_native::close(); 
 -     } 
 - } 
 -  
 -  
 -  
 -  
 -  
 -  
 - function handler_fatal_error( $errtype, $msg ) 
 - { 
 -     global $_debug_safe_ip; 
 -     $log_str = $errtype.':'.$msg; 
 -     if ( OPEN_DEBUG === true || $_debug_safe_ip ) 
 -     { 
 -         throw new Exception( $log_str ); 
 -     } 
 -     else 
 -     {         
 -         log::add('fatal_error', $msg); 
 -         header ( "location:/404.html" ); 
 -         exit(); 
 -     } 
 - } 
 -  
 -  
 -  
 -  
 -  
 -  
 -  
 -  
 - function run_controller() 
 - { 
 -     try 
 -     { 
 -         $ac = preg_replace("/[^0-9a-z_]/i", '', req::item('ac', 'index') ); 
 -         $ac = emptyempty ( $ac ) ? $ac = 'index' : $ac; 
 -              
 -         $ctl = 'ctl_'.preg_replace("/[^0-9a-z_]/i", '', req::item('ct', 'index') ); 
 -         $path_file = PATH_CONTROL . '/' . $ctl . '.php'; 
 -  
 -         if( file_exists( $path_file ) ) 
 -         { 
 -             require $path_file; 
 -         } 
 -         else 
 -         { 
 -             throw new Exception ( "Contrl {$ctl}--{$path_file} is not exists!" ); 
 -         } 
 -         if( method_exists ( $ctl, $ac ) === true ) 
 -         { 
 -             $instance = new $ctl ( ); 
 -             $instance->$ac (); 
 -         } 
 -         else 
 -         { 
 -             throw new Exception ( "Method {$ctl}::{$ac}() is not exists!" ); 
 -         } 
 -     } 
 -     catch ( Exception $e ) 
 -     { 
 -         handler_fatal_error( 'init.php run_controller()', $e->getMessage().' url:'.util::get_cururl() ); 
 -     } 
 - } 
 -  
 -  
 -  
 -  
 -  
 -  
 -  
 - function __autoload( $classname ) 
 - { 
 -     $classname = preg_replace("/[^0-9a-z_]/i", '', $classname); 
 -     if( class_exists ( $classname ) ) { 
 -         return true; 
 -     } 
 -     $classfile = $classname.'.php'; 
 -     try 
 -     { 
 -         if ( file_exists ( PATH_LIBRARY.'/'.$classfile ) ) 
 -         { 
 -             require PATH_LIBRARY.'/'.$classfile; 
 -         } 
 -         else if( file_exists ( PATH_MODEL.'/'.$classfile ) )  
 -         { 
 -             require PATH_MODEL.'/'.$classfile; 
 -         } 
 -         else if( file_exists ( require PATH_ROOT.'/model/'.$classfile ) )  
 -         { 
 -             require PATH_ROOT.'/model/'.$classfile; 
 -         } 
 -         else 
 -         { 
 -             return false; 
 -             throw new Exception ( 'Error: Cannot find the '.$classname ); 
 -         } 
 -     } 
 -     catch ( Exception $e ) 
 -     { 
 -         handler_fatal_error( 'init.php __autoload()', $e->getMessage().'|'.$classname.' url:'.util::get_cururl() ); 
 -     } 
 - } 
 -  
 -  
 -  
 -  
 - function request($key, $df='') 
 - { 
 -     return req::item($key, $df); 
 - } 
 
  
  
         |