[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_handlers/ -> debug_handler.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_handlers/debug_handler.php,v $
  14  |     $Revision: 1.21 $
  15  |     $Date: 2006/12/04 13:32:10 $
  16  |     $Author: mrpete $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  //
  21  // IMPORTANT Info for devs who want to add to and/or use debug definitions!
  22  //
  23  // MAKING NEW DEBUG DEFS
  24  // The debug levels are Single Bit Binary Values. i.e, 1,2,4,8,16...
  25  // In the table below, if you want to define a new value, pick one of
  26  // the "FILLIN" items and give it the name and definition you need
  27  //
  28  // USING DEBUG DEFINITIONS
  29  // Since these are Bit Values, **never** test using < or > comparisons. Always
  30  // test using boolean operations, such as
  31  //    if (E107_DBG_PATH)
  32  //    if (E107_DBG_SQLQUERIES | E107_DBG_SQLDETAILS)
  33  // Since constants are defined for all possible bits, you should never need to use a number value like
  34  //    if (E107_DEBUG_LEVEL & 256)
  35  // And there's never a reason to use
  36  //    if (E107_DEBUG_LEVEL > 254)
  37  
  38  if (!defined('e107_INIT')) { exit; }
  39  
  40  //
  41  // If debugging enabled, set it all up
  42  // If no debugging, then E107_DEBUG_LEVEL will be zero
  43  //
  44  if (strstr(e_MENU, "debug") || isset($_COOKIE['e107_debug_level'])) {
  45      $e107_debug = new e107_debug;
  46      require_once(e_HANDLER.'db_debug_class.php');
  47      $db_debug = new e107_db_debug;
  48      $e107_debug->set_error_reporting();
  49      $e107_debug_level = $e107_debug->debug_level;
  50      define('E107_DEBUG_LEVEL', $e107_debug_level);
  51  } else {
  52      define('E107_DEBUG_LEVEL', 0);
  53  }
  54  
  55  // 
  56  // Define all debug constants -- each one will be zero or a value
  57  // They all have different values and can be 'or'ed together
  58  //
  59  
  60  // Basic levels
  61  define('E107_DBG_BASIC',        (E107_DEBUG_LEVEL & 1));       // basics: worst php errors, sql errors, log, etc
  62  define('E107_DBG_SQLQUERIES',    (E107_DEBUG_LEVEL & 2));       // display all sql queries
  63  define('E107_DBG_TRAFFIC',        (E107_DEBUG_LEVEL & 4));       // display traffic counters
  64  define('E107_DBG_FILLIN8',        (E107_DEBUG_LEVEL & 8));       // fill in what it is
  65  define('E107_DBG_FILLIN16',        (E107_DEBUG_LEVEL & 16));      // fill in what it is
  66  define('E107_DBG_FILLIN32',        (E107_DEBUG_LEVEL & 32));      // fill in what it is
  67  define('E107_DBG_FILLIN64',        (E107_DEBUG_LEVEL & 64));      // fill in what it is
  68  define('E107_DBG_FILLIN128',    (E107_DEBUG_LEVEL & 128));     // fill in what it is
  69  
  70  // Gory detail levels
  71  define('E107_DBG_TIMEDETAILS',(E107_DEBUG_LEVEL &   256));    // detailed time profile
  72  define('E107_DBG_SQLDETAILS',    (E107_DEBUG_LEVEL &   512));    // detailed sql analysis
  73  define('E107_DBG_PATH',         (E107_DEBUG_LEVEL &  1024));    // show e107 predefined paths
  74  define('E107_DBG_BBSC',         (E107_DEBUG_LEVEL &  2048));    // Show BBCode/ Shortcode usage in postings
  75  define('E107_DBG_SC',           (E107_DEBUG_LEVEL &  4096));    // Dump (inline) SC filenames as used
  76  define('E107_DBG_ERRBACKTRACE',    (E107_DEBUG_LEVEL &  8192));    // show backtrace for php errors
  77  define('E107_DBG_DEPRECATED', (E107_DEBUG_LEVEL & 16384));    // Show use of deprecated functions
  78  define('E107_DBG_ALLERRORS',    (E107_DEBUG_LEVEL & 32768));   // show ALL php errors (including notices), not just fatal issues
  79  
  80  class e107_debug {
  81  
  82      var $debug_level = 1;
  83      //
  84      // DEBUG SHORTCUTS
  85      //
  86      var $aDebugShortcuts = array(
  87          'all'               => 255,     // all basics
  88          'basic'            => 255,     // all basics
  89          'b'                  => 255,     // all basics
  90          'warn'            => 1,       // just php warnings, parse errrors, debug log, etc
  91          'showsql'        => 2,       // sql basics
  92          'counts'        => 4,       // traffic counters
  93  
  94          'detail'        => 32767,   // all details
  95          'd'               => 32767,   // all details
  96          'time'             => 257,     // time details and php errors
  97          'sql'             => 513,     // sql details and php errors
  98          'paths'         => 1024,        // dump path strings
  99          'bbsc'             => 2048,        // show bb and sc details
 100          'sc'              => 4096,           // Shortcode paths dumped inline
 101          'backtrace' => 8192,        // show backtrace when PHP has errors
 102          'deprecated'    => 16384,   // show if code is using deprecated functions
 103          'notice'        => 32768,   // you REALLY don't want all this, do you?
 104          'everything'=> 61439,   //(65535-4096) everything we know, and the rumors too
 105                                  // (but shortcode paths removed: inline debug breaks pages!
 106      );
 107  
 108  	function e107_debug() {
 109          if (preg_match('/debug(=?)(.*?),?(\+|stick|-|unstick|$)/', e_MENU, $debug_param) || isset($_COOKIE['e107_debug_level'])) {
 110              $dVals=0;
 111              if (isset($_COOKIE['e107_debug_level'])) {
 112                  $dVals = substr($_COOKIE['e107_debug_level'],6);
 113              }
 114              if (preg_match('/debug(=?)(.*?),?(\+|stick|-|unstick|$)/', e_MENU)) {
 115                  $dVals = $debug_param[1] == '=' ? $debug_param[2] : 'everything';
 116              }
 117              
 118              $aDVal = explode('.',$dVals); // support multiple values, OR'd together
 119              $dVal = 0;
 120              foreach ($aDVal as $curDVal)
 121              {
 122                  if (isset($this->aDebugShortcuts[$curDVal])) {
 123                      $dVal |= $this->aDebugShortcuts[$curDVal];
 124                  } else {
 125                      $dVal |= $curDVal;
 126                  }
 127              }
 128                  
 129              if (isset($debug_param[3]))
 130              {
 131                  if ($debug_param[3] == '+' || $debug_param[3] == 'stick')
 132                  {
 133                      cookie('e107_debug_level', 'level='.$dVal, time() + 86400);
 134                  }
 135                  if ($debug_param[3] == '-' || $debug_param[3] == 'unstick')
 136                  {
 137                      cookie('e107_debug_level', '', time() - 3600);
 138                  }
 139              }
 140  
 141                  $this->debug_level = $dVal;
 142              }
 143          }
 144  
 145  	function set_error_reporting() {
 146      }
 147  }
 148  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7