diff --git a/.gitignore b/.gitignore index dcdfd3c386..16dba4ad47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ *~ phpunit.xml phpBB/cache/*.php +phpBB/cache/queue.php.lock phpBB/config.php phpBB/files/* +phpBB/images/avatars/gallery/* phpBB/images/avatars/upload/* phpBB/store/* tests/phpbb_unit_tests.sqlite2 diff --git a/build/build.xml b/build/build.xml index 724f201eb3..268f09d674 100644 --- a/build/build.xml +++ b/build/build.xml @@ -13,6 +13,7 @@ + diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index a6777ff9c9..4f6ae71d4b 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -55,12 +55,24 @@ quit() fi } -msg=$(grep -nE '.{81,}' "$1"); +# Check for empty commit message +if ! grep -qv '^#' "$1" +then + # Commit message is empty (or contains only comments). + # Let git handle this. + # It will abort with a message like so: + # + # Aborting commit due to empty commit message. + exit 0 +fi + +msg=$(grep -v '^#' "$1" |grep -nE '.{81,}') if [ $? -eq 0 ] then - echo "The following lines are greater than 80 characters long:\n" >&2; - echo $msg >&2; + echo "The following lines are greater than 80 characters long:" >&2; + echo >&2 + echo "$msg" >&2; quit $ERR_LENGTH; fi @@ -107,7 +119,19 @@ do case $expect in "header") err=$ERR_HEADER; - echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$" + echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] .+$" + result=$? + if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$" + then + # Don't be too strict. + # Commits may be temporary, intended to be squashed later. + # Just issue a warning here. + echo "Warning: heading should be a sentence beginning with a capital letter." 1>&2 + echo "You entered:" 1>&2 + echo "$line" 1>&2 + fi + # restore exit code + (exit $result) ;; "empty") err=$ERR_EMPTY; @@ -128,6 +152,10 @@ do # Should not end up here false ;; + "possibly-eof") + # Allow empty and/or comment lines at the end + ! tail -n +"$i" "$1" |grep -qvE '^($|#)' + ;; "comment") echo "$line" | grep -Eq "^#"; ;; @@ -188,7 +216,7 @@ do in_description=1; ;; "footer") - expecting="footer eof"; + expecting="footer possibly-eof"; if [ "$tickets" = "" ] then tickets="$line"; @@ -199,6 +227,9 @@ do "comment") # Comments should expect the same thing again ;; + "possibly-eof") + expecting="eof"; + ;; *) echo "Unrecognised token $expect" >&2; quit 254; diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg index 2bf25e58a4..11d2b6b2f2 100755 --- a/git-tools/hooks/prepare-commit-msg +++ b/git-tools/hooks/prepare-commit-msg @@ -35,8 +35,8 @@ then # Branch is prefixed with 'ticket/', append ticket ID to message if [ "$branch" != "${branch##ticket/}" ]; then - tail="\n\nPHPBB3-${branch##ticket/}"; + tail="$(printf "\n\nPHPBB3-${branch##ticket/}")"; fi - echo "[$branch]$tail $(cat "$1")" > "$1" + echo "[$branch] $tail$(cat "$1")" > "$1" fi diff --git a/git-tools/merge.php b/git-tools/merge.php new file mode 100755 index 0000000000..cbd84b896f --- /dev/null +++ b/git-tools/merge.php @@ -0,0 +1,175 @@ +#!/usr/bin/env php +getMessage(); + exit($e->getCode()); +} + +function work($pull_id, $remote) +{ + // Get some basic data + $pull = get_pull('phpbb', 'phpbb3', $pull_id); + + if (!$pull_id) + { + show_usage(); + } + + if ($pull['state'] != 'open') + { + throw new RuntimeException(sprintf("Error: pull request is closed\n", + $target_branch), 5); + } + + $pull_user = $pull['head'][0]; + $pull_branch = $pull['head'][1]; + $target_branch = $pull['base'][1]; + + switch ($target_branch) + { + case 'develop-olympus': + run("git checkout develop-olympus"); + run("git pull $remote develop-olympus"); + + add_remote($pull_user, 'phpbb3'); + run("git fetch $pull_user"); + run("git merge --no-ff $pull_user/$pull_branch"); + run("phpunit"); + + run("git checkout develop"); + run("git pull $remote develop"); + run("git merge --no-ff develop-olympus"); + run("phpunit"); + break; + + case 'develop': + run("git checkout develop"); + run("git pull $remote develop"); + + add_remote($pull_user, 'phpbb3'); + run("git fetch $pull_user"); + run("git merge --no-ff $pull_user/$pull_branch"); + run("phpunit"); + break; + + default: + throw new RuntimeException(sprintf("Error: pull request target branch '%s' is not a main branch\n", + $target_branch), 5); + break; + } +} + +function add_remote($username, $repository, $pushable = false) +{ + $url = get_repository_url($username, $repository, false); + run("git remote add $username $url", true); + + if ($pushable) + { + $ssh_url = get_repository_url($username, $repository, true); + run("git remote set-url --push $username $ssh_url"); + } +} + +function get_repository_url($username, $repository, $ssh = false) +{ + $url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/'; + + return $url_base . $username . '/' . $repository . '.git'; +} + +function api_request($query) +{ + $contents = file_get_contents("http://github.com/api/v2/json/$query"); + + if ($contents === false) + { + throw new RuntimeException("Error: failed to retrieve pull request data\n", 4); + } + + return json_decode($contents); +} + +function get_pull($username, $repository, $pull_id) +{ + $request = api_request("pulls/$username/$repository/$pull_id"); + + $pull = $request->pull; + + $pull_data = array( + 'base' => array($pull->base->user->login, $pull->base->ref), + 'head' => array($pull->head->user->login, $pull->head->ref), + 'state' => $pull->state, + ); + + return $pull_data; +} + +function get_arg($array, $index, $default) +{ + return isset($array[$index]) ? $array[$index] : $default; +} + +function run($cmd, $ignore_fail = false) +{ + global $dry_run; + + if (!empty($dry_run)) + { + echo "$cmd\n"; + } + else + { + passthru(escapeshellcmd($cmd), $status); + + if ($status != 0 && !$ignore_fail) + { + throw new RuntimeException(sprintf("Error: command '%s' failed with status %s'\n", + $cmd, $status), 6); + } + } +} diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 22f271ea82..d938135440 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -371,6 +371,79 @@ + + +
+ +
+ {L_TITLE} + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{L_FILENAME}{L_POSTED}{L_FILESIZE}{L_DELETE}
+ {L_EXTENSION_GROUP}: {attachments.EXT_GROUP_NAME}{L_NO_EXT_GROUP}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE} + {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_TOPIC}: {attachments.TOPIC_TITLE} +
{attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER}
{attachments.FILESIZE}
 {L_MARK_ALL} :: {L_UNMARK_ALL}
+ + +
+ {L_DISPLAY_LOG}:  {S_LIMIT_DAYS} {L_SORT_BY}: {S_SORT_KEY} {S_SORT_DIR} + +
+ +
+ + + + +

+   + +

+ {S_FORM_TOKEN} +
+
+ + +
+ {L_RESYNC_STATS} +
+
+

{L_RESYNC_FILES_STATS_EXPLAIN}
+
+
+
+
+ diff --git a/phpBB/adm/style/acp_ban.html b/phpBB/adm/style/acp_ban.html index cbcc6dfa60..2eeb748e4b 100644 --- a/phpBB/adm/style/acp_ban.html +++ b/phpBB/adm/style/acp_ban.html @@ -33,7 +33,7 @@ { document.getElementById('acp_unban').unbangivereason.innerHTML = ban_give_reason[option]; document.getElementById('acp_unban').unbanreason.innerHTML = ban_reason[option]; - document.getElementById('acp_unban').unbanlength.innerHTML = ban_length[option]; + document.getElementById('acp_unban').unbanlength.value = ban_length[option]; } // ]]> diff --git a/phpBB/adm/style/acp_email.html b/phpBB/adm/style/acp_email.html index 885809ffe2..ff52500dca 100644 --- a/phpBB/adm/style/acp_email.html +++ b/phpBB/adm/style/acp_email.html @@ -38,6 +38,10 @@
+
+

{L_MAIL_BANNED_EXPLAIN}
+
+
diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 07f7d072e8..2f812c443d 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -70,6 +70,10 @@
+
+
+
+

{L_GROUP_RECEIVE_PM_EXPLAIN}
diff --git a/phpBB/adm/style/acp_groups_position.html b/phpBB/adm/style/acp_groups_position.html new file mode 100644 index 0000000000..49212a4408 --- /dev/null +++ b/phpBB/adm/style/acp_groups_position.html @@ -0,0 +1,158 @@ + + + + +

{L_MANAGE_LEGEND}

+ +
enctype="multipart/form-data"> + +
+ {L_LEGEND_SETTINGS} +
+

{L_LEGEND_SORT_GROUPNAME_EXPLAIN}
+
+ + +
+
+ +

+   + + + {S_FORM_TOKEN} +

+
+
+ +

{L_LEGEND_EXPLAIN}

+ + + + + + + + + + + + + + + + + + + + + + + +
{L_GROUP}{L_GROUP_TYPE}{L_ACTION}
{legend.GROUP_NAME}{legend.GROUP_TYPE} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_DELETE} +
{L_NO_GROUPS_ADDED}
+ +
+
+ + + + {S_FORM_TOKEN} +
+
+ +

{L_MANAGE_TEAMPAGE}

+ +
enctype="multipart/form-data"> + +
+ {L_TEAMPAGE_SETTINGS} +
+

{L_TEAMPAGE_MULTIPLE_EXPLAIN}
+
+ + +
+
+
+

{L_TEAMPAGE_FORUMS_EXPLAIN}
+
+ + +
+
+ +

+   + + + {S_FORM_TOKEN} +

+
+
+ +

{L_TEAMPAGE_EXPLAIN}

+ + + + + + + + + + + + + + + + + + + + + + + +
{L_GROUP}{L_GROUP_TYPE}{L_ACTION}
{teampage.GROUP_NAME}{teampage.GROUP_TYPE} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} + + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} + + {ICON_DELETE} +
{L_NO_GROUPS_ADDED}
+ +
+
+ + + + {S_FORM_TOKEN} +
+
+ + diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index 9306e30269..2ad8b3e8aa 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -35,8 +35,8 @@
-
-
+
+
@@ -1097,7 +1102,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&

General function usage:

-

Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistant over the code.

+

Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistent over the code.

  • diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf index 54a5c316ca..c82f5c8e49 100644 --- a/phpBB/docs/nginx.sample.conf +++ b/phpBB/docs/nginx.sample.conf @@ -18,14 +18,23 @@ http { gzip_vary on; gzip_http_version 1.1; gzip_min_length 700; + + # Compression levels over 6 do not give an appreciable improvement + # in compression ratio, but take more resources. gzip_comp_level 6; - gzip_disable "MSIE [1-6]\."; + + # IE 6 and lower do not support gzip with Vary correctly. + gzip_disable "msie6"; + # Before nginx 0.7.63: + #gzip_disable "MSIE [1-6]\."; # Catch-all server for requests to invalid hosts. # Also catches vulnerability scanners probing IP addresses. - # Should be first. server { - listen 80; + # default specifies that this block is to be used when + # no other block matches. + listen 80 default; + server_name bogus; return 444; root /var/empty; @@ -34,14 +43,20 @@ http { # If you have domains with and without www prefix, # redirect one to the other. server { - listen 80; + # Default port is 80. + #listen 80; + server_name myforums.com; - rewrite ^(.*)$ http://www.myforums.com$1 permanent; + + # A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites: + rewrite ^ http://www.myforums.com$request_uri permanent; + # Equivalent to: + #rewrite ^(.*)$ http://www.myforums.com$1 permanent; } # The actual board domain. server { - listen 80; + #listen 80; server_name www.myforums.com; root /path/to/phpbb; @@ -53,8 +68,10 @@ http { # Deny access to internal phpbb files. location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) { - internal; deny all; + # deny was ignored before 0.8.40 for connections over IPv6. + # Use internal directive to prohibit access on older versions. + internal; } # Pass the php scripts to fastcgi server specified in upstream declaration. @@ -68,8 +85,8 @@ http { # Deny access to version control system directories. location ~ /\.svn|/\.git { - internal; deny all; + internal; } } diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 5016e7f549..d33a50c149 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -194,8 +194,7 @@ else $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - // Global announcement? - $f_download = (!$row) ? $auth->acl_getf_global('f_download') : $auth->acl_get('f_download', $row['forum_id']); + $f_download = $auth->acl_get('f_download', $row['forum_id']); if ($auth->acl_get('u_download') && $f_download) { diff --git a/phpBB/feed.php b/phpBB/feed.php index 1b06b17c03..1a09e4da23 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -95,11 +95,13 @@ while ($row = $feed->get_item()) $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); - $item_time = (int) $row[$feed->get('date')]; + $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0; + $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0; $item_row = array( 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', - 'pubdate' => feed_format_date($item_time), + 'published' => ($published > 0) ? feed_format_date($published) : '', + 'updated' => ($updated > 0) ? feed_format_date($updated) : '', 'link' => '', 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', @@ -113,7 +115,7 @@ while ($row = $feed->get_item()) $item_vars[] = $item_row; - $feed_updated_time = max($feed_updated_time, $item_time); + $feed_updated_time = max($feed_updated_time, $published, $updated); } // If we do not have any items at all, sending the current time is better than sending no time. @@ -192,7 +194,13 @@ foreach ($item_vars as $row) echo '' . "\n"; } - echo '' . $row['pubdate'] . '' . "\n"; + echo '' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '' . "\n"; + + if (!empty($row['published'])) + { + echo '' . $row['published'] . '' . "\n"; + } + echo '' . $row['link'] . '' . "\n"; echo '' . "\n"; echo '<![CDATA[' . $row['title'] . ']]>' . "\n\n"; @@ -675,7 +683,8 @@ class phpbb_feed_post_base extends phpbb_feed_base $this->set('author_id', 'user_id'); $this->set('creator', 'username'); - $this->set('date', 'post_time'); + $this->set('published', 'post_time'); + $this->set('updated', 'post_edit_time'); $this->set('text', 'post_text'); $this->set('bitfield', 'bbcode_bitfield'); @@ -695,7 +704,7 @@ class phpbb_feed_post_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row['post_time']) + . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); } } @@ -717,7 +726,8 @@ class phpbb_feed_topic_base extends phpbb_feed_base $this->set('author_id', 'topic_poster'); $this->set('creator', 'topic_first_poster_name'); - $this->set('date', 'topic_time'); + $this->set('published', 'post_time'); + $this->set('updated', 'post_edit_time'); $this->set('text', 'post_text'); $this->set('bitfield', 'bbcode_bitfield'); @@ -737,7 +747,7 @@ class phpbb_feed_topic_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('date')]) + . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); @@ -765,9 +775,6 @@ class phpbb_feed_overall extends phpbb_feed_post_base return false; } - // Add global forum id - $forum_ids[] = 0; - // m_approve forums $fid_m_approve = $this->get_moderator_approve_forums(); $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', $fid_m_approve) : ''; @@ -800,7 +807,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base // Get the actual data $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, ' . - 'p.post_id, p.topic_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( USERS_TABLE => 'u', @@ -905,12 +912,11 @@ class phpbb_feed_forum extends phpbb_feed_post_base global $auth, $db; $m_approve = ($auth->acl_get('m_approve', $this->forum_id)) ? true : false; - $forum_ids = array(0, $this->forum_id); // Determine topics with recent activity $sql = 'SELECT topic_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' + WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 ' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . ' ORDER BY topic_last_post_time DESC'; @@ -932,7 +938,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base } $this->sql = array( - 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -999,96 +1005,37 @@ class phpbb_feed_topic extends phpbb_feed_post_base trigger_error('NO_TOPIC'); } - if ($this->topic_data['topic_type'] == POST_GLOBAL) + $this->forum_id = (int) $this->topic_data['forum_id']; + + // Make sure topic is either approved or user authed + if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) { - // We need to find at least one postable forum where feeds are enabled, - // that the user can read and maybe also has approve permissions. - $in_fid_ary = $this->get_readable_forums(); - - if (empty($in_fid_ary)) - { - // User cannot read any forums - trigger_error('SORRY_AUTH_READ'); - } - - if (!$this->topic_data['topic_approved']) - { - // Also require m_approve - $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - } - - // Diff excluded forums - $in_fid_ary = array_diff($in_fid_ary, $this->get_excluded_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - - // Also exclude passworded forums - $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - - $sql = 'SELECT forum_id, left_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . ' - AND ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' - ORDER BY left_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $this->forum_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (empty($this->forum_data)) - { - // No forum found. - trigger_error('SORRY_AUTH_READ'); - } - - unset($in_fid_ary); + trigger_error('SORRY_AUTH_READ'); } - else + + // Make sure forum is not excluded from feed + if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) { - $this->forum_id = (int) $this->topic_data['forum_id']; + trigger_error('NO_FEED'); + } - // Make sure topic is either approved or user authed - if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) + // Make sure we can read this forum + if (!$auth->acl_get('f_read', $this->forum_id)) + { + trigger_error('SORRY_AUTH_READ'); + } + + // Make sure forum is not passworded or user is authed + if ($this->topic_data['forum_password']) + { + $forum_ids_passworded = $this->get_passworded_forums(); + + if (isset($forum_ids_passworded[$this->forum_id])) { trigger_error('SORRY_AUTH_READ'); } - // Make sure forum is not excluded from feed - if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) - { - trigger_error('NO_FEED'); - } - - // Make sure we can read this forum - if (!$auth->acl_get('f_read', $this->forum_id)) - { - trigger_error('SORRY_AUTH_READ'); - } - - // Make sure forum is not passworded or user is authed - if ($this->topic_data['forum_password']) - { - $forum_ids_passworded = $this->get_passworded_forums(); - - if (isset($forum_ids_passworded[$this->forum_id])) - { - trigger_error('SORRY_AUTH_READ'); - } - - unset($forum_ids_passworded); - } + unset($forum_ids_passworded); } } @@ -1097,7 +1044,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base global $auth, $db; $this->sql = array( - 'SELECT' => 'p.post_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1136,7 +1083,7 @@ class phpbb_feed_forums extends phpbb_feed_base $this->set('text', 'forum_desc'); $this->set('bitfield', 'forum_desc_bitfield'); $this->set('bbcode_uid','forum_desc_uid'); - $this->set('date', 'forum_last_post_time'); + $this->set('updated', 'forum_last_post_time'); $this->set('options', 'forum_desc_options'); } @@ -1235,9 +1182,6 @@ class phpbb_feed_news extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' @@ -1261,8 +1205,8 @@ class phpbb_feed_news extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, - p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time, + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1308,9 +1252,6 @@ class phpbb_feed_topics extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' @@ -1334,8 +1275,8 @@ class phpbb_feed_topics extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, - p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time, + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1381,8 +1322,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base $this->set('author_id', 'topic_last_poster_id'); $this->set('creator', 'topic_last_poster_name'); - $this->set('date', 'topic_last_post_time'); - $this->set('text', 'post_text'); } function get_sql() @@ -1402,9 +1341,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // Search for topics in last X days $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : ''; @@ -1434,7 +1370,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, - p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 3179be7de7..c62fefae46 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -61,6 +61,10 @@ class acp_attachments $l_title = 'ACP_ORPHAN_ATTACHMENTS'; break; + case 'manage': + $l_title = 'ACP_MANAGE_ATTACHMENTS'; + break; + default: trigger_error('NO_MODE', E_USER_ERROR); break; @@ -1043,6 +1047,230 @@ class acp_attachments $db->sql_freeresult($result); break; + + case 'manage': + + if ($submit) + { + $delete_files = (isset($_POST['delete'])) ? array_keys(request_var('delete', array('' => 0))) : array(); + + if (sizeof($delete_files)) + { + // Select those attachments we want to delete... + $sql = 'SELECT real_filename + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' + AND is_orphan = 0'; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $deleted_filenames[] = $row['real_filename']; + } + $db->sql_freeresult($result); + + if ($num_deleted = delete_attachments('attach', $delete_files)) + { + if (sizeof($delete_files) != $num_deleted) + { + $error[] = $user->lang['FILES_GONE']; + } + add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $deleted_filenames)); + $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode(', ', $deleted_filenames)); + } + else + { + $error[] = $user->lang['NO_FILES_TO_DELETE']; + } + } + } + + $template->assign_vars(array( + 'S_MANAGE' => true) + ); + + $start = request_var('start', 0); + + // Sort keys + $sort_days = request_var('st', 0); + $sort_key = request_var('sk', 't'); + $sort_dir = request_var('sd', 'd'); + + // Sorting + $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); + $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']); + $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username'); + + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); + + $min_filetime = ($sort_days) ? (time() - ($sort_days * 86400)) : ''; + $limit_filetime = ($min_filetime) ? " AND a.filetime >= $min_filetime " : ''; + $start = ($sort_days && isset($_POST['sort'])) ? 0 : $start; + + $attachments_per_page = (int) $config['topics_per_page']; + + // Handle files stats resync + $action = request_var('action', ''); + $resync_files_stats = false; + if ($action && $action = 'stats') + { + if (!confirm_box(true)) + { + confirm_box(false, $user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + ))); + } + else + { + $resync_files_stats = true; + add_log('admin', 'LOG_RESYNC_FILES_STATS'); + } + } + + // Check if files stats are accurate + $sql = 'SELECT COUNT(attach_id) as num_files + FROM ' . ATTACHMENTS_TABLE . ' + WHERE is_orphan = 0'; + $result = $db->sql_query($sql, 600); + $num_files_real = (int) $db->sql_fetchfield('num_files'); + if ($resync_files_stats === true) + { + set_config('num_files', $num_files_real, true); + } + $db->sql_freeresult($result); + + $sql = 'SELECT SUM(filesize) as upload_dir_size + FROM ' . ATTACHMENTS_TABLE . ' + WHERE is_orphan = 0'; + $result = $db->sql_query($sql, 600); + $total_size_real = (float) $db->sql_fetchfield('upload_dir_size'); + if ($resync_files_stats === true) + { + set_config('upload_dir_size', $total_size_real, true); + } + $db->sql_freeresult($result); + + // Get current files stats + $num_files = (int) $config['num_files']; + $total_size = (float) $config['upload_dir_size']; + + // Issue warning message if files stats are inaccurate + if (($num_files != $num_files_real) || ($total_size != $total_size_real)) + { + $error[] = sprintf($user->lang['FILES_STATS_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + + $template->assign_vars(array( + 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, + 'U_ACTION' => $this->u_action,) + ); + } + + // Make sure $start is set to the last page if it exceeds the amount + if ($start < 0 || $start > $num_files) + { + $start = ($start < 0) ? 0 : floor(($num_files - 1) / $attachments_per_page) * $attachments_per_page; + } + + // If the user is trying to reach the second half of the attachments list, fetch it starting from the end + $store_reverse = false; + $sql_limit = $attachments_per_page; + + if ($start > $num_files / 2) + { + $store_reverse = true; + + if ($start + $attachments_per_page > $num_files) + { + $sql_limit = min($attachments_per_page, max(1, $num_files - $start)); + } + + // Select the sort order. Add time sort anchor for non-time sorting cases + $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') : ''; + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') . $sql_sort_anchor; + $sql_start = max(0, $num_files - $sql_limit - $start); + } + else + { + // Select the sort order. Add time sort anchor for non-time sorting cases + $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') : ''; + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . $sql_sort_anchor; + $sql_start = $start; + + } + + $attachments_list = array(); + + // Just get the files + $sql = 'SELECT a.*, u.username, u.user_colour, t.topic_title + FROM ' . ATTACHMENTS_TABLE . ' a + LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id) + LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id) + WHERE a.is_orphan = 0 + $limit_filetime + ORDER BY $sql_sort_order"; + $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); + + $i = ($store_reverse) ? $sql_limit - 1 : 0; + + // Store increment value in a variable to save some conditional calls + $i_increment = ($store_reverse) ? -1 : 1; + while ($attachment_row = $db->sql_fetchrow($result)) + { + $attachments_list[$i] = $attachment_row; + $i = $i + $i_increment; + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'TOTAL_FILES' => $num_files, + 'TOTAL_SIZE' => get_formatted_filesize($total_size), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $num_files, $attachments_per_page, $start, true), + + 'S_ON_PAGE' => on_page($num_files, $attachments_per_page, $start), + 'S_LIMIT_DAYS' => $s_limit_days, + 'S_SORT_KEY' => $s_sort_key, + 'S_SORT_DIR' => $s_sort_dir) + ); + + // Grab extensions + $extensions = $cache->obtain_attach_extensions(true); + + for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i) + { + $row = $attachments_list[$i]; + + $row['extension'] = strtolower(trim((string) $row['extension'])); + $comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('
    ', "\n"), $row['attach_comment']) : ''; + $display_cat = $extensions[$row['extension']]['display_cat']; + $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNT' : 'VIEWED_COUNT'; + $l_download_count = (!isset($row['download_count']) || (int) $row['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (((int) $row['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $row['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $row['download_count'])); + + $template->assign_block_vars('attachments', array( + 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), + 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), + 'FILETIME' => $user->format_date((int) $row['filetime']), + 'REAL_FILENAME' => (!$row['in_message']) ? utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
    ', true) : '', + 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), + 'EXT_GROUP_NAME' => (!empty($extensions[$row['extension']]['group_name'])) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '', + 'COMMENT' => $comment, + 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', + 'ATTACH_ID' => (int) $row['attach_id'], + 'POST_ID' => (int) $row['post_msg_id'], + 'TOPIC_ID' => (int) $row['topic_id'], + 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? (int) $post_ids[$row['attach_id']] : '', + + 'L_DOWNLOAD_COUNT' => $l_download_count, + + 'S_IN_MESSAGE' => (bool) $row['in_message'], + + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}", + 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) + ); + } + + break; } if (sizeof($error)) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index d77fbca7c2..6821073749 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -110,10 +110,10 @@ class acp_board 'vars' => array( 'legend1' => 'ACP_AVATAR_SETTINGS', - 'avatar_min_width' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'avatar_min_height' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'avatar_max_width' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), + 'avatar_min_width' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), + 'avatar_min_height' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), + 'avatar_max_width' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), + 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), @@ -124,7 +124,7 @@ class acp_board 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true), - 'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true) + 'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), ) ); break; @@ -296,7 +296,7 @@ class acp_board 'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'validate' => 'string', 'type' => 'text::255', 'explain' => false), 'cookie_name' => array('lang' => 'COOKIE_NAME', 'validate' => 'string', 'type' => 'text::16', 'explain' => false), 'cookie_path' => array('lang' => 'COOKIE_PATH', 'validate' => 'string', 'type' => 'text::255', 'explain' => false), - 'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'validate' => 'bool', 'type' => 'radio:disabled_enabled', 'explain' => true) + 'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'validate' => 'bool', 'type' => 'radio:disabled_enabled', 'explain' => true), ) ); break; @@ -340,7 +340,7 @@ class acp_board 'title' => 'ACP_AUTH_SETTINGS', 'vars' => array( 'legend1' => 'ACP_AUTH_SETTINGS', - 'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'select_auth_method', 'explain' => false) + 'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'select_auth_method', 'explain' => false), ) ); break; diff --git a/phpBB/includes/acp/acp_disallow.php b/phpBB/includes/acp/acp_disallow.php index e3496bfc8b..f29e902910 100644 --- a/phpBB/includes/acp/acp_disallow.php +++ b/phpBB/includes/acp/acp_disallow.php @@ -56,6 +56,18 @@ class acp_disallow trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); } + $sql = 'SELECT disallow_id + FROM ' . DISALLOW_TABLE . " + WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user)); $db->sql_query($sql); diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index b4f0e50029..b4755d3984 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -82,23 +82,48 @@ class acp_email { if ($group_id) { - $sql = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug - WHERE ug.group_id = ' . $group_id . ' + $sql_ary = array( + 'SELECT' => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type', + 'FROM' => array( + USERS_TABLE => 'u', + USER_GROUP_TABLE => 'ug', + ), + 'WHERE' => 'ug.group_id = ' . $group_id . ' AND ug.user_pending = 0 AND u.user_id = ug.user_id AND u.user_allow_massemail = 1 - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - ORDER BY u.user_lang, u.user_notify_type'; + AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', + 'ORDER_BY' => 'u.user_lang, u.user_notify_type', + ); } else { - $sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang - FROM ' . USERS_TABLE . ' - WHERE user_allow_massemail = 1 - AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - ORDER BY user_lang, user_notify_type'; + $sql_ary = array( + 'SELECT' => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type', + 'FROM' => array( + USERS_TABLE => 'u', + ), + 'WHERE' => 'u.user_allow_massemail = 1 + AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', + 'ORDER_BY' => 'u.user_lang, u.user_notify_type', + ); } + + // Mail banned or not + if (!isset($_REQUEST['mail_banned_flag'])) + { + $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL + OR b.ban_exclude = 1)'; + $sql_ary['LEFT_JOIN'] = array( + array( + 'FROM' => array( + BANLIST_TABLE => 'b', + ), + 'ON' => 'u.user_id = b.ban_userid', + ), + ); + } + $sql = $db->sql_build_query('SELECT', $sql_ary); } $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index d47c12eafd..dde556c19e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -35,6 +35,12 @@ class acp_groups $form_key = 'acp_groups'; add_form_key($form_key); + if ($mode == 'position') + { + $this->manage_position(); + return; + } + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); // Check and set some common vars @@ -306,6 +312,7 @@ class acp_groups 'rank' => request_var('group_rank', 0), 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'legend' => isset($_REQUEST['group_legend']) ? 1 : 0, + 'teampage' => isset($_REQUEST['group_teampage']) ? 1 : 0, 'message_limit' => request_var('group_message_limit', 0), 'max_recipients' => request_var('group_max_recipients', 0), 'founder_manage' => 0, @@ -419,6 +426,7 @@ class acp_groups 'avatar_height' => 'int', 'receive_pm' => 'int', 'legend' => 'int', + 'teampage' => 'int', 'message_limit' => 'int', 'max_recipients'=> 'int', 'founder_manage'=> 'int', @@ -584,6 +592,7 @@ class acp_groups 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', 'GROUP_FOUNDER_MANAGE' => (isset($group_row['group_founder_manage']) && $group_row['group_founder_manage']) ? ' checked="checked"' : '', 'GROUP_LEGEND' => (isset($group_row['group_legend']) && $group_row['group_legend']) ? ' checked="checked"' : '', + 'GROUP_TEAMPAGE' => (isset($group_row['group_teampage']) && $group_row['group_teampage']) ? ' checked="checked"' : '', 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', @@ -793,4 +802,122 @@ class acp_groups } } } + + public function manage_position() + { + global $config, $db, $template, $user; + + $this->tpl_name = 'acp_groups_position'; + $this->page_title = 'ACP_GROUPS_POSITION'; + + $field = request_var('field', ''); + $action = request_var('action', ''); + $group_id = request_var('g', 0); + + if ($field && !in_array($field, array('legend', 'teampage'))) + { + // Invalid mode + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); + } + else if ($field) + { + $group_position = new phpbb_group_positions($db, $field, $this->u_action); + } + + switch ($action) + { + case 'set_config_legend': + set_config('legend_sort_groupname', request_var('legend_sort_groupname', 0)); + break; + + case 'set_config_teampage': + set_config('teampage_forums', request_var('teampage_forums', 0)); + set_config('teampage_multiple', request_var('teampage_multiple', 0)); + break; + + case 'add': + $group_position->add_group($group_id); + break; + + case 'delete': + $group_position->delete_group($group_id); + break; + + case 'move_up': + $group_position->move_up($group_id); + break; + + case 'move_down': + $group_position->move_down($group_id); + break; + } + + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_legend, group_name ASC'; + $result = $db->sql_query($sql); + + $s_group_select_legend = ''; + while ($row = $db->sql_fetchrow($result)) + { + $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + if ($row['group_legend']) + { + $template->assign_block_vars('legend', array( + 'GROUP_NAME' => $group_name, + 'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '', + 'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])], + + 'U_MOVE_DOWN' => "{$this->u_action}&field=legend&action=move_down&g=" . $row['group_id'], + 'U_MOVE_UP' => "{$this->u_action}&field=legend&action=move_up&g=" . $row['group_id'], + 'U_DELETE' => "{$this->u_action}&field=legend&action=delete&g=" . $row['group_id'], + )); + } + else + { + $s_group_select_legend .= ''; + } + } + $db->sql_freeresult($result); + + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_teampage + FROM ' . GROUPS_TABLE . ' + ORDER BY group_teampage, group_name ASC'; + $result = $db->sql_query($sql); + + $s_group_select_teampage = ''; + while ($row = $db->sql_fetchrow($result)) + { + $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + if ($row['group_teampage']) + { + $template->assign_block_vars('teampage', array( + 'GROUP_NAME' => $group_name, + 'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '', + 'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])], + + 'U_MOVE_DOWN' => "{$this->u_action}&field=teampage&action=move_down&g=" . $row['group_id'], + 'U_MOVE_UP' => "{$this->u_action}&field=teampage&action=move_up&g=" . $row['group_id'], + 'U_DELETE' => "{$this->u_action}&field=teampage&action=delete&g=" . $row['group_id'], + )); + } + else + { + $s_group_select_teampage .= ''; + } + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'U_ACTION_LEGEND' => $this->u_action . '&field=legend', + 'U_ACTION_TEAMPAGE' => $this->u_action . '&field=teampage', + + 'S_GROUP_SELECT_LEGEND' => $s_group_select_legend, + 'S_GROUP_SELECT_TEAMPAGE' => $s_group_select_teampage, + 'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false, + 'DISPLAY_MULTIPLE' => ($config['teampage_multiple']) ? true : false, + 'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false, + )); + } } diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index a525efb510..c848039c66 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -395,6 +395,10 @@ class acp_icons { // skip images where add wasn't checked } + else if (!file_exists($phpbb_root_path . $img_path . '/' . $image)) + { + $errors[$image] = 'SMILIE_NO_FILE'; + } else { if ($image_width[$image] == 0 || $image_height[$image] == 0) diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 27e636ddcc..a3061ae2da 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -384,17 +384,30 @@ class acp_search AND post_id <= ' . (int) ($post_counter + $this->batch_size); $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + $buffer = $db->sql_buffer_nested_transactions(); + + if ($buffer) { - // Indexing enabled for this forum or global announcement? - // Global announcements get indexed by default. - if (!$row['forum_id'] || (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']])) + $rows = $db->sql_fetchrowset($result); + $rows[] = false; // indicate end of array for while loop below + + $db->sql_freeresult($result); + } + + $i = 0; + while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result))) + { + // Indexing enabled for this forum + if (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']]) { $this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } $row_count++; } - $db->sql_freeresult($result); + if (!$buffer) + { + $db->sql_freeresult($result); + } $post_counter += $this->batch_size; } diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 4f13ee376f..e32a4d2310 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -45,7 +45,7 @@ class acp_styles $bitfield->set(9); $bitfield->set(11); $bitfield->set(12); - define('TEMPLATE_BITFIELD', $bitfield->get_base64()); + $this->template_bitfield = $bitfield->get_base64(); unset($bitfield); $user->add_lang('acp/styles'); @@ -716,7 +716,7 @@ parse_css_file = {PARSE_CSS_FILE} $save_changes = (isset($_POST['save'])) ? true : false; // make sure template_file path doesn't go upwards - $template_file = str_replace('..', '.', $template_file); + $template_file = preg_replace('#\.{2,}#', '.', $template_file); // Retrieve some information about the template $sql = 'SELECT template_storedb, template_path, template_name @@ -3496,7 +3496,7 @@ parse_css_file = {PARSE_CSS_FILE} } else { - $sql_ary['bbcode_bitfield'] = TEMPLATE_BITFIELD; + $sql_ary['bbcode_bitfield'] = $this->template_bitfield; } // We set a pre-defined bitfield here which we may use further in 3.2 diff --git a/phpBB/includes/acp/info/acp_attachments.php b/phpBB/includes/acp/info/acp_attachments.php index d5f57ece4e..4bcd7e2ea5 100644 --- a/phpBB/includes/acp/info/acp_attachments.php +++ b/phpBB/includes/acp/info/acp_attachments.php @@ -23,7 +23,8 @@ class acp_attachments_info 'attach' => array('title' => 'ACP_ATTACHMENT_SETTINGS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_ATTACHMENTS')), 'extensions' => array('title' => 'ACP_MANAGE_EXTENSIONS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'ext_groups' => array('title' => 'ACP_EXTENSION_GROUPS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), - 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')) + 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), + 'manage' => array('title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), ), ); } diff --git a/phpBB/includes/acp/info/acp_groups.php b/phpBB/includes/acp/info/acp_groups.php index bbf92d670e..36e8793007 100644 --- a/phpBB/includes/acp/info/acp_groups.php +++ b/phpBB/includes/acp/info/acp_groups.php @@ -21,6 +21,7 @@ class acp_groups_info 'version' => '1.0.0', 'modes' => array( 'manage' => array('title' => 'ACP_GROUPS_MANAGE', 'auth' => 'acl_a_group', 'cat' => array('ACP_GROUPS')), + 'position' => array('title' => 'ACP_GROUPS_POSITION', 'auth' => 'acl_a_group', 'cat' => array('ACP_GROUPS')), ), ); } diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 5b197e93f3..22aca5faf9 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -109,6 +109,7 @@ class auth */ function _fill_acl($user_permissions) { + $seq_cache = array(); $this->acl = array(); $user_permissions = explode("\n", $user_permissions); @@ -125,8 +126,17 @@ class auth while ($subseq = substr($seq, $i, 6)) { + if (isset($seq_cache[$subseq])) + { + $converted = $seq_cache[$subseq]; + } + else + { + $converted = $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); + } + // We put the original bitstring into the acl array - $this->acl[$f] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); + $this->acl[$f] .= $converted; $i += 6; } } diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php new file mode 100755 index 0000000000..f0997c3cad --- /dev/null +++ b/phpBB/includes/cache/driver/redis.php @@ -0,0 +1,150 @@ +redis = new Redis(); + foreach (explode(',', PHPBB_ACM_REDIS) as $server) + { + $parts = explode('/', $server); + $this->redis->connect(trim($parts[0]), trim($parts[1])); + } + + if (defined('PHPBB_ACM_REDIS_PASSWORD')) + { + if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD)) + { + global $acm_type; + + trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR); + } + } + + $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); + $this->redis->setOption(Redis::OPT_PREFIX, $this->key_prefix); + + if (defined('PHPBB_ACM_REDIS_DB')) + { + if (!$this->redis->select(PHPBB_ACM_REDIS_DB)) + { + global $acm_type; + + trigger_error("Incorrect database for the ACM module $acm_type.", E_USER_ERROR); + } + } + } + + /** + * Unload the cache resources + * + * @return void + */ + function unload() + { + parent::unload(); + + $this->redis->close(); + } + + /** + * Purge cache data + * + * @return void + */ + function purge() + { + $this->redis->flushDB(); + + parent::purge(); + } + + /** + * Fetch an item from the cache + * + * @access protected + * @param string $var Cache key + * @return mixed Cached data + */ + function _read($var) + { + return $this->redis->get($var); + } + + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) + { + return $this->redis->setex($var, $ttl, $data); + } + + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) + { + if ($this->redis->delete($var) > 0) + { + return true; + } + return false; + } +} + diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php index 68026c8647..0c01953d55 100644 --- a/phpBB/includes/cache/service.php +++ b/phpBB/includes/cache/service.php @@ -194,6 +194,7 @@ class phpbb_cache_service 'max_filesize' => (int) $row['max_filesize'], 'allow_group' => $row['allow_group'], 'allow_in_pm' => $row['allow_in_pm'], + 'group_name' => $row['group_name'], ); $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array(); diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php index b9b0914e0c..15f34aa58f 100644 --- a/phpBB/includes/captcha/captcha_gd.php +++ b/phpBB/includes/captcha/captcha_gd.php @@ -112,7 +112,7 @@ class captcha $noise_bitmaps = $this->captcha_noise_bg_bitmaps(); for ($i = 0; $i < $code_len; ++$i) { - $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, count($noise_bitmaps['data']))); + $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, sizeof($noise_bitmaps['data']))); list($min, $max) = $noise[$i]->range(); //$box = $noise[$i]->dimensions($sizes[$i]); @@ -1669,32 +1669,32 @@ class captcha 'height' => 15, 'data' => array( - 'A' => $chars['A'][mt_rand(0, min(count($chars['A']), $config['captcha_gd_fonts']) -1)], - 'B' => $chars['B'][mt_rand(0, min(count($chars['B']), $config['captcha_gd_fonts']) -1)], - 'C' => $chars['C'][mt_rand(0, min(count($chars['C']), $config['captcha_gd_fonts']) -1)], - 'D' => $chars['D'][mt_rand(0, min(count($chars['D']), $config['captcha_gd_fonts']) -1)], - 'E' => $chars['E'][mt_rand(0, min(count($chars['E']), $config['captcha_gd_fonts']) -1)], - 'F' => $chars['F'][mt_rand(0, min(count($chars['F']), $config['captcha_gd_fonts']) -1)], - 'G' => $chars['G'][mt_rand(0, min(count($chars['G']), $config['captcha_gd_fonts']) -1)], - 'H' => $chars['H'][mt_rand(0, min(count($chars['H']), $config['captcha_gd_fonts']) -1)], - 'I' => $chars['I'][mt_rand(0, min(count($chars['I']), $config['captcha_gd_fonts']) -1)], - 'J' => $chars['J'][mt_rand(0, min(count($chars['J']), $config['captcha_gd_fonts']) -1)], - 'K' => $chars['K'][mt_rand(0, min(count($chars['K']), $config['captcha_gd_fonts']) -1)], - 'L' => $chars['L'][mt_rand(0, min(count($chars['L']), $config['captcha_gd_fonts']) -1)], - 'M' => $chars['M'][mt_rand(0, min(count($chars['M']), $config['captcha_gd_fonts']) -1)], - 'N' => $chars['N'][mt_rand(0, min(count($chars['N']), $config['captcha_gd_fonts']) -1)], - 'O' => $chars['O'][mt_rand(0, min(count($chars['O']), $config['captcha_gd_fonts']) -1)], - 'P' => $chars['P'][mt_rand(0, min(count($chars['P']), $config['captcha_gd_fonts']) -1)], - 'Q' => $chars['Q'][mt_rand(0, min(count($chars['Q']), $config['captcha_gd_fonts']) -1)], - 'R' => $chars['R'][mt_rand(0, min(count($chars['R']), $config['captcha_gd_fonts']) -1)], - 'S' => $chars['S'][mt_rand(0, min(count($chars['S']), $config['captcha_gd_fonts']) -1)], - 'T' => $chars['T'][mt_rand(0, min(count($chars['T']), $config['captcha_gd_fonts']) -1)], - 'U' => $chars['U'][mt_rand(0, min(count($chars['U']), $config['captcha_gd_fonts']) -1)], - 'V' => $chars['V'][mt_rand(0, min(count($chars['V']), $config['captcha_gd_fonts']) -1)], - 'W' => $chars['W'][mt_rand(0, min(count($chars['W']), $config['captcha_gd_fonts']) -1)], - 'X' => $chars['X'][mt_rand(0, min(count($chars['X']), $config['captcha_gd_fonts']) -1)], - 'Y' => $chars['Y'][mt_rand(0, min(count($chars['Y']), $config['captcha_gd_fonts']) -1)], - 'Z' => $chars['Z'][mt_rand(0, min(count($chars['Z']), $config['captcha_gd_fonts']) -1)], + 'A' => $chars['A'][mt_rand(0, min(sizeof($chars['A']), $config['captcha_gd_fonts']) -1)], + 'B' => $chars['B'][mt_rand(0, min(sizeof($chars['B']), $config['captcha_gd_fonts']) -1)], + 'C' => $chars['C'][mt_rand(0, min(sizeof($chars['C']), $config['captcha_gd_fonts']) -1)], + 'D' => $chars['D'][mt_rand(0, min(sizeof($chars['D']), $config['captcha_gd_fonts']) -1)], + 'E' => $chars['E'][mt_rand(0, min(sizeof($chars['E']), $config['captcha_gd_fonts']) -1)], + 'F' => $chars['F'][mt_rand(0, min(sizeof($chars['F']), $config['captcha_gd_fonts']) -1)], + 'G' => $chars['G'][mt_rand(0, min(sizeof($chars['G']), $config['captcha_gd_fonts']) -1)], + 'H' => $chars['H'][mt_rand(0, min(sizeof($chars['H']), $config['captcha_gd_fonts']) -1)], + 'I' => $chars['I'][mt_rand(0, min(sizeof($chars['I']), $config['captcha_gd_fonts']) -1)], + 'J' => $chars['J'][mt_rand(0, min(sizeof($chars['J']), $config['captcha_gd_fonts']) -1)], + 'K' => $chars['K'][mt_rand(0, min(sizeof($chars['K']), $config['captcha_gd_fonts']) -1)], + 'L' => $chars['L'][mt_rand(0, min(sizeof($chars['L']), $config['captcha_gd_fonts']) -1)], + 'M' => $chars['M'][mt_rand(0, min(sizeof($chars['M']), $config['captcha_gd_fonts']) -1)], + 'N' => $chars['N'][mt_rand(0, min(sizeof($chars['N']), $config['captcha_gd_fonts']) -1)], + 'O' => $chars['O'][mt_rand(0, min(sizeof($chars['O']), $config['captcha_gd_fonts']) -1)], + 'P' => $chars['P'][mt_rand(0, min(sizeof($chars['P']), $config['captcha_gd_fonts']) -1)], + 'Q' => $chars['Q'][mt_rand(0, min(sizeof($chars['Q']), $config['captcha_gd_fonts']) -1)], + 'R' => $chars['R'][mt_rand(0, min(sizeof($chars['R']), $config['captcha_gd_fonts']) -1)], + 'S' => $chars['S'][mt_rand(0, min(sizeof($chars['S']), $config['captcha_gd_fonts']) -1)], + 'T' => $chars['T'][mt_rand(0, min(sizeof($chars['T']), $config['captcha_gd_fonts']) -1)], + 'U' => $chars['U'][mt_rand(0, min(sizeof($chars['U']), $config['captcha_gd_fonts']) -1)], + 'V' => $chars['V'][mt_rand(0, min(sizeof($chars['V']), $config['captcha_gd_fonts']) -1)], + 'W' => $chars['W'][mt_rand(0, min(sizeof($chars['W']), $config['captcha_gd_fonts']) -1)], + 'X' => $chars['X'][mt_rand(0, min(sizeof($chars['X']), $config['captcha_gd_fonts']) -1)], + 'Y' => $chars['Y'][mt_rand(0, min(sizeof($chars['Y']), $config['captcha_gd_fonts']) -1)], + 'Z' => $chars['Z'][mt_rand(0, min(sizeof($chars['Z']), $config['captcha_gd_fonts']) -1)], '1' => array( array(0,0,0,1,1,0,0,0,0), diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index c0b22e5192..aea39b3123 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -207,7 +207,6 @@ class phpbb_default_captcha { if ($this->check_code()) { - // $this->delete_code(); commented out to allow posting.php to repeat the question $this->solved = true; } else @@ -329,17 +328,6 @@ class phpbb_default_captcha return (strcasecmp($this->code, $this->confirm_code) === 0); } - function delete_code() - { - global $db, $user; - - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; - $db->sql_query($sql); - } - function get_attempt_count() { return $this->attempts; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 14dce3cbe3..75fef25a9f 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -379,7 +379,6 @@ class phpbb_captcha_qa { if ($this->check_answer()) { - // $this->delete_code(); commented out to allow posting.php to repeat the question $this->solved = true; } else @@ -566,20 +565,6 @@ class phpbb_captcha_qa return $this->solved; } - /** - * API function - clean the entry - */ - function delete_code() - { - global $db, $user; - - $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; - $db->sql_query($sql); - } - /** * API function */ diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 64fef28cfa..354dc85c03 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -103,15 +103,28 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable return count($this->config); } + /** + * Removes a configuration option + * + * @param String $key The configuration option's name + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached + * @return void + */ + public function delete($key, $use_cache = true) + { + unset($this->config[$key]); + } + /** * Sets a configuration option's value * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. + * @param string $key The configuration option's name + * @param string $value New configuration value + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached. */ - public function set($key, $value, $cache = true) + public function set($key, $value, $use_cache = true) { $this->config[$key] = $value; } @@ -122,16 +135,16 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * * @param string $key The configuration option's name * @param string $old_value Current configuration value - * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it + * @param string $new_value New configuration value + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. * @return bool True if the value was changed, false otherwise. */ - public function set_atomic($key, $old_value, $value, $cache = true) + public function set_atomic($key, $old_value, $new_value, $use_cache = true) { if (!isset($this->config[$key]) || $this->config[$key] == $old_value) { - $this->config[$key] = $value; + $this->config[$key] = $new_value; return true; } return false; @@ -142,10 +155,10 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * * @param string $key The configuration option's name * @param int $increment Amount to increment by - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. */ - function increment($key, $increment, $cache = true) + function increment($key, $increment, $use_cache = true) { if (!isset($this->config[$key])) { diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 74fb0504ce..a2db4056df 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -90,17 +90,39 @@ class phpbb_config_db extends phpbb_config parent::__construct($config); } + /** + * Removes a configuration option + * + * @param String $key The configuration option's name + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached + * @return void + */ + public function delete($key, $use_cache = true) + { + $sql = 'DELETE FROM ' . $this->table . " + WHERE config_name = '" . $this->db->sql_escape($key) . "'"; + $this->db->sql_query($sql); + + unset($this->config[$key]); + + if ($use_cache) + { + $this->cache->destroy('config'); + } + } + /** * Sets a configuration option's value * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. + * @param string $key The configuration option's name + * @param string $value New configuration value + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached. */ - public function set($key, $value, $cache = true) + public function set($key, $value, $use_cache = true) { - $this->set_atomic($key, false, $value, $cache); + $this->set_atomic($key, false, $value, $use_cache); } /** @@ -111,11 +133,11 @@ class phpbb_config_db extends phpbb_config * @param mixed $old_value Current configuration value or false to ignore * the old value * @param string $new_value New configuration value - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached * @return bool True if the value was changed, false otherwise */ - public function set_atomic($key, $old_value, $new_value, $cache = true) + public function set_atomic($key, $old_value, $new_value, $use_cache = true) { $sql = 'UPDATE ' . $this->table . " SET config_value = '" . $this->db->sql_escape($new_value) . "' @@ -138,11 +160,11 @@ class phpbb_config_db extends phpbb_config $sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( 'config_name' => $key, 'config_value' => $new_value, - 'is_dynamic' => ($cache) ? 0 : 1)); + 'is_dynamic' => ($use_cache) ? 0 : 1)); $this->db->sql_query($sql); } - if ($cache) + if ($use_cache) { $this->cache->destroy('config'); } @@ -159,14 +181,14 @@ class phpbb_config_db extends phpbb_config * * @param string $key The configuration option's name * @param int $increment Amount to increment by - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. */ - function increment($key, $increment, $cache = true) + function increment($key, $increment, $use_cache = true) { if (!isset($this->config[$key])) { - $this->set($key, '0', $cache); + $this->set($key, '0', $use_cache); } $sql_update = $this->db->cast_expr_to_string($this->db->cast_expr_to_bigint('config_value') . ' + ' . (int) $increment); @@ -175,7 +197,7 @@ class phpbb_config_db extends phpbb_config SET config_value = ' . $sql_update . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"); - if ($cache) + if ($use_cache) { $this->cache->destroy('config'); } diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php index 38c0b844d9..9db8e3bd44 100644 --- a/phpBB/includes/cron/task/base.php +++ b/phpBB/includes/cron/task/base.php @@ -51,23 +51,4 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task { return true; } - - /** - * Returns whether this cron task can be run in shutdown function. - * - * By the time shutdown sequence invokes a particular piece of code, - * resources that that code requires may already be released. - * If so, a particular cron task may be marked shutdown function- - * unsafe, and it will be executed in normal program flow. - * - * Generally speaking cron tasks should start off as shutdown function- - * safe, and only be marked shutdown function-unsafe if a problem - * is discovered. - * - * @return bool Whether the cron task is shutdown function-safe. - */ - public function is_shutdown_function_safe() - { - return true; - } } diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index 0e9de05984..96cade0ce5 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -64,21 +64,4 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base global $config; return $config['last_queue_run'] < time() - $config['queue_interval_config']; } - - /** - * Returns whether this cron task can be run in shutdown function. - * - * A user reported that using the mail() function during shutdown - * function execution does not work. Therefore if email is delivered - * via the mail() function (as opposed to SMTP) queue cron task marks - * itself shutdown function-unsafe. - * - * @return bool - */ - public function is_shutdown_function_safe() - { - global $config; - // A user reported using the mail() function while using shutdown does not work. We do not want to risk that. - return !$config['smtp_delivery']; - } } diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 58c4a96f8e..cceccce44f 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -45,20 +45,4 @@ interface phpbb_cron_task * @return bool */ public function should_run(); - - /** - * Returns whether this cron task can be run in shutdown function. - * - * By the time shutdown sequence invokes a particular piece of code, - * resources that that code requires may already be released. - * If so, a particular cron task may be marked shutdown function- - * unsafe, and it will be executed in normal program flow. - * - * Generally speaking cron tasks should start off as shutdown function- - * safe, and only be marked shutdown function-unsafe if a problem - * is discovered. - * - * @return bool - */ - public function is_shutdown_function_safe(); } diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index ed1d67b8e9..148f56b5a8 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -241,6 +241,16 @@ class dbal return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); } + /** + * Returns whether results of a query need to be buffered to run a transaction while iterating over them. + * + * @return bool Whether buffering is required. + */ + function sql_buffer_nested_transaction() + { + return false; + } + /** * SQL Transaction * @access private diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 69476f79f8..8868d4e317 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -28,6 +28,7 @@ class dbal_firebird extends dbal var $last_query_text = ''; var $service_handle = false; var $affected_rows = 0; + var $connect_error = ''; /** * Connect to server @@ -53,9 +54,35 @@ class dbal_firebird extends dbal $use_database = $this->server . ':' . $this->dbname; } - $this->db_connect_id = ($this->persistency) ? @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3); + if ($this->persistency) + { + if (!function_exists('ibase_pconnect')) + { + $this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3); + } + else + { + if (!function_exists('ibase_connect')) + { + $this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3); + } - $this->service_handle = (function_exists('ibase_service_attach') && $this->server) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false; + // Do not call ibase_service_attach if connection failed, + // otherwise error message from ibase_(p)connect call will be clobbered. + if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server) + { + $this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword); + } + else + { + $this->service_handle = false; + } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); } @@ -487,8 +514,24 @@ class dbal_firebird extends dbal */ function _sql_error() { + // Need special handling here because ibase_errmsg returns + // connection errors, however if the interbase extension + // is not installed then ibase_errmsg does not exist and + // we cannot call it. + if (function_exists('ibase_errmsg')) + { + $msg = @ibase_errmsg(); + if (!$msg) + { + $msg = $this->connect_error; + } + } + else + { + $msg = $this->connect_error; + } return array( - 'message' => @ibase_errmsg(), + 'message' => $msg, 'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '') ); } diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index e893d746bc..710a054e5f 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -50,7 +50,7 @@ class result_mssqlnative } } - $this->m_row_count = count($this->m_rows); + $this->m_row_count = sizeof($this->m_rows); } private function array_to_obj($array, &$obj) @@ -258,6 +258,14 @@ class dbal_mssqlnative extends dbal return ($this->sql_server_version) ? 'MSSQL
    ' . $this->sql_server_version : 'MSSQL'; } + /** + * {@inheritDoc} + */ + function sql_buffer_nested_transaction() + { + return true; + } + /** * SQL Transaction * @access private @@ -628,7 +636,7 @@ class dbal_mssqlnative extends dbal return false; } } - + /** * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter. */ diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index fc2e35e13c..e0d9370bd8 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -269,11 +269,12 @@ class dbal_oracle extends dbal { $cols = explode(', ', $regs[2]); + preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); + /* The code inside this comment block breaks clob handling, but does allow the database restore script to work. If you want to allow no posts longer than 4KB and/or need the db restore script, uncomment this. - preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); if (sizeof($cols) !== sizeof($vals)) { diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index 424ce12245..959d8df139 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -18,6 +18,11 @@ if (!defined('IN_PHPBB')) include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); +if (!class_exists('phpbb_error_collector')) +{ + include($phpbb_root_path . 'includes/error_collector.' . $phpEx); +} + /** * PostgreSQL Database Abstraction Layer * Minimum Requirement is Version 7.3+ @@ -26,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_postgres extends dbal { var $last_query_text = ''; + var $connect_error = ''; /** * Connect to server @@ -81,13 +87,29 @@ class dbal_postgres extends dbal if ($this->persistency) { + if (!function_exists('pg_pconnect')) + { + $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?'; + return $this->sql_error(''); + } + $collector = new phpbb_error_collector; + $collector->install(); $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW); } else { + if (!function_exists('pg_connect')) + { + $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?'; + return $this->sql_error(''); + } + $collector = new phpbb_error_collector; + $collector->install(); $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW); } + $collector->uninstall(); + if ($this->db_connect_id) { if (version_compare($this->sql_server_info(true), '8.2', '>=')) @@ -102,6 +124,7 @@ class dbal_postgres extends dbal return $this->db_connect_id; } + $this->connect_error = $collector->format_errors(); return $this->sql_error(''); } @@ -387,8 +410,19 @@ class dbal_postgres extends dbal */ function _sql_error() { + // pg_last_error only works when there is an established connection. + // Connection errors have to be tracked by us manually. + if ($this->db_connect_id) + { + $message = @pg_last_error($this->db_connect_id); + } + else + { + $message = $this->connect_error; + } + return array( - 'message' => (!$this->db_connect_id) ? @pg_last_error() : @pg_last_error($this->db_connect_id), + 'message' => $message, 'code' => '' ); } diff --git a/phpBB/includes/error_collector.php b/phpBB/includes/error_collector.php new file mode 100644 index 0000000000..55834f354c --- /dev/null +++ b/phpBB/includes/error_collector.php @@ -0,0 +1,61 @@ +errors = array(); + } + + function install() + { + set_error_handler(array(&$this, 'error_handler')); + } + + function uninstall() + { + restore_error_handler(); + } + + function error_handler($errno, $msg_text, $errfile, $errline) + { + $this->errors[] = array($errno, $msg_text, $errfile, $errline); + } + + function format_errors() + { + $text = ''; + foreach ($this->errors as $error) + { + if (!empty($text)) + { + $text .= "
    \n"; + } + list($errno, $msg_text, $errfile, $errline) = $error; + $text .= "Errno $errno: $msg_text"; + if (defined('DEBUG_EXTRA') || defined('IN_INSTALL')) + { + $text .= " at $errfile line $errline"; + } + } + return $text; + } +} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 418e8dc51d..63d0f3387a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -48,11 +48,16 @@ function set_var(&$result, $var, $type, $multibyte = false) * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks * @param bool $cookie This param is mapped to phpbb_request_interface::COOKIE as the last param for * phpbb_request_interface::variable for backwards compatability reasons. +* @param phpbb_request_interface|null|false If an instance of phpbb_request_interface is given the instance is stored in +* a static variable and used for all further calls where this parameters is null. Until +* the function is called with an instance it automatically creates a new phpbb_request +* instance on every call. By passing false this per-call instantiation can be restored +* after having passed in a phpbb_request_interface instance. * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ -function request_var($var_name, $default, $multibyte = false, $cookie = false, phpbb_request_interface $request = null) +function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null) { // This is all just an ugly hack to add "Dependency Injection" to a function // the only real code is the function call which maps this function to a method. @@ -67,6 +72,15 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, p return; } } + else if ($request === false) + { + $static_request = null; + + if (empty($var_name)) + { + return; + } + } $tmp_request = $static_request; @@ -168,8 +182,8 @@ function unique_id($extra = 'c') if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10))) { - set_config('rand_seed', $config['rand_seed'], true); set_config('rand_seed_last_update', time(), true); + set_config('rand_seed', $config['rand_seed'], true); $dss_seeded = true; } @@ -444,7 +458,7 @@ function _hash_crypt_private($password, $setting, &$itoa64) $output = '*'; // Check for correct hash - if (substr($setting, 0, 3) != '$H$') + if (substr($setting, 0, 3) != '$H$' && substr($setting, 0, 3) != '$P$') { return $output; } @@ -1309,35 +1323,6 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ { $mark_time = array(); - // Get global announcement info - if ($global_announce_list && sizeof($global_announce_list)) - { - if (!isset($forum_mark_time[0])) - { - global $db; - - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND forum_id = 0"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $mark_time[0] = $row['mark_time']; - } - } - else - { - if ($forum_mark_time[0] !== false) - { - $mark_time[0] = $forum_mark_time[0]; - } - } - } - if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false) { $mark_time[$forum_id] = $forum_mark_time[$forum_id]; @@ -1347,14 +1332,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } @@ -1366,7 +1344,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ */ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false) { - global $config, $user; + global $config, $user, $request; $last_read = array(); @@ -1398,8 +1376,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis $sql = 'SELECT forum_id, mark_time FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} - AND forum_id " . - (($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id"); + AND forum_id = $forum_id"; $result = $db->sql_query($sql); $mark_time = array(); @@ -1413,14 +1390,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } } @@ -1458,13 +1428,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis if (sizeof($topic_ids)) { $mark_time = array(); - if ($global_announce_list && sizeof($global_announce_list)) - { - if (isset($tracking_topics['f'][0])) - { - $mark_time[0] = base_convert($tracking_topics['f'][0], 36, 10) + $config['board_startdate']; - } - } if (isset($tracking_topics['f'][$forum_id])) { @@ -1475,14 +1438,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } } @@ -1630,7 +1586,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s */ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) { - global $db, $tracking_topics, $user, $config; + global $db, $tracking_topics, $user, $config, $request; // Determine the users last forum mark time if not given. if ($mark_time_forum === false) @@ -2069,7 +2025,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) /** * Generate board url (example: http://www.example.com/phpBB) +* * @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) +* +* @return string the generated board url */ function generate_board_url($without_script_path = false) { @@ -3253,7 +3212,7 @@ function get_preg_expression($mode) * Depends on whether installed PHP version supports unicode properties * * @param string $word word template to be replaced -* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode +* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode * * @return string $preg_expr regex to use with word censor */ @@ -4244,7 +4203,7 @@ function phpbb_http_login($param) if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0) { list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2); - } + } if (!is_null($username) && !is_null($password)) { @@ -4595,7 +4554,7 @@ function page_footer($run_cron = true) // Call cron-type script $call_cron = false; - if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable']) + if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot']) { $call_cron = true; $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index d944d9bd62..f28bca91ee 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -1,550 +1,550 @@ -assign_vars(array( - 'PAGE_TITLE' => $page_title, - 'USERNAME' => $user->data['username'], - - 'SID' => $SID, - '_SID' => $_SID, - 'SESSION_ID' => $user->session_id, - 'ROOT_PATH' => $phpbb_admin_path, - - 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'), - 'U_ADM_LOGOUT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'), - 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), - - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", - - 'ICON_MOVE_UP' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_UP_DISABLED' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_DOWN' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_MOVE_DOWN_DISABLED' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_EDIT' => '' . $user->lang['EDIT'] . '', - 'ICON_EDIT_DISABLED' => '' . $user->lang['EDIT'] . '', - 'ICON_DELETE' => '' . $user->lang['DELETE'] . '', - 'ICON_DELETE_DISABLED' => '' . $user->lang['DELETE'] . '', - 'ICON_SYNC' => '' . $user->lang['RESYNC'] . '', - 'ICON_SYNC_DISABLED' => '' . $user->lang['RESYNC'] . '', - - 'S_USER_LANG' => $user->lang['USER_LANG'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', - )); - - // application/xhtml+xml not used because of IE - header('Content-type: text/html; charset=UTF-8'); - - header('Cache-Control: private, no-cache="set-cookie"'); - header('Expires: 0'); - header('Pragma: no-cache'); - - return; -} - -/** -* Page footer for acp pages -*/ -function adm_page_footer($copyright_html = true) -{ - global $db, $config, $template, $user, $auth, $cache; - global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx; - global $request; - - // Output page creation time - if (defined('DEBUG')) - { - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) - { - $db->sql_report('display'); - } - - $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); - - if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) - { - if (function_exists('memory_get_usage')) - { - if ($memory_usage = memory_get_usage()) - { - global $base_memory_usage; - $memory_usage -= $base_memory_usage; - $memory_usage = get_formatted_filesize($memory_usage); - - $debug_output .= ' | Memory Usage: ' . $memory_usage; - } - } - - $debug_output .= ' | Explain'; - } - } - - $template->assign_vars(array( - 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', - 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'S_COPYRIGHT_HTML' => $copyright_html, - 'VERSION' => $config['version']) - ); - - $template->display('body'); - - garbage_collection(); - exit_handler(); -} - -/** -* Generate back link for acp pages -*/ -function adm_back_link($u_action) -{ - global $user; - return '

    « ' . $user->lang['BACK_TO_PREV'] . ''; -} - -/** -* Build select field options in acp pages -*/ -function build_select($option_ary, $option_default = false) -{ - global $user; - - $html = ''; - foreach ($option_ary as $value => $title) - { - $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : ''; - $html .= ''; - } - - return $html; -} - -/** -* Build radio fields in acp pages -*/ -function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false) -{ - global $user; - - $html = ''; - $id_assigned = false; - foreach ($input_ary as $value => $title) - { - $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : ''; - $html .= ''; - $id_assigned = true; - } - - return $html; -} - -/** -* Build configuration template for acp configuration pages -*/ -function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) -{ - global $user, $module; - - $tpl = ''; - $name = 'config[' . $config_key . ']'; - - // Make sure there is no notice printed out for non-existent config options (we simply set them) - if (!isset($new[$config_key])) - { - $new[$config_key] = ''; - } - - switch ($tpl_type[0]) - { - case 'text': - case 'password': - $size = (int) $tpl_type[1]; - $maxlength = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'dimension': - $size = (int) $tpl_type[1]; - $maxlength = (int) $tpl_type[2]; - - $tpl = ' x '; - break; - - case 'textarea': - $rows = (int) $tpl_type[1]; - $cols = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'radio': - $key_yes = ($new[$config_key]) ? ' checked="checked"' : ''; - $key_no = (!$new[$config_key]) ? ' checked="checked"' : ''; - - $tpl_type_cond = explode('_', $tpl_type[1]); - $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true; - - $tpl_no = ''; - $tpl_yes = ''; - - $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes; - break; - - case 'select': - case 'custom': - - $return = ''; - - if (isset($vars['method'])) - { - $call = array($module->module, $vars['method']); - } - else if (isset($vars['function'])) - { - $call = $vars['function']; - } - else - { - break; - } - - if (isset($vars['params'])) - { - $args = array(); - foreach ($vars['params'] as $value) - { - switch ($value) - { - case '{CONFIG_VALUE}': - $value = $new[$config_key]; - break; - - case '{KEY}': - $value = $key; - break; - } - - $args[] = $value; - } - } - else - { - $args = array($new[$config_key], $key); - } - - $return = call_user_func_array($call, $args); - - if ($tpl_type[0] == 'select') - { - $tpl = ''; - } - else - { - $tpl = $return; - } - - break; - - default: - break; - } - - if (isset($vars['append'])) - { - $tpl .= $vars['append']; - } - - return $tpl; -} - -/** -* Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int. -* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required. -*/ -function validate_config_vars($config_vars, &$cfg_array, &$error) -{ - global $phpbb_root_path, $user; - $type = 0; - $min = 1; - $max = 2; - - foreach ($config_vars as $config_name => $config_definition) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - if (!isset($config_definition['validate'])) - { - continue; - } - - $validator = explode(':', $config_definition['validate']); - - // Validate a bit. ;) (0 = type, 1 = min, 2= max) - switch ($validator[$type]) - { - case 'string': - $length = strlen($cfg_array[$config_name]); - - // the column is a VARCHAR - $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255; - - if (isset($validator[$min]) && $length < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $length > $validator[2]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - break; - - case 'bool': - $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; - break; - - case 'int': - $cfg_array[$config_name] = (int) $cfg_array[$config_name]; - - if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max]) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - - if (strpos($config_name, '_max') !== false) - { - // Min/max pairs of settings should ensure that min <= max - // Replace _max with _min to find the name of the minimum - // corresponding configuration variable - $min_name = str_replace('_max', '_min', $config_name); - - if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) - { - // A minimum value exists and the maximum value is less than it - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); - } - } - break; - - // Absolute path - case 'script_path': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = str_replace('\\', '/', $cfg_array[$config_name]); - - if ($destination !== '/') - { - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', './'), '', $destination); - - if ($destination[0] != '/') - { - $destination = '/' . $destination; - } - } - - $cfg_array[$config_name] = trim($destination); - - break; - - // Absolute path - case 'lang': - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = basename($cfg_array[$config_name]); - - if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/')) - { - $error[] = $user->lang['WRONG_DATA_LANG']; - } - break; - - // Relative path (appended $phpbb_root_path) - case 'rpath': - case 'rwpath': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = $cfg_array[$config_name]; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - $cfg_array[$config_name] = trim($destination); - - // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... - case 'path': - case 'wpath': - - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = trim($cfg_array[$config_name]); - - // Make sure no NUL byte is present... - if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false) - { - $cfg_array[$config_name] = ''; - break; - } - - if (!file_exists($phpbb_root_path . $cfg_array[$config_name])) - { - $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); - } - - if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name])) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); - } - - // Check if the path is writable - if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') - { - if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !phpbb_is_writable($phpbb_root_path . $cfg_array[$config_name])) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); - } - } - - break; - } - } - - return; -} - -/** -* Checks whatever or not a variable is OK for use in the Database -* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))' -* param mixed $error The error array -*/ -function validate_range($value_ary, &$error) -{ - global $user; - - $column_types = array( - 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1), - 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535), - 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff), - // Do not use (int) 0x80000000 - it evaluates to different - // values on 32-bit and 64-bit systems. - // Apparently -2147483648 is a float on 32-bit systems, - // despite fitting in an int, thus explicit cast is needed. - 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff), - 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127), - - 'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255), - ); - foreach ($value_ary as $value) - { - $column = explode(':', $value['column_type']); - $max = $min = 0; - $type = 0; - if (!isset($column_types[$column[0]])) - { - continue; - } - else - { - $type = $column_types[$column[0]]; - } - - switch ($type['php_type']) - { - case 'string' : - $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max']; - if (strlen($value['value']) > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max); - } - break; - - case 'int': - $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min']; - $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max']; - if ($value['value'] < $min) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min); - } - else if ($value['value'] > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max); - } - break; - } - } -} +assign_vars(array( + 'PAGE_TITLE' => $page_title, + 'USERNAME' => $user->data['username'], + + 'SID' => $SID, + '_SID' => $_SID, + 'SESSION_ID' => $user->session_id, + 'ROOT_PATH' => $phpbb_admin_path, + + 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'), + 'U_ADM_LOGOUT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'), + 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), + 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), + + 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", + 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", + 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", + 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", + 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", + 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", + 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", + + 'ICON_MOVE_UP' => '' . $user->lang['MOVE_UP'] . '', + 'ICON_MOVE_UP_DISABLED' => '' . $user->lang['MOVE_UP'] . '', + 'ICON_MOVE_DOWN' => '' . $user->lang['MOVE_DOWN'] . '', + 'ICON_MOVE_DOWN_DISABLED' => '' . $user->lang['MOVE_DOWN'] . '', + 'ICON_EDIT' => '' . $user->lang['EDIT'] . '', + 'ICON_EDIT_DISABLED' => '' . $user->lang['EDIT'] . '', + 'ICON_DELETE' => '' . $user->lang['DELETE'] . '', + 'ICON_DELETE_DISABLED' => '' . $user->lang['DELETE'] . '', + 'ICON_SYNC' => '' . $user->lang['RESYNC'] . '', + 'ICON_SYNC_DISABLED' => '' . $user->lang['RESYNC'] . '', + + 'S_USER_LANG' => $user->lang['USER_LANG'], + 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], + 'S_CONTENT_ENCODING' => 'UTF-8', + 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', + 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', + )); + + // application/xhtml+xml not used because of IE + header('Content-type: text/html; charset=UTF-8'); + + header('Cache-Control: private, no-cache="set-cookie"'); + header('Expires: 0'); + header('Pragma: no-cache'); + + return; +} + +/** +* Page footer for acp pages +*/ +function adm_page_footer($copyright_html = true) +{ + global $db, $config, $template, $user, $auth, $cache; + global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $request; + + // Output page creation time + if (defined('DEBUG')) + { + $mtime = explode(' ', microtime()); + $totaltime = $mtime[0] + $mtime[1] - $starttime; + + if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) + { + $db->sql_report('display'); + } + + $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); + + if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) + { + if (function_exists('memory_get_usage')) + { + if ($memory_usage = memory_get_usage()) + { + global $base_memory_usage; + $memory_usage -= $base_memory_usage; + $memory_usage = get_formatted_filesize($memory_usage); + + $debug_output .= ' | Memory Usage: ' . $memory_usage; + } + } + + $debug_output .= ' | Explain'; + } + } + + $template->assign_vars(array( + 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', + 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', + 'S_COPYRIGHT_HTML' => $copyright_html, + 'VERSION' => $config['version']) + ); + + $template->display('body'); + + garbage_collection(); + exit_handler(); +} + +/** +* Generate back link for acp pages +*/ +function adm_back_link($u_action) +{ + global $user; + return '

    « ' . $user->lang['BACK_TO_PREV'] . ''; +} + +/** +* Build select field options in acp pages +*/ +function build_select($option_ary, $option_default = false) +{ + global $user; + + $html = ''; + foreach ($option_ary as $value => $title) + { + $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : ''; + $html .= ''; + } + + return $html; +} + +/** +* Build radio fields in acp pages +*/ +function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false) +{ + global $user; + + $html = ''; + $id_assigned = false; + foreach ($input_ary as $value => $title) + { + $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : ''; + $html .= ''; + $id_assigned = true; + } + + return $html; +} + +/** +* Build configuration template for acp configuration pages +*/ +function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) +{ + global $user, $module; + + $tpl = ''; + $name = 'config[' . $config_key . ']'; + + // Make sure there is no notice printed out for non-existent config options (we simply set them) + if (!isset($new[$config_key])) + { + $new[$config_key] = ''; + } + + switch ($tpl_type[0]) + { + case 'text': + case 'password': + $size = (int) $tpl_type[1]; + $maxlength = (int) $tpl_type[2]; + + $tpl = ''; + break; + + case 'dimension': + $size = (int) $tpl_type[1]; + $maxlength = (int) $tpl_type[2]; + + $tpl = ' x '; + break; + + case 'textarea': + $rows = (int) $tpl_type[1]; + $cols = (int) $tpl_type[2]; + + $tpl = ''; + break; + + case 'radio': + $key_yes = ($new[$config_key]) ? ' checked="checked"' : ''; + $key_no = (!$new[$config_key]) ? ' checked="checked"' : ''; + + $tpl_type_cond = explode('_', $tpl_type[1]); + $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true; + + $tpl_no = ''; + $tpl_yes = ''; + + $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes; + break; + + case 'select': + case 'custom': + + $return = ''; + + if (isset($vars['method'])) + { + $call = array($module->module, $vars['method']); + } + else if (isset($vars['function'])) + { + $call = $vars['function']; + } + else + { + break; + } + + if (isset($vars['params'])) + { + $args = array(); + foreach ($vars['params'] as $value) + { + switch ($value) + { + case '{CONFIG_VALUE}': + $value = $new[$config_key]; + break; + + case '{KEY}': + $value = $key; + break; + } + + $args[] = $value; + } + } + else + { + $args = array($new[$config_key], $key); + } + + $return = call_user_func_array($call, $args); + + if ($tpl_type[0] == 'select') + { + $tpl = ''; + } + else + { + $tpl = $return; + } + + break; + + default: + break; + } + + if (isset($vars['append'])) + { + $tpl .= $vars['append']; + } + + return $tpl; +} + +/** +* Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int. +* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required. +*/ +function validate_config_vars($config_vars, &$cfg_array, &$error) +{ + global $phpbb_root_path, $user; + $type = 0; + $min = 1; + $max = 2; + + foreach ($config_vars as $config_name => $config_definition) + { + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + { + continue; + } + + if (!isset($config_definition['validate'])) + { + continue; + } + + $validator = explode(':', $config_definition['validate']); + + // Validate a bit. ;) (0 = type, 1 = min, 2= max) + switch ($validator[$type]) + { + case 'string': + $length = strlen($cfg_array[$config_name]); + + // the column is a VARCHAR + $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255; + + if (isset($validator[$min]) && $length < $validator[$min]) + { + $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]); + } + else if (isset($validator[$max]) && $length > $validator[2]) + { + $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]); + } + break; + + case 'bool': + $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; + break; + + case 'int': + $cfg_array[$config_name] = (int) $cfg_array[$config_name]; + + if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min]) + { + $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]); + } + else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max]) + { + $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); + } + + if (strpos($config_name, '_max') !== false) + { + // Min/max pairs of settings should ensure that min <= max + // Replace _max with _min to find the name of the minimum + // corresponding configuration variable + $min_name = str_replace('_max', '_min', $config_name); + + if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) + { + // A minimum value exists and the maximum value is less than it + $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); + } + } + break; + + // Absolute path + case 'script_path': + if (!$cfg_array[$config_name]) + { + break; + } + + $destination = str_replace('\\', '/', $cfg_array[$config_name]); + + if ($destination !== '/') + { + // Adjust destination path (no trailing slash) + if (substr($destination, -1, 1) == '/') + { + $destination = substr($destination, 0, -1); + } + + $destination = str_replace(array('../', './'), '', $destination); + + if ($destination[0] != '/') + { + $destination = '/' . $destination; + } + } + + $cfg_array[$config_name] = trim($destination); + + break; + + // Absolute path + case 'lang': + if (!$cfg_array[$config_name]) + { + break; + } + + $cfg_array[$config_name] = basename($cfg_array[$config_name]); + + if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/')) + { + $error[] = $user->lang['WRONG_DATA_LANG']; + } + break; + + // Relative path (appended $phpbb_root_path) + case 'rpath': + case 'rwpath': + if (!$cfg_array[$config_name]) + { + break; + } + + $destination = $cfg_array[$config_name]; + + // Adjust destination path (no trailing slash) + if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') + { + $destination = substr($destination, 0, -1); + } + + $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); + if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) + { + $destination = ''; + } + + $cfg_array[$config_name] = trim($destination); + + // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... + case 'path': + case 'wpath': + + if (!$cfg_array[$config_name]) + { + break; + } + + $cfg_array[$config_name] = trim($cfg_array[$config_name]); + + // Make sure no NUL byte is present... + if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false) + { + $cfg_array[$config_name] = ''; + break; + } + + if (!file_exists($phpbb_root_path . $cfg_array[$config_name])) + { + $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); + } + + if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name])) + { + $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); + } + + // Check if the path is writable + if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') + { + if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !phpbb_is_writable($phpbb_root_path . $cfg_array[$config_name])) + { + $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); + } + } + + break; + } + } + + return; +} + +/** +* Checks whatever or not a variable is OK for use in the Database +* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))' +* param mixed $error The error array +*/ +function validate_range($value_ary, &$error) +{ + global $user; + + $column_types = array( + 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1), + 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535), + 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff), + // Do not use (int) 0x80000000 - it evaluates to different + // values on 32-bit and 64-bit systems. + // Apparently -2147483648 is a float on 32-bit systems, + // despite fitting in an int, thus explicit cast is needed. + 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff), + 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127), + + 'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255), + ); + foreach ($value_ary as $value) + { + $column = explode(':', $value['column_type']); + $max = $min = 0; + $type = 0; + if (!isset($column_types[$column[0]])) + { + continue; + } + else + { + $type = $column_types[$column[0]]; + } + + switch ($type['php_type']) + { + case 'string' : + $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max']; + if (strlen($value['value']) > $max) + { + $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max); + } + break; + + case 'int': + $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min']; + $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max']; + if ($value['value'] < $min) + { + $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min); + } + else if ($value['value'] > $max) + { + $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max); + } + break; + } + } +} diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 1468345003..ee59d77cdb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2208,6 +2208,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync if (!($prune_flags & FORUM_FLAG_PRUNE_ANNOUNCE)) { $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; + $sql_and .= ' AND topic_type <> ' . POST_GLOBAL; } if (!($prune_flags & FORUM_FLAG_PRUNE_STICKY)) @@ -2695,29 +2696,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) + if ($auth->acl_get('f_read', $row['forum_id'])) { - if ($auth->acl_getf_global('f_read')) - { - if (!$default_forum_id) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - $f_result = $db->sql_query_limit($sql, 1); - $default_forum_id = (int) $db->sql_fetchfield('forum_id', false, $f_result); - $db->sql_freeresult($f_result); - } - - $is_auth[$row['topic_id']] = $default_forum_id; - } - } - else - { - if ($auth->acl_get('f_read', $row['forum_id'])) - { - $is_auth[$row['topic_id']] = $row['forum_id']; - } + $is_auth[$row['topic_id']] = $row['forum_id']; } if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index eb64a115c6..abc5b3e29f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -104,18 +104,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; - // Check for unread global announcements (index page only) - $ga_unread = false; - if ($root_data['forum_id'] == 0) - { - $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); - - if (!empty($unread_ga_list)) - { - $ga_unread = true; - } - } - while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; @@ -269,8 +257,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else { - // Add 0 to forums array to mark global announcements correctly - $forum_ids[] = 0; markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); } @@ -323,12 +309,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; - // Mark the first visible forum on index as unread if there's any unread global announcement - if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0]) - { - $forum_unread = true; - } - $folder_image = $folder_alt = $l_subforums = ''; $subforums_list = array(); @@ -464,6 +444,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'TOPICS' => $row['forum_topics'], $l_post_click_count => $post_click_count, + 'FORUM_IMG_STYLE' => $folder_image, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 61cc096e26..0bb0ef8722 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -338,7 +338,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) $topic_type_array[] = array( 'VALUE' => $topic_value['const'], - 'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '', + 'S_CHECKED' => ($cur_topic_type == $topic_value['const']) ? ' checked="checked"' : '', 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] ); } @@ -560,7 +560,6 @@ function get_supported_image_types($type = false) if ($type !== false) { // Type is one of the IMAGETYPE constants - it is fetched from getimagesize() - // We do not use the constants here, because some were not available in PHP 4.3.x switch ($type) { // GIF @@ -1465,11 +1464,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) delete_topics('topic_id', array($topic_id), false); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; - $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; - } + $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; + $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1489,10 +1485,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time']; @@ -1503,10 +1496,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) break; case 'delete_last_post': - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1548,10 +1538,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); $next_post_id = (int) $row['post_id']; @@ -1703,7 +1690,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'post': case 'reply': $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'poster_id' => (int) $user->data['user_id'], 'icon_id' => $data['icon_id'], 'poster_ip' => $user->ip, @@ -1771,7 +1758,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'poster_id' => $data['poster_id'], 'icon_id' => $data['icon_id'], 'post_approved' => (!$post_approval) ? 0 : $data['post_approved'], @@ -1807,7 +1794,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'topic_poster' => (int) $user->data['user_id'], 'topic_time' => $current_time, 'topic_last_view_time' => $current_time, - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => $post_approval, 'topic_title' => $subject, @@ -1843,14 +1830,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); - if ($topic_type != POST_GLOBAL) + if ($post_approval) { - if ($post_approval) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; - } - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : ''); + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : ''); break; case 'reply': @@ -1863,7 +1847,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); - if ($post_approval && $topic_type != POST_GLOBAL) + if ($post_approval) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } @@ -1887,7 +1871,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => (!$post_approval) ? 0 : $data['topic_approved'], 'topic_title' => $subject, @@ -2002,61 +1986,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u unset($sql_data[POSTS_TABLE]['sql']); } - $make_global = false; - - // Are we globalising or unglobalising? - if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic') - { - if (!sizeof($topic_row)) - { - $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $data['topic_id']; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - // globalise/unglobalise? - if (($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) || ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)) - { - if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat'])) - { - $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']); - } - - $make_global = true; - $sql_data[FORUMS_TABLE]['stat'] = array(); - } - - // globalise - if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) - { - // Decrement topic/post count - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - // unglobalise - else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) - { - // Increment topic/post count - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($topic_row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics + 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . $data['forum_id'] . ' - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - } - // Update the topics table if (isset($sql_data[TOPICS_TABLE]['sql'])) { @@ -2219,9 +2148,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // we need to update the last forum information - // only applicable if the topic is not global and it is approved - // we also check to make sure we are not dealing with globaling the latest topic (pretty rare but still needs to be checked) - if ($topic_type != POST_GLOBAL && !$make_global && ($post_approved || !$data['post_approved'])) + // only applicable if the topic is approved + if ($post_approved || !$data['post_approved']) { // the last post makes us update the forum table. This can happen if... // We make a new topic @@ -2311,78 +2239,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } } } - else if ($make_global) - { - // somebody decided to be a party pooper, we must recalculate the whole shebang (maybe) - $sql = 'SELECT forum_last_post_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $data['forum_id']; - $result = $db->sql_query($sql); - $forum_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // we made a topic global, go get new data - if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id']) - { - // we need a fresh change of socks, everything has become invalidated - $sql = 'SELECT MAX(topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . (int) $data['forum_id'] . ' - AND topic_approved = 1'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // any posts left in this forum? - if (!empty($row['last_post_id'])) - { - $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND p.post_id = ' . (int) $row['last_post_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // salvation, a post is found! jam it into the forums table - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - } - else - { - // just our luck, the last topic in the forum has just been globalized... - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = ''"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = ''"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''"; - } - } - else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL && $forum_row['forum_last_post_id'] < $topic_row['topic_last_post_id']) - { - // this post has a higher id, it is newer - $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND p.post_id = ' . (int) $topic_row['topic_last_post_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // salvation, a post is found! jam it into the forums table - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - } - } // topic sync time! // simply, we update if it is a reply or the last post is edited @@ -2470,7 +2326,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement - if ($make_global) + if ($topic_type == POST_GLOBAL) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = ' . $data['topic_id']; @@ -2514,7 +2370,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u trigger_error($error); } - $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); + $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $data['forum_id']); } // Topic Notification, do not change if moderator is changing other users posts... @@ -2543,7 +2399,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time()); + markread('topic', $data['forum_id'], $data['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -2551,7 +2407,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); + AND forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); @@ -2564,23 +2420,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) { // Update forum info - if ($topic_type == POST_GLOBAL) - { - $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0'; - } - else - { - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data['forum_id']; - } + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); - update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false); + update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); } // Send Notifications diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index d3f9e0dda1..8c58c33b0d 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -322,7 +322,7 @@ class template_compile // Is the designer wanting to call another loop in a loop? if (strpos($tag_args, '!') === 0) { - // Count the number if ! occurrences (not allowed in vars) + // Count the number of ! occurrences (not allowed in vars) $no_nesting = substr_count($tag_args, '!'); $tag_args = substr($tag_args, $no_nesting); } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9b16a56b1c..de01c3e5cb 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -761,7 +761,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } else { - trigger_error('LENGTH_BAN_INVALID'); + trigger_error('LENGTH_BAN_INVALID', E_USER_WARNING); } } } @@ -821,7 +821,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas // Make sure we have been given someone to ban if (!sizeof($sql_usernames)) { - trigger_error('NO_USER_SPECIFIED'); + trigger_error('NO_USER_SPECIFIED', E_USER_WARNING); } $sql = 'SELECT user_id @@ -852,7 +852,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas else { $db->sql_freeresult($result); - trigger_error('NO_USERS'); + trigger_error('NO_USERS', E_USER_WARNING); } $db->sql_freeresult($result); break; @@ -954,7 +954,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (empty($banlist_ary)) { - trigger_error('NO_IPS_DEFINED'); + trigger_error('NO_IPS_DEFINED', E_USER_WARNING); } } break; @@ -982,12 +982,12 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (sizeof($ban_list) == 0) { - trigger_error('NO_EMAILS_DEFINED'); + trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING); } break; default: - trigger_error('NO_MODE'); + trigger_error('NO_MODE', E_USER_WARNING); break; } @@ -1449,6 +1449,31 @@ function validate_match($string, $optional = false, $match = '') return false; } +/** +* Validate Language Pack ISO Name +* +* Tests whether a language name is valid and installed +* +* @param string $lang_iso The language string to test +* +* @return bool|string Either false if validation succeeded or +* a string which will be used as the error message +* (with the variable name appended) +*/ +function validate_language_iso_name($lang_iso) +{ + global $db; + + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'"; + $result = $db->sql_query($sql); + $lang_id = (int) $db->sql_fetchfield('lang_id'); + $db->sql_freeresult($result); + + return ($lang_id) ? false : 'WRONG_DATA'; +} + /** * Check to see if the username has been taken, or if it is disallowed. * Also checks if it includes the " character, which we don't allow in usernames. @@ -1608,8 +1633,9 @@ function validate_password($password) { global $config, $db, $user; - if (!$password) + if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY') { + // Password empty or no password complexity required. return false; } @@ -1620,7 +1646,6 @@ function validate_password($password) { $upp = '\p{Lu}'; $low = '\p{Ll}'; - $let = '\p{L}'; $num = '\p{N}'; $sym = '[^\p{Lu}\p{Ll}\p{N}]'; $pcre = true; @@ -1630,7 +1655,6 @@ function validate_password($password) mb_regex_encoding('UTF-8'); $upp = '[[:upper:]]'; $low = '[[:lower:]]'; - $let = '[[:lower:][:upper:]]'; $num = '[[:digit:]]'; $sym = '[^[:upper:][:lower:][:digit:]]'; $mbstring = true; @@ -1639,7 +1663,6 @@ function validate_password($password) { $upp = '[A-Z]'; $low = '[a-z]'; - $let = '[a-zA-Z]'; $num = '[0-9]'; $sym = '[^A-Za-z0-9]'; $pcre = true; @@ -1649,22 +1672,22 @@ function validate_password($password) switch ($config['pass_complex']) { + // No break statements below ... + // We require strong passwords in case pass_complex is not set or is invalid + default: + + // Require mixed case letters, numbers and symbols + case 'PASS_TYPE_SYMBOL': + $chars[] = $sym; + + // Require mixed case letters and numbers + case 'PASS_TYPE_ALPHA': + $chars[] = $num; + + // Require mixed case letters case 'PASS_TYPE_CASE': $chars[] = $low; $chars[] = $upp; - break; - - case 'PASS_TYPE_ALPHA': - $chars[] = $let; - $chars[] = $num; - break; - - case 'PASS_TYPE_SYMBOL': - $chars[] = $low; - $chars[] = $upp; - $chars[] = $num; - $chars[] = $sym; - break; } if ($pcre) @@ -2485,6 +2508,69 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (!sizeof($error)) { + $current_legend = phpbb_group_positions::GROUP_DISABLED; + $current_teampage = phpbb_group_positions::GROUP_DISABLED; + + $legend = new phpbb_group_positions($db, 'legend'); + $teampage = new phpbb_group_positions($db, 'teampage'); + if ($group_id) + { + $current_legend = $legend->get_group_value($group_id); + $current_teampage = $teampage->get_group_value($group_id); + } + + if (!empty($group_attributes['group_legend'])) + { + if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) + { + // Old group currently not in the legend or new group, add at the end. + $group_attributes['group_legend'] = 1 + $legend->get_group_count(); + } + else + { + // Group stayes in the legend + $group_attributes['group_legend'] = $current_legend; + } + } + else if ($group_id && ($current_legend > phpbb_group_positions::GROUP_DISABLED)) + { + // Group is removed from the legend + $legend->delete_group($group_id, true); + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + + if (!empty($group_attributes['group_teampage'])) + { + if (($group_id && ($current_teampage == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) + { + // Old group currently not on the teampage or new group, add at the end. + $group_attributes['group_teampage'] = 1 + $teampage->get_group_count(); + } + else + { + // Group stayes on the teampage + $group_attributes['group_teampage'] = $current_teampage; + } + } + else if ($group_id && ($current_teampage > phpbb_group_positions::GROUP_DISABLED)) + { + // Group is removed from the teampage + $teampage->delete_group($group_id, true); + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + + // Unset the objects, we don't need them anymore. + unset($legend); + unset($teampage); + $user_ary = array(); $sql_ary = array( 'group_name' => (string) $name, @@ -2709,6 +2795,14 @@ function group_delete($group_id, $group_name = false) } while ($start); + // Delete group from legend and teampage + $legend = new phpbb_group_positions($db, 'legend'); + $legend->delete_group($group_id); + unset($legend); + $teampage = new phpbb_group_positions($db, 'teampage'); + $teampage->delete_group($group_id); + unset($teampage); + // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; diff --git a/phpBB/includes/group_positions.php b/phpBB/includes/group_positions.php new file mode 100644 index 0000000000..fc44e3249d --- /dev/null +++ b/phpBB/includes/group_positions.php @@ -0,0 +1,261 @@ +adm_back_link = $adm_back_link; + + if (!in_array($field, array('teampage', 'legend'))) + { + $this->error('NO_MODE'); + } + + $this->db = $db; + $this->field = $field; + } + + /** + * Returns the group_{$this->field} for a given group, if the group exists. + * @param int $group_id group_id of the group to be selected + * @return int position of the group + */ + public function get_group_value($group_id) + { + $sql = 'SELECT group_' . $this->field . ' + FROM ' . GROUPS_TABLE . ' + WHERE group_id = ' . (int) $group_id; + $result = $this->db->sql_query($sql); + $current_value = $this->db->sql_fetchfield('group_' . $this->field); + $this->db->sql_freeresult($result); + + if ($current_value === false) + { + // Group not found. + $this->error('NO_GROUP'); + } + + return (int) $current_value; + } + + /** + * Get number of groups, displayed on the teampage/legend + * + * @return int value of the last group displayed + */ + public function get_group_count() + { + $sql = 'SELECT group_' . $this->field . ' + FROM ' . GROUPS_TABLE . ' + ORDER BY group_' . $this->field . ' DESC'; + $result = $this->db->sql_query_limit($sql, 1); + $group_count = (int) $this->db->sql_fetchfield('group_' . $this->field); + $this->db->sql_freeresult($result); + + return $group_count; + } + + /** + * Addes a group by group_id + * + * @param int $group_id group_id of the group to be added + * @return void + */ + public function add_group($group_id) + { + $current_value = $this->get_group_value($group_id); + + if ($current_value == self::GROUP_DISABLED) + { + // Group is currently not displayed, add it at the end. + $next_value = 1 + $this->get_group_count(); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = ' . $next_value . ' + WHERE group_' . $this->field . ' = ' . self::GROUP_DISABLED . ' + AND group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + } + + /** + * Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list. + * + * @param int $group_id group_id of the group to be deleted + * @param bool $skip_group Skip setting the group to GROUP_DISABLED, to save the query, when you need to update it anyway. + * @return void + */ + public function delete_group($group_id, $skip_group = false) + { + $current_value = $this->get_group_value($group_id); + + if ($current_value != self::GROUP_DISABLED) + { + $this->db->sql_transaction('begin'); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . ' - 1 + WHERE group_' . $this->field . ' > ' . $current_value; + $this->db->sql_query($sql); + + if (!$skip_group) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = ' . self::GROUP_DISABLED . ' + WHERE group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + + $this->db->sql_transaction('commit'); + } + } + + /** + * Moves a group up by group_id + * + * @param int $group_id group_id of the group to be moved + * @return void + */ + public function move_up($group_id) + { + $this->move($group_id, 1); + } + + /** + * Moves a group down by group_id + * + * @param int $group_id group_id of the group to be moved + * @return void + */ + public function move_down($group_id) + { + $this->move($group_id, -1); + } + + /** + * Moves a group up/down + * + * @param int $group_id group_id of the group to be moved + * @param int $delta number of steps: + * - positive = move up + * - negative = move down + * @return void + */ + public function move($group_id, $delta) + { + if (!is_int($delta) || !$delta) + { + return; + } + + $move_up = ($delta > 0) ? true : false; + $current_value = $this->get_group_value($group_id); + + if ($current_value != self::GROUP_DISABLED) + { + $this->db->sql_transaction('begin'); + + // First we move all groups between our current value and the target value up/down 1, + // so we have a gap for our group to move. + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . (($move_up) ? ' + 1' : ' - 1') . ' + WHERE group_' . $this->field . ' > ' . self::GROUP_DISABLED . ' + AND group_' . $this->field . (($move_up) ? ' >= ' : ' <= ') . ($current_value - $delta) . ' + AND group_' . $this->field . (($move_up) ? ' < ' : ' > ') . $current_value; + $this->db->sql_query($sql); + + // Because there might be fewer groups above/below the group than we wanted to move, + // we use the number of changed groups, to update the group. + $delta = (int) $this->db->sql_affectedrows(); + + if ($delta) + { + // And now finally, when we moved some other groups and built a gap, + // we can move the desired group to it. + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_' . $this->field . ' = group_' . $this->field . (($move_up) ? ' - ' : ' + ') . $delta . ' + WHERE group_id = ' . (int) $group_id; + $this->db->sql_query($sql); + } + + $this->db->sql_transaction('commit'); + } + } + + /** + * Get group type language var + * + * @param int $group_type group_type from the groups-table + * @return string name of the language variable for the given group-type. + */ + static public function group_type_language($group_type) + { + switch ($group_type) + { + case GROUP_OPEN: + return 'GROUP_REQUEST'; + case GROUP_CLOSED: + return 'GROUP_CLOSED'; + case GROUP_HIDDEN: + return 'GROUP_HIDDEN'; + case GROUP_SPECIAL: + return 'GROUP_SPECIAL'; + case GROUP_FREE: + return 'GROUP_OPEN'; + } + } + + /** + * Error + */ + public function error($message) + { + global $user; + trigger_error($user->lang[$message] . (($this->adm_back_link) ? adm_back_link($this->adm_back_link) : ''), E_USER_WARNING); + } +} diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index cf49e478a7..f170dd68eb 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -150,10 +150,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $read_tracking_join = $read_tracking_select = ''; } - $sql = "SELECT t.topic_id - FROM " . TOPICS_TABLE . " t - WHERE t.forum_id IN($forum_id, 0) - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.forum_id = ' . $forum_id . ' + ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); @@ -188,11 +188,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info) { if ($config['load_db_lastread']) { - $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); + $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } @@ -225,6 +225,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $topic_row = array( 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 7375e20d96..eca67c5ac1 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action) { $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); @@ -47,8 +47,6 @@ function mcp_front_view($id, $mode, $action) if ($total) { - $global_id = $forum_list[0]; - $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); @@ -62,7 +60,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0 ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); @@ -91,17 +89,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('unapproved', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), @@ -109,7 +101,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], @@ -159,15 +151,13 @@ function mcp_front_view($id, $mode, $action) WHERE r.post_id = p.post_id AND r.pm_id = 0 AND r.report_closed = 0 - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; + AND ' . $db->sql_in_set('p.forum_id', $forum_list); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { - $global_id = $forum_list[0]; - $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', @@ -193,7 +183,7 @@ function mcp_front_view($id, $mode, $action) AND p.topic_id = t.topic_id AND r.user_id = u.user_id AND p.poster_id = u2.user_id - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', + AND ' . $db->sql_in_set('p.forum_id', $forum_list), 'ORDER_BY' => 'p.post_time DESC' )); @@ -201,17 +191,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('report', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view"), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), @@ -224,7 +208,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), - 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), @@ -347,9 +331,6 @@ function mcp_front_view($id, $mode, $action) if (!empty($forum_list)) { - // Add forum_id 0 for global announcements - $forum_list[] = 0; - $log_count = false; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index db7bc7c7ea..6c6c5a5532 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -333,131 +333,22 @@ function change_topic_type($action, $topic_ids) if (confirm_box(true)) { - if ($new_topic_type != POST_GLOBAL) + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_type = $new_topic_type + WHERE " . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + + if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids)) { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; + // Delete topic shadows for global announcements + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); $db->sql_query($sql); - // Reset forum id if a global topic is within the array - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $to_forum_id); - } - } - else - { - // Get away with those topics already being a global announcement by re-calculating $topic_ids - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (sizeof($topic_ids)) - { - // Delete topic shadows for global announcements - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = 0 - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $forum_id); - } + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_type = $new_topic_type + WHERE " . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); } $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; @@ -474,41 +365,7 @@ function change_topic_type($action, $topic_ids) } else { - // Global topic involved? - $global_involved = false; - - if ($new_topic_type != POST_GLOBAL) - { - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $global_involved = true; - } - } - - if ($global_involved) - { - global $template; - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true), - 'S_CAN_LEAVE_SHADOW' => false, - 'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS']) - ); - - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html'); - } - else - { - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); - } + confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); } $redirect = request_var('redirect', "index.$phpEx"); @@ -628,16 +485,13 @@ function mcp_move_topic($topic_ids) $topic_posts_added += $topic_info['topic_replies']; - if ($topic_info['topic_type'] != POST_GLOBAL) - { - $topics_removed++; - $topic_posts_removed += $topic_info['topic_replies']; + $topics_removed++; + $topic_posts_removed += $topic_info['topic_replies']; - if ($topic_info['topic_approved']) - { - $topics_authed_removed++; - $topic_posts_removed++; - } + if ($topic_info['topic_approved']) + { + $topics_authed_removed++; + $topic_posts_removed++; } } @@ -675,15 +529,6 @@ function mcp_move_topic($topic_ids) $forum_ids[] = $row['forum_id']; add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']); - // If we have moved a global announcement, we need to correct the topic type - if ($row['topic_type'] == POST_GLOBAL) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_type = ' . POST_ANNOUNCE . ' - WHERE topic_id = ' . (int) $row['topic_id']; - $db->sql_query($sql); - } - // Leave a redirection if required and only if the topic is visible to users if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL) { @@ -1058,37 +903,38 @@ function mcp_fork_topic($topic_ids) $total_posts = 0; $new_topic_id_list = array(); - if ($topic_data['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = basename($config['search_type']); - - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - if (!class_exists($search_type)) - { - include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); - } - - $error = false; - $search = new $search_type($error); - $search_mode = 'post'; - - if ($error) - { - trigger_error($error); - } - } - else - { - $search_type = false; - } foreach ($topic_data as $topic_id => $topic_row) { + if (!isset($search_type) && $topic_row['enable_indexing']) + { + // Select the search method and do some additional checks to ensure it can actually be utilised + $search_type = basename($config['search_type']); + + if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + { + trigger_error('NO_SUCH_SEARCH_MODULE'); + } + + if (!class_exists($search_type)) + { + include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + } + + $error = false; + $search = new $search_type($error); + $search_mode = 'post'; + + if ($error) + { + trigger_error($error); + } + } + else if (!isset($search_type) && !$topic_row['enable_indexing']) + { + $search_type = false; + } + $sql_ary = array( 'forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], @@ -1197,9 +1043,9 @@ function mcp_fork_topic($topic_ids) // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); - if ($search_type) + if (!empty($search_type)) { - $search->index($search_mode, $sql_ary['post_id'], $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); + $search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); $search_mode = 'reply'; // After one we index replies } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a5e0e426be..0630f55b12 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -268,13 +268,11 @@ class mcp_queue trigger_error('NOT_MODERATOR'); } - $global_id = $forum_list[0]; - $forum_list = implode(', ', $forum_list); $sql = 'SELECT SUM(forum_topics) as sum_forum_topics - FROM ' . FORUMS_TABLE . " - WHERE forum_id IN (0, $forum_list)"; + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); @@ -290,7 +288,6 @@ class mcp_queue $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; - $global_id = $forum_id; } $forum_options = ''; @@ -312,10 +309,10 @@ class mcp_queue if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . " - WHERE p.forum_id IN (0, $forum_list) + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' + WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' AND p.post_approved = 0 - " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' + ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id AND t.topic_first_post_id <> p.post_id @@ -345,10 +342,7 @@ class mcp_queue $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); @@ -368,7 +362,7 @@ class mcp_queue { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t - WHERE forum_id IN (0, $forum_list) + WHERE " . $db->sql_in_set('forum_id', $forum_list) . " AND topic_approved = 0 $limit_time_sql ORDER BY $sort_order_sql"; @@ -377,10 +371,7 @@ class mcp_queue $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $rowset[] = $row; } $db->sql_freeresult($result); @@ -404,12 +395,6 @@ class mcp_queue foreach ($rowset as $row) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - if (empty($row['post_username'])) { $row['post_username'] = $user->lang['GUEST']; @@ -417,7 +402,7 @@ class mcp_queue $template->assign_block_vars('postrow', array( 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&start=$start&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&t={$row['topic_id']}" : '')), @@ -427,7 +412,7 @@ class mcp_queue 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time'])) @@ -504,11 +489,7 @@ function approve_post($post_id_list, $id, $mode) } $topic_id_list[$post_data['topic_id']] = 1; - - if ($post_data['forum_id']) - { - $forum_id_list[$post_data['forum_id']] = 1; - } + $forum_id_list[$post_data['forum_id']] = 1; // User post update (we do not care about topic or post, since user posts are strictly connected to posts) // But we care about forums where post counts get not increased. ;) @@ -520,10 +501,7 @@ function approve_post($post_id_list, $id, $mode) // Topic or Post. ;) if ($post_data['topic_first_post_id'] == $post_id) { - if ($post_data['forum_id']) - { - $total_topics++; - } + $total_topics++; $topic_approve_sql[] = $post_data['topic_id']; $approve_log[] = array( @@ -543,16 +521,13 @@ function approve_post($post_id_list, $id, $mode) ); } - if ($post_data['forum_id']) - { - $total_posts++; + $total_posts++; - // Increment by topic_replies if we approve a topic... - // This works because we do not adjust the topic_replies when re-approving a topic after an edit. - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) - { - $total_posts += $post_data['topic_replies']; - } + // Increment by topic_replies if we approve a topic... + // This works because we do not adjust the topic_replies when re-approving a topic after an edit. + if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) + { + $total_posts += $post_data['topic_replies']; } $post_approve_sql[] = $post_id; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index f6e46b57ee..a7275382e6 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -312,7 +312,6 @@ class mcp_reports $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); - $global_id = $forum_id; } $forum_list[] = 0; @@ -382,14 +381,8 @@ class mcp_reports $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('postrow', array( - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), @@ -403,7 +396,7 @@ class mcp_reports 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 6d33723292..c6132d86d4 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -110,19 +110,19 @@ class bbcode_firstpass extends bbcode // order, so it is important to keep [code] in first position and // [quote] in second position. $this->bbcodes = array( - 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), - 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), - 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), - 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")), - 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")), - 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), - 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), - 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), - 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), - 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), - 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), - 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) + 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uise' => "\$this->bbcode_code('\$1', '\$2')")), + 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uise' => "\$this->bbcode_quote('\$0')")), + 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#uise' => "\$this->bbcode_attachment('\$1', '\$2')")), + 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->bbcode_strong('\$1')")), + 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#uise' => "\$this->bbcode_italic('\$1')")), + 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#uiUe' => "\$this->validate_url('\$2', '\$3')")), + 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#uiUe' => "\$this->bbcode_img('\$1')")), + 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uise' => "\$this->bbcode_size('\$1', '\$2')")), + 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uise' => "\$this->bbcode_color('\$1', '\$2')")), + 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#uise' => "\$this->bbcode_underline('\$1')")), + 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#uise' => "\$this->bbcode_parse_list('\$0')")), + 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#uise' => "\$this->validate_email('\$1', '\$2')")), + 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#uie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) ); // Zero the parsed items array @@ -1332,7 +1332,9 @@ class parse_message extends bbcode_firstpass { if ($max_smilies) { - $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#', $this->message, $matches); + // 'u' modifier has been added to correctly parse smilies within unicode strings + // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 + $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#u', $this->message, $matches); unset($matches); if ($num_matches !== false && $num_matches > $max_smilies) @@ -1343,7 +1345,10 @@ class parse_message extends bbcode_firstpass } // Make sure the delimiter # is added in front and at the end of every element within $match - $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); + // 'u' modifier has been added to correctly parse smilies within unicode strings + // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 + + $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#u'), $replace, $this->message)); } } diff --git a/phpBB/includes/request/deactivated_super_global.php b/phpBB/includes/request/deactivated_super_global.php index d7a5b3145f..123d6ba5f7 100644 --- a/phpBB/includes/request/deactivated_super_global.php +++ b/phpBB/includes/request/deactivated_super_global.php @@ -60,7 +60,7 @@ class phpbb_request_deactivated_super_global implements ArrayAccess, Countable, $file = ''; $line = 0; - $message = 'Illegal use of $' . $this->name . '. You must use the request class or request_var() to access input data. Found in %s on line %d. This error message was generated'; + $message = 'Illegal use of $' . $this->name . '. You must use the request class or request_var() to access input data. Found in %s on line %d. This error message was generated by deactivated_super_global.'; $backtrace = debug_backtrace(); if (isset($backtrace[1])) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index b47eff0ab5..893ec2c0cc 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -598,6 +598,13 @@ class session $bot = false; } + // Bot user, if they have a SID in the Request URI we need to get rid of it + // otherwise they'll index this page with the SID, duplicate content oh my! + if ($bot && isset($_GET['sid'])) + { + redirect(build_url(array('sid'))); + } + // If no data was returned one or more of the following occurred: // Key didn't match one in the DB // User does not exist @@ -634,12 +641,6 @@ class session } else { - // Bot user, if they have a SID in the Request URI we need to get rid of it - // otherwise they'll index this page with the SID, duplicate content oh my! - if (isset($_GET['sid'])) - { - redirect(build_url(array('sid'))); - } $this->data['session_last_visit'] = $this->time_now; } diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 643a86cde9..5192c334d8 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -276,7 +276,7 @@ class template $this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; $recompile = false; - if (!file_exists($filename) || @filesize($filename) === 0) + if (!file_exists($filename) || @filesize($filename) === 0 || defined('DEBUG_EXTRA')) { $recompile = true; } diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index c10516c769..34b0b6d879 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -98,6 +98,13 @@ class ucp_activate SET user_actkey = '' WHERE user_id = {$user_row['user_id']}"; $db->sql_query($sql); + + // Create the correct logs + add_log('user', $user_row['user_id'], 'LOG_USER_ACTIVE_USER'); + if ($auth->acl_get('a_user')) + { + add_log('admin', 'LOG_USER_ACTIVE', $user_row['username']); + } } if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index d5bdb731ac..f4fdb50ecd 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -57,38 +57,29 @@ class ucp_main $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $sql_select .= ', tt.mark_time'; + + $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id + AND ft.user_id = ' . $user->data['user_id'] . ')'; + $sql_select .= ', ft.mark_time AS forum_mark_time'; } $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; $folder = 'global_read'; $folder_new = 'global_unread'; - // Get cleaned up list... return only those forums not having the f_read permission - $forum_ary = $auth->acl_getf('!f_read', true); + // Get cleaned up list... return only those forums having the f_read permission + $forum_ary = $auth->acl_getf('f_read', true); $forum_ary = array_unique(array_keys($forum_ary)); - // Determine first forum the user is able to read into - for global announcement link - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - - if (sizeof($forum_ary)) - { - $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); - } - $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - $sql = "SELECT t.* $sql_select FROM $sql_from - WHERE t.forum_id = 0 - AND t.topic_type = " . POST_GLOBAL . ' + WHERE t.topic_type = " . POST_GLOBAL . ' + AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . ' ORDER BY t.topic_last_post_time DESC'; $topic_list = $rowset = array(); // If the user can't see any forums, he can't read any posts because fid of 0 is invalid - if ($g_forum_id) + if (!empty($forum_ary)) { $result = $db->sql_query($sql); @@ -100,15 +91,34 @@ class ucp_main $db->sql_freeresult($result); } - $topic_tracking_info = array(); + $topic_forum_list = array(); + foreach ($rowset as $t_id => $row) + { + if (isset($forum_tracking_info[$row['forum_id']])) + { + $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; + } + + $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; + $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; + } + + $topic_tracking_info = $tracking_topics = array(); if ($config['load_db_lastread']) { - $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list); + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); + } } else { - $topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list); + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); + } } + unset($topic_forum_list); foreach ($topic_list as $topic_id) { @@ -149,6 +159,7 @@ class ucp_main 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '', @@ -157,10 +168,10 @@ class ucp_main 'S_UNREAD' => $unread_topic, 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], + 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread', - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id")) + 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id")) ); } @@ -335,6 +346,7 @@ class ucp_main $template->assign_block_vars('forumrow', array( 'FORUM_ID' => $forum_id, + 'FORUM_IMG_STYLE' => $folder_image, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_IMAGE' => ($row['forum_image']) ? '' . $user->lang[$folder_alt] . '' : '', @@ -748,14 +760,14 @@ class ucp_main { foreach ($topic_forum_list as $f_id => $topic_row) { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false); + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); } } else { foreach ($topic_forum_list as $f_id => $topic_row) { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list); + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); } } @@ -803,15 +815,15 @@ class ucp_main 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false, - 'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false, - 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id")), + 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id")), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'FORUM_NAME' => $row['forum_name'], + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 4efa09c3c8..1758bb5eb1 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -165,10 +165,12 @@ function view_folder($id, $mode, $folder_id, $folder) 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '' : '', 'PM_ICON_URL' => (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '', 'FOLDER_IMG' => $user->img($folder_img, $folder_alt), + 'FOLDER_IMG_STYLE' => $folder_img, 'FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '', 'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'S_PM_UNREAD' => ($row['pm_unread']) ? true : false, 'S_PM_DELETED' => ($row['pm_deleted']) ? true : false, 'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false, 'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false, diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index bee2ea95dd..74a32a68c9 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -208,7 +208,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id) : '', 'U_WWW' => (!empty($user_info['user_website'])) ? $user_info['user_website'] : '', - 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '', + 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people' . urlencode($user_info['user_icq']) . '/' : '', 'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '', 'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '', 'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '', diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index b1f96356d5..51262c2289 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -65,7 +65,7 @@ class ucp_prefs $error = validate_data($data, array( 'dateformat' => array('string', false, 1, 30), - 'lang' => array('match', false, '#^[a-z0-9_\-]{2,}$#i'), + 'lang' => array('language_iso_name'), 'tz' => array('num', false, -14, 14), )); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index eaad4a7093..71374a9381 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -57,7 +57,7 @@ class ucp_register { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); - if (file_exists($user->lang_path . $use_lang . '/')) + if (!validate_language_iso_name($use_lang)) { if ($change_lang) { @@ -211,7 +211,7 @@ class ucp_register array('email')), 'email_confirm' => array('string', false, 6, 60), 'tz' => array('num', false, -14, 14), - 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), + 'lang' => array('language_iso_name'), )); if (!check_form_key('ucp_register')) diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index cac5b4e744..65d40c0fd3 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1712,49 +1712,106 @@ function utf8_case_fold_nfc($text, $option = 'full') return $text; } -/** -* A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings -* to be in NFC (Normalization Form Composition). -* -* @param mixed $strings a string or an array of strings to normalize -* @return mixed the normalized content, preserving array keys if array given. -*/ -function utf8_normalize_nfc($strings) +if (extension_loaded('intl')) { - if (empty($strings)) + /** + * wrapper around PHP's native normalizer from intl + * previously a PECL extension, included in the core since PHP 5.3.0 + * http://php.net/manual/en/normalizer.normalize.php + * + * @param mixed $strings a string or an array of strings to normalize + * @return mixed the normalized content, preserving array keys if array given. + */ + function utf8_normalize_nfc($strings) { - return $strings; - } - - if (!class_exists('utf_normalizer')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); - } - - if (!is_array($strings)) - { - utf_normalizer::nfc($strings); - } - else if (is_array($strings)) - { - foreach ($strings as $key => $string) + if (empty($strings)) { - if (is_array($string)) + return $strings; + } + + if (!is_array($strings)) + { + if (Normalizer::isNormalized($strings)) { - foreach ($string as $_key => $_string) + return $strings; + } + return (string) Normalizer::normalize($strings); + } + else + { + foreach ($strings as $key => $string) + { + if (is_array($string)) { - utf_normalizer::nfc($strings[$key][$_key]); + foreach ($string as $_key => $_string) + { + if (Normalizer::isNormalized($strings[$key][$_key])) + { + continue; + } + $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); + } + } + else + { + if (Normalizer::isNormalized($strings[$key])) + { + continue; + } + $strings[$key] = (string) Normalizer::normalize($strings[$key]); } } - else + } + + return $strings; + } +} +else +{ + /** + * A wrapper function for the normalizer which takes care of including the class if + * required and modifies the passed strings to be in NFC (Normalization Form Composition). + * + * @param mixed $strings a string or an array of strings to normalize + * @return mixed the normalized content, preserving array keys if array given. + */ + function utf8_normalize_nfc($strings) + { + if (empty($strings)) + { + return $strings; + } + + if (!class_exists('utf_normalizer')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + } + + if (!is_array($strings)) + { + utf_normalizer::nfc($strings); + } + else if (is_array($strings)) + { + foreach ($strings as $key => $string) { - utf_normalizer::nfc($strings[$key]); + if (is_array($string)) + { + foreach ($string as $_key => $_string) + { + utf_normalizer::nfc($strings[$key][$_key]); + } + } + else + { + utf_normalizer::nfc($strings[$key]); + } } } - } - return $strings; + return $strings; + } } /** diff --git a/phpBB/index.php b/phpBB/index.php index 95bdade42f..0830dd0686 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -36,17 +36,18 @@ $l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER' $l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER'; $l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER'; +$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; // Grab group details for legend display if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) { - $sql = 'SELECT group_id, group_name, group_colour, group_type + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; + WHERE group_legend > 0 + ORDER BY ' . $order_legend . ' ASC'; } else { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type + $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend FROM ' . GROUPS_TABLE . ' g LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON ( @@ -54,9 +55,9 @@ else AND ug.user_id = ' . $user->data['user_id'] . ' AND ug.user_pending = 0 ) - WHERE g.group_legend = 1 + WHERE g.group_legend > 0 AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.group_name ASC'; + ORDER BY g.' . $order_legend . ' ASC'; } $result = $db->sql_query($sql); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fab79e6dc1..63d191806a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,6 +177,69 @@ $database_update_info = database_update_info(); $error_ary = array(); $errored = false; +$sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; +$result = $db->sql_query_limit($sql, 1); +$has_global = (int) $db->sql_fetchfield('topic_id'); +$db->sql_freeresult($result); +$ga_forum_id = request_var('ga_forum_id', 0); + +if ($has_global && !$ga_forum_id) +{ + ?> + + + + + + + + + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> + + + + + + +
    + + +
    +
    +
    + +
    +
    + +

    + +
    + +
    + + + + +
    + @@ -930,8 +993,19 @@ function database_update_info() ), ), - // No changes from 3.1.0-dev to 3.1.0-A1 - '3.1.0-dev' => array(), + // Changes from 3.1.0-dev to 3.1.0-A1 + '3.1.0-dev' => array( + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ), ); } @@ -1902,6 +1976,140 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': set_config('use_system_cron', 0); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + _sql($sql, $errored, $error_ary); + + set_config('legend_sort_groupname', '0'); + set_config('teampage_multiple', '1'); + set_config('teampage_forums', '1'); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $db->sql_query($sql); + + $next_legend = 1; + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + _sql($sql, $errored, $error_ary); + + $next_legend++; + } + $db->sql_freeresult($result); + unset($next_legend); + + // Install modules + $modules_to_install = array( + 'position' => array( + 'base' => 'groups', + 'class' => 'acp', + 'title' => 'ACP_GROUPS_POSITION', + 'auth' => 'acl_a_group', + 'cat' => 'ACP_GROUPS', + ), + 'manage' => array( + 'base' => 'attachments', + 'class' => 'acp', + 'title' => 'ACP_MANAGE_ATTACHMENTS', + 'auth' => 'acl_a_attach', + 'cat' => 'ACP_ATTACHMENTS', + ), + ); + + _add_modules($modules_to_install); + + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $ga_forum_id = request_var('ga_forum_id', 0); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $db->sql_query($sql); + $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); + $db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + _sql($sql, $errored, $error_ary); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $db->sql_in_set('topic_id', $global_announcements); + _sql($sql, $errored, $error_ary); + } + unset($table_ary); + } + + $no_updates = false; break; } } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 01ed223c27..e18ed43778 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1867,7 +1867,7 @@ class install_install extends module if (!$user_id) { - // If we can't insert this user then continue to the next one to avoid inconsistant data + // If we can't insert this user then continue to the next one to avoid inconsistent data $this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true); continue; } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index ab622e8fde..e16b4ab64c 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -444,7 +444,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INTEGER DEFAULT 0 NOT NULL, group_message_limit INTEGER DEFAULT 0 NOT NULL, group_max_recipients INTEGER DEFAULT 0 NOT NULL, - group_legend INTEGER DEFAULT 1 NOT NULL + group_legend INTEGER DEFAULT 0 NOT NULL, + group_teampage INTEGER DEFAULT 0 NOT NULL );; ALTER TABLE phpbb_groups ADD PRIMARY KEY (group_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 068373c9a1..a14e246c8f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -546,7 +546,8 @@ CREATE TABLE [phpbb_groups] ( [group_receive_pm] [int] DEFAULT (0) NOT NULL , [group_message_limit] [int] DEFAULT (0) NOT NULL , [group_max_recipients] [int] DEFAULT (0) NOT NULL , - [group_legend] [int] DEFAULT (1) NOT NULL + [group_legend] [int] DEFAULT (0) NOT NULL , + [group_teampage] [int] DEFAULT (0) NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 0dd2a579e6..3b79afa942 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -316,7 +316,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (group_id), KEY group_legend_name (group_legend, group_name(255)) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 071033ae53..a4b34c05db 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -316,7 +316,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (group_id), KEY group_legend_name (group_legend, group_name) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 811c975d5d..9b516b4a56 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -605,7 +605,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm number(1) DEFAULT '0' NOT NULL, group_message_limit number(8) DEFAULT '0' NOT NULL, group_max_recipients number(8) DEFAULT '0' NOT NULL, - group_legend number(1) DEFAULT '1' NOT NULL, + group_legend number(8) DEFAULT '0' NOT NULL, + group_teampage number(8) DEFAULT '0' NOT NULL, CONSTRAINT pk_phpbb_groups PRIMARY KEY (group_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 217ecd3771..1b9c1a75aa 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -459,7 +459,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INT2 DEFAULT '0' NOT NULL CHECK (group_receive_pm >= 0), group_message_limit INT4 DEFAULT '0' NOT NULL CHECK (group_message_limit >= 0), group_max_recipients INT4 DEFAULT '0' NOT NULL CHECK (group_max_recipients >= 0), - group_legend INT2 DEFAULT '1' NOT NULL CHECK (group_legend >= 0), + group_legend INT4 DEFAULT '0' NOT NULL CHECK (group_legend >= 0), + group_teampage INT4 DEFAULT '0' NOT NULL CHECK (group_teampage >= 0), PRIMARY KEY (group_id) ); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 88265d3173..9a29ad7b4d 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -151,6 +151,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_user_filter', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('legend_sort_groupname', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); @@ -238,6 +239,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_password', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_username', ''); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_multiple', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('teampage_forums', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); @@ -520,13 +523,13 @@ INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_reg INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 1, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, '', '', '', 0); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, '', '', '', 5); -INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('REGISTERED_COPPA', 3, 0, '', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GLOBAL_MODERATORS', 3, 0, '00AA00', 2, 2, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, 1, '', '', '', 0); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, 0, '', '', '', 5); +INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, 0, '', '', '', 5); # -- User -> Group INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (1, 1, 0, 0); @@ -566,7 +569,7 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT # No Avatar (u_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar', 'u_masspm', 'u_masspm_group'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar'); # Full Moderator (m_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 10, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%'; diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index e83b4342fb..9344a29929 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -308,7 +308,8 @@ CREATE TABLE phpbb_groups ( group_receive_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', group_message_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', group_max_recipients INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_legend INTEGER UNSIGNED NOT NULL DEFAULT '1' + group_legend INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_teampage INTEGER UNSIGNED NOT NULL DEFAULT '0' ); CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index 9ae250a95a..eede2c5d50 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -62,6 +62,7 @@ $lang = array_merge($lang, array( 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', 'ATTACH_ORPHAN_URL' => 'Orphan attachments', 'ATTACH_POST_ID' => 'Post ID', + 'ATTACH_POST_TYPE' => 'Post type', 'ATTACH_QUOTA' => 'Total attachment quota', 'ATTACH_QUOTA_EXPLAIN' => 'Maximum drive space available for attachments for the whole board, with 0 being unlimited.', 'ATTACH_TO_POST' => 'Attach file to post', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 25a020d8a2..2a8ed86175 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -100,6 +100,7 @@ $lang = array_merge($lang, array( 'ACP_GROUPS_MANAGE' => 'Manage groups', 'ACP_GROUPS_MANAGEMENT' => 'Group management', 'ACP_GROUPS_PERMISSIONS' => 'Groups’ permissions', + 'ACP_GROUPS_POSITION' => 'Manage group positions', 'ACP_ICONS' => 'Topic icons', 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', @@ -115,6 +116,10 @@ $lang = array_merge($lang, array( 'ACP_LOGGING' => 'Logging', 'ACP_MAIN' => 'ACP index', + + 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', + 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.', + 'ACP_MANAGE_EXTENSIONS' => 'Manage extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', 'ACP_MANAGE_RANKS' => 'Manage ranks', @@ -226,12 +231,16 @@ $lang = array_merge($lang, array( 'DOWNLOAD_AS' => 'Download as', 'DOWNLOAD_STORE' => 'Download or store file', 'DOWNLOAD_STORE_EXPLAIN' => 'You may directly download the file or save it in your store/ folder.', + 'DOWNLOADS' => 'Downloads', 'EDIT' => 'Edit', 'ENABLE' => 'Enable', 'EXPORT_DOWNLOAD' => 'Download', 'EXPORT_STORE' => 'Store', + 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', + 'FILES_STATS_WRONG' => 'Your files statistics are probably inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', + 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', 'GLOBAL_MASK' => 'Global permission mask', @@ -257,6 +266,7 @@ $lang = array_merge($lang, array( 'NOTIFY' => 'Notification', 'NO_ADMIN' => 'You are not authorised to administer this board.', 'NO_EMAILS_DEFINED' => 'No valid e-mail addresses found.', + 'NO_FILES_TO_DELETE' => 'Attachments you selected for deletion do not exist.', 'NO_PASSWORD_SUPPLIED' => 'You need to enter your password to access the Administration Control Panel.', 'OFF' => 'Off', @@ -271,6 +281,8 @@ $lang = array_merge($lang, array( 'REMIND' => 'Remind', 'RESYNC' => 'Resynchronise', + 'RESYNC_FILES_STATS' => 'Resynchronise files statistics', + 'RESYNC_FILES_STATS_EXPLAIN' => 'Recalculates the total number and size of files attached to posts and private messages.', 'RETURN_TO' => 'Return to…', 'SELECT_ANONYMOUS' => 'Select anonymous user', @@ -283,6 +295,8 @@ $lang = array_merge($lang, array( 'SHOW_ALL_OPERATIONS' => 'Show all operations', + 'TOTAL_SIZE' => 'Total size', + 'UCP' => 'User Control Panel', 'USERNAMES_EXPLAIN' => 'Place each username on a separate line.', 'USER_CONTROL_PANEL' => 'User Control Panel', @@ -355,6 +369,7 @@ $lang = array_merge($lang, array( 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', + 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', @@ -659,6 +674,7 @@ $lang = array_merge($lang, array( 'LOG_REFERER_INVALID' => 'Referer validation failed
    »Referer was “%1$s”. The request was rejected and the session killed.', 'LOG_RESET_DATE' => 'Board start date reset', 'LOG_RESET_ONLINE' => 'Most users online reset', + 'LOG_RESYNC_FILES_STATS' => 'Files statistics resynchronised', 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised', diff --git a/phpBB/language/en/acp/email.php b/phpBB/language/en/acp/email.php index b8b299bee9..6ce8ddd59b 100644 --- a/phpBB/language/en/acp/email.php +++ b/phpBB/language/en/acp/email.php @@ -52,14 +52,16 @@ $lang = array_merge($lang, array( 'SEND_TO_GROUP' => 'Send to group', 'SEND_TO_USERS' => 'Send to users', 'SEND_TO_USERS_EXPLAIN' => 'Entering names here will override any group selected above. Enter each username on a new line.', - + + 'MAIL_BANNED' => 'Mail banned users', + 'MAIL_BANNED_EXPLAIN' => 'When sending a mass e-mail to a group you can select here whether banned users will also receive the e-mail.', 'MAIL_HIGH_PRIORITY' => 'High', 'MAIL_LOW_PRIORITY' => 'Low', 'MAIL_NORMAL_PRIORITY' => 'Normal', 'MAIL_PRIORITY' => 'Mail priority', 'MASS_MESSAGE' => 'Your message', 'MASS_MESSAGE_EXPLAIN' => 'Please note that you may enter only plain text. All markup will be removed before sending.', - + 'NO_EMAIL_MESSAGE' => 'You must enter a message.', 'NO_EMAIL_SUBJECT' => 'You must specify a subject for your message.', )); diff --git a/phpBB/language/en/acp/groups.php b/phpBB/language/en/acp/groups.php index 3b3953ac36..11342bf4f2 100644 --- a/phpBB/language/en/acp/groups.php +++ b/phpBB/language/en/acp/groups.php @@ -97,6 +97,8 @@ $lang = array_merge($lang, array( 'GROUP_SETTINGS_SAVE' => 'Group wide settings', 'GROUP_SKIP_AUTH' => 'Exempt group leader from permissions', 'GROUP_SKIP_AUTH_EXPLAIN' => 'If enabled group leader no longer inherit permissions from the group.', + 'GROUP_SPECIAL' => 'Pre-defined', + 'GROUP_TEAMPAGE' => 'Display group on teampage', 'GROUP_TYPE' => 'Group type', 'GROUP_TYPE_EXPLAIN' => 'This determines which users can join or view this group.', 'GROUP_UPDATED' => 'Group preferences updated successfully.', @@ -105,19 +107,34 @@ $lang = array_merge($lang, array( 'GROUP_USERS_EXIST' => 'The selected users are already members.', 'GROUP_USERS_REMOVE' => 'Users removed from group and new defaults set successfully.', + 'LEGEND_EXPLAIN' => 'These are the groups which are displayed in the group legend:', + 'LEGEND_SETTINGS' => 'Legend settings', + 'LEGEND_SORT_GROUPNAME' => 'Sort legend by group name', + 'LEGEND_SORT_GROUPNAME_EXPLAIN' => 'The order below is ignored when this option is enabled.', + + 'MANAGE_LEGEND' => 'Manage group legend', + 'MANAGE_TEAMPAGE' => 'Manage teampage', 'MAKE_DEFAULT_FOR_ALL' => 'Make default group for every member', 'MEMBERS' => 'Members', 'NO_GROUP' => 'No group specified.', + 'NO_GROUPS_ADDED' => 'No groups added yet.', 'NO_GROUPS_CREATED' => 'No groups created yet.', 'NO_PERMISSIONS' => 'Do not copy permissions', 'NO_USERS' => 'You haven’t entered any users.', 'NO_USERS_ADDED' => 'No users were added to the group.', 'NO_VALID_USERS' => 'You haven’t entered any users eligible for that action.', + 'SELECT_GROUP' => 'Select a group', 'SPECIAL_GROUPS' => 'Pre-defined groups', 'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings.', + 'TEAMPAGE_EXPLAIN' => 'These are the groups which are displayed on the teampage:', + 'TEAMPAGE_FORUMS' => 'Display moderated forums', + 'TEAMPAGE_FORUMS_EXPLAIN' => 'If set to yes, moderators will have a list with all of the forums where they have moderator permissions displayed in their row. This can be very database intensive for big boards.', + 'TEAMPAGE_MULTIPLE' => 'Display users in all groups', + 'TEAMPAGE_MULTIPLE_EXPLAIN' => 'If set to no, the users will only be displayed in their primary group (If the primary group is not listed, the users will be displayed in their first displayed group).', + 'TEAMPAGE_SETTINGS' => 'Teampage settings', 'TOTAL_MEMBERS' => 'Members', 'USERS_APPROVED' => 'Users approved successfully.', diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index b0f1b74faa..16e1aaca66 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -168,8 +168,9 @@ $lang = array_merge($lang, array( 'SMILIES_CONFIG' => 'Smiley configuration', 'SMILIES_DELETED' => 'The smiley has been removed successfully.', 'SMILIES_EDIT' => 'Edit smiley', - 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.', - 'SMILIE_NO_EMOTION' => 'The smilie “%s” was ignored, as there was no emotion entered.', + 'SMILIE_NO_CODE' => 'The smiley “%s” was ignored, as there was no code entered.', + 'SMILIE_NO_EMOTION' => 'The smiley “%s” was ignored, as there was no emotion entered.', + 'SMILIE_NO_FILE' => 'The smiley “%s” was ignored, as the file is missing.', 'SMILIES_NONE_EDITED' => 'No smilies were updated.', 'SMILIES_ONE_EDITED' => 'The smiley has been updated successfully.', 'SMILIES_EDITED' => 'The smilies have been updated successfully.', @@ -233,13 +234,13 @@ $lang = array_merge($lang, array( // Disallow Usernames $lang = array_merge($lang, array( - 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *. Please note that you will not be allowed to specify any username that has already been registered, you must first delete that name then disallow it.', + 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *.', 'ADD_DISALLOW_EXPLAIN' => 'You can disallow a username using the wildcard character * to match any character.', 'ADD_DISALLOW_TITLE' => 'Add a disallowed username', 'DELETE_DISALLOW_EXPLAIN' => 'You can remove a disallowed username by selecting the username from this list and clicking submit.', 'DELETE_DISALLOW_TITLE' => 'Remove a disallowed username', - 'DISALLOWED_ALREADY' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present.', + 'DISALLOWED_ALREADY' => 'The name you entered is already disallowed.', 'DISALLOWED_DELETED' => 'The disallowed username has been successfully removed.', 'DISALLOW_SUCCESSFUL' => 'The disallowed username has been successfully added.', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index d5311c5820..4a17deb32e 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -190,7 +190,7 @@ $lang = array_merge($lang, array( 'FORM_INVALID' => 'The submitted form was invalid. Try submitting again.', 'FORUM' => 'Forum', 'FORUMS' => 'Forums', - 'FORUMS_MARKED' => 'All forums have been marked read.', + 'FORUMS_MARKED' => 'The selected forums have been marked read.', 'FORUM_CAT' => 'Forum category', 'FORUM_INDEX' => 'Board index', 'FORUM_LINK' => 'Forum link', @@ -322,6 +322,7 @@ $lang = array_merge($lang, array( 'MARK' => 'Mark', 'MARK_ALL' => 'Mark all', 'MARK_FORUMS_READ' => 'Mark forums read', + 'MARK_SUBFORUMS_READ' => 'Mark subforums read', 'MB' => 'MB', 'MIB' => 'MiB', 'MCP' => 'Moderator Control Panel', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 021f5eccb0..bc5a3ab936 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -302,7 +302,7 @@ $lang = array_merge($lang, array( 'PHP_SETTINGS' => 'PHP version and settings', 'PHP_SETTINGS_EXPLAIN' => 'Required - You must be running at least version 4.3.3 of PHP in order to install phpBB. If safe mode is displayed below your PHP installation is running in that mode. This will impose limitations on remote administration and similar features.', 'PHP_URL_FOPEN_SUPPORT' => 'PHP setting allow_url_fopen is enabled', - 'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => 'Optional - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it. ', + 'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => 'Optional - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it.', 'PHP_VERSION_REQD' => 'PHP version >= 4.3.3', 'POST_ID' => 'Post ID', 'PREFIX_FOUND' => 'A scan of your tables has shown a valid installation using %s as table prefix.', @@ -323,6 +323,7 @@ $lang = array_merge($lang, array( 'SERVER_CONFIG' => 'Server configuration', 'SEARCH_INDEX_UNCONVERTED' => 'Search index was not converted', 'SEARCH_INDEX_UNCONVERTED_EXPLAIN' => 'Your old search index was not converted. Searching will always yield an empty result. To create a new search index go to the Administration Control Panel, select Maintenance and then choose Search index from the submenu.', + 'SELECT_FORUM_GA' => 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):', 'SOFTWARE' => 'Board software', 'SPECIFY_OPTIONS' => 'Specify conversion options', 'STAGE_ADMINISTRATOR' => 'Administrator details', diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 401a12d0f9..0029d224cd 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -85,7 +85,7 @@ if ($post_id) $db->sql_freeresult($result); $topic_id = (int) $row['topic_id']; - $forum_id = (int) ($row['forum_id']) ? $row['forum_id'] : $forum_id; + $forum_id = (int) $row['forum_id']; } else if ($topic_id) { @@ -400,12 +400,6 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false) while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) - { - // Global Announcement? - $row['forum_id'] = request_var('f', 0); - } - $rowset[$row['topic_id']] = $row; if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) @@ -485,12 +479,6 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false) while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) - { - // Global Announcement? - $row['forum_id'] = request_var('f', 0); - } - if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) { continue; diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0b2fd24871..685830c656 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -77,189 +77,196 @@ switch ($mode) $page_title = $user->lang['THE_TEAM']; $template_html = 'memberlist_leaders.html'; - $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false); + $sql_ary = array( + 'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, g.group_teampage, ug.user_id as ug_user_id', - $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array(); - foreach ($user_ary as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $id_ary) - { - if (!$forum_id) - { - if ($auth_option == 'a_') - { - $admin_id_ary = array_merge($admin_id_ary, $id_ary); - } - else - { - $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary); - } - continue; - } - else - { - $mod_id_ary = array_merge($mod_id_ary, $id_ary); - } - - if ($forum_id) - { - foreach ($id_ary as $id) - { - $forum_id_ary[$id][] = $forum_id; - } - } - } - } - - $admin_id_ary = array_unique($admin_id_ary); - $global_mod_id_ary = array_unique($global_mod_id_ary); - - $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary); - $mod_id_ary = array_unique($mod_id_ary); - - // Admin group id... - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'ADMINISTRATORS'"; - $result = $db->sql_query($sql); - $admin_group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - // Get group memberships for the admin id ary... - $admin_memberships = group_memberships($admin_group_id, $admin_id_ary); - - $admin_user_ids = array(); - - if (!empty($admin_memberships)) - { - // ok, we only need the user ids... - foreach ($admin_memberships as $row) - { - $admin_user_ids[$row['user_id']] = true; - } - } - unset($admin_memberships); - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forums = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forums[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', - - 'FROM' => array( - USERS_TABLE => 'u', - GROUPS_TABLE => 'g' - ), + 'FROM' => array(GROUPS_TABLE => 'g'), 'LEFT_JOIN' => array( array( 'FROM' => array(USER_GROUP_TABLE => 'ug'), - 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] - ) + 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'], + ), ), - 'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . ' - AND u.group_id = g.group_id', + 'WHERE' => '', - 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' - )); - $result = $db->sql_query($sql); + 'ORDER_BY' => 'g.group_teampage ASC', + ); + $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); + + $group_ids = $groups_ary = array(); while ($row = $db->sql_fetchrow($result)) { - $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod'; - - // We sort out admins not within the 'Administrators' group. - // Else, we will list those as admin only having the permission to view logs for example. - if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']])) + if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) { - // Remove from admin_id_ary, because the user may be a mod instead - unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]); - - if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary)) - { - continue; - } - else - { - $which_row = 'mod'; - } + $row['group_name'] = $user->lang['GROUP_UNDISCLOSED']; + $row['u_group'] = ''; + } + else + { + $row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); } - $s_forum_select = ''; - $undisclosed_forum = false; - - if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary)) + if ($row['group_teampage']) { - if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']]))) + // Only put groups into the array we want to display. + // We are fetching all groups, to ensure we got all data for default groups. + $group_ids[] = (int) $row['group_id']; + } + $groups_ary[(int) $row['group_id']] = $row; + } + $db->sql_freeresult($result); + + $sql_ary = array( + 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id', + + 'FROM' => array( + USER_GROUP_TABLE => 'ug', + ), + + 'LEFT_JOIN' => array( + array( + 'FROM' => array(USERS_TABLE => 'u'), + 'ON' => 'ug.user_id = u.user_id AND ug.user_pending = 0', + ), + array( + 'FROM' => array(GROUPS_TABLE => 'g'), + 'ON' => 'ug.group_id = g.group_id', + ), + ), + + 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true), + + 'ORDER_BY' => 'u.username_clean ASC', + ); + + $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); + + $user_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['forums'] = ''; + $row['forums_ary'] = array(); + $user_ary[(int) $row['user_id']] = $row; + $user_ids[] = (int) $row['user_id']; + $group_users[(int) $row['group_id']][] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + + if ($config['teampage_forums']) + { + $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true); + // Get all moderators + $perm_ary = $auth->acl_get_list(array_unique($user_ids), array('m_'), false); + + foreach ($perm_ary as $forum_id => $forum_ary) + { + foreach ($forum_ary as $auth_option => $id_ary) { - foreach ($forum_id_ary[$row['user_id']] as $forum_id) + foreach ($id_ary as $id) { - if (isset($forums[$forum_id])) + if (!$forum_id) { - if ($auth->acl_get('f_list', $forum_id)) - { - $s_forum_select .= ''; - } - else - { - $undisclosed_forum = true; - } + $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS']; + } + else + { + $user_ary[$id]['forums_ary'][] = $forum_id; } } } } - // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then... - if (!$s_forum_select && $undisclosed_forum) + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); + + $forums = array(); + while ($row = $db->sql_fetchrow($result)) { -// $s_forum_select = ''; - continue; + $forums[$row['forum_id']] = $row['forum_name']; } + $db->sql_freeresult($result); - // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden. - if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) + foreach ($user_ary as $user_id => $user_data) { - $group_name = $user->lang['GROUP_UNDISCLOSED']; - $u_group = ''; + if (!$user_data['forums']) + { + foreach ($user_data['forums_ary'] as $forum_id) + { + $user_ary[$user_id]['forums_options'] = true; + if (isset($forums[$forum_id])) + { + if ($auth->acl_get('f_list', $forum_id)) + { + $user_ary[$user_id]['forums'] .= ''; + } + } + } + } + } + } + + foreach ($groups_ary as $group_id => $group_data) + { + if ($group_data['group_teampage']) + { + $template->assign_block_vars('group', array( + 'GROUP_NAME' => $group_data['group_name'], + 'GROUP_COLOR' => $group_data['group_colour'], + 'U_GROUP' => $group_data['u_group'], + )); + } + + // Display group members. + if (!empty($group_users[$group_id])) + { + foreach ($group_users[$group_id] as $user_id) + { + if (isset($user_ary[$user_id])) + { + $row = $user_ary[$user_id]; + if (!$config['teampage_multiple'] && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['group_teampage']) + { + // Display users in their primary group, instead of the first group, when it is displayed on the teampage. + continue; + } + + $rank_title = $rank_img = $rank_img_src = ''; + get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src); + + $template->assign_block_vars('group.user', array( + 'USER_ID' => $row['user_id'], + 'FORUMS' => $row['forums'], + 'FORUM_OPTIONS' => (isset($row['forums_options'])) ? true : false, + 'RANK_TITLE' => $rank_title, + + 'GROUP_NAME' => $groups_ary[$row['default_group']]['group_name'], + 'GROUP_COLOR' => $groups_ary[$row['default_group']]['group_colour'], + 'U_GROUP' => $groups_ary[$row['default_group']]['u_group'], + + 'RANK_IMG' => $rank_img, + 'RANK_IMG_SRC' => $rank_img_src, + + 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', + + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), + )); + + if (!$config['teampage_multiple']) + { + unset($user_ary[$user_id]); + } + } + } } - else - { - $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; - $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); - } - - $rank_title = $rank_img = ''; - get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src); - - $template->assign_block_vars($which_row, array( - 'USER_ID' => $row['user_id'], - 'FORUMS' => $s_forum_select, - 'RANK_TITLE' => $rank_title, - 'GROUP_NAME' => $group_name, - 'GROUP_COLOR' => $row['group_colour'], - - 'RANK_IMG' => $rank_img, - 'RANK_IMG_SRC' => $rank_img_src, - - 'U_GROUP' => $u_group, - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - )); } - $db->sql_freeresult($result); $template->assign_vars(array( 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) @@ -1069,8 +1076,27 @@ switch ($mode) $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - $sql_where .= (sizeof($joined) > 1 && isset($find_key_match[$joined_select])) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; - $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 && isset($find_key_match[$active_select])) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; + + if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3) + { + $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]); + + if ($joined_time !== false) + { + $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time; + } + } + + if (isset($find_key_match[$active_select]) && sizeof($active) == 3 && $auth->acl_get('u_viewonline')) + { + $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); + + if ($active_time !== false) + { + $sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time; + } + } + $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : ''; if ($search_group_id) @@ -1110,7 +1136,7 @@ switch ($mode) $sql = 'SELECT DISTINCT poster_id FROM ' . POSTS_TABLE . ' WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) - AND forum_id IN (0, " . implode(', ', $ip_forums) . ')'; + AND " . $db->sql_in_set('forum_id', $ip_forums); $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) @@ -1692,7 +1718,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'U_EMAIL' => $email, 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', 'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '', - 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '', + 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '', 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '', 'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', diff --git a/phpBB/posting.php b/phpBB/posting.php index 41559056b9..734e97742c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,9 +87,8 @@ switch ($mode) $sql = 'SELECT f.*, t.* FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); + AND f.forum_id = t.forum_id" . + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); break; case 'quote': @@ -116,9 +115,8 @@ switch ($mode) WHERE p.post_id = $post_id AND t.topic_id = p.topic_id AND u.user_id = p.poster_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); + AND f.forum_id = t.forum_id" . + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); break; case 'smilies': @@ -1005,60 +1003,6 @@ if ($submit || $preview || $refresh) // Store message, sync counters if (!sizeof($error) && $submit) { - // Check if we want to de-globalize the topic... and ask for new forum - if ($post_data['topic_type'] != POST_GLOBAL) - { - $sql = 'SELECT topic_type, forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) - { - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'SELECT forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $to_forum_id; - $result = $db->sql_query($sql); - $forum_type = (int) $db->sql_fetchfield('forum_type'); - $db->sql_freeresult($result); - - if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) - { - $to_forum_id = 0; - } - } - - if (!$to_forum_id) - { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), - 'S_UNGLOBALISE' => true) - ); - - $submit = false; - $refresh = true; - } - else - { - if (!$auth->acl_get('f_post', $to_forum_id)) - { - // This will only be triggered if the user tried to trick the forum. - trigger_error('NOT_AUTHORISED'); - } - - $forum_id = $to_forum_id; - } - } - } - if ($submit) { // Lock/Unlock Topic diff --git a/phpBB/report.php b/phpBB/report.php index 8e780813ff..a30914392b 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -70,7 +70,7 @@ if ($post_id) trigger_error('POST_NOT_EXIST'); } - $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id; + $forum_id = (int) $report_data['forum_id']; $topic_id = (int) $report_data['topic_id']; $sql = 'SELECT * diff --git a/phpBB/search.php b/phpBB/search.php index b7cea03057..4b1527b7e7 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -719,11 +719,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) { if ($user->data['is_registered'] && $config['load_db_lastread']) { - $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time'])); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']); if (!$user->data['is_registered']) { @@ -832,35 +832,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $result_topic_id = $row['topic_id']; $topic_title = censor_text($row['topic_title']); - // we need to select a forum id for this global topic - if (!$forum_id) - { - if (!isset($g_forum_id)) - { - // Get a list of forums the user cannot read - $forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true))); - - // Determine first forum the user is able to read (must not be a category) - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - - if (sizeof($forum_ary)) - { - $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); - } - - $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id'); - } - $u_forum_id = $g_forum_id; - } - else - { - $u_forum_id = $forum_id; - } - - $view_topic_url_params = "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); + $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; @@ -898,6 +870,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url), 'TOPIC_TYPE' => $topic_type, + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], @@ -910,7 +883,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - 'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false, 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, diff --git a/phpBB/styles/prosilver/template/attachment.html b/phpBB/styles/prosilver/template/attachment.html index cc5aacff2f..4c0a326f1e 100644 --- a/phpBB/styles/prosilver/template/attachment.html +++ b/phpBB/styles/prosilver/template/attachment.html @@ -70,12 +70,12 @@ - + - + diff --git a/phpBB/styles/prosilver/template/forumlist_body.html b/phpBB/styles/prosilver/template/forumlist_body.html index e9ed5d9daf..d6596203e5 100644 --- a/phpBB/styles/prosilver/template/forumlist_body.html +++ b/phpBB/styles/prosilver/template/forumlist_body.html @@ -25,7 +25,7 @@
  • -
    +
    diff --git a/phpBB/styles/prosilver/template/mcp_forum.html b/phpBB/styles/prosilver/template/mcp_forum.html index 7c914a7b68..49d4601dfa 100644 --- a/phpBB/styles/prosilver/template/mcp_forum.html +++ b/phpBB/styles/prosilver/template/mcp_forum.html @@ -34,7 +34,7 @@
  • -
    +
    style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"> [ {L_SELECT_MERGE} ]   {topicrow.TOPIC_TITLE} diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 29c4cf1b91..88c57eb8c5 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -39,7 +39,7 @@
     
    {L_IM_ADD_CONTACT}
    {L_IM_SEND_MESSAGE}
    -
    {L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
    +
    {L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
    diff --git a/phpBB/styles/prosilver/template/memberlist_leaders.html b/phpBB/styles/prosilver/template/memberlist_leaders.html index 090476e365..1a63793bc3 100644 --- a/phpBB/styles/prosilver/template/memberlist_leaders.html +++ b/phpBB/styles/prosilver/template/memberlist_leaders.html @@ -4,72 +4,43 @@
    +
    - + - + - - - - + + - + + + - + - +
    {L_RANK} {L_ADMINISTRATORS}{L_RANK} {group.GROUP_NAME}{group.GROUP_NAME} {L_PRIMARY_GROUP}{L_FORUMS}{L_MODERATOR}
    {admin.RANK_IMG}{admin.RANK_TITLE}{admin.USERNAME_FULL} - style="font-weight: bold; color:#{admin.GROUP_COLOR}" href="{admin.U_GROUP}">{admin.GROUP_NAME} + +
    {group.user.RANK_IMG}{group.user.RANK_TITLE}{group.user.USERNAME_FULL} + style="font-weight: bold; color: #{group.user.GROUP_COLOR}" href="{group.user.U_GROUP}">{group.user.GROUP_NAME} - {admin.GROUP_NAME} + {group.user.GROUP_NAME} -{group.user.FORUMS}-
    {L_NO_ADMINISTRATORS}{L_NO_MEMBERS}
    + -
    -
    - - - - - - - - - - - - - - - - - - - - - - -
    {L_MODERATORS}  
    {mod.RANK_IMG}{mod.RANK_TITLE}{mod.USERNAME_FULL} - style="font-weight: bold; color:#{mod.GROUP_COLOR}" href="{mod.U_GROUP}">{mod.GROUP_NAME} - - {mod.GROUP_NAME} - {L_ALL_FORUMS}
    {L_NO_MODERATORS}
    - -
    -
    -
    diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index b95185a6f2..9df648f644 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -37,7 +37,7 @@ function insert_single(user) } // ]]> - +

    {L_FIND_USERNAME}

    diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index ff14abe370..463ed2b5c1 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -81,8 +81,8 @@ // ]]> - - + + @@ -145,7 +145,7 @@
  • - + - + diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index 7b650dda70..329c323ffa 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -19,7 +19,7 @@ -
    {L_IM_ADD_CONTACT}
    {L_IM_SEND_MESSAGE}

    {L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS} +
    {L_IM_ADD_CONTACT}
    {L_IM_SEND_MESSAGE}

    {L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}   diff --git a/phpBB/styles/subsilver2/template/memberlist_leaders.html b/phpBB/styles/subsilver2/template/memberlist_leaders.html index 57f5838e7f..75fff9f98a 100644 --- a/phpBB/styles/subsilver2/template/memberlist_leaders.html +++ b/phpBB/styles/subsilver2/template/memberlist_leaders.html @@ -5,57 +5,36 @@ - + + - + - - + + - - + + - - + + - + - - - - - - - - - - - - - - - - - - + +
    {L_USERNAME}{L_FORUMS}{L_FORUMS} {L_PRIMARY_GROUP} {L_RANK} {L_SEND_MESSAGE}
    {L_ADMINISTRATORS}{group.GROUP_NAME}{group.GROUP_NAME}
    {admin.USERNAME_FULL} {group.user.USERNAME_FULL}{group.user.FORUMS}-   - - style="font-weight: bold; color:#{admin.GROUP_COLOR}" href="{admin.U_GROUP}">{admin.GROUP_NAME} + + style="font-weight: bold; color:#{group.user.GROUP_COLOR}" href="{group.user.U_GROUP}">{group.user.GROUP_NAME} - {admin.GROUP_NAME} + {group.user.GROUP_NAME}  {admin.RANK_IMG}{admin.RANK_TITLE} {PM_IMG} {group.user.RANK_IMG}{group.user.RANK_TITLE} {PM_IMG} 
    {L_NO_ADMINISTRATORS}{L_NO_MEMBERS}
    {L_MODERATORS}
    {mod.USERNAME_FULL}{L_ALL_FORUMS}   - - style="font-weight: bold; color:#{mod.GROUP_COLOR}" href="{mod.U_GROUP}">{mod.GROUP_NAME} - - {mod.GROUP_NAME} - -  {mod.RANK_IMG}{mod.RANK_TITLE} {PM_IMG} 
    {L_NO_MODERATORS}
    diff --git a/phpBB/styles/subsilver2/template/posting_buttons.html b/phpBB/styles/subsilver2/template/posting_buttons.html index 621fa87fd4..92b4bd3e39 100644 --- a/phpBB/styles/subsilver2/template/posting_buttons.html +++ b/phpBB/styles/subsilver2/template/posting_buttons.html @@ -33,7 +33,7 @@ // ]]> - + diff --git a/phpBB/styles/subsilver2/template/posting_smilies.html b/phpBB/styles/subsilver2/template/posting_smilies.html index 06e830845a..691ba239b2 100644 --- a/phpBB/styles/subsilver2/template/posting_smilies.html +++ b/phpBB/styles/subsilver2/template/posting_smilies.html @@ -6,7 +6,7 @@ var text_name = 'message'; // ]]> - + diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html index 823d057f06..282b0f864b 100644 --- a/phpBB/styles/subsilver2/template/search_results.html +++ b/phpBB/styles/subsilver2/template/search_results.html @@ -45,11 +45,7 @@

    [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {searchresults.PAGINATION} ]

    - -

    {L_GLOBAL}

    - -

    {L_IN} {searchresults.FORUM_TITLE}

    - +

    {L_IN} {searchresults.FORUM_TITLE}

    @@ -84,7 +80,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index 65d8ef51c0..5c20b84541 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -202,6 +202,7 @@

    [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ]

    +

    {L_IN} {topicrow.FORUM_NAME}

    diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 2672703042..c53150d89b 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -177,8 +177,7 @@ if ($mark_read == 'topics') $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { - // Add 0 to forums array to mark global announcements correctly - markread('topics', array($forum_id, 0)); + markread('topics', array($forum_id)); } $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); meta_refresh(3, $redirect_url); @@ -238,9 +237,10 @@ if ($sort_days) $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . " WHERE forum_id = $forum_id - AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time) - OR topic_type = " . POST_ANNOUNCE . ") - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); + AND (topic_last_post_time >= $min_post_time + OR topic_type = " . POST_ANNOUNCE . ' + OR topic_type = ' . POST_GLOBAL . ') + ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); @@ -324,7 +324,7 @@ $template->assign_vars(array( $icons = $cache->obtain_icons(); // Grab all topic data -$rowset = $announcement_list = $topic_list = $global_announce_list = array(); +$rowset = $announcement_list = $topic_list = $global_announce_forums = array(); $sql_array = array( 'SELECT' => 't.*', @@ -359,14 +359,24 @@ if ($user->data['is_registered']) if ($forum_data['forum_type'] == FORUM_POST) { + // Get global announcement forums + $g_forum_ary = $auth->acl_getf('f_read', true); + $g_forum_ary = array_unique(array_keys($g_forum_ary)); + + $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN']; + $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'); + $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name'; + // Obtain announcements ... removed sort ordering, sort by time in all cases $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => $sql_array['SELECT'], + 'SELECT' => $sql_anounce_array['SELECT'], 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], + 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'], - 'WHERE' => 't.forum_id IN (' . $forum_id . ', 0) - AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')', + 'WHERE' => '(t.forum_id = ' . $forum_id . ' + AND t.topic_type = ' . POST_ANNOUNCE . ') OR + (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . ' + AND t.topic_type = ' . POST_GLOBAL . ')', 'ORDER_BY' => 't.topic_time DESC', )); @@ -377,18 +387,37 @@ if ($forum_data['forum_type'] == FORUM_POST) $rowset[$row['topic_id']] = $row; $announcement_list[] = $row['topic_id']; - if ($row['topic_type'] == POST_GLOBAL) + if ($forum_id != $row['forum_id']) { - $global_announce_list[$row['topic_id']] = true; - } - else - { - $topics_count--; + $topics_count++; + $global_announce_forums[] = $row['forum_id']; } } $db->sql_freeresult($result); } +$forum_tracking_info = array(); + +if ($user->data['is_registered']) +{ + $forum_tracking_info[$forum_id] = $forum_data['mark_time']; + + if (!empty($global_announce_forums) && $config['load_db_lastread']) + { + $sql = 'SELECT forum_id, mark_time + FROM ' . FORUMS_TRACK_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . ' + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_tracking_info[$row['forum_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + } +} + // If the user is trying to reach late pages, start searching from the end $store_reverse = false; $sql_limit = $config['topics_per_page']; @@ -546,45 +575,44 @@ if (sizeof($topic_list)) $mark_forum_read = true; $mark_time_forum = 0; - // Active topics? - if ($s_display_active && sizeof($active_forum_ary)) + // Generate topic forum list... + $topic_forum_list = array(); + foreach ($rowset as $t_id => $row) { - // Generate topic forum list... - $topic_forum_list = array(); - foreach ($rowset as $t_id => $row) + if (isset($forum_tracking_info[$row['forum_id']])) { - $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; - $topic_forum_list[$row['forum_id']]['topics'][] = $t_id; + $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; } - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false); - } - } - - unset($topic_forum_list); + $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; + $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; } - else + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); + } + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); + } + } + + unset($topic_forum_list); + + if (!$s_display_active) { if ($config['load_db_lastread'] && $user->data['is_registered']) { - $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list); $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list); - if (!$user->data['is_registered']) { $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; @@ -622,16 +650,16 @@ if (sizeof($topic_list)) topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); // Generate all the URIs ... - $view_topic_url_params = 'f=' . $topic_forum_id . '&t=' . $topic_id; + $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; + $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template $template->assign_block_vars('topicrow', array( - 'FORUM_ID' => $topic_forum_id, + 'FORUM_ID' => $row['forum_id'], 'TOPIC_ID' => $topic_id, 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), @@ -649,7 +677,9 @@ if (sizeof($topic_list)) 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, + 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'], + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], @@ -659,13 +689,13 @@ if (sizeof($topic_list)) 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $topic_forum_id)) ? true : false, + 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => ($row['poll_start']) ? true : false, @@ -680,7 +710,8 @@ if (sizeof($topic_list)) 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_VIEW_TOPIC' => $view_topic_url, - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $topic_forum_id . '&t=' . $topic_id, true, $user->session_id), + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), + 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&t=' . $topic_id, true, $user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue, 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index ff4e018d12..74ad7eba0d 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -371,17 +371,18 @@ unset($vars_online); $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"), $counter, $config['topics_per_page'], $start); +$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; // Grab group details for legend display if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) { - $sql = 'SELECT group_id, group_name, group_colour, group_type + $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; + WHERE group_legend = > 0 + ORDER BY ' . $order_legend . ' ASC'; } else { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type + $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend FROM ' . GROUPS_TABLE . ' g LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON ( @@ -389,9 +390,9 @@ else AND ug.user_id = ' . $user->data['user_id'] . ' AND ug.user_pending = 0 ) - WHERE g.group_legend = 1 + WHERE g.group_legend > 0 AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.group_name ASC'; + ORDER BY g.' . $order_legend . ' ASC'; } $result = $db->sql_query($sql); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index b8f1b9d3b0..53119e2ae7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -152,26 +152,12 @@ if ($view && !$post_id) else { $topic_id = $row['topic_id']; - - // Check for global announcement correctness? - if (!$row['forum_id'] && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if ($row['forum_id']) - { - $forum_id = $row['forum_id']; - } + $forum_id = $row['forum_id']; } } } - // Check for global announcement correctness? - if ((!isset($row) || !$row['forum_id']) && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if (isset($row) && $row['forum_id']) + if (isset($row) && $row['forum_id']) { $forum_id = $row['forum_id']; } @@ -186,13 +172,6 @@ $sql_array = array( 'FROM' => array(FORUMS_TABLE => 'f'), ); -// Firebird handles two columns of the same name a little differently, this -// addresses that by forcing the forum_id to come from the forums table. -if ($db->sql_layer === 'firebird') -{ - $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT']; -} - // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { @@ -247,26 +226,8 @@ else $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; } -$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id'; +$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; -if (!$forum_id) -{ - // If it is a global announcement make sure to set the forum id to a postable forum - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . ' - AND f.forum_type = ' . FORUM_POST . ')'; -} -else -{ - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . " - AND f.forum_id = $forum_id)"; -} - -$sql_array['WHERE'] .= ')'; - -// Join to forum table on topic forum_id unless topic forum_id is zero -// whereupon we join on the forum_id passed as a parameter ... this -// is done so navigation, forum name, etc. remain consistent with where -// user clicked to view a global topic $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $topic_data = $db->sql_fetchrow($result); @@ -1157,7 +1118,7 @@ while ($row = $db->sql_fetchrow($result)) if (!empty($row['user_icq'])) { - $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq']; + $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/'; $user_cache[$poster_id]['icq_status_img'] = ''; } else @@ -1540,13 +1501,14 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '#p' . $row['post_id'], + 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'POST_ID' => $row['post_id'], + 'POST_NUMBER' => $i + $start + 1, 'POSTER_ID' => $poster_id, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, @@ -1615,34 +1577,13 @@ if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($use } } -// Get last post time for all global announcements -// to keep proper forums tracking -if ($topic_data['topic_type'] == POST_GLOBAL) -{ - $sql = 'SELECT topic_last_post_time as forum_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - ORDER BY topic_last_post_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - $sql = 'SELECT mark_time as forum_mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE forum_id = 0 - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time'); - $db->sql_freeresult($result); -} - // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) { - markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time); + markread('topic', $forum_id, $topic_id, $max_post_time); // Update forum info - $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); + $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); } else { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8c4f1ed874..b7c3534cde 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,10 @@ $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; $table_prefix = 'phpbb_'; +if (!defined('E_DEPRECATED')) +{ + define('E_DEPRECATED', 8192); +} error_reporting(E_ALL & ~E_DEPRECATED); // If we are on PHP >= 6.0.0 we do not need some code diff --git a/tests/config/config_test.php b/tests/config/config_test.php index 73a365c847..9c91d9eb87 100644 --- a/tests/config/config_test.php +++ b/tests/config/config_test.php @@ -109,4 +109,12 @@ class phpbb_config_test extends phpbb_test_case $config->increment('foo', 1); $this->assertEquals(27, $config['foo']); } + + public function test_delete() + { + $config = new phpbb_config(array('foo' => 'bar')); + + $config->delete('foo'); + $this->assertFalse(isset($config['foo'])); + } } diff --git a/tests/config/db_test.php b/tests/config/db_test.php index e0d5252f19..e817545a54 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -125,4 +125,42 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config->increment('foobar', 3); $this->assertEquals(3, $this->config['foobar']);; } + + public function test_delete() + { + $this->assertTrue(isset($this->config['foo'])); + $this->config->delete('foo'); + $this->cache->checkVarUnset($this, 'foo'); + $this->assertFalse(isset($this->config['foo'])); + + // re-read config and populate cache + $cache2 = new phpbb_mock_cache; + $config2 = new phpbb_config_db($this->db, $cache2, 'phpbb_config'); + $cache2->checkVarUnset($this, 'foo'); + $this->assertFalse(isset($config2['foo'])); + } + + public function test_delete_write_read_not_cacheable() + { + // bar is dynamic + $this->assertTrue(isset($this->config['bar'])); + $this->config->delete('bar'); + $this->cache->checkVarUnset($this, 'bar'); + $this->assertFalse(isset($this->config['bar'])); + + $this->config->set('bar', 'new bar', false); + $this->assertEquals('new bar', $this->config['bar']); + } + + public function test_delete_write_read_cacheable() + { + // foo is not dynamic + $this->assertTrue(isset($this->config['foo'])); + $this->config->delete('foo'); + $this->cache->checkVarUnset($this, 'foo'); + $this->assertFalse(isset($this->config['foo'])); + + $this->config->set('foo', 'new foo', true); + $this->assertEquals('new foo', $this->config['foo']); + } } diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 6288a5c641..65d8360fbb 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -7,18 +7,18 @@ * */ -require_once __DIR__ . '/../mock/cache.php'; -require_once __DIR__ . '/task/testmod/dummy_task.php'; -require_once __DIR__ . '/task/testmod/second_dummy_task.php'; -require_once __DIR__ . '/task2/testmod/simple_ready.php'; -require_once __DIR__ . '/task2/testmod/simple_not_runnable.php'; -require_once __DIR__ . '/task2/testmod/simple_should_not_run.php'; +require_once dirname(__FILE__) . '/../mock/cache.php'; +require_once dirname(__FILE__) . '/task/testmod/dummy_task.php'; +require_once dirname(__FILE__) . '/task/testmod/second_dummy_task.php'; +require_once dirname(__FILE__) . '/task2/testmod/simple_ready.php'; +require_once dirname(__FILE__) . '/task2/testmod/simple_not_runnable.php'; +require_once dirname(__FILE__) . '/task2/testmod/simple_should_not_run.php'; class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase { public function setUp() { - $this->manager = new phpbb_cron_manager(__DIR__ . '/task/', 'php'); + $this->manager = new phpbb_cron_manager(dirname(__FILE__) . '/task/', 'php'); $this->task_name = 'phpbb_cron_task_testmod_dummy_task'; } @@ -57,7 +57,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_all_ready_tasks_cached() { $cache = new phpbb_mock_cache(array('_cron_tasks' => array($this->task_name))); - $manager = new phpbb_cron_manager(__DIR__ . '/../../phpBB/', 'php', $cache); + $manager = new phpbb_cron_manager(dirname(__FILE__) . '/../../phpBB/', 'php', $cache); $tasks = $manager->find_all_ready_tasks(); $this->assertEquals(1, sizeof($tasks)); @@ -65,7 +65,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_only_ready_tasks() { - $manager = new phpbb_cron_manager(__DIR__ . '/task2/', 'php'); + $manager = new phpbb_cron_manager(dirname(__FILE__) . '/task2/', 'php'); $tasks = $manager->find_all_ready_tasks(); $task_names = $this->tasks_to_names($tasks); $this->assertEquals(array('phpbb_cron_task_testmod_simple_ready'), $task_names); diff --git a/tests/group_positions/fixtures/group_positions.xml b/tests/group_positions/fixtures/group_positions.xml new file mode 100644 index 0000000000..55b1c2e08d --- /dev/null +++ b/tests/group_positions/fixtures/group_positions.xml @@ -0,0 +1,23 @@ + + +

    {searchresults.TOPIC_AUTHOR_FULL}

    {searchresults.TOPIC_REPLIES}

    {searchresults.L_IGNORE_POST}

     {L_FORUM}: {searchresults.FORUM_TITLE}{L_GLOBAL}   {L_TOPIC}: {searchresults.TOPIC_TITLE}

     {L_FORUM}: {searchresults.FORUM_TITLE}   {L_TOPIC}: {searchresults.TOPIC_TITLE}

    {topicrow.TOPIC_AUTHOR_FULL}

    {topicrow.REPLIES}

    + group_id + group_teampage + group_legend + + 1 + 0 + 0 + + + 2 + 1 + 0 + + + 3 + 2 + 1 + +
    + diff --git a/tests/group_positions/group_positions_test.php b/tests/group_positions/group_positions_test.php new file mode 100644 index 0000000000..b68f205b37 --- /dev/null +++ b/tests/group_positions/group_positions_test.php @@ -0,0 +1,287 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/group_positions.xml'); + } + + public static function get_group_value_data() + { + return array( + array('teampage', 1, 0), + array('teampage', 2, 1), + array('legend', 1, 0), + array('legend', 3, 1), + ); + } + + /** + * @dataProvider get_group_value_data + */ + public function test_get_group_value($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + + $test_class = new phpbb_group_positions($db, $field); + $this->assertEquals($expected, $test_class->get_group_value($group_id)); + } + + public static function get_group_count_data() + { + return array( + array('teampage', 2), + array('legend', 1), + ); + } + + /** + * @dataProvider get_group_count_data + */ + public function test_get_group_count($field, $expected) + { + global $db; + + $db = $this->new_dbal(); + + $test_class = new phpbb_group_positions($db, $field); + $this->assertEquals($expected, $test_class->get_group_count()); + } + + public static function add_group_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 3, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider add_group_data + */ + public function test_add_group($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->add_group($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function delete_group_data() + { + return array( + array('teampage', 1, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, false, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 0, 'group_legend' => 1), + )), + array('teampage', 1, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, true, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider delete_group_data + */ + public function test_delete_group($field, $group_id, $skip_group, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->delete_group($group_id, $skip_group); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_up_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_up_data + */ + public function test_move_up($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move_up($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_down_data() + { + return array( + array('teampage', 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_down_data + */ + public function test_move_down($field, $group_id, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move_down($group_id); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function move_data() + { + return array( + array('teampage', 1, 1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 1, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 3, 3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 2, 0, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + array('teampage', 2, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 2, -3, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 2, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 1, 'group_legend' => 1), + )), + array('teampage', 3, -1, array( + array('group_id' => 1, 'group_teampage' => 0, 'group_legend' => 0), + array('group_id' => 2, 'group_teampage' => 1, 'group_legend' => 0), + array('group_id' => 3, 'group_teampage' => 2, 'group_legend' => 1), + )), + ); + } + + /** + * @dataProvider move_data + */ + public function test_move($field, $group_id, $increment, $expected) + { + global $db; + + $db = $this->new_dbal(); + $test_class = new phpbb_group_positions($db, $field); + $test_class->move($group_id, $increment); + + $result = $db->sql_query('SELECT group_id, group_teampage, group_legend + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} + diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index 3b2e3ea3b2..ed15423314 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_lock_db_test extends phpbb_database_test_case { diff --git a/tests/mock/cache.php b/tests/mock/cache.php index 713f1ca817..d3f9b8ad5a 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -42,9 +42,21 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface $test->assertFalse(isset($this->data[$var_name])); } - public function check(PHPUnit_Framework_Assert $test, $data) + public function check(PHPUnit_Framework_Assert $test, $data, $ignore_db_info = true) { - $test->assertEquals($data, $this->data); + $cache_data = $this->data; + + if ($ignore_db_info) + { + unset($cache_data['mssqlodbc_version']); + unset($cache_data['mssql_version']); + unset($cache_data['mysql_version']); + unset($cache_data['mysqli_version']); + unset($cache_data['pgsql_version']); + unset($cache_data['sqlite_version']); + } + + $test->assertEquals($data, $cache_data); } function load() diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php new file mode 100644 index 0000000000..21e8d12a0a --- /dev/null +++ b/tests/regex/password_complexity_test.php @@ -0,0 +1,81 @@ +assertFalse(validate_password($password)); + } + + /** + * @dataProvider password_complexity_test_data_negative + */ + public function test_password_complexity_negative($password, $mode) + { + global $config; + $config['pass_complex'] = $mode; + $this->assertEquals('INVALID_CHARS', validate_password($password)); + } +} diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 6a0ede0106..7a45ef2fee 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -12,6 +12,15 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_var_test extends phpbb_test_case { + /** + * Makes sure request_var has its standard behaviour. + */ + protected function setUp() + { + parent::setUp(); + request_var(false, false, false, false, false); + } + /** * @dataProvider request_variables */ diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php new file mode 100644 index 0000000000..19a3822145 --- /dev/null +++ b/tests/security/hash_test.php @@ -0,0 +1,21 @@ +assertTrue(phpbb_check_hash('test', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); + $this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); + $this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); + } +} + diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php index 06b03f5780..6737562a0a 100644 --- a/tests/session/continue_test.php +++ b/tests/session/continue_test.php @@ -19,27 +19,30 @@ class phpbb_session_continue_test extends phpbb_database_test_case static public function session_begin_attempts() { - global $_SID; + // The session_id field is defined as CHAR(32) in the database schema. + // Thus the data we put in session_id fields has to have a length of 32 characters on stricter DBMSes. + // Thus we fill those strings up with zeroes until they have a string length of 32. + return array( array( - 'bar_session', '4', 'user agent', '127.0.0.1', + 'bar_session000000000000000000000', '4', 'user agent', '127.0.0.1', array( - array('session_id' => 'anon_session', 'session_user_id' => 1), - array('session_id' => 'bar_session', 'session_user_id' => 4) + array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1), + array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), ), array(), 'If a request comes with a valid session id with matching user agent and IP, no new session should be created.', ), array( - 'anon_session', '4', 'user agent', '127.0.0.1', + 'anon_session00000000000000000000', '4', 'user agent', '127.0.0.1', array( - array('session_id' => 'bar_session', 'session_user_id' => 4), - array('session_id' => null, 'session_user_id' => 1) // use generated SID + array('session_id' => '__new_session_id__', 'session_user_id' => 1), // use generated SID + array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), ), array( 'u' => array('1', null), 'k' => array(null, null), - 'sid' => array($_SID, null), + 'sid' => array('__new_session_id__', null), ), 'If a request comes with a valid session id and IP but different user id and user agent, a new anonymous session is created and the session matching the supplied session id is deleted.', ), @@ -71,26 +74,48 @@ class phpbb_session_continue_test extends phpbb_database_test_case $session->session_begin(); $sql = 'SELECT session_id, session_user_id - FROM phpbb_sessions'; + FROM phpbb_sessions + ORDER BY session_user_id'; - // little tickery to allow using a dataProvider with dynamic expected result - foreach ($expected_sessions as $i => $s) - { - if (is_null($s['session_id'])) - { - $expected_sessions[$i]['session_id'] = $session->session_id; - } - } + $expected_sessions = $this->replace_session($expected_sessions, $session->session_id); + $expected_cookies = $this->replace_session($expected_cookies, $session->session_id); $this->assertSqlResultEquals( $expected_sessions, $sql, - 'Check if no new session was created' + $message ); $session->check_cookies($this, $expected_cookies); $session_factory->check($this); } -} + /** + * Replaces recursively the value __new_session_id__ with the given session + * id. + * + * @param array $array An array of data + * @param string $session_id The new session id to use instead of the + * placeholder. + * @return array The input array with all occurances of __new_session_id__ + * replaced. + */ + public function replace_session($array, $session_id) + { + foreach ($array as $key => &$value) + { + if ($value === '__new_session_id__') + { + $value = $session_id; + } + + if (is_array($value)) + { + $value = $this->replace_session($value, $session_id); + } + } + + return $array; + } +} diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml index 4559a08c55..bf6fc65997 100644 --- a/tests/session/fixtures/sessions_full.xml +++ b/tests/session/fixtures/sessions_full.xml @@ -22,13 +22,13 @@ session_ip session_browser - anon_session + anon_session00000000000000000000 1 127.0.0.1 anonymous user agent - bar_session + bar_session000000000000000000000 4 127.0.0.1 user agent diff --git a/tests/template/template_test.php b/tests/template/template_test.php index a3ba3e581f..62f94f7d32 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -324,8 +324,7 @@ class phpbb_template_template_test extends phpbb_test_case */ public function test_template($file, array $vars, array $block_vars, array $destroy, $expected) { - global $phpEx; - $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx; + $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php'; $this->assertFileNotExists($cache_file); @@ -375,11 +374,9 @@ class phpbb_template_template_test extends phpbb_test_case public function test_php() { - global $phpEx; - $GLOBALS['config']['tpl_allow_php'] = true; - $cache_file = $this->template->cachepath . 'php.html.' . $phpEx; + $cache_file = $this->template->cachepath . 'php.html.php'; $this->assertFileNotExists($cache_file); @@ -390,21 +387,14 @@ class phpbb_template_template_test extends phpbb_test_case public function test_includephp() { - $this->markTestIncomplete('Include PHP test file paths are broken'); - $GLOBALS['config']['tpl_allow_php'] = true; - $cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT; - - $cwd = getcwd(); - chdir(dirname(__FILE__) . '/templates'); + $cache_file = $this->template->cachepath . 'includephp.html.php'; $this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file); $this->template->set_filenames(array('test' => 'includephp.html')); - $this->assertEquals('testing included php', $this->display('test'), "Testing $file"); - - chdir($cwd); + $this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP"); $GLOBALS['config']['tpl_allow_php'] = false; } @@ -418,17 +408,16 @@ class phpbb_template_template_test extends phpbb_test_case false, 'insert', << 'before'), - false, - 'insert', - << 'after'), - true, - 'insert', - << 'pos #1'), - 1, - 'insert', - << 'before'), - false, - 'insert', - << 'before'), - false, - 'insert', - << 'before'), - false, - 'insert', - <<markTestIncomplete('Alter Block Test is broken'); - $this->template->set_filenames(array('test' => 'loop_nested.html')); // @todo Change this @@ -656,12 +498,11 @@ EOT $this->template->assign_block_vars('outer', array()); $this->template->assign_block_vars('outer.middle', array()); $this->template->assign_block_vars('outer.middle', array()); - $this->template->assign_block_vars('outer.middle', array()); $this->template->assign_block_vars('outer', array()); $this->template->assign_block_vars('outer.middle', array()); $this->template->assign_block_vars('outer.middle', array()); - $this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification'); + $this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification'); $this->template->alter_block_array($alter_block, $vararray, $key, $mode); $this->assertEquals($expect, $this->display('test'), $description); diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html index 117d4273f0..70ebdac0d0 100644 --- a/tests/template/templates/includephp.html +++ b/tests/template/templates/includephp.html @@ -1 +1 @@ - + diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html index 571df97b4c..9b251cd453 100644 --- a/tests/template/templates/loop_nested.html +++ b/tests/template/templates/loop_nested.html @@ -1,8 +1,8 @@ - {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS} - {outer.VARIABLE} + outer - {outer.S_ROW_COUNT} - {outer.VARIABLE} - {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS} - {middle.VARIABLE} + middle - {middle.S_ROW_COUNT} - {middle.VARIABLE} diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 6c06857fbc..a7559e2183 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -123,7 +123,7 @@ class phpbb_database_test_connection_manager try { - $this->pdo->exec('DROP DATABASE ' . $config['dbname']); + $this->pdo->exec('DROP DATABASE ' . $this->config['dbname']); } catch (PDOException $e) {