phpBB

Code Changes

File: phpbb/log/log.php

  Unmodified   Added   Modified   Removed
Line 27Line 27

/**
* An array with the disabled log types. Logs of such types will not be


/**
* An array with the disabled log types. Logs of such types will not be

	* added when add_log() is called.

	* added when add() is called.

	* @var array
*/
protected $disabled_types;

	* @var array
*/
protected $disabled_types;

Line 223Line 223
			return false;
}


			return false;
}


		if ($log_time == false)

		if ($log_time === false)

		{
$log_time = time();
}

$sql_ary = array(

		{
$log_time = time();
}

$sql_ary = array(

			'user_id'		=> $user_id,
'log_ip' => $log_ip,

			'user_id'		=> !empty($user_id) ? $user_id : ANONYMOUS,
'log_ip' => !empty($log_ip) ? $log_ip : '',

			'log_time'		=> $log_time,
'log_operation' => $log_operation,
);

			'log_time'		=> $log_time,
'log_operation' => $log_operation,
);

Line 249Line 249
				unset($additional_data['forum_id']);
$topic_id = isset($additional_data['topic_id']) ? (int) $additional_data['topic_id'] : 0;
unset($additional_data['topic_id']);

				unset($additional_data['forum_id']);
$topic_id = isset($additional_data['topic_id']) ? (int) $additional_data['topic_id'] : 0;
unset($additional_data['topic_id']);

 
				$post_id = isset($additional_data['post_id']) ? (int) $additional_data['post_id'] : 0;
unset($additional_data['post_id']);

				$sql_ary += array(
'log_type' => LOG_MOD,
'forum_id' => $forum_id,
'topic_id' => $topic_id,

				$sql_ary += array(
'log_type' => LOG_MOD,
'forum_id' => $forum_id,
'topic_id' => $topic_id,

 
					'post_id'		=> $post_id,

					'log_data'		=> (!empty($additional_data)) ? serialize($additional_data) : '',
);
break;

					'log_data'		=> (!empty($additional_data)) ? serialize($additional_data) : '',
);
break;

Line 402Line 405
			}
}


			}
}


		$sql = 'DELETE FROM ' . LOG_TABLE . "

		$sql = 'DELETE FROM ' . $this->log_table . "

					$sql_where";
$this->db->sql_query($sql);


					$sql_where";
$this->db->sql_query($sql);


Line 521Line 524
			$sql_keywords = $this->generate_sql_keyword($keywords);
}


			$sql_keywords = $this->generate_sql_keyword($keywords);
}


		if ($count_logs)
{
$sql = 'SELECT COUNT(l.log_id) AS total_entries
FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u
WHERE l.log_type = ' . (int) $log_type . '



		$get_logs_sql_ary = array(
'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour',
'FROM' => array(
$this->log_table => 'l',
USERS_TABLE => 'u',
),
'WHERE' => 'l.log_type = ' . (int) $log_type . "

					AND l.user_id = u.user_id

					AND l.user_id = u.user_id

					AND l.log_time >= ' . (int) $log_time . "

 
					$sql_keywords

					$sql_keywords

					$sql_additional";






























































					$sql_additional",

'ORDER_BY' => $sort_by,
);

if ($log_time)
{
$get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . '
AND ' . $get_logs_sql_ary['WHERE'];
}

/**
* Modify the query to obtain the logs data
*
* @event core.get_logs_main_query_before
* @var array get_logs_sql_ary The array in the format of the query builder with the query
* to get the log count and the log list
* @var string mode Mode of the entries we display
* @var bool count_logs Do we count all matching entries?
* @var int limit Limit the number of entries
* @var int offset Offset when fetching the entries
* @var mixed forum_id Limit entries to the forum_id,
* can also be an array of forum_ids
* @var int topic_id Limit entries to the topic_id
* @var int user_id Limit entries to the user_id
* @var int log_time Limit maximum age of log entries
* @var string sort_by SQL order option
* @var string keywords Will only return entries that have the
* keywords in log_operation or log_data
* @var string profile_url URL to the users profile
* @var int log_type Limit logs to a certain type. If log_type
* is false, no entries will be returned.
* @var string sql_additional Additional conditions for the entries,
* e.g.: 'AND l.forum_id = 1'
* @since 3.1.5-RC1
*/
$vars = array(
'get_logs_sql_ary',
'mode',
'count_logs',
'limit',
'offset',
'forum_id',
'topic_id',
'user_id',
'log_time',
'sort_by',
'keywords',
'profile_url',
'log_type',
'sql_additional',
);
extract($this->dispatcher->trigger_event('core.get_logs_main_query_before', compact($vars)));

if ($count_logs)
{
$count_logs_sql_ary = $get_logs_sql_ary;

$count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries';
unset($count_logs_sql_ary['ORDER_BY']);

$sql = $this->db->sql_build_query('SELECT', $count_logs_sql_ary);

			$result = $this->db->sql_query($sql);
$this->entry_count = (int) $this->db->sql_fetchfield('total_entries');
$this->db->sql_freeresult($result);

			$result = $this->db->sql_query($sql);
$this->entry_count = (int) $this->db->sql_fetchfield('total_entries');
$this->db->sql_freeresult($result);

Line 548Line 613
			}
}


			}
}


		$sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour
FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u
WHERE l.log_type = ' . (int) $log_type . '
AND u.user_id = l.user_id
' . (($log_time) ? 'AND l.log_time >= ' . (int) $log_time : '') . "
$sql_keywords
$sql_additional
ORDER BY $sort_by";

		$sql = $this->db->sql_build_query('SELECT', $get_logs_sql_ary);








		$result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset);

$i = 0;

		$result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset);

$i = 0;

Line 588Line 646
				'time'				=> (int) $row['log_time'],
'forum_id' => (int) $row['forum_id'],
'topic_id' => (int) $row['topic_id'],

				'time'				=> (int) $row['log_time'],
'forum_id' => (int) $row['forum_id'],
'topic_id' => (int) $row['topic_id'],

 
				'post_id'			=> (int) $row['post_id'],


'viewforum' => ($row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false,
'action' => (isset($this->user->lang[$row['log_operation']])) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',


'viewforum' => ($row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false,
'action' => (isset($this->user->lang[$row['log_operation']])) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',

Line 688Line 747
			foreach ($log as $key => $row)
{
$log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false;

			foreach ($log as $key => $row)
{
$log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false;

 
				$log[$key]['viewpost'] = (isset($topic_auth['f_read'][$row['topic_id']]) && $row['post_id']) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id'] . '&p=' . $row['post_id']) : false;

				$log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $this->user->session_id) : false;
}
}

				$log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $this->user->session_id) : false;
}
}

Line 707Line 767
				$log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_data_list[$row['reportee_id']]['username'], $reportee_data_list[$row['reportee_id']]['user_colour'], false, $profile_url);
}
}

				$log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_data_list[$row['reportee_id']]['username'], $reportee_data_list[$row['reportee_id']]['user_colour'], false, $profile_url);
}
}

 

/**
* Allow modifying or execute extra final filter on log entries
*
* @event core.get_logs_after
* @var array log Array with all our log entries
* @var array topic_id_list Array of topic ids, for which we
* get the permission data
* @var array reportee_id_list Array of additional user IDs we
* get the username strings for
* @var string mode Mode of the entries we display
* @var bool count_logs Do we count all matching entries?
* @var int limit Limit the number of entries
* @var int offset Offset when fetching the entries
* @var mixed forum_id Limit entries to the forum_id,
* can also be an array of forum_ids
* @var int topic_id Limit entries to the topic_id
* @var int user_id Limit entries to the user_id
* @var int log_time Limit maximum age of log entries
* @var string sort_by SQL order option
* @var string keywords Will only return entries that have the
* keywords in log_operation or log_data
* @var string profile_url URL to the users profile
* @var int log_type The type of logs it was filtered
* @since 3.1.3-RC1
*/
$vars = array(
'log',
'topic_id_list',
'reportee_id_list',
'mode',
'count_logs',
'limit',
'offset',
'forum_id',
'topic_id',
'user_id',
'log_time',
'sort_by',
'keywords',
'profile_url',
'log_type',
);
extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars)));


return $log;
}


return $log;
}

Line 794Line 898
		$forum_auth = array('f_read' => array(), 'm_' => array());
$topic_ids = array_unique($topic_ids);


		$forum_auth = array('f_read' => array(), 'm_' => array());
$topic_ids = array_unique($topic_ids);


		$sql = 'SELECT topic_id, forum_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $this->db->sql_in_set('topic_id', array_map('intval', $topic_ids));





















		$sql_ary = array(
'SELECT' => 'topic_id, forum_id',
'FROM' => array(
TOPICS_TABLE => 't',
),
'WHERE' => $this->db->sql_in_set('topic_id', array_map('intval', $topic_ids)),
);

/**
* Allow modifying SQL query before topic data is retrieved.
*
* @event core.phpbb_log_get_topic_auth_sql_before
* @var array topic_ids Array with unique topic IDs
* @var array sql_ary SQL array
* @since 3.1.11-RC1
*/
$vars = array(
'topic_ids',
'sql_ary',
);
extract($this->dispatcher->trigger_event('core.phpbb_log_get_topic_auth_sql_before', compact($vars)));

$sql = $this->db->sql_build_query('SELECT', $sql_ary);

		$result = $this->db->sql_query($sql);

while ($row = $this->db->sql_fetchrow($result))

		$result = $this->db->sql_query($sql);

while ($row = $this->db->sql_fetchrow($result))