[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/includes/ -> log.php (source)

   1  <?php
   2  /*=======================================================================
   3   Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
   4   =======================================================================*/
   5  
   6  /************************************************************************
   7     Nuke-Evolution: Admin / Error Tracker
   8     ============================================
   9     Copyright (c) 2005 by The Nuke-Evolution Team
  10  
  11     Filename      : log.php
  12     Author        : JeFFb68CAM (www.Evo-Mods.com)
  13     Version       : 1.0.2
  14     Date          : 11.28.2005 (mm.dd.yyyy)
  15  
  16     Notes         : Logs the following:
  17                          - Admin account creation
  18                          - Failed admin logins
  19                          - Intruder Alert
  20                          - MySQL Errors
  21                     Original admin tracker by Technocrat
  22  ************************************************************************/
  23  
  24  /*****[CHANGES]**********************************************************
  25  -=[Base]=-
  26        Nuke Patched                             v3.1.0       06/26/2005
  27  -=[Mod]=-
  28        Advanced Username Color                  v1.0.5       06/11/2005
  29   ************************************************************************/
  30  
  31  if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {
  32      exit('Access Denied');
  33  }
  34  
  35  function log_write($file, $output, $title = 'General Error') {
  36      global $cookie;
  37      if(isset($cookie) && is_array($cookie)) {
  38          $username = $cookie[1];
  39      } else {
  40          if(isset($_COOKIE['user']) && !empty($_COOKIE['user'])) {
  41              $ucookie = explode(':', base64_decode($_COOKIE['user']));
  42          }
  43          if(isset($ucookie) && is_array($ucookie) && !empty($ucookie[1])) {
  44              $username = $ucookie[1];
  45          } else {
  46              $username = _ANONYMOUS;
  47          }
  48      }
  49      $ip = GetHostByName(identify::get_ip());
  50      $date = date("d M Y - H:i:s");
  51      if($file == 'admin') {
  52          $string = '';
  53      } elseif ($file == 'error') {
  54          $string = 'URL: <a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '">' . $_SERVER['REQUEST_URI'] . "</a>\n";
  55      }
  56      $header  = "---------[" . $title . "]------------------------------------------------------------------------------------------------------------\n";
  57      $wdata = $header;
  58      $wdata .= "- [" . $date . "] - \n";
  59  /*****[BEGIN]******************************************
  60   [ Mod:    Advanced Username Color             v1.0.5 ]
  61   ******************************************************/
  62      $wdata .= "User: ".UsernameColor($username)."\n";
  63  /*****[END]********************************************
  64   [ Mod:    Advanced Username Color             v1.0.5 ]
  65   ******************************************************/
  66      $wdata .= 'IP: '.$ip."\n";
  67      $wdata .= $string;
  68      $wdata .= "\n";
  69      if(is_array($output)) {
  70          foreach($output as $line) {
  71               $wdata .= htmlspecialchars($line) . "\n";
  72          }
  73      } else {
  74          $wdata .= htmlspecialchars($output) . "\n";
  75      }
  76      $wdata .= str_repeat('-', strlen($header));
  77      $wdata .= "\n\n";
  78      if($handle = @fopen(NUKE_INCLUDE_DIR.'log/' . $file . '.log','a')) {
  79          fwrite($handle, $wdata);
  80          fclose($handle);
  81      }
  82      return;
  83  }
  84  
  85  function log_size($file) {
  86      global $db, $prefix;
  87  
  88      $filename = NUKE_INCLUDE_DIR.'log/' . $file . '.log';
  89      if(!is_file($filename)) {
  90          return -1;
  91      }
  92      if(!is_writable($filename)) {
  93          return -2;
  94      }
  95      if(filesize($filename) == 0) {
  96          return 0;
  97      }
  98      $handle = @fopen($filename,'r');
  99      if($handle) {
 100          $content = fread($handle, filesize($filename));
 101          @fclose($handle);
 102      } else {
 103          return -1;
 104      }
 105      $file_num = substr_count($content, "\n");
 106      $row_log = $db->sql_ufetchrow('SELECT ' . $file . '_log_lines FROM '.$prefix.'_config');
 107      if($row_log[0] != $file_num) {
 108          return 1;
 109      }
 110      return 0;
 111  }
 112  
 113  ?>


Generated: Wed Jun 6 11:38:01 2007 Cross-referenced by PHPXref 0.7