From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/phpbb/log/interface.php | 106 ++++++ phpBB/phpbb/log/log.php | 739 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 845 insertions(+) create mode 100644 phpBB/phpbb/log/interface.php create mode 100644 phpBB/phpbb/log/log.php (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/interface.php b/phpBB/phpbb/log/interface.php new file mode 100644 index 0000000000..3b459c9bdf --- /dev/null +++ b/phpBB/phpbb/log/interface.php @@ -0,0 +1,106 @@ +db = $db; + $this->user = $user; + $this->auth = $auth; + $this->dispatcher = $phpbb_dispatcher; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpbb_admin_path = $this->phpbb_root_path . $relative_admin_path; + $this->php_ext = $php_ext; + $this->log_table = $log_table; + + /* + * IN_ADMIN is set after the session is created, + * so we need to take ADMIN_START into account as well, otherwise + * it will not work for the phpbb_log object we create in common.php + */ + $this->set_is_admin((defined('ADMIN_START') && ADMIN_START) || (defined('IN_ADMIN') && IN_ADMIN)); + $this->enable(); + } + + /** + * Set is_in_admin in order to return administrative user profile links + * in get_logs() + * + * @param bool $is_in_admin Are we called from within the acp? + * @return null + */ + public function set_is_admin($is_in_admin) + { + $this->is_in_admin = (bool) $is_in_admin; + } + + /** + * Returns the is_in_admin option + * + * @return bool + */ + public function get_is_admin() + { + return $this->is_in_admin; + } + + /** + * Set table name + * + * @param string $log_table Can overwrite the table to use for the logs + * @return null + */ + public function set_log_table($log_table) + { + $this->log_table = $log_table; + } + + /** + * This function returns the state of the log system. + * + * {@inheritDoc} + */ + public function is_enabled($type = '') + { + if ($type == '' || $type == 'all') + { + return !isset($this->disabled_types['all']); + } + return !isset($this->disabled_types[$type]) && !isset($this->disabled_types['all']); + } + + /** + * Disable log + * + * This function allows disabling the log system or parts of it, for this + * page call. When add_log is called and the type is disabled, + * the log will not be added to the database. + * + * {@inheritDoc} + */ + public function disable($type = '') + { + if (is_array($type)) + { + foreach ($type as $disable_type) + { + $this->disable($disable_type); + } + return; + } + + // Empty string is an equivalent for all types. + if ($type == '') + { + $type = 'all'; + } + $this->disabled_types[$type] = true; + } + + /** + * Enable log + * + * This function allows re-enabling the log system. + * + * {@inheritDoc} + */ + public function enable($type = '') + { + if (is_array($type)) + { + foreach ($type as $enable_type) + { + $this->enable($enable_type); + } + return; + } + + if ($type == '' || $type == 'all') + { + $this->disabled_types = array(); + return; + } + unset($this->disabled_types[$type]); + } + + /** + * Adds a log to the database + * + * {@inheritDoc} + */ + public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) + { + if (!$this->is_enabled($mode)) + { + return false; + } + + if ($log_time == false) + { + $log_time = time(); + } + + $sql_ary = array( + 'user_id' => $user_id, + 'log_ip' => $log_ip, + 'log_time' => $log_time, + 'log_operation' => $log_operation, + ); + + switch ($mode) + { + case 'admin': + $sql_ary += array( + 'log_type' => LOG_ADMIN, + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', + ); + break; + + case 'mod': + $forum_id = (int) $additional_data['forum_id']; + unset($additional_data['forum_id']); + $topic_id = (int) $additional_data['topic_id']; + unset($additional_data['topic_id']); + $sql_ary += array( + 'log_type' => LOG_MOD, + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', + ); + break; + + case 'user': + $reportee_id = (int) $additional_data['reportee_id']; + unset($additional_data['reportee_id']); + + $sql_ary += array( + 'log_type' => LOG_USERS, + 'reportee_id' => $reportee_id, + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', + ); + break; + + case 'critical': + $sql_ary += array( + 'log_type' => LOG_CRITICAL, + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', + ); + break; + } + + /** + * Allows to modify log data before we add it to the database + * + * NOTE: if sql_ary does not contain a log_type value, the entry will + * not be stored in the database. So ensure to set it, if needed. + * + * @event core.add_log + * @var string mode Mode of the entry we log + * @var int user_id ID of the user who triggered the log + * @var string log_ip IP of the user who triggered the log + * @var string log_operation Language key of the log operation + * @var int log_time Timestamp, when the log was added + * @var array additional_data Array with additional log data + * @var array sql_ary Array with log data we insert into the + * database. If sql_ary[log_type] is not set, + * we won't add the entry to the database. + * @since 3.1-A1 + */ + $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); + extract($this->dispatcher->trigger_event('core.add_log', $vars)); + + // We didn't find a log_type, so we don't save it in the database. + if (!isset($sql_ary['log_type'])) + { + return false; + } + + $this->db->sql_query('INSERT INTO ' . $this->log_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary)); + + return $this->db->sql_nextid(); + } + + /** + * Grab the logs from the database + * + * {@inheritDoc} + */ + public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') + { + $this->entry_count = 0; + $this->last_page_offset = $offset; + + $topic_id_list = $reportee_id_list = array(); + + $profile_url = ($this->get_is_admin() && $this->phpbb_admin_path) ? append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", 'i=users&mode=overview') : append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile'); + + switch ($mode) + { + case 'admin': + $log_type = LOG_ADMIN; + $sql_additional = ''; + break; + + case 'mod': + $log_type = LOG_MOD; + $sql_additional = ''; + + if ($topic_id) + { + $sql_additional = 'AND l.topic_id = ' . (int) $topic_id; + } + else if (is_array($forum_id)) + { + $sql_additional = 'AND ' . $this->db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); + } + else if ($forum_id) + { + $sql_additional = 'AND l.forum_id = ' . (int) $forum_id; + } + break; + + case 'user': + $log_type = LOG_USERS; + $sql_additional = 'AND l.reportee_id = ' . (int) $user_id; + break; + + case 'users': + $log_type = LOG_USERS; + $sql_additional = ''; + break; + + case 'critical': + $log_type = LOG_CRITICAL; + $sql_additional = ''; + break; + + default: + $log_type = false; + $sql_additional = ''; + } + + /** + * Overwrite log type and limitations before we count and get the logs + * + * NOTE: if log_type is false, no entries will be returned. + * + * @event core.get_logs_modify_type + * @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-A1 + */ + $vars = array('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_modify_type', $vars)); + + if ($log_type === false) + { + $this->last_page_offset = 0; + return array(); + } + + $sql_keywords = ''; + if (!empty($keywords)) + { + // Get the SQL condition for our keywords + $sql_keywords = $this->generate_sql_keyword($keywords); + } + + if ($count_logs) + { + $sql = 'SELECT COUNT(l.log_id) AS total_entries + FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . ' u + WHERE l.log_type = ' . (int) $log_type . ' + AND l.user_id = u.user_id + AND l.log_time >= ' . (int) $log_time . " + $sql_keywords + $sql_additional"; + $result = $this->db->sql_query($sql); + $this->entry_count = (int) $this->db->sql_fetchfield('total_entries'); + $this->db->sql_freeresult($result); + + if ($this->entry_count == 0) + { + // Save the queries, because there are no logs to display + $this->last_page_offset = 0; + return array(); + } + + // Return the user to the last page that is valid + while ($this->last_page_offset >= $this->entry_count) + { + $this->last_page_offset = max(0, $this->last_page_offset - $limit); + } + } + + $sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour + FROM ' . 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"; + $result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset); + + $i = 0; + $log = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $row['forum_id'] = (int) $row['forum_id']; + if ($row['topic_id']) + { + $topic_id_list[] = (int) $row['topic_id']; + } + + if ($row['reportee_id']) + { + $reportee_id_list[] = (int) $row['reportee_id']; + } + + $log_entry_data = array( + 'id' => (int) $row['log_id'], + + 'reportee_id' => (int) $row['reportee_id'], + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => (int) $row['user_id'], + 'username' => $row['username'], + 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, $profile_url), + + 'ip' => $row['log_ip'], + 'time' => (int) $row['log_time'], + 'forum_id' => (int) $row['forum_id'], + 'topic_id' => (int) $row['topic_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']])) ? $this->user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', + ); + + /** + * Modify the entry's data before it is returned + * + * @event core.get_logs_modify_entry_data + * @var array row Entry data from the database + * @var array log_entry_data Entry's data which is returned + * @since 3.1-A1 + */ + $vars = array('row', 'log_entry_data'); + extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); + + $log[$i] = $log_entry_data; + + if (!empty($row['log_data'])) + { + $log_data_ary = unserialize($row['log_data']); + $log_data_ary = ($log_data_ary !== false) ? $log_data_ary : array(); + + if (isset($this->user->lang[$row['log_operation']])) + { + // Check if there are more occurrences of % than + // arguments, if there are we fill out the arguments + // array. It doesn't matter if we add more arguments than + // placeholders. + if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); + } + + $log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary); + + // If within the admin panel we do not censor text out + if ($this->get_is_admin()) + { + $log[$i]['action'] = bbcode_nl2br($log[$i]['action']); + } + else + { + $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); + } + } + else if (!empty($log_data_ary)) + { + $log[$i]['action'] .= '
' . implode('', $log_data_ary); + } + + /* Apply make_clickable... has to be seen if it is for good. :/ + // Seems to be not for the moment, reconsider later... + $log[$i]['action'] = make_clickable($log[$i]['action']); + */ + } + + $i++; + } + $this->db->sql_freeresult($result); + + /** + * Get some additional data after we got all log entries + * + * @event core.get_logs_get_additional_data + * @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 + * @since 3.1-A1 + */ + $vars = array('log', 'topic_id_list', 'reportee_id_list'); + extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); + + if (sizeof($topic_id_list)) + { + $topic_auth = $this->get_topic_auth($topic_id_list); + + 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]['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; + } + } + + if (sizeof($reportee_id_list)) + { + $reportee_data_list = $this->get_reportee_data($reportee_id_list); + + foreach ($log as $key => $row) + { + if (!isset($reportee_data_list[$row['reportee_id']])) + { + continue; + } + + $log[$key]['reportee_username'] = $reportee_data_list[$row['reportee_id']]['username']; + $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); + } + } + + return $log; + } + + /** + * Generates a sql condition for the specified keywords + * + * @param string $keywords The keywords the user specified to search for + * + * @return string Returns the SQL condition searching for the keywords + */ + protected function generate_sql_keyword($keywords) + { + // Use no preg_quote for $keywords because this would lead to sole + // backslashes being added. We also use an OR connection here for + // spaces and the | string. Currently, regex is not supported for + // searching (but may come later). + $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); + $sql_keywords = ''; + + if (!empty($keywords)) + { + $keywords_pattern = array(); + + // Build pattern and keywords... + for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) + { + $keywords_pattern[] = preg_quote($keywords[$i], '#'); + $keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char); + } + + $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; + + $operations = array(); + foreach ($this->user->lang as $key => $value) + { + if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) + { + $operations[] = $key; + } + } + + $sql_keywords = 'AND ('; + if (!empty($operations)) + { + $sql_keywords .= $this->db->sql_in_set('l.log_operation', $operations) . ' OR '; + } + $sql_lower = $this->db->sql_lower_text('l.log_data'); + $sql_keywords .= " $sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; + } + + return $sql_keywords; + } + + /** + * Determine whether the user is allowed to read and/or moderate the forum of the topic + * + * @param array $topic_ids Array with the topic ids + * + * @return array Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample: + * array( + * 'permission' => array( + * topic_id => forum_id + * ), + * ), + */ + protected function get_topic_auth(array $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)); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $row['topic_id'] = (int) $row['topic_id']; + $row['forum_id'] = (int) $row['forum_id']; + + if ($this->auth->acl_get('f_read', $row['forum_id'])) + { + $forum_auth['f_read'][$row['topic_id']] = $row['forum_id']; + } + + if ($this->auth->acl_gets('a_', 'm_', $row['forum_id'])) + { + $forum_auth['m_'][$row['topic_id']] = $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + + return $forum_auth; + } + + /** + * Get the data for all reportee from the database + * + * @param array $reportee_ids Array with the user ids of the reportees + * + * @return array Returns an array with the reportee data + */ + protected function get_reportee_data(array $reportee_ids) + { + $reportee_ids = array_unique($reportee_ids); + $reportee_data_list = array(); + + $sql = 'SELECT user_id, username, user_colour + FROM ' . USERS_TABLE . ' + WHERE ' . $this->db->sql_in_set('user_id', $reportee_ids); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $reportee_data_list[$row['user_id']] = $row; + } + $this->db->sql_freeresult($result); + + return $reportee_data_list; + } + + /** + * Get total log count + * + * {@inheritDoc} + */ + public function get_log_count() + { + return ($this->entry_count) ? $this->entry_count : 0; + } + + /** + * Get offset of the last valid log page + * + * {@inheritDoc} + */ + public function get_valid_offset() + { + return ($this->last_page_offset) ? $this->last_page_offset : 0; + } +} -- cgit v1.2.1 From b81613e5e57fd208e832637b6886abf9ec806c4b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 12:25:28 -0400 Subject: [ticket/11700] With namespaces interface will no longer be a valid classname PHPBB3-11700 --- phpBB/phpbb/log/interface.php | 106 -------------------------------------- phpBB/phpbb/log/log_interface.php | 106 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 106 deletions(-) delete mode 100644 phpBB/phpbb/log/interface.php create mode 100644 phpBB/phpbb/log/log_interface.php (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/interface.php b/phpBB/phpbb/log/interface.php deleted file mode 100644 index 3b459c9bdf..0000000000 --- a/phpBB/phpbb/log/interface.php +++ /dev/null @@ -1,106 +0,0 @@ - Date: Sun, 14 Jul 2013 13:30:52 -0400 Subject: [ticket/11700] Modify all code to use the new interface names PHPBB3-11700 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 7a26858348..0a755b5c78 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * * @package phpbb_log */ -class phpbb_log implements phpbb_log_interface +class phpbb_log implements phpbb_log_log_interface { /** * If set, administrative user profile links will be returned and messages -- cgit v1.2.1 From 3f230b1a8c716adb77b679fed91d50c391387b19 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 26 Jul 2013 12:29:49 -0500 Subject: [ticket/11744] Create null log class (primarily for unit test) PHPBB3-11744 --- phpBB/phpbb/log/null.php | 125 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 phpBB/phpbb/log/null.php (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php new file mode 100644 index 0000000000..9837058ef5 --- /dev/null +++ b/phpBB/phpbb/log/null.php @@ -0,0 +1,125 @@ + Date: Sun, 28 Jul 2013 21:10:17 -0500 Subject: [ticket/11744] Inheritdoc PHPBB3-11744 --- phpBB/phpbb/log/null.php | 61 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 54 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 9837058ef5..14b5f65eec 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -23,12 +23,7 @@ if (!defined('IN_PHPBB')) class phpbb_log_null implements phpbb_log_interface { /** - * This function returns the state of the log system. - * - * @param string $type The log type we want to check. Empty to get - * global log status. - * - * @return bool True if log for the type is enabled + * {@inheritdoc} */ public function is_enabled($type = '') { @@ -36,46 +31,21 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Disable log - * - * This function allows disabling the log system or parts of it, for this - * page call. When add_log is called and the type is disabled, - * the log will not be added to the database. - * - * @param mixed $type The log type we want to disable. Empty to - * disable all logs. Can also be an array of types. - * - * @return null + * {@inheritdoc} */ public function disable($type = '') { } /** - * Enable log - * - * This function allows re-enabling the log system. - * - * @param mixed $type The log type we want to enable. Empty to - * enable all logs. Can also be an array of types. - * - * @return null + * {@inheritdoc} */ public function enable($type = '') { } /** - * Adds a log entry to the database - * - * @param string $mode The mode defines which log_type is used and from which log the entry is retrieved - * @param int $user_id User ID of the user - * @param string $log_ip IP address of the user - * @param string $log_operation Name of the operation - * @param int $log_time Timestamp when the log entry was added, if empty time() will be used - * @param array $additional_data More arguments can be added, depending on the log_type - * - * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. + * {@inheritdoc} */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) { @@ -83,20 +53,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Grab the logs from the database - * - * @param string $mode The mode defines which log_type is used and ifrom which log the entry is retrieved - * @param bool $count_logs Shall we count all matching log entries? - * @param int $limit Limit the number of entries that are returned - * @param int $offset Offset when fetching the log entries, f.e. when paginating - * @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) - * @param int $topic_id Restrict the log entries to the given topic_id - * @param int $user_id Restrict the log entries to the given user_id - * @param int $log_time Only get log entries newer than the given timestamp - * @param string $sort_by SQL order option, e.g. 'l.log_time DESC' - * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data - * - * @return array The result array with the logs + * {@inheritdoc} */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { @@ -104,9 +61,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Get total log count - * - * @return int Returns the number of matching logs from the last call to get_logs() + * {@inheritdoc} */ public function get_log_count() { @@ -114,9 +69,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Get offset of the last valid page - * - * @return int Returns the offset of the last valid page from the last call to get_logs() + * {@inheritdoc} */ public function get_valid_offset() { -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/phpbb/log/log.php | 22 ++++++++++++---------- phpBB/phpbb/log/log_interface.php | 8 +++++--- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0a755b5c78..7f4e52ed39 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -1,12 +1,14 @@ set_is_admin((defined('ADMIN_START') && ADMIN_START) || (defined('IN_ADMIN') && IN_ADMIN)); $this->enable(); diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index 2d41c9994f..427d30015d 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -1,12 +1,14 @@ Date: Mon, 16 Sep 2013 02:41:03 +0200 Subject: [ticket/11700] Fix tests after merging new develop code PHPBB3-11700 --- phpBB/phpbb/log/null.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 14b5f65eec..2ef69926ee 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -7,6 +7,8 @@ * */ +namespace phpbb\log; + /** * @ignore */ @@ -20,7 +22,7 @@ if (!defined('IN_PHPBB')) * * @package phpbb_log */ -class phpbb_log_null implements phpbb_log_interface +class null implements log_interface { /** * {@inheritdoc} -- cgit v1.2.1 From 7aa8f6461f1e85cf91931f56b95384e54fec07c2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:05:28 +0100 Subject: [task/code-sniffer] Remove the IN_PHPBB check side-effect from class files. PHPBB3-11980 --- phpBB/phpbb/log/log.php | 8 -------- phpBB/phpbb/log/log_interface.php | 8 -------- phpBB/phpbb/log/null.php | 8 -------- 3 files changed, 24 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 7f4e52ed39..a6ee06ebf2 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -9,14 +9,6 @@ namespace phpbb\log; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * This class is used to add entries into the log table. * diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index 427d30015d..420ba79691 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -9,14 +9,6 @@ namespace phpbb\log; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * The interface for the log-system. * diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 2ef69926ee..77d0fbe2d7 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -9,14 +9,6 @@ namespace phpbb\log; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Null logger * -- cgit v1.2.1 From 83ec308eff0554037fdf1f215e9e9ad444bc30a9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 12 Jan 2014 21:19:35 +0100 Subject: [ticket/12107] Use log table property instead of log table constant. PHPBB3-12107 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index a6ee06ebf2..62edc6a77f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -424,7 +424,7 @@ class log implements \phpbb\log\log_interface if ($count_logs) { $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . ' u + FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u WHERE l.log_type = ' . (int) $log_type . ' AND l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " @@ -449,7 +449,7 @@ class log implements \phpbb\log\log_interface } $sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour - FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . ' u + 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 : '') . " -- cgit v1.2.1 From 4051ab689f6b9765de6d6fb5a07ff67f1fb93302 Mon Sep 17 00:00:00 2001 From: "Forumhulp.com" Date: Fri, 21 Mar 2014 14:48:58 +0100 Subject: [ticket/12293] Add missing compact() call to phpBB/phpbb/log/log.php events. PHPBB3-12293 --- phpBB/phpbb/log/log.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 62edc6a77f..68b023e244 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -308,7 +308,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($this->dispatcher->trigger_event('core.add_log', $vars)); + extract($this->dispatcher->trigger_event('core.add_log', compact($vars))); // We didn't find a log_type, so we don't save it in the database. if (!isset($sql_ary['log_type'])) @@ -406,7 +406,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('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_modify_type', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) { @@ -502,7 +502,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('row', 'log_entry_data'); - extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', compact($vars))); $log[$i] = $log_entry_data; @@ -561,7 +561,7 @@ class log implements \phpbb\log\log_interface * @since 3.1-A1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); - extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars))); if (sizeof($topic_id_list)) { -- cgit v1.2.1 From 11a9104b8a50cbc62cba0c242dee554b5209a327 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Mar 2014 13:29:35 +0100 Subject: [ticket/12282] Use interface for type hinting PHPBB3-12282 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 68b023e244..3a66ad732d 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -93,10 +93,10 @@ class log implements \phpbb\log\log_interface /** * Constructor * - * @param \phpbb\db\driver\driver $db Database object + * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param \phpbb\auth\auth $auth Auth object - * @param phpbb_dispatcher $phpbb_dispatcher Event dispatcher + * @param \phpbb\event\dispatcher $phpbb_dispatcher Event dispatcher * @param string $phpbb_root_path Root path * @param string $relative_admin_path Relative admin root path * @param string $php_ext PHP Extension -- cgit v1.2.1 From 668f248c4d88b066a559e23d53d57e7170570c4c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 1 Apr 2014 22:43:07 +0200 Subject: [ticket/12113] Allow log entries to use plurals PHPBB3-12113 --- phpBB/phpbb/log/log.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 68b023e244..706c8e165c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -490,7 +490,7 @@ class log implements \phpbb\log\log_interface 'topic_id' => (int) $row['topic_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']])) ? $this->user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', + 'action' => (isset($this->user->lang[$row['log_operation']])) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', ); /** @@ -517,12 +517,26 @@ class log implements \phpbb\log\log_interface // arguments, if there are we fill out the arguments // array. It doesn't matter if we add more arguments than // placeholders. - if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0) + $num_args = 0; + if (!is_array($this->user->lang[$row['log_operation']])) { - $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); + $num_args = substr_count($log[$i]['action'], '%'); + } + else + { + foreach ($this->user->lang[$row['log_operation']] as $case => $plural_string) + { + $num_args = max($num_args, substr_count($plural_string, '%')); + } + } + + if (($num_args - sizeof($log_data_ary)) > 0) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, $num_args - sizeof($log_data_ary), '')); } - $log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary); + $lang_arguments = array_merge(array($log[$i]['action']), $log_data_ary); + $log[$i]['action'] = call_user_func_array(array($this->user, 'lang'), $lang_arguments); // If within the admin panel we do not censor text out if ($this->get_is_admin()) -- cgit v1.2.1 From d3f378d1d62acb000d822a50a1695110ebe731ab Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 09:08:46 +0200 Subject: [ticket/12388] Fix translation of log entries without additional log data PHPBB3-12388 --- phpBB/phpbb/log/log.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 24eb408b63..44fba06d9d 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -558,6 +558,10 @@ class log implements \phpbb\log\log_interface $log[$i]['action'] = make_clickable($log[$i]['action']); */ } + else + { + $log[$i]['action'] = $this->user->lang($log[$i]['action']); + } $i++; } -- cgit v1.2.1 From 1905a2a7b24a7c9fa3fe5431695922ad387d0d17 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 20 Apr 2014 18:36:35 +0200 Subject: [ticket/12422] Fix debug warning in log search PHPBB3-12422 --- phpBB/phpbb/log/log.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 44fba06d9d..e38950f4c1 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -643,9 +643,23 @@ class log implements \phpbb\log\log_interface $operations = array(); foreach ($this->user->lang as $key => $value) { - if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) + if (substr($key, 0, 4) == 'LOG_') { - $operations[] = $key; + if (is_array($value)) + { + foreach ($value as $plural_value) + { + if (preg_match($keywords_pattern, $plural_value)) + { + $operations[] = $key; + break; + } + } + } + else if (preg_match($keywords_pattern, $value)) + { + $operations[] = $key; + } } } -- cgit v1.2.1 From c2dace762ec295c7a2d67758006b1fff56f1f573 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:13:13 +0200 Subject: [ticket/12273] Fix long $vars lines for existing events PHPBB3-12273 --- phpBB/phpbb/log/log.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 44fba06d9d..b0aa637002 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -405,7 +405,9 @@ class log implements \phpbb\log\log_interface * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 */ - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); + $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id'); + $vars = array_merge($vars, array('user_id', 'log_time', 'sort_by', 'keywords')); + $vars = array_merge($vars, array('profile_url', 'log_type', 'sql_additional')); extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) -- cgit v1.2.1 From 87899b0e140400e23341ea1286d50e330132be90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:46:44 +0200 Subject: [ticket/12273] Update existing events PHPBB3-12273 --- phpBB/phpbb/log/log.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index b0aa637002..ea04344c59 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -307,7 +307,15 @@ class log implements \phpbb\log\log_interface * we won't add the entry to the database. * @since 3.1-A1 */ - $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); + $vars = array( + 'mode', + 'user_id', + 'log_ip', + 'log_operation', + 'log_time', + 'additional_data', + 'sql_ary', + ); extract($this->dispatcher->trigger_event('core.add_log', compact($vars))); // We didn't find a log_type, so we don't save it in the database. @@ -405,9 +413,21 @@ class log implements \phpbb\log\log_interface * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 */ - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id'); - $vars = array_merge($vars, array('user_id', 'log_time', 'sort_by', 'keywords')); - $vars = array_merge($vars, array('profile_url', 'log_type', 'sql_additional')); + $vars = array( + '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_modify_type', compact($vars))); if ($log_type === false) -- cgit v1.2.1 From b32895308d13d5d9b0cd954fd8ce871a1fa073da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:15:44 +0200 Subject: [ticket/12273] Update since version to 3.1.0-a* style PHPBB3-12273 --- phpBB/phpbb/log/log.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index ea04344c59..d1a09f9a2b 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -305,7 +305,7 @@ class log implements \phpbb\log\log_interface * @var array sql_ary Array with log data we insert into the * database. If sql_ary[log_type] is not set, * we won't add the entry to the database. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'mode', @@ -411,7 +411,7 @@ class log implements \phpbb\log\log_interface * 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-A1 + * @since 3.1.0-a1 */ $vars = array( 'mode', @@ -521,7 +521,7 @@ class log implements \phpbb\log\log_interface * @event core.get_logs_modify_entry_data * @var array row Entry data from the database * @var array log_entry_data Entry's data which is returned - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('row', 'log_entry_data'); extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', compact($vars))); @@ -598,7 +598,7 @@ class log implements \phpbb\log\log_interface * get the permission data * @var array reportee_id_list Array of additional user IDs we * get the username strings for - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars))); -- cgit v1.2.1 From 2991918bac1656bbc97dd7b1b2b335af24c11d18 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 25 Apr 2014 23:31:31 +0200 Subject: [ticket/12444] The logs message aren't filled correctly https://tracker.phpbb.com/browse/PHPBB3-12444 PHPBB3-12444 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e38950f4c1..24b622dbac 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -520,7 +520,7 @@ class log implements \phpbb\log\log_interface $num_args = 0; if (!is_array($this->user->lang[$row['log_operation']])) { - $num_args = substr_count($log[$i]['action'], '%'); + $num_args = substr_count($this->user->lang[$row['log_operation']], '%'); } else { -- cgit v1.2.1 From c5a4ad3d31047f9580b19b3401ef523b0fd53733 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 10 May 2014 16:58:11 +0200 Subject: [ticket/10899] Using Delete All in log viewer with keyword search https://tracker.phpbb.com/browse/PHPBB3-10899 PHPBB3-10899 --- phpBB/phpbb/log/log.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e4c5ce47d9..e3a0fa0261 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -636,11 +636,12 @@ class log implements \phpbb\log\log_interface /** * Generates a sql condition for the specified keywords * - * @param string $keywords The keywords the user specified to search for + * @param string $keywords The keywords the user specified to search for + * @param string $table_alias The alias of the logs' table ('l.' by default) * * @return string Returns the SQL condition searching for the keywords */ - protected function generate_sql_keyword($keywords) + public function generate_sql_keyword($keywords, $table_alias = 'l.') { // Use no preg_quote for $keywords because this would lead to sole // backslashes being added. We also use an OR connection here for @@ -688,9 +689,9 @@ class log implements \phpbb\log\log_interface $sql_keywords = 'AND ('; if (!empty($operations)) { - $sql_keywords .= $this->db->sql_in_set('l.log_operation', $operations) . ' OR '; + $sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; } - $sql_lower = $this->db->sql_lower_text('l.log_data'); + $sql_lower = $this->db->sql_lower_text($table_alias . 'log_data'); $sql_keywords .= " $sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; } -- cgit v1.2.1 From c6d7875b9b76a931e27e8dbf742ad7af25fe19cf Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 10 May 2014 18:24:07 +0200 Subject: [ticket/10899] Refactoring in \phpbb\log\log_interface PHPBB3-10899 --- phpBB/phpbb/log/log.php | 57 ++++++++++++++++++++++++++++++++++++--- phpBB/phpbb/log/log_interface.php | 12 +++++++++ phpBB/phpbb/log/null.php | 7 +++++ 3 files changed, 72 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e3a0fa0261..a0d399ccee 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -329,6 +329,54 @@ class log implements \phpbb\log\log_interface return $this->db->sql_nextid(); } + /** + * {@inheritDoc} + */ + public function delete($mode, $conditions = array()) + { + $sql_where = ''; + $started = false; + foreach ($conditions as $field => $field_value) + { + if ($started) + { + $sql_where .= ' AND '; + } + else + { + $sql_where = 'WHERE '; + $started = true; + } + + if ($field == 'keywords') + { + $sql_where .= $this->generate_sql_keyword($field_value, '', ''); + } + else + { + if (is_array($field_value) && sizeof($field_value) == 2) + { + $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; + } + else if (is_array($field_value) && sizeof($field_value) > 2) + { + $sql_where .= $this->db->sql_in_set($field, $field_value);; + } + else + { + $sql_where .= $field . ' = ' . $field_value; + } + + } + } + + $sql = 'DELETE FROM ' . LOG_TABLE . " + $sql_where"; + $this->db->sql_query($sql); + + $this->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CLEAR_' . strtoupper($mode)); + } + /** * Grab the logs from the database * @@ -636,12 +684,13 @@ class log implements \phpbb\log\log_interface /** * Generates a sql condition for the specified keywords * - * @param string $keywords The keywords the user specified to search for - * @param string $table_alias The alias of the logs' table ('l.' by default) + * @param string $keywords The keywords the user specified to search for + * @param string $table_alias The alias of the logs' table ('l.' by default) + * @param string $statement_operator The operator used to prefix the statement ('AND' by default) * * @return string Returns the SQL condition searching for the keywords */ - public function generate_sql_keyword($keywords, $table_alias = 'l.') + protected function generate_sql_keyword($keywords, $table_alias = 'l.', $statement_operator = 'AND') { // Use no preg_quote for $keywords because this would lead to sole // backslashes being added. We also use an OR connection here for @@ -686,7 +735,7 @@ class log implements \phpbb\log\log_interface } } - $sql_keywords = 'AND ('; + $sql_keywords = $statement_operator . ' ('; if (!empty($operations)) { $sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index 420ba79691..dff43b946a 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -66,6 +66,18 @@ interface log_interface */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()); + /** + * Delete entries in the logs + * + * @param string $mode The mode defines which log_type is used and from which log the entries are deleted + * @param array $conditions An array of conditions, 3 different forms are accepted + * 1) => 'value> transformed into 'AND = ' (value should be an integer) + * 2) => array(, ) transformed into 'AND ' (value should be an integer) + * 3) => array() transformed into 'AND IN ' + * A special field, keywords, can also be defined. In this case only the log entries that have the keywords in log_operation or log_data will be deleted. + */ + public function delete($mode, $conditions = array()); + /** * Grab the logs from the database * diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 77d0fbe2d7..2a79e74bbd 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -46,6 +46,13 @@ class null implements log_interface return false; } + /** + * {@inheritdoc} + */ + public function delete($mode, $conditions = array()) + { + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 56aaba696f01a920713a08f0b418604609505d83 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 10 May 2014 18:25:24 +0200 Subject: [ticket/10899] Typo PHPBB3-10899 --- phpBB/phpbb/log/log_interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index dff43b946a..165eeaeed2 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -71,7 +71,7 @@ interface log_interface * * @param string $mode The mode defines which log_type is used and from which log the entries are deleted * @param array $conditions An array of conditions, 3 different forms are accepted - * 1) => 'value> transformed into 'AND = ' (value should be an integer) + * 1) => transformed into 'AND = ' (value should be an integer) * 2) => array(, ) transformed into 'AND ' (value should be an integer) * 3) => array() transformed into 'AND IN ' * A special field, keywords, can also be defined. In this case only the log entries that have the keywords in log_operation or log_data will be deleted. -- cgit v1.2.1 From 164f52c3f30d6afd85e1f25cea7ebc75f327d12d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 10 May 2014 19:04:37 +0200 Subject: [ticket/10899] Remove extra ';' PHPBB3-10899 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index a0d399ccee..4b1a8e40ad 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -360,7 +360,7 @@ class log implements \phpbb\log\log_interface } else if (is_array($field_value) && sizeof($field_value) > 2) { - $sql_where .= $this->db->sql_in_set($field, $field_value);; + $sql_where .= $this->db->sql_in_set($field, $field_value); } else { -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/log/log.php | 12 +++++++----- phpBB/phpbb/log/log_interface.php | 12 +++++++----- phpBB/phpbb/log/null.php | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e4c5ce47d9..d83fa90a8e 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -11,8 +15,6 @@ namespace phpbb\log; /** * This class is used to add entries into the log table. -* -* @package \phpbb\log\log */ class log implements \phpbb\log\log_interface { diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index 420ba79691..2a44ebecb6 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -11,8 +15,6 @@ namespace phpbb\log; /** * The interface for the log-system. -* -* @package \phpbb\log\log */ interface log_interface { diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 77d0fbe2d7..7b11cc9e21 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -11,8 +15,6 @@ namespace phpbb\log; /** * Null logger -* -* @package phpbb_log */ class null implements log_interface { -- cgit v1.2.1 From 05e76e55e149936d112ccb3441f88bbd3ce235fb Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 28 May 2014 00:54:22 +0200 Subject: [ticket/10899] Add unit tests PHPBB3-10899 --- phpBB/phpbb/log/log.php | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 4b1a8e40ad..8b51ed7758 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -334,19 +334,41 @@ class log implements \phpbb\log\log_interface */ public function delete($mode, $conditions = array()) { - $sql_where = ''; - $started = false; + switch ($mode) + { + case 'admin': + $log_type = LOG_ADMIN; + break; + + case 'mod': + $log_type = LOG_MOD; + break; + + case 'user': + $log_type = LOG_USERS; + break; + + case 'users': + $log_type = LOG_USERS; + break; + + case 'critical': + $log_type = LOG_CRITICAL;; + break; + + default: + $log_type = false; + } + + if ($log_type === false) + { + return; + } + + $sql_where = 'WHERE log_type = ' . $log_type; foreach ($conditions as $field => $field_value) { - if ($started) - { - $sql_where .= ' AND '; - } - else - { - $sql_where = 'WHERE '; - $started = true; - } + $sql_where .= ' AND '; if ($field == 'keywords') { @@ -354,11 +376,11 @@ class log implements \phpbb\log\log_interface } else { - if (is_array($field_value) && sizeof($field_value) == 2) + if (is_array($field_value) && sizeof($field_value) == 2 && is_string($field_value[0])) { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; } - else if (is_array($field_value) && sizeof($field_value) > 2) + else if (is_array($field_value)) { $sql_where .= $this->db->sql_in_set($field, $field_value); } @@ -366,7 +388,6 @@ class log implements \phpbb\log\log_interface { $sql_where .= $field . ' = ' . $field_value; } - } } -- cgit v1.2.1 From d3f4dbedde157c316fe5a675de923e9b1e73d6f2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 28 May 2014 11:50:13 +0200 Subject: [ticket/10899] Remove trailing ; PHPBB3-10899 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 8b51ed7758..206a665283 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -353,7 +353,7 @@ class log implements \phpbb\log\log_interface break; case 'critical': - $log_type = LOG_CRITICAL;; + $log_type = LOG_CRITICAL; break; default: -- cgit v1.2.1 From 59f39273d42bb863ffa0d46e017919bdbe39d8d5 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 28 May 2014 23:20:50 +0200 Subject: [ticket/10899] Add event core.delete_log PHPBB3-10899 --- phpBB/phpbb/log/log.php | 29 ++++++++++++++++++++++++++--- phpBB/phpbb/log/log_interface.php | 4 ++-- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 206a665283..6c0c160b58 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -360,6 +360,29 @@ class log implements \phpbb\log\log_interface $log_type = false; } + /** + * Allows to modify log data before we delete it from the database + * + * NOTE: if sql_ary does not contain a log_type value, the entry will + * not be deleted in the database. So ensure to set it, if needed. + * + * @event core.add_log + * @var string mode Mode of the entry we log + * @var string log_type Type ID of the log (should be different than false) + * @var array conditions An array of conditions, 3 different forms are accepted + * 1) => transformed into 'AND = ' (value should be an integer) + * 2) => array(, ) transformed into 'AND ' (values can't be an array) + * 3) => array('IN' => array()) transformed into 'AND IN ' + * A special field, keywords, can also be defined. In this case only the log entries that have the keywords in log_operation or log_data will be deleted. + * @since 3.1.0-b4 + */ + $vars = array( + 'mode', + 'log_type', + 'conditions', + ); + extract($this->dispatcher->trigger_event('core.delete_log', compact($vars))); + if ($log_type === false) { return; @@ -376,13 +399,13 @@ class log implements \phpbb\log\log_interface } else { - if (is_array($field_value) && sizeof($field_value) == 2 && is_string($field_value[0])) + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; } - else if (is_array($field_value)) + else if (is_array($field_value) && sizeof($field_value) == 1 && is_array($field_value['IN'])) { - $sql_where .= $this->db->sql_in_set($field, $field_value); + $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); } else { diff --git a/phpBB/phpbb/log/log_interface.php b/phpBB/phpbb/log/log_interface.php index 165eeaeed2..eb3f700953 100644 --- a/phpBB/phpbb/log/log_interface.php +++ b/phpBB/phpbb/log/log_interface.php @@ -72,8 +72,8 @@ interface log_interface * @param string $mode The mode defines which log_type is used and from which log the entries are deleted * @param array $conditions An array of conditions, 3 different forms are accepted * 1) => transformed into 'AND = ' (value should be an integer) - * 2) => array(, ) transformed into 'AND ' (value should be an integer) - * 3) => array() transformed into 'AND IN ' + * 2) => array(, ) transformed into 'AND ' (values can't be an array) + * 3) => array('IN' => array()) transformed into 'AND IN ' * A special field, keywords, can also be defined. In this case only the log entries that have the keywords in log_operation or log_data will be deleted. */ public function delete($mode, $conditions = array()); -- cgit v1.2.1 From ff5fd3442d9e985e0b3c48f5a13254448d27d929 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 28 May 2014 23:30:47 +0200 Subject: [ticket/10899] Use isset($field_value['IN']) PHPBB3-10899 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 6c0c160b58..879a1b49e8 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -403,7 +403,7 @@ class log implements \phpbb\log\log_interface { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; } - else if (is_array($field_value) && sizeof($field_value) == 1 && is_array($field_value['IN'])) + else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) { $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); } -- cgit v1.2.1 From 4b3bba6693d96fe5ce918a635af8ff5ec7a8c1f0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 29 May 2014 02:30:15 +0200 Subject: [ticket/10899] Update doc block PHPBB3-10899 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 879a1b49e8..e7875e1a12 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -366,7 +366,7 @@ class log implements \phpbb\log\log_interface * NOTE: if sql_ary does not contain a log_type value, the entry will * not be deleted in the database. So ensure to set it, if needed. * - * @event core.add_log + * @event core.delete_log * @var string mode Mode of the entry we log * @var string log_type Type ID of the log (should be different than false) * @var array conditions An array of conditions, 3 different forms are accepted -- cgit v1.2.1 From 36071ded9d37f38d446d17013b90dff9da94245b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 31 May 2014 12:56:44 +0200 Subject: [ticket/12639] Delete entry in admin-log leads to mysql-error PHPBB3-12639 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 453cb740bb..6217a7fe46 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -393,14 +393,14 @@ class log implements \phpbb\log\log_interface $sql_where = 'WHERE log_type = ' . $log_type; foreach ($conditions as $field => $field_value) { - $sql_where .= ' AND '; - if ($field == 'keywords') { $sql_where .= $this->generate_sql_keyword($field_value, '', ''); } else { + $sql_where .= ' AND '; + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; -- cgit v1.2.1 From 9c497a7b462a24b980912af669a44bfb82f5bdc2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 31 May 2014 13:34:04 +0200 Subject: [ticket/12639] Add a test case with an empty keywords list PHPBB3-12639 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 6217a7fe46..0dce9306df 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -395,7 +395,7 @@ class log implements \phpbb\log\log_interface { if ($field == 'keywords') { - $sql_where .= $this->generate_sql_keyword($field_value, '', ''); + $sql_where .= $this->generate_sql_keyword($field_value, '', ' AND'); } else { -- cgit v1.2.1 From f980fed5d26e2a7d2e1c139da7e1d8be7c1523e3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 2 Jun 2014 23:35:35 +0200 Subject: [ticket/12639] Handle $conditions['keywords'] outside of the loop PHPBB3-12639 --- phpBB/phpbb/log/log.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0dce9306df..d2c946d28b 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -391,28 +391,29 @@ class log implements \phpbb\log\log_interface } $sql_where = 'WHERE log_type = ' . $log_type; + + if (isset($conditions['keywords'])) + { + $sql_where .= $this->generate_sql_keyword($conditions['keywords'], '', ' AND'); + + unset($conditions['keywords']); + } + foreach ($conditions as $field => $field_value) { - if ($field == 'keywords') + $sql_where .= ' AND '; + + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) + { + $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; + } + else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) { - $sql_where .= $this->generate_sql_keyword($field_value, '', ' AND'); + $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); } else { - $sql_where .= ' AND '; - - if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) - { - $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; - } - else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) - { - $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); - } - else - { - $sql_where .= $field . ' = ' . $field_value; - } + $sql_where .= $field . ' = ' . $field_value; } } -- cgit v1.2.1 From fb46e42ab3393f3899c0aa8b6b4482214ec1d275 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 20:22:22 +0200 Subject: [ticket/12639] Add a space in the code generated by generate_sql_keyword() PHPBB3-12639 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index d2c946d28b..10efe5fd1c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -394,7 +394,7 @@ class log implements \phpbb\log\log_interface if (isset($conditions['keywords'])) { - $sql_where .= $this->generate_sql_keyword($conditions['keywords'], '', ' AND'); + $sql_where .= $this->generate_sql_keyword($conditions['keywords'], ''); unset($conditions['keywords']); } @@ -782,7 +782,7 @@ class log implements \phpbb\log\log_interface } } - $sql_keywords = $statement_operator . ' ('; + $sql_keywords = ' ' . $statement_operator . ' ('; if (!empty($operations)) { $sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; -- cgit v1.2.1 From d357dd9e47cf717671874498400ad16a05e4103a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 14:21:43 +0200 Subject: [ticket/12715] Cleanup comments in \phpbb\log\* PHPBB3-12715 --- phpBB/phpbb/log/log.php | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 10efe5fd1c..bf0bfe0ae1 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -70,7 +70,7 @@ class log implements \phpbb\log\log_interface /** * Event dispatcher object - * @var phpbb_dispatcher + * @var \phpbb\event\dispatcher */ protected $dispatcher; @@ -103,7 +103,6 @@ class log implements \phpbb\log\log_interface * @param string $relative_admin_path Relative admin root path * @param string $php_ext PHP Extension * @param string $log_table Name of the table we use to store our logs - * @return null */ public function __construct($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, $relative_admin_path, $php_ext, $log_table) { @@ -159,8 +158,6 @@ class log implements \phpbb\log\log_interface } /** - * This function returns the state of the log system. - * * {@inheritDoc} */ public function is_enabled($type = '') @@ -173,12 +170,6 @@ class log implements \phpbb\log\log_interface } /** - * Disable log - * - * This function allows disabling the log system or parts of it, for this - * page call. When add_log is called and the type is disabled, - * the log will not be added to the database. - * * {@inheritDoc} */ public function disable($type = '') @@ -201,10 +192,6 @@ class log implements \phpbb\log\log_interface } /** - * Enable log - * - * This function allows re-enabling the log system. - * * {@inheritDoc} */ public function enable($type = '') @@ -227,8 +214,6 @@ class log implements \phpbb\log\log_interface } /** - * Adds a log to the database - * * {@inheritDoc} */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) @@ -425,8 +410,6 @@ class log implements \phpbb\log\log_interface } /** - * Grab the logs from the database - * * {@inheritDoc} */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') @@ -863,8 +846,6 @@ class log implements \phpbb\log\log_interface } /** - * Get total log count - * * {@inheritDoc} */ public function get_log_count() @@ -873,8 +854,6 @@ class log implements \phpbb\log\log_interface } /** - * Get offset of the last valid log page - * * {@inheritDoc} */ public function get_valid_offset() -- cgit v1.2.1 From ff6e026a403a622bd1aa498bff396a737735faed Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 26 Jun 2014 17:17:35 +0200 Subject: [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts PHPBB3-12446 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index bf0bfe0ae1..4ffe7345f3 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -737,7 +737,7 @@ class log implements \phpbb\log\log_interface for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) { $keywords_pattern[] = preg_quote($keywords[$i], '#'); - $keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char); + $keywords[$i] = $this->db->sql_like_expression($this->db->get_any_char() . $keywords[$i] . $this->db->get_any_char()); } $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; -- cgit v1.2.1 From eb13b4ae28223700034ae7482ab27a6d2cdbccd1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 28 Jun 2014 13:19:55 +0200 Subject: [ticket/12782] Use an interface for the phpbb event_dispatcher PHPBB3-12782 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index bf0bfe0ae1..ee44b599b3 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -70,7 +70,7 @@ class log implements \phpbb\log\log_interface /** * Event dispatcher object - * @var \phpbb\event\dispatcher + * @var \phpbb\event\dispatcher_interface */ protected $dispatcher; @@ -98,7 +98,7 @@ class log implements \phpbb\log\log_interface * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\event\dispatcher $phpbb_dispatcher Event dispatcher + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher * @param string $phpbb_root_path Root path * @param string $relative_admin_path Relative admin root path * @param string $php_ext PHP Extension -- cgit v1.2.1 From d5db09e88846253accbd64490061b6f9fc73e333 Mon Sep 17 00:00:00 2001 From: Tabitha Backoff Date: Sun, 3 Aug 2014 13:06:20 -0400 Subject: [ticket/12912] Undefined index when adding logs from extensions Add isset() to forum_id and topic_id. PHPBB3-12912 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index c522c3273f..2af8b50b54 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -245,9 +245,9 @@ class log implements \phpbb\log\log_interface break; case 'mod': - $forum_id = (int) $additional_data['forum_id']; + $forum_id = isset($additional_data['forum_id']) ? (int) $additional_data['forum_id'] : 0; unset($additional_data['forum_id']); - $topic_id = (int) $additional_data['topic_id']; + $topic_id = isset($additional_data['topic_id']) ? (int) $additional_data['topic_id'] : 0; unset($additional_data['topic_id']); $sql_ary += array( 'log_type' => LOG_MOD, -- cgit v1.2.1 From b7f83b2cfc384b2a734ab720c88596cb1606bb43 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 16:04:32 +0000 Subject: [ticket/13148] Creating a final way to modify edit logs output PHPBB3-13148 --- phpBB/phpbb/log/log.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 2af8b50b54..23e39ba71a 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -708,6 +708,20 @@ class log implements \phpbb\log\log_interface } } + /** + * 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 + * @since 3.1.3-RC1 + */ + $vars = array('log', 'topic_id_list', 'reportee_id_list'); + extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars))); + return $log; } -- cgit v1.2.1 From cf036ea0e89b281a233e5cb861288b54357a86cd Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 28 Dec 2014 19:52:58 +0000 Subject: [ticket/13148] Added more variables as requested Added more variables as requested and some extra that may be of use. PHPBB3-13148 --- phpBB/phpbb/log/log.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 23e39ba71a..fd7db98a3a 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -717,9 +717,40 @@ class log implements \phpbb\log\log_interface * get the permission data * @var array reportee_id_list Array of additional user IDs we * get the username strings for - * @since 3.1.3-RC1 + * @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.0-a1 */ - $vars = array('log', 'topic_id_list', 'reportee_id_list'); + $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', + ); + $vars = array(); extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars))); return $log; -- cgit v1.2.1 From d455dd68f6e338497ce07d711f3ee35cb75ad81f Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 28 Dec 2014 20:25:36 +0000 Subject: [ticket/13148] Fixed syntax error PHPBB3-13148 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index fd7db98a3a..8dedc72e52 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -736,7 +736,7 @@ class log implements \phpbb\log\log_interface $vars = array( 'log', 'topic_id_list', - 'reportee_id_list' + 'reportee_id_list', 'mode', 'count_logs', 'limit', -- cgit v1.2.1 From 0104188074deb85c55f5edb7e4563afe2a0a3810 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 28 Dec 2014 20:35:16 +0000 Subject: [ticket/13148] Fixed my error PHPBB3-13148 --- phpBB/phpbb/log/log.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 8dedc72e52..d495707c70 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -750,7 +750,6 @@ class log implements \phpbb\log\log_interface 'profile_url', 'log_type', ); - $vars = array(); extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars))); return $log; -- cgit v1.2.1 From 92d7c16782eaa1e964f190e5913228cf7b42238c Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 29 Dec 2014 08:23:31 +0000 Subject: [ticket/13148] Wrong version num; copy & paste fail PHPBB3-13148 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index d495707c70..0c5205530b 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -731,7 +731,7 @@ class log implements \phpbb\log\log_interface * 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.0-a1 + * @since 3.1.3-RC1 */ $vars = array( 'log', -- cgit v1.2.1 From dbc09bf0d4d2537d0570f6de5958d5f2e38a864e Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 28 Feb 2015 20:34:25 +0000 Subject: [ticket/13661] Transform queries to get logs and log count into built queries PHPBB3-13661 --- phpBB/phpbb/log/log.php | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0c5205530b..6fb8dc79c6 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -521,15 +521,30 @@ class log implements \phpbb\log\log_interface $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 . ' - AND l.user_id = u.user_id + $get_logs_sql_ary = array( + 'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour', + 'FROM' => $this->log_table . ' l, ' . USERS_TABLE . ' u', + 'WHERE' => 'l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " $sql_keywords - $sql_additional"; + $sql_additional", + + 'ORDER_BY' => $sort_by, + ); + + if($log_type){ + $get_logs_sql_ary['WHERE'] = 'l.log_type = ' . (int) $log_type . ' + AND ' . $get_logs_sql_ary['WHERE']; + } + + 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_array('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); @@ -548,14 +563,7 @@ class log implements \phpbb\log\log_interface } } - $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_array('SELECT', $get_logs_sql_ary); $result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset); $i = 0; -- cgit v1.2.1 From d66a53a53127f9c50dd62c34bf08fdabacdea001 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 10:07:18 +0000 Subject: [ticket/13661] Add event to allow editing the queries used to get the logs PHPBB3-13661 --- phpBB/phpbb/log/log.php | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 6fb8dc79c6..1aa9e073f0 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -537,6 +537,49 @@ class log implements \phpbb\log\log_interface 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.0-a1 + */ + $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; @@ -544,7 +587,7 @@ class log implements \phpbb\log\log_interface $count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries'; unset($count_logs_sql_ary['ORDER_BY']); - $sql = $this->db->sql_build_array('SELECT', $count_logs_sql_ary); + $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); @@ -563,7 +606,7 @@ class log implements \phpbb\log\log_interface } } - $sql = $this->db->sql_build_array('SELECT', $get_logs_sql_ary); + $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; -- cgit v1.2.1 From c887eedaa5c9efeeec82cf29117325480905c9f3 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 14:01:57 +0000 Subject: [ticket/13661] Fixed the "FROM" in the built query. I was doing it wrong by giving a string to the FROM clause in the built query. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 1aa9e073f0..e2802ba3e1 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -523,7 +523,10 @@ class log implements \phpbb\log\log_interface $get_logs_sql_ary = array( 'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour', - 'FROM' => $this->log_table . ' l, ' . USERS_TABLE . ' u', + 'FROM' => array( + $this->log_table => 'l', + USERS_TABLE => 'u', + ), 'WHERE' => 'l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " $sql_keywords -- cgit v1.2.1 From d0a1650a04fc74fb81c0123505854a09352d49c1 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 18:35:11 +0000 Subject: [ticket/13661] bugfix: The conditional is the log_time, not log_type I mistakenly made the log_type the conditional instead of log_time. Thankfully, the automated tests helped finding this mistake. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e2802ba3e1..735d595bb5 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -527,8 +527,8 @@ class log implements \phpbb\log\log_interface $this->log_table => 'l', USERS_TABLE => 'u', ), - 'WHERE' => 'l.user_id = u.user_id - AND l.log_time >= ' . (int) $log_time . " + 'WHERE' => 'l.log_type = ' . (int) $log_type . " + AND l.user_id = u.user_id $sql_keywords $sql_additional", @@ -536,7 +536,7 @@ class log implements \phpbb\log\log_interface ); if($log_type){ - $get_logs_sql_ary['WHERE'] = 'l.log_type = ' . (int) $log_type . ' + $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } -- cgit v1.2.1 From 772bbdfeae879b17aa2b62f10469bc8b63230093 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 19:58:57 +0000 Subject: [ticket/13661] Removed superfluous whitespace PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 735d595bb5..0fd33b4618 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -582,7 +582,7 @@ class log implements \phpbb\log\log_interface '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; -- cgit v1.2.1 From d53b584c9a5ac247bfb88aa230dc064b7a73e72c Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 20:12:37 +0000 Subject: [ticket/13661] Wrong event @since version PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0fd33b4618..8e5f75807c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -563,7 +563,7 @@ class log implements \phpbb\log\log_interface * 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.0-a1 + * @since 3.1.4-RC1 */ $vars = array( 'get_logs_sql_ary', -- cgit v1.2.1 From c7cc8a098e2a38bbe822468cead4ee9df1745104 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 21:17:06 +0000 Subject: [ticket/13661] Re-Fixed $log_type -> $log_time Thanks to goof for pointing it out... PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 8e5f75807c..3d89e7403f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -535,7 +535,7 @@ class log implements \phpbb\log\log_interface 'ORDER_BY' => $sort_by, ); - if($log_type){ + if($log_time){ $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } -- cgit v1.2.1 From 134a5e0391aa4d05d347a77c0218b29ab9b60a1b Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 2 Mar 2015 08:34:52 +0000 Subject: [ticket/13661] Brackets in their own line I didn't even notice that I used my own coding guidelines there... Thanks to MGaetan89 for pointing it out. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 3d89e7403f..1aba5851a5 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -535,7 +535,8 @@ class log implements \phpbb\log\log_interface 'ORDER_BY' => $sort_by, ); - if($log_time){ + if($log_time) + { $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } -- cgit v1.2.1 From 684a050916c55570ef6b21ad00b3aee81279439d Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 6 May 2015 22:53:43 +0100 Subject: [ticket/13661] BUMP version to 3.1.5-dev PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 1aba5851a5..f4ba76ff0c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -564,7 +564,7 @@ class log implements \phpbb\log\log_interface * 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.4-RC1 + * @since 3.1.5-RC1 */ $vars = array( 'get_logs_sql_ary', -- cgit v1.2.1 From 9203bf3141851812bbef9cff3a2634d9849d8f44 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 7 Jun 2015 22:53:41 +0200 Subject: [ticket/13930] Add missing spaces to code PHPBB3-13930 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index f4ba76ff0c..3d995b4e4a 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -535,7 +535,7 @@ class log implements \phpbb\log\log_interface 'ORDER_BY' => $sort_by, ); - if($log_time) + if ($log_time) { $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; -- cgit v1.2.1 From 0cc41b94b1715ed6ae0175f77403410552f671af Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 10 Jan 2016 17:43:10 +0100 Subject: [ticket/14403] Don't expect user_id and user_ip in phpbb\log PHPBB3-14403 --- phpBB/phpbb/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 3d995b4e4a..d46e3d1f3f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -229,8 +229,8 @@ class log implements \phpbb\log\log_interface } $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, ); -- cgit v1.2.1 From 97040dc6ff07595a4ba5a455c92d810bc3471e80 Mon Sep 17 00:00:00 2001 From: "Forumhulp.com" Date: Wed, 27 Jul 2016 00:17:47 +0200 Subject: [ticket/14796] Use log_table class member instead of table constant Was still using the old LOG_TABLE constant in the delete method. PHPBB3-14796 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index d46e3d1f3f..094ff78abe 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -402,7 +402,7 @@ class log implements \phpbb\log\log_interface } } - $sql = 'DELETE FROM ' . LOG_TABLE . " + $sql = 'DELETE FROM ' . $this->log_table . " $sql_where"; $this->db->sql_query($sql); -- cgit v1.2.1 From 2df3703b2aee76d97717b73049e741b68ed514fa Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 20 Nov 2016 17:48:05 +0100 Subject: [ticket/13149] Add core.phpbb_log_get_topic_auth_sql_before PHPBB3-13149 --- phpBB/phpbb/log/log.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/log') diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 094ff78abe..8f199cd931 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -893,9 +893,29 @@ class log implements \phpbb\log\log_interface $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)) -- cgit v1.2.1