aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_admin.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r--phpBB/includes/functions_admin.php459
1 files changed, 352 insertions, 107 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 79282c0358..d42a81fa35 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -17,95 +17,47 @@ if (!defined('IN_PHPBB'))
}
/**
-* Recalculate Binary Tree
-function recalc_btree($sql_id, $sql_table, $module_class = '')
+* Recalculate Nested Sets
+*
+* @param int $new_id first left_id (should start with 1)
+* @param string $pkey primary key-column (containing the id for the parent_id of the children)
+* @param string $table constant or fullname of the table
+* @param int $parent_id parent_id of the current set (default = 0)
+* @param array $where contains strings to compare closer on the where statement (additional)
+*
+* @author EXreaction
+*/
+function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array())
{
global $db;
- if (!$sql_id || !$sql_table)
- {
- return;
- }
-
- $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : '';
-
- // Reset to minimum possible left and right id
- $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id
- FROM $sql_table
- $sql_where";
+ $sql = 'SELECT *
+ FROM ' . $table . '
+ WHERE parent_id = ' . (int) $parent_id .
+ ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . '
+ ORDER BY left_id ASC';
$result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1);
-
- if ($substract > 0)
- {
- $sql = "UPDATE $sql_table
- SET left_id = left_id - $substract, right_id = right_id - $substract
- $sql_where";
- $db->sql_query($sql);
- }
-
- $sql = "SELECT $sql_id, parent_id, left_id, right_id
- FROM $sql_table
- $sql_where
- ORDER BY left_id ASC, parent_id ASC, $sql_id ASC";
- $f_result = $db->sql_query($sql);
-
- while ($item_data = $db->sql_fetchrow($f_result))
+ while ($row = $db->sql_fetchrow($result))
{
- if ($item_data['parent_id'])
+ // First we update the left_id for this module
+ if ($row['left_id'] != $new_id)
{
- $sql = "SELECT left_id, right_id
- FROM $sql_table
- $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
- $sql_id = {$item_data['parent_id']}";
- $result = $db->sql_query($sql);
-
- if (!$row = $db->sql_fetchrow($result))
- {
- $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id];
- $db->sql_query($sql);
- }
- $db->sql_freeresult($result);
-
- $sql = "UPDATE $sql_table
- SET left_id = left_id + 2, right_id = right_id + 2
- $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
- left_id > {$row['right_id']}";
- $db->sql_query($sql);
+ $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}");
+ }
+ $new_id++;
- $sql = "UPDATE $sql_table
- SET right_id = right_id + 2
- $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
- {$row['left_id']} BETWEEN left_id AND right_id";
- $db->sql_query($sql);
+ // Then we go through any children and update their left/right id's
+ recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where);
- $item_data['left_id'] = $row['right_id'];
- $item_data['right_id'] = $row['right_id'] + 1;
- }
- else
+ // Then we come back and update the right_id for this module
+ if ($row['right_id'] != $new_id)
{
- $sql = "SELECT MAX(right_id) AS right_id
- FROM $sql_table
- $sql_where";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $item_data['left_id'] = $row['right_id'] + 1;
- $item_data['right_id'] = $row['right_id'] + 2;
+ $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}");
}
-
- $sql = "UPDATE $sql_table
- SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}
- WHERE $sql_id = " . $item_data[$sql_id];
- $db->sql_query($sql);
+ $new_id++;
}
- $db->sql_freeresult($f_result);
+ $db->sql_freeresult($result);
}
-*/
/**
* Simple version of jumpbox, just lists authed forums
@@ -117,7 +69,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'));
// This query is identical to the jumpbox one
- $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
+ $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);
@@ -355,11 +307,156 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl
}
/**
+* Copies permissions from one forum to others
+*
+* @param int $src_forum_id The source forum we want to copy permissions from
+* @param array $dest_forum_ids The destination forum(s) we want to copy to
+* @param bool $clear_dest_perms True if destination permissions should be deleted
+* @param bool $add_log True if log entry should be added
+*
+* @return bool False on error
+*
+* @author bantu
+*/
+function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true)
+{
+ global $db;
+
+ // Only one forum id specified
+ if (!is_array($dest_forum_ids))
+ {
+ $dest_forum_ids = array($dest_forum_ids);
+ }
+
+ // Make sure forum ids are integers
+ $src_forum_id = (int) $src_forum_id;
+ $dest_forum_ids = array_map('intval', $dest_forum_ids);
+
+ // No source forum or no destination forums specified
+ if (empty($src_forum_id) || empty($dest_forum_ids))
+ {
+ return false;
+ }
+
+ // Check if source forum exists
+ $sql = 'SELECT forum_name
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_id = ' . $src_forum_id;
+ $result = $db->sql_query($sql);
+ $src_forum_name = $db->sql_fetchfield('forum_name');
+ $db->sql_freeresult($result);
+
+ // Source forum doesn't exist
+ if (empty($src_forum_name))
+ {
+ return false;
+ }
+
+ // Check if destination forums exists
+ $sql = 'SELECT forum_id, forum_name
+ FROM ' . FORUMS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids);
+ $result = $db->sql_query($sql);
+
+ $dest_forum_ids = $dest_forum_names = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $dest_forum_ids[] = (int) $row['forum_id'];
+ $dest_forum_names[] = $row['forum_name'];
+ }
+ $db->sql_freeresult($result);
+
+ // No destination forum exists
+ if (empty($dest_forum_ids))
+ {
+ return false;
+ }
+
+ // From the mysql documentation:
+ // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear
+ // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
+ // Due to this we stay on the safe side if we do the insertion "the manual way"
+
+ // Rowsets we're going to insert
+ $users_sql_ary = $groups_sql_ary = array();
+
+ // Query acl users table for source forum data
+ $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting
+ FROM ' . ACL_USERS_TABLE . '
+ WHERE forum_id = ' . $src_forum_id;
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $row = array(
+ 'user_id' => (int) $row['user_id'],
+ 'auth_option_id' => (int) $row['auth_option_id'],
+ 'auth_role_id' => (int) $row['auth_role_id'],
+ 'auth_setting' => (int) $row['auth_setting'],
+ );
+
+ foreach ($dest_forum_ids as $dest_forum_id)
+ {
+ $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ // Query acl groups table for source forum data
+ $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting
+ FROM ' . ACL_GROUPS_TABLE . '
+ WHERE forum_id = ' . $src_forum_id;
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $row = array(
+ 'group_id' => (int) $row['group_id'],
+ 'auth_option_id' => (int) $row['auth_option_id'],
+ 'auth_role_id' => (int) $row['auth_role_id'],
+ 'auth_setting' => (int) $row['auth_setting'],
+ );
+
+ foreach ($dest_forum_ids as $dest_forum_id)
+ {
+ $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $db->sql_transaction('begin');
+
+ // Clear current permissions of destination forums
+ if ($clear_dest_perms)
+ {
+ $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids);
+ $db->sql_query($sql);
+
+ $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids);
+ $db->sql_query($sql);
+ }
+
+ $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
+ $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
+
+ if ($add_log)
+ {
+ add_log('admin', 'LOG_FORUM_COPIED_PERMISSIONS', $src_forum_name, implode(', ', $dest_forum_names));
+ }
+
+ $db->sql_transaction('commit');
+
+ return true;
+}
+
+/**
* Get physical file listing
*/
function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
{
- $matches = array();
+ $matches = array($dir => array());
// Remove initial / if present
$rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir;
@@ -940,19 +1037,61 @@ function delete_attachments($mode, $ids, $resync = true)
// Update post indicators for posts now no longer having attachments
if (sizeof($post_ids))
{
- $sql = 'UPDATE ' . POSTS_TABLE . '
- SET post_attachment = 0
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ // Just check which posts are still having an assigned attachment not orphaned by querying the attachments table
+ $sql = 'SELECT post_msg_id
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . '
+ AND in_message = 0
+ AND is_orphan = 0';
+ $result = $db->sql_query($sql);
+
+ $remaining_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $remaining_ids[] = $row['post_msg_id'];
+ }
+ $db->sql_freeresult($result);
+
+ // Now only unset those ids remaining
+ $post_ids = array_diff($post_ids, $remaining_ids);
+
+ if (sizeof($post_ids))
+ {
+ $sql = 'UPDATE ' . POSTS_TABLE . '
+ SET post_attachment = 0
+ WHERE ' . $db->sql_in_set('post_id', $post_ids);
+ $db->sql_query($sql);
+ }
}
// Update message table if messages are affected
if (sizeof($message_ids))
{
- $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
- SET message_attachment = 0
- WHERE ' . $db->sql_in_set('msg_id', $message_ids);
- $db->sql_query($sql);
+ // Just check which messages are still having an assigned attachment not orphaned by querying the attachments table
+ $sql = 'SELECT post_msg_id
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE ' . $db->sql_in_set('post_msg_id', $message_ids) . '
+ AND in_message = 1
+ AND is_orphan = 0';
+ $result = $db->sql_query($sql);
+
+ $remaining_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $remaining_ids[] = $row['post_msg_id'];
+ }
+ $db->sql_freeresult($result);
+
+ // Now only unset those ids remaining
+ $message_ids = array_diff($message_ids, $remaining_ids);
+
+ if (sizeof($message_ids))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_attachment = 0
+ WHERE ' . $db->sql_in_set('msg_id', $message_ids);
+ $db->sql_query($sql);
+ }
}
// Now update the topics. This is a bit trickier, because there could be posts still having attachments within the topic
@@ -1098,7 +1237,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
// Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself.
$sql = 'SELECT COUNT(attach_id) AS num_entries
FROM ' . ATTACHMENTS_TABLE . "
- WHERE physical_filename = '" . $db->sql_escape(basename($filename)) . "'";
+ WHERE physical_filename = '" . $db->sql_escape(utf8_basename($filename)) . "'";
$result = $db->sql_query($sql);
$num_entries = (int) $db->sql_fetchfield('num_entries');
$db->sql_freeresult($result);
@@ -1109,7 +1248,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
return false;
}
- $filename = ($mode == 'thumbnail') ? 'thumb_' . basename($filename) : basename($filename);
+ $filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename);
return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename);
}
@@ -1193,6 +1332,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
switch ($mode)
{
case 'topic_moved':
+ $db->sql_transaction('begin');
switch ($db->sql_layer)
{
case 'mysql4':
@@ -1229,9 +1369,13 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
break;
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'topic_approved':
+
+ $db->sql_transaction('begin');
switch ($db->sql_layer)
{
case 'mysql4':
@@ -1267,11 +1411,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$db->sql_query($sql);
break;
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'post_reported':
$post_ids = $post_reported = array();
+ $db->sql_transaction('begin');
+
$sql = 'SELECT p.post_id, p.post_reported
FROM ' . POSTS_TABLE . " p
$where_sql
@@ -1322,7 +1470,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'topic_reported':
if ($sync_extra)
@@ -1332,6 +1482,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_ids = $topic_reported = array();
+ $db->sql_transaction('begin');
+
$sql = 'SELECT DISTINCT(t.topic_id)
FROM ' . POSTS_TABLE . " t
$where_sql_and t.post_reported = 1";
@@ -1364,11 +1516,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'post_attachment':
$post_ids = $post_attachment = array();
+ $db->sql_transaction('begin');
+
$sql = 'SELECT p.post_id, p.post_attachment
FROM ' . POSTS_TABLE . " p
$where_sql
@@ -1419,7 +1575,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'topic_attachment':
if ($sync_extra)
@@ -1429,6 +1587,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_ids = $topic_attachment = array();
+ $db->sql_transaction('begin');
+
$sql = 'SELECT DISTINCT(t.topic_id)
FROM ' . POSTS_TABLE . " t
$where_sql_and t.post_attachment = 1";
@@ -1461,10 +1621,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
- break;
+
+ $db->sql_transaction('commit');
+
+ break;
case 'forum':
+ $db->sql_transaction('begin');
+
// 1: Get the list of all forums
$sql = 'SELECT f.*
FROM ' . FORUMS_TABLE . " f
@@ -1665,11 +1830,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$db->sql_query($sql);
}
}
- break;
+
+ $db->sql_transaction('commit');
+ break;
case 'topic':
$topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array();
+ $db->sql_transaction('begin');
+
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time
FROM ' . TOPICS_TABLE . " t
$where_sql";
@@ -1992,6 +2161,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
unset($topic_data);
+ $db->sql_transaction('commit');
+
// if some topics have been resync'ed then resync parent forums
// except when we're only syncing a range, we don't want to sync forums during
// batch processing.
@@ -1999,7 +2170,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}
- break;
+ break;
}
return;
@@ -2185,12 +2356,13 @@ function cache_moderators()
// Remove users who have group memberships with DENY moderator permissions
$sql = $db->sql_build_query('SELECT', array(
- 'SELECT' => 'a.forum_id, ug.user_id',
+ 'SELECT' => 'a.forum_id, ug.user_id, g.group_id',
'FROM' => array(
ACL_OPTIONS_TABLE => 'o',
USER_GROUP_TABLE => 'ug',
- ACL_GROUPS_TABLE => 'a'
+ ACL_GROUPS_TABLE => 'a',
+ GROUPS_TABLE => 'g',
),
'LEFT_JOIN' => array(
@@ -2204,6 +2376,8 @@ function cache_moderators()
AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL)
OR r.auth_setting = ' . ACL_NEVER . ')
AND a.group_id = ug.group_id
+ AND g.group_id = ug.group_id
+ AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)
AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
AND ug.user_pending = 0
AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char),
@@ -2323,7 +2497,7 @@ function cache_moderators()
/**
* View log
*/
-function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC')
+function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '')
{
global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path;
@@ -2343,15 +2517,15 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
if ($topic_id)
{
- $sql_forum = 'AND l.topic_id = ' . intval($topic_id);
+ $sql_forum = 'AND l.topic_id = ' . (int) $topic_id;
}
else if (is_array($forum_id))
{
$sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id));
}
- else
+ else if ($forum_id)
{
- $sql_forum = ($forum_id) ? 'AND l.forum_id = ' . intval($forum_id) : '';
+ $sql_forum = 'AND l.forum_id = ' . (int) $forum_id;
}
break;
@@ -2374,11 +2548,40 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
return;
}
+ $keywords = preg_split('#[\s+\-|*()]+#u', utf8_strtolower(preg_quote($keywords, '#')), 0, PREG_SPLIT_NO_EMPTY);
+ $sql_keywords = '';
+
+ if (!empty($keywords))
+ {
+ $keywords_pattern = '#' . implode('|', $keywords) . '#ui';
+ for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++)
+ {
+ $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char);
+ }
+
+ $operations = array();
+ foreach ($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 .= $db->sql_in_set('l.log_operation', $operations) . ' OR ';
+ }
+ $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')';
+ }
+
$sql = "SELECT l.*, u.username, u.username_clean, u.user_colour
FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u
WHERE l.log_type = $log_type
AND u.user_id = l.user_id
" . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . "
+ $sql_keywords
$sql_forum
ORDER BY $sort_by";
$result = $db->sql_query_limit($sql, $limit, $offset);
@@ -2419,7 +2622,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
if (!empty($row['log_data']))
{
- $log_data_ary = unserialize($row['log_data']);
+ $log_data_ary = @unserialize($row['log_data']);
+ $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary;
if (isset($user->lang[$row['log_operation']]))
{
@@ -2442,7 +2646,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action']));
}
}
- else
+ else if (!empty($log_data_ary))
{
$log[$i]['action'] .= '<br />' . implode('', $log_data_ary);
}
@@ -2540,9 +2744,11 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
}
$sql = 'SELECT COUNT(l.log_id) AS total_entries
- FROM ' . LOG_TABLE . " l
+ FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
WHERE l.log_type = $log_type
+ AND l.user_id = u.user_id
AND l.log_time >= $limit_days
+ $sql_keywords
$sql_forum";
$result = $db->sql_query($sql);
$log_count = (int) $db->sql_fetchfield('total_entries');
@@ -2685,7 +2891,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
$offset = ($offset - $limit < 0) ? 0 : $offset - $limit;
}
- $sql = 'SELECT user_id, username, user_regdate, user_lastvisit, user_inactive_time, user_inactive_reason
+ $sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_type = ' . USER_INACTIVE .
(($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . "
@@ -3054,4 +3260,43 @@ function add_permission_language()
return true;
}
+/**
+ * Obtains the latest version information
+ *
+ * @param bool $force_update Ignores cached data. Defaults to false.
+ * @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false.
+ * @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
+ *
+ * @return string | false Version info on success, false on failure.
+ */
+function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400)
+{
+ global $cache;
+
+ $info = $cache->get('versioncheck');
+
+ if ($info === false || $force_update)
+ {
+ $errstr = '';
+ $errno = 0;
+
+ $info = get_remote_file('www.phpbb.com', '/updatecheck',
+ ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
+
+ if ($info === false)
+ {
+ $cache->destroy('versioncheck');
+ if ($warn_fail)
+ {
+ trigger_error($errstr, E_USER_WARNING);
+ }
+ return false;
+ }
+
+ $cache->put('versioncheck', $info, $ttl);
+ }
+
+ return $info;
+}
+
?> \ No newline at end of file