[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/includes/ -> functions_log.php (source)

   1  <?php
   2  /*=======================================================================
   3   Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
   4   =======================================================================*/
   5  
   6  /***************************************************************************
   7   *                        functions_log.php
   8   *                       -------------------
   9   *     begin                : Jan 24 2003
  10   *     copyright            : Morpheus
  11   *     email                : morpheus@2037.biz
  12   *
  13   *     $Id: function_log.php,v 1.85.2.9 2003/01/24 18:31:54 Moprheus Exp $
  14   *
  15   ****************************************************************************/
  16  
  17  /***************************************************************************
  18   *
  19   *   This program is free software; you can redistribute it and/or modify
  20   *   it under the terms of the GNU General Public License as published by
  21   *   the Free Software Foundation; either version 2 of the License, or
  22   *   (at your option) any later version.
  23   *
  24   ***************************************************************************/
  25  
  26  if (!defined('IN_PHPBB'))
  27  {
  28      die('Hacking attempt');
  29  }
  30  
  31  function log_action($action, $new_topic_id, $topic_id, $user_id, $forum_id, $new_forum_id)
  32  {
  33      global $db;
  34      if (!isset($user_id) || empty($user_id)) {
  35          return;
  36      }
  37        if ( $action == 'split' )
  38        {
  39          $where = "WHERE topic_id = '$new_topic_id'";
  40        }
  41        else
  42        {
  43          $where = "WHERE topic_id = '$topic_id'";
  44        }
  45              $sql = "SELECT topic_last_post_id
  46                      FROM ". TOPICS_TABLE ."
  47                      $where";
  48              if ( !($result = $db->sql_query($sql)) )
  49              {
  50                  message_die(GENERAL_ERROR, 'Could not get topic_last_post_id', '', __LINE__, __FILE__, $sql);
  51              }
  52              $row = $db->sql_fetchrow($result);
  53              $last_post_id = $row['topic_last_post_id'];
  54              $db->sql_freeresult($result);
  55  
  56      $sql = "SELECT session_ip
  57          FROM " . SESSIONS_TABLE . "
  58          WHERE session_user_id = $user_id ";
  59  
  60      if ( !($result = $db->sql_query($sql)) )
  61      {
  62          message_die(GENERAL_ERROR, 'Could not select session_ip', '', __LINE__, __FILE__, $sql);
  63      }
  64      $row = $db->sql_fetchrow($result);
  65      $db->sql_freeresult($result);
  66      $user_ip = $row['session_ip'];
  67  
  68      $sql = "SELECT username
  69          FROM " . USERS_TABLE . "
  70          WHERE user_id = $user_id ";
  71  
  72      if ( !($result = $db->sql_query($sql)) )
  73      {
  74          message_die(GENERAL_ERROR, 'Could not select username', '', __LINE__, __FILE__, $sql);
  75      }
  76      $row2 = $db->sql_fetchrow($result);
  77      $db->sql_freeresult($result);
  78      $username = $row2['username'];
  79      $username = addslashes($username);
  80  
  81      $time = time();
  82  
  83      $sql = "INSERT INTO " . LOGS_TABLE . " (mode, topic_id, user_id, username, user_ip, time, new_topic_id, forum_id, new_forum_id, last_post_id)
  84          VALUES ('$action', '$topic_id', '$user_id', '$username', '$user_ip', '$time', '$new_topic_id', '$forum_id', '$new_forum_id', '$last_post_id')";
  85  
  86      if ( !($result = $db->sql_query($sql)) )
  87      {
  88          message_die(GENERAL_ERROR, 'Could not insert data into logs table', '', __LINE__, __FILE__, $sql);
  89      }
  90      $db->sql_freeresult($result);
  91  }
  92  
  93  function prune_logs($prune_days)
  94  {
  95      global $db;
  96  
  97      $prune = time() - ( $prune_days * 86400 );
  98  
  99      $sql = "SELECT log_id
 100          FROM " . LOGS_TABLE . "
 101          WHERE time < $prune ";
 102  
 103      if ( !($result = $db->sql_query($sql)) )
 104      {
 105          message_die(GENERAL_ERROR, 'Could not obtain list of logs to prune', '', __LINE__, __FILE__, $sql);
 106      }
 107  
 108      $logs = '';
 109      while ( $row = $db->sql_fetchrow($result) )
 110      {
 111          $logs .= ( ( $logs != '' ) ? ', ' : '' ) . $row['log_id'];
 112      }
 113      $db->sql_freeresult($result);
 114  
 115      if ( $logs != '' )
 116      {
 117          $sql = "DELETE FROM " . LOGS_TABLE . "
 118              WHERE log_id IN ($logs)";
 119  
 120          if ( !$db->sql_query($sql) )
 121          {
 122              message_die(GENERAL_ERROR, 'Could not delete logs', '', __LINE__, __FILE__, $sql);
 123          }
 124  
 125          return TRUE;
 126      }
 127  }
 128  
 129  function auto_prune_logs()
 130  {
 131      global $db;
 132  
 133      // To do
 134  }
 135  
 136  ?>


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