⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system_debug.class.inc.php

📁 This is the script which used on 10minutemail.com for temporary email.
💻 PHP
字号:
<?php

  /*****************************************************
  ** Title........: Debugging and error handling
  ** Filename.....: debug.class.inc.php
  ** Author.......: Ralf Stadtaus
  ** Homepage.....: http://www.stadtaus.com/
  ** Contact......: mailto:info@stadtaus.com
  ** Version......: 0.1
  ** Notes........:
  ** Last changed.: 
  ** Last change..: 
  *****************************************************/




/**
 * Class name and unique identifier for $GLOBALS array that contains the
 * instance
 */
define('SYSTEM_DEBUG_CLASS', 't12l_system_debug');
define('SYSTEM_DEBUG_INSTANCE', 't12l_system_debug_instance');


/**
 * Core class for error handling and debug messaging
 * 
 * @access public
 */
class t12l_system_debug
{
    
    var $messages;
    var $types = array('debug', 'system', 'error');

    //--------------------------------------------------------------------------




    /**
     * Constructor
     * 
     * @access private
   	 */
    function t12l_system_debug()
    {
        
    }
  
    //--------------------------------------------------------------------------


    

    /**
     * Create single instance
     * 
   	 */
    function &get_instance()
    {
        if (!isset($GLOBALS[SYSTEM_DEBUG_INSTANCE])) {
            $GLOBALS[SYSTEM_DEBUG_INSTANCE] = new t12l_system_debug;
        }
        
        return $GLOBALS[SYSTEM_DEBUG_INSTANCE];
    }
  
    //--------------------------------------------------------------------------




    /**
     * Add system, error or debug message
     * 
     * debug  = Debugging information for developer
     * error  = Error message for developer and admin
     * system = System message for enduser
     * 
     * Example:
     * <code>
     * t12l_system_debug::add_message('Title', 'Message text' [,
     * 'system|error|debug']);
     * </code>
     * 
     * @access public
     * @param string $title Message title
     * @param string $message Message content
     * @param string $type Message type (system, error, debug [default])
   	 */
    function add_message($title, $message, $type = 'debug', $backtrace = array())
    {
        if ($message == '') {
            return;
        }

        $deb =& t12l_system_debug::get_instance();

        if (sizeof($backtrace) > 0) {
            while (list($key, $val) = each ($backtrace))
            {
                $temp = array();
                while (list($k, $v) = each($val))
                {
                    if ($k == 'args') {
                        if (!is_array($v)) {
                            $temp[] = $k . ': ' . join('<br />', $v);
                        }
                        continue;
                    }
                    if (is_object($v)) {
                        continue;
                    }
                    $temp[] = $k . ': ' . $v;
                }

                $result[] = join('<br />', $temp);
            } 
            $backtrace = $result;
        }
        
        if (is_array($backtrace)) {
            $joint_backtrace = join('<br /><br />', $backtrace);
        } else {
            $joint_backtrace = $backtrace;
        }

        $arr = array('title'     => $title,
                     'message'   => $message,
                     'backtrace' => $joint_backtrace);
        
        $deb->messages[$type][] = $arr;
        
    }
  
    //--------------------------------------------------------------------------




    /**
     * Get system, error, debug or all messages (if type empty)
     * 
     * @access public
     * @param string $type Message type (system, error, debug)
   	 */
    function get_messages($type = '')
    {
        $output = array();
        $deb =& t12l_system_debug::get_instance();
        reset($deb->types);
        while (list(, $val) = each($deb->types))
        {
            if (($type == '' or $type == $val) and isset($deb->messages[$val])) {
                $output +=  $deb->messages[$val];
            }
        }
        
        return $output;
    }
  
    //--------------------------------------------------------------------------


}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -