[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_handlers/ -> admin_log_class.php (source)

   1  <?php
   2  
   3  /*
   4  + ----------------------------------------------------------------------------+
   5  |     e107 website system
   6  |
   7  |     �Steve Dunstan 2001-2002
   8  |     http://e107.org
   9  |     jalist@e107.org
  10  |
  11  |     Released under the terms and conditions of the
  12  |     GNU General Public License (http://gnu.org).
  13  |
  14  |     $Source: /cvsroot/e107/e107_0.7/e107_handlers/admin_log_class.php,v $
  15  |     $Revision: 1.9 $
  16  |     $Date: 2006/10/24 17:02:57 $
  17  |     $Author: e107coders $
  18  +----------------------------------------------------------------------------+
  19  */
  20  
  21  if (!defined('e107_INIT')) { exit; }
  22  
  23  /**
  24   * Admin logging class.
  25   *
  26   */
  27  class e_admin_log {
  28  
  29      /**
  30       * Contains default class options, plus any that are overidden by the constructor
  31       *
  32       * @var array
  33       */
  34      var $_options = array(
  35          'log_level' => 2,
  36          'backtrace' => false,
  37      );
  38  
  39      /**
  40       * Constructor. Sets up constants and overwrites default options where set.
  41       *
  42       * @param array $options
  43       * @return e_admin_log
  44       */
  45  	function e_admin_log ($options = array()){
  46          foreach ($options as $key => $val) {
  47              $this->_options[$key] = $val;
  48          }
  49  
  50          /**
  51           * Minmal Log Level, including really minor stuff
  52           *
  53           */
  54  
  55          define("E_LOG_INFORMATIVE", 0);
  56  
  57          /**
  58           * More important than informative, but less important than notice
  59           *
  60           */
  61          define("E_LOG_NOTICE", 1);
  62  
  63          /**
  64           * Not anything serious, but important information
  65           *
  66           */
  67          define("E_LOG_WARNING", 2);
  68  
  69          /**
  70           * An event so bad your site ceased execution.
  71           *
  72           */
  73          define("E_LOG_FATAL", 3);
  74  
  75          /*
  76           *     Plugin Information.
  77           */
  78  
  79          define("E_LOG_PLUGIN", 4);
  80      }
  81  
  82      /**
  83       * Log an event to the core table
  84       *
  85       * @param string $event_title
  86       * @param string $event_detail
  87       * @param int $event_type Log level
  88       */
  89  	function log_event ($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE) {
  90          global $e107, $sql, $tp;
  91          if($event_type >= $this->_options['log_level']) {
  92              $event_title = $tp -> toDB($event_title, true);
  93              $event_detail = $tp -> toDB($event_detail, true);
  94              $event_type = $tp -> toDB($event_type, true);
  95              $time_stamp = time();
  96              $uid = (USERID !== FALSE) ? USERID : '0';
  97              $ip = $e107->getip();
  98              if($this->_options['backtrace'] == true) {
  99                  $event_detail .= "\n\n".debug_backtrace();
 100              }
 101              $sql->db_Insert('dblog', "'', '{$event_type}', {$time_stamp}, {$uid}, '{$ip}', '{$event_title}', '{$event_detail}' ");
 102          }
 103      }
 104  
 105  	function get_log_events($count = 15, $offset) {
 106          global $sql;
 107          $count = intval($count);
 108      }
 109  
 110      /**
 111       * Removes all events older than $days, or truncates the table if $days == false
 112       *
 113       * @param int $days
 114       */
 115  	function purge_log_events($days) {
 116          global $sql;
 117          if($days == false) {
 118              // $days is false, so truncate the log table
 119              $sql->db_Select_gen("TRUNCATE TABLE #dblog ");
 120          } else {
 121              // $days is set, so remove all entries older than that.
 122              $days = intval($days);
 123              $mintime = $days * 24 * 60 * 60;
 124              $time = time() - $mintime;
 125              $sql->db_Delete("dblog", "WHERE `dblog_datestamp` < {$time}", true);
 126          }
 127      }
 128  }
 129  
 130  ?>


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