[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/mcp/ -> mcp_logs.php (source)

   1  <?php
   2  /**
   3  *
   4  * @package mcp
   5  * @version $Id$
   6  * @copyright (c) 2005 phpBB Group
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   8  *
   9  */
  10  
  11  /**
  12  * @ignore
  13  */
  14  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  /**
  20  * mcp_logs
  21  * Handling warning the users
  22  * @package mcp
  23  */
  24  class mcp_logs
  25  {
  26      var $u_action;
  27      var $p_master;
  28  
  29  	function mcp_logs(&$p_master)
  30      {
  31          $this->p_master = &$p_master;
  32      }
  33  
  34  	function main($id, $mode)
  35      {
  36          global $auth, $db, $user, $template;
  37          global $config, $phpbb_root_path, $phpEx;
  38  
  39          $user->add_lang('acp/common');
  40  
  41          $action = request_var('action', array('' => ''));
  42  
  43          if (is_array($action))
  44          {
  45              list($action, ) = each($action);
  46          }
  47          else
  48          {
  49              $action = request_var('action', '');
  50          }
  51  
  52          // Set up general vars
  53          $start        = request_var('start', 0);
  54          $deletemark = ($action == 'del_marked') ? true : false;
  55          $deleteall    = ($action == 'del_all') ? true : false;
  56          $marked        = request_var('mark', array(0));
  57  
  58          // Sort keys
  59          $sort_days    = request_var('st', 0);
  60          $sort_key    = request_var('sk', 't');
  61          $sort_dir    = request_var('sd', 'd');
  62  
  63          $this->tpl_name = 'mcp_logs';
  64          $this->page_title = 'MCP_LOGS';
  65  
  66          $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
  67          $forum_list[] = 0;
  68  
  69          $forum_id = $topic_id = 0;
  70  
  71          switch ($mode)
  72          {
  73              case 'front':
  74              break;
  75  
  76              case 'forum_logs':
  77                  $forum_id = request_var('f', 0);
  78  
  79                  if (!in_array($forum_id, $forum_list))
  80                  {
  81                      trigger_error('NOT_AUTHORISED');
  82                  }
  83  
  84                  $forum_list = array($forum_id);
  85              break;
  86  
  87              case 'topic_logs':
  88                  $topic_id = request_var('t', 0);
  89  
  90                  $sql = 'SELECT forum_id
  91                      FROM ' . TOPICS_TABLE . '
  92                      WHERE topic_id = ' . $topic_id;
  93                  $result = $db->sql_query($sql);
  94                  $forum_id = (int) $db->sql_fetchfield('forum_id');
  95                  $db->sql_freeresult($result);
  96  
  97                  if (!in_array($forum_id, $forum_list))
  98                  {
  99                      trigger_error('NOT_AUTHORISED');
 100                  }
 101  
 102                  $forum_list = array($forum_id);
 103              break;
 104          }
 105  
 106          // Delete entries if requested and able
 107          if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
 108          {
 109              if (confirm_box(true))
 110              {
 111                  if ($deletemark && sizeof($marked))
 112                  {
 113                      $sql = 'DELETE FROM ' . LOG_TABLE . '
 114                          WHERE log_type = ' . LOG_MOD . '
 115                              AND ' . $db->sql_in_set('forum_id', $forum_list) . '
 116                              AND ' . $db->sql_in_set('log_id', $marked);
 117                      $db->sql_query($sql);
 118  
 119                      add_log('admin', 'LOG_CLEAR_MOD');
 120                  }
 121                  else if ($deleteall)
 122                  {
 123                      $sql = 'DELETE FROM ' . LOG_TABLE . '
 124                          WHERE log_type = ' . LOG_MOD . '
 125                              AND ' . $db->sql_in_set('forum_id', $forum_list);
 126  
 127                      if ($mode == 'topic_logs')
 128                      {
 129                          $sql .= ' AND topic_id = ' . $topic_id;
 130                      }
 131                      $db->sql_query($sql);
 132  
 133                      add_log('admin', 'LOG_CLEAR_MOD');
 134                  }
 135              }
 136              else
 137              {
 138                  confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 139                      'f'            => $forum_id,
 140                      't'            => $topic_id,
 141                      'start'        => $start,
 142                      'delmarked'    => $deletemark,
 143                      'delall'    => $deleteall,
 144                      'mark'        => $marked,
 145                      'st'        => $sort_days,
 146                      'sk'        => $sort_key,
 147                      'sd'        => $sort_dir,
 148                      'i'            => $id,
 149                      'mode'        => $mode,
 150                      'action'    => request_var('action', array('' => ''))))
 151                  );
 152              }
 153          }
 154  
 155          // Sorting
 156          $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
 157          $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
 158          $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
 159  
 160          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
 161          gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
 162  
 163          // Define where and sort sql for use in displaying logs
 164          $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
 165          $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
 166  
 167          $keywords = utf8_normalize_nfc(request_var('keywords', '', true));
 168          $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
 169  
 170          // Grab log data
 171          $log_data = array();
 172          $log_count = 0;
 173          $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);
 174  
 175          $template->assign_vars(array(
 176              'PAGE_NUMBER'        => on_page($log_count, $config['topics_per_page'], $start),
 177              'TOTAL'                => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count),
 178              'PAGINATION'        => generate_pagination($this->u_action . "&amp;$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start),
 179  
 180              'L_TITLE'            => $user->lang['MCP_LOGS'],
 181  
 182              'U_POST_ACTION'            => $this->u_action . "&amp;$u_sort_param$keywords_param&amp;start=$start",
 183              'S_CLEAR_ALLOWED'        => ($auth->acl_get('a_clearlogs')) ? true : false,
 184              'S_SELECT_SORT_DIR'        => $s_sort_dir,
 185              'S_SELECT_SORT_KEY'        => $s_sort_key,
 186              'S_SELECT_SORT_DAYS'    => $s_limit_days,
 187              'S_LOGS'                => ($log_count > 0),
 188              'S_KEYWORDS'            => $keywords,
 189              )
 190          );
 191  
 192          foreach ($log_data as $row)
 193          {
 194              $data = array();
 195  
 196              $checks = array('viewtopic', 'viewforum');
 197              foreach ($checks as $check)
 198              {
 199                  if (isset($row[$check]) && $row[$check])
 200                  {
 201                      $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
 202                  }
 203              }
 204  
 205              $template->assign_block_vars('log', array(
 206                  'USERNAME'        => $row['username_full'],
 207                  'IP'            => $row['ip'],
 208                  'DATE'            => $user->format_date($row['time']),
 209                  'ACTION'        => $row['action'],
 210                  'DATA'            => (sizeof($data)) ? implode(' | ', $data) : '',
 211                  'ID'            => $row['id'],
 212                  )
 213              );
 214          }
 215      }
 216  }
 217  
 218  ?>


Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1