[ Index ]

PHP Cross Reference of phpBB-3.3.0-deutsch

title

Body

[close]

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

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


Generated: Tue Apr 7 19:44:41 2020 Cross-referenced by PHPXref 0.7.1