aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--build/build.xml1
-rwxr-xr-xgit-tools/hooks/commit-msg34
-rwxr-xr-xgit-tools/hooks/prepare-commit-msg4
-rwxr-xr-xgit-tools/setup_github_network.php248
-rw-r--r--phpBB/adm/index.php6
-rw-r--r--phpBB/adm/style/acp_ban.html2
-rw-r--r--phpBB/adm/style/acp_ranks.html4
-rw-r--r--phpBB/adm/style/acp_styles.html15
-rw-r--r--phpBB/develop/create_schema_files.php2
-rw-r--r--phpBB/develop/mysql_upgrader.php3
-rw-r--r--phpBB/docs/AUTHORS23
-rw-r--r--phpBB/docs/coding-guidelines.html2
-rw-r--r--phpBB/docs/nginx.sample.conf33
-rw-r--r--phpBB/download/file.php14
-rw-r--r--phpBB/feed.php46
-rw-r--r--phpBB/includes/acm/acm_file.php4
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php2
-rw-r--r--phpBB/includes/acp/acp_language.php12
-rw-r--r--phpBB/includes/acp/acp_main.php2
-rw-r--r--phpBB/includes/acp/acp_profile.php2
-rw-r--r--phpBB/includes/acp/acp_styles.php260
-rw-r--r--phpBB/includes/captcha/captcha_gd_wave.php4
-rw-r--r--phpBB/includes/constants.php3
-rw-r--r--phpBB/includes/db/firebird.php49
-rw-r--r--phpBB/includes/db/postgres.php36
-rw-r--r--phpBB/includes/error_collector.php61
-rw-r--r--phpBB/includes/functions.php8
-rw-r--r--phpBB/includes/functions_admin.php24
-rw-r--r--phpBB/includes/functions_posting.php4
-rw-r--r--phpBB/includes/functions_user.php38
-rw-r--r--phpBB/includes/mcp/mcp_front.php2
-rw-r--r--phpBB/includes/mcp/mcp_post.php4
-rw-r--r--phpBB/includes/session.php14
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php1
-rw-r--r--phpBB/install/database_update.php35
-rw-r--r--phpBB/install/install_install.php2
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql2
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql2
-rw-r--r--phpBB/install/schemas/oracle_schema.sql2
-rw-r--r--phpBB/install/schemas/postgres_schema.sql2
-rw-r--r--phpBB/install/schemas/schema_data.sql18
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql2
-rw-r--r--phpBB/language/en/acp/styles.php8
-rw-r--r--phpBB/posting.php4
-rw-r--r--phpBB/styles/prosilver/template/mcp_post.html4
-rw-r--r--phpBB/styles/prosilver/template/memberlist_search.html2
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html13
-rw-r--r--phpBB/styles/prosilver/template/posting_buttons.html2
-rw-r--r--phpBB/styles/prosilver/template/posting_smilies.html2
-rw-r--r--phpBB/styles/prosilver/template/simple_header.html4
-rw-r--r--phpBB/styles/prosilver/theme/colours.css2
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html7
-rw-r--r--phpBB/styles/subsilver2/template/posting_buttons.html2
-rw-r--r--phpBB/styles/subsilver2/template/posting_smilies.html2
-rw-r--r--phpBB/viewtopic.php1
-rw-r--r--tests/bootstrap.php5
-rw-r--r--tests/dbal/select_test.php2
-rw-r--r--tests/dbal/write_test.php2
-rw-r--r--tests/mock/cache.php11
-rw-r--r--tests/mock/session_testable.php11
-rw-r--r--tests/network/checkdnsrr_test.php2
-rw-r--r--tests/random/gen_rand_string_test.php2
-rw-r--r--tests/regex/censor_test.php2
-rw-r--r--tests/regex/email_test.php2
-rw-r--r--tests/regex/ipv4_test.php2
-rw-r--r--tests/regex/ipv6_test.php2
-rw-r--r--tests/regex/url_test.php2
-rw-r--r--tests/request/request_var_test.php4
-rw-r--r--tests/security/extract_current_page_test.php6
-rw-r--r--tests/security/redirect_test.php6
-rw-r--r--tests/session/continue_test.php117
-rw-r--r--tests/session/fixtures/sessions_empty.xml6
-rw-r--r--tests/session/init_test.php56
-rw-r--r--tests/session/session_continue.php117
-rw-r--r--tests/session/session_init.php76
-rw-r--r--tests/session/testable_factory.php171
-rw-r--r--tests/template/template_test.php251
-rw-r--r--tests/template/templates/includephp.html2
-rw-r--r--tests/template/templates/loop_nested.html4
-rw-r--r--tests/test_framework/phpbb_database_test_case.php293
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php346
-rw-r--r--tests/text_processing/make_clickable_test.php4
-rw-r--r--tests/user/lang_test.php58
-rw-r--r--tests/utf/normalizer_test.php10
-rw-r--r--tests/utf/utf8_clean_string_test.php2
-rw-r--r--tests/utf/utf8_wordwrap_test.php2
87 files changed, 1741 insertions, 921 deletions
diff --git a/.gitignore b/.gitignore
index c417bf01c1..22a3124b69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@ phpunit.xml
phpBB/cache/*.php
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 @@
<!-- These are the main targets which you will probably want to use -->
<target name="package" depends="clean,prepare,create-package" />
<target name="all" depends="clean,prepare,test,docs,create-package" />
+ <target name="build" depends="clean,prepare,test,docs" />
<target name="prepare">
<mkdir dir="build/logs" />
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg
index a6777ff9c9..ad4d69a9da 100755
--- a/git-tools/hooks/commit-msg
+++ b/git-tools/hooks/commit-msg
@@ -55,6 +55,17 @@ quit()
fi
}
+# 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 -nE '.{81,}' "$1");
if [ $? -eq 0 ]
@@ -107,7 +118,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 +151,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 +215,7 @@ do
in_description=1;
;;
"footer")
- expecting="footer eof";
+ expecting="footer possibly-eof";
if [ "$tickets" = "" ]
then
tickets="$line";
@@ -199,6 +226,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/setup_github_network.php b/git-tools/setup_github_network.php
new file mode 100755
index 0000000000..e4e212eef6
--- /dev/null
+++ b/git-tools/setup_github_network.php
@@ -0,0 +1,248 @@
+#!/usr/bin/env php
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+function show_usage()
+{
+ $filename = basename(__FILE__);
+
+ echo "$filename adds repositories of a github network as remotes to a local git repository.\n";
+ echo "\n";
+
+ echo "Usage: [php] $filename -s collaborators|organisation|contributors|network [OPTIONS]\n";
+ echo "\n";
+
+ echo "Scopes:\n";
+ echo " collaborators Repositories of people who have push access to the specified repository\n";
+ echo " contributors Repositories of people who have contributed to the specified repository\n";
+ echo " organisation Repositories of members of the organisation at github\n";
+ echo " network All repositories of the whole github network\n";
+ echo "\n";
+
+ echo "Options:\n";
+ echo " -s scope See description above (mandatory)\n";
+ echo " -u github_username Overwrites the github username (optional)\n";
+ echo " -r repository_name Overwrites the repository name (optional)\n";
+ echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
+ echo " -d Outputs the commands instead of running them (optional)\n";
+ echo " -h This help text\n";
+
+ exit(1);
+}
+
+// Handle arguments
+$opts = getopt('s:u:r:m:dh');
+
+if (empty($opts) || isset($opts['h']))
+{
+ show_usage();
+}
+
+$scope = get_arg($opts, 's', '');
+$username = get_arg($opts, 'u', 'phpbb');
+$repository = get_arg($opts, 'r', 'phpbb3');
+$developer = get_arg($opts, 'm', '');
+$dry_run = !get_arg($opts, 'd', true);
+run(null, $dry_run);
+exit(work($scope, $username, $repository, $developer));
+
+function work($scope, $username, $repository, $developer)
+{
+ // Get some basic data
+ $network = get_network($username, $repository);
+ $collaborators = get_collaborators($username, $repository);
+
+ if ($network === false || $collaborators === false)
+ {
+ echo "Error: failed to retrieve network or collaborators\n";
+ return 1;
+ }
+
+ switch ($scope)
+ {
+ case 'collaborators':
+ $remotes = array_intersect_key($network, $collaborators);
+ break;
+
+ case 'organisation':
+ $remotes = array_intersect_key($network, get_organisation_members($username));
+ break;
+
+ case 'contributors':
+ $remotes = array_intersect_key($network, get_contributors($username, $repository));
+ break;
+
+ case 'network':
+ $remotes = $network;
+ break;
+
+ default:
+ show_usage();
+ }
+
+ if (file_exists('.git'))
+ {
+ add_remote($username, $repository, isset($collaborators[$developer]));
+ }
+ else
+ {
+ clone_repository($username, $repository, isset($collaborators[$developer]));
+ }
+
+ // Add private security repository for developers
+ if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer]))
+ {
+ run("git remote add $username-security " . get_repository_url($username, "$repository-security", true));
+ }
+
+ // Skip blessed repository.
+ unset($remotes[$username]);
+
+ foreach ($remotes as $remote)
+ {
+ add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
+ }
+
+ run('git remote update');
+}
+
+function clone_repository($username, $repository, $pushable = false)
+{
+ $url = get_repository_url($username, $repository, false);
+ run("git clone $url ./ --origin $username");
+
+ if ($pushable)
+ {
+ $ssh_url = get_repository_url($username, $repository, true);
+ run("git remote set-url --push $username $ssh_url");
+ }
+}
+
+function add_remote($username, $repository, $pushable = false)
+{
+ $url = get_repository_url($username, $repository, false);
+ run("git remote add $username $url");
+
+ 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)
+ {
+ return false;
+ }
+ return json_decode($contents);
+}
+
+function get_contributors($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/contributors");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->contributors as $contributor)
+ {
+ $usernames[$contributor->login] = $contributor->login;
+ }
+
+ return $usernames;
+}
+
+function get_organisation_members($username)
+{
+ $request = api_request("organizations/$username/public_members");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->users as $member)
+ {
+ $usernames[$member->login] = $member->login;
+ }
+
+ return $usernames;
+}
+
+function get_collaborators($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/collaborators");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->collaborators as $collaborator)
+ {
+ $usernames[$collaborator] = $collaborator;
+ }
+
+ return $usernames;
+}
+
+function get_network($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/network");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->network as $network)
+ {
+ $usernames[$network->owner] = array(
+ 'username' => $network->owner,
+ 'repository' => $network->name,
+ );
+ }
+
+ return $usernames;
+}
+
+function get_arg($array, $index, $default)
+{
+ return isset($array[$index]) ? $array[$index] : $default;
+}
+
+function run($cmd, $dry = false)
+{
+ static $dry_run;
+
+ if (is_null($cmd))
+ {
+ $dry_run = $dry;
+ }
+ else if (!empty($dry_run))
+ {
+ echo "$cmd\n";
+ }
+ else
+ {
+ passthru(escapeshellcmd($cmd));
+ }
+}
diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index 92bcf90039..dd8f4c279d 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -573,7 +573,11 @@ function validate_range($value_ary, &$error)
'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),
- 'INT' => array('php_type' => 'int', 'min' => (int) 0x80000000, '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),
diff --git a/phpBB/adm/style/acp_ban.html b/phpBB/adm/style/acp_ban.html
index cf44f4aaa7..0e2e71822e 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_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 @@
</dl>
<dl>
<dt><label for="special_rank">{L_RANK_SPECIAL}:</label></dt>
- <dd><label><input onchange="dE('posts', -1)" type="radio" class="radio" name="special_rank" value="1" id="special_rank"<!-- IF S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> />{L_YES}</label>
- <label><input onchange="dE('posts', 1)" type="radio" class="radio" name="special_rank" value="0"<!-- IF not S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
+ <dd><label><input onclick="dE('posts', -1)" type="radio" class="radio" name="special_rank" value="1" id="special_rank"<!-- IF S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> />{L_YES}</label>
+ <label><input onclick="dE('posts', 1)" type="radio" class="radio" name="special_rank" value="0"<!-- IF not S_SPECIAL_RANK --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl>
<!-- IF S_SPECIAL_RANK --><div id="posts" style="display: none;"><!-- ELSE --><div id="posts"><!-- ENDIF -->
<dl>
diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html
index cb4361dd6f..098cc723d9 100644
--- a/phpBB/adm/style/acp_styles.html
+++ b/phpBB/adm/style/acp_styles.html
@@ -22,6 +22,21 @@
<dt><label for="new_id">{L_REPLACE}:</label><br /><span>{L_REPLACE_EXPLAIN}</span></dt>
<dd><select id="new_id" name="new_id">{S_REPLACE_OPTIONS}</select></dd>
</dl>
+ <!-- IF S_DELETE_STYLE -->
+ <hr />
+ <dl>
+ <dt><label for="new_template_id">{L_DELETE_TEMPLATE}:</label><br /><span>{L_REPLACE_TEMPLATE_EXPLAIN}</span></dt>
+ <dd><select id="new_template_id" name="new_template_id">{S_REPLACE_TEMPLATE_OPTIONS}</select></dd>
+ </dl>
+ <dl>
+ <dt><label for="new_theme_id">{L_DELETE_THEME}:</label><br /><span>{L_REPLACE_THEME_EXPLAIN}</span></dt>
+ <dd><select id="new_theme_id" name="new_theme_id">{S_REPLACE_THEME_OPTIONS}</select></dd>
+ </dl>
+ <dl>
+ <dt><label for="new_imageset_id">{L_DELETE_IMAGESET}:</label><br /><span>{L_REPLACE_IMAGESET_EXPLAIN}</span></dt>
+ <dd><select id="new_imageset_id" name="new_imageset_id">{S_REPLACE_IMAGESET_OPTIONS}</select></dd>
+ </dl>
+ <!-- ENDIF -->
<p class="quick">
<input class="button1" type="submit" name="update" value="{L_DELETE}" />
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 0515d801f2..87670722aa 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -926,7 +926,7 @@ function get_schema_struct()
$schema_data['phpbb_bbcodes'] = array(
'COLUMNS' => array(
- 'bbcode_id' => array('TINT:3', 0),
+ 'bbcode_id' => array('USINT', 0),
'bbcode_tag' => array('VCHAR:16', ''),
'bbcode_helpline' => array('VCHAR_UNI', ''),
'display_on_posting' => array('BOOL', 0),
diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php
index 57230339e8..70c8173a32 100644
--- a/phpBB/develop/mysql_upgrader.php
+++ b/phpBB/develop/mysql_upgrader.php
@@ -21,6 +21,7 @@
die("Please read the first lines of this script for instructions on how to enable it");
define('IN_PHPBB', true);
+$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
@@ -414,7 +415,7 @@ function get_schema_struct()
$schema_data['phpbb_bbcodes'] = array(
'COLUMNS' => array(
- 'bbcode_id' => array('TINT:3', 0),
+ 'bbcode_id' => array('USINT', 0),
'bbcode_tag' => array('VCHAR:16', ''),
'bbcode_helpline' => array('VCHAR_UNI', ''),
'display_on_posting' => array('BOOL', 0),
diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS
index 1dfb80141c..83feca009b 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -22,20 +22,18 @@ involved in phpBB.
phpBB Lead Developer: naderman (Nils Adermann)
-phpBB Developers: A_Jelly_Doughnut (Josh Woody)
- Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
+phpBB Developers: Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
APTX (Marek A. R.)
bantu (Andreas Fischer)
- dhn (Dominik Dröscher)
+ ckwalsh (Cullen Walsh)
igorw (Igor Wiedler)
kellanved (Henry Sudhof)
nickvergessen (Joas Schilling)
+ nn- (Oleg Pudeyev)
rxu (Ruslan Uzdenov)
- Terrafrost (Jim Wigginton)
ToonArmy (Chris Smith)
-Contributions by: Brainy (Cullen Walsh)
- leviatan21 (Gabriel Vazquez)
+Contributions by: leviatan21 (Gabriel Vazquez)
Raimon (Raimon Meuldijk)
Xore (Robert Hetzler)
@@ -47,11 +45,14 @@ phpBB Project Manager: theFinn (James Atkinson) [Founder - 04/2007]
phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005]
-phpBB Developers: Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
- BartVB (Bart van Bragt) [11/2000 - 03/2006]
- DavidMJ (David M.) [12/2005 - 08/2009]
- GrahamJE (Graham Eames) [09/2005 - 11/2006]
- Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
+phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
+ Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
+ BartVB (Bart van Bragt) [11/2000 - 03/2006]
+ DavidMJ (David M.) [12/2005 - 08/2009]
+ dhn (Dominik Dröscher) [05/2007 - 01/2011]
+ GrahamJE (Graham Eames) [09/2005 - 11/2006]
+ TerraFrost (Jim Wigginton) [04/2009 - 01/2011]
+ Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
-- Copyrights --
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 7434fa4870..bce65335d6 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -1018,7 +1018,7 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<h4>General function usage: </h4>
- <p>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.</p>
+ <p>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.</p>
<ul>
<li>
diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf
index 2a11e057c5..40b6ee76da 100644
--- a/phpBB/docs/nginx.sample.conf
+++ b/phpBB/docs/nginx.sample.conf
@@ -10,14 +10,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;
@@ -26,14 +35,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;
@@ -45,8 +60,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.
@@ -60,8 +77,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 5f45b88359..e1ec835b9b 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -64,7 +64,7 @@ if (isset($_GET['avatar']))
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0';
$config = $cache->obtain_config();
- $filename = $_GET['avatar'];
+ $filename = request_var('avatar', '');
$avatar_group = false;
$exit = false;
@@ -125,11 +125,13 @@ $user->setup('viewtopic');
if (!$download_id)
{
+ send_status_line(404, 'Not Found');
trigger_error('NO_ATTACHMENT_SELECTED');
}
if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
{
+ send_status_line(404, 'Not Found');
trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
}
@@ -142,11 +144,13 @@ $db->sql_freeresult($result);
if (!$attachment)
{
+ send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
if ((!$attachment['in_message'] && !$config['allow_attachments']) || ($attachment['in_message'] && !$config['allow_pm_attach']))
{
+ send_status_line(404, 'Not Found');
trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
}
@@ -159,6 +163,7 @@ if ($attachment['is_orphan'])
if (!$own_attachment || ($attachment['in_message'] && !$auth->acl_get('u_pm_download')) || (!$attachment['in_message'] && !$auth->acl_get('u_download')))
{
+ send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
@@ -191,6 +196,7 @@ else
}
else
{
+ send_status_line(403, 'Forbidden');
trigger_error('SORRY_AUTH_VIEW_ATTACH');
}
}
@@ -231,6 +237,7 @@ else
$extensions = array();
if (!extension_allowed($row['forum_id'], $attachment['extension'], $extensions))
{
+ send_status_line(404, 'Forbidden');
trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
}
@@ -253,6 +260,7 @@ $db->sql_freeresult($result);
if (!$attachment)
{
+ send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
@@ -295,6 +303,7 @@ else
// This presenting method should no longer be used
if (!@is_dir($phpbb_root_path . $config['upload_path']))
{
+ send_status_line(500, 'Internal Server Error');
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
}
@@ -419,6 +428,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
if (!@file_exists($filename))
{
+ send_status_line(404, 'Not Found');
trigger_error($user->lang['ERROR_NO_ATTACHMENT'] . '<br /><br />' . sprintf($user->lang['FILE_NOT_FOUND_404'], $filename));
}
@@ -445,9 +455,11 @@ function send_file_to_browser($attachment, $upload_dir, $category)
// PHP track_errors setting On?
if (!empty($php_errormsg))
{
+ send_status_line(500, 'Internal Server Error');
trigger_error($user->lang['UNABLE_TO_DELIVER_FILE'] . '<br />' . sprintf($user->lang['TRACKED_PHP_ERROR'], $php_errormsg));
}
+ send_status_line(500, 'Internal Server Error');
trigger_error('UNABLE_TO_DELIVER_FILE');
}
diff --git a/phpBB/feed.php b/phpBB/feed.php
index c4b71f3a26..d737b8e10c 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 '<author><name><![CDATA[' . $row['author'] . ']]></name></author>' . "\n";
}
- echo '<updated>' . $row['pubdate'] . '</updated>' . "\n";
+ echo '<updated>' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '</updated>' . "\n";
+
+ if (!empty($row['published']))
+ {
+ echo '<published>' . $row['published'] . '</published>' . "\n";
+ }
+
echo '<id>' . $row['link'] . '</id>' . "\n";
echo '<link href="' . $row['link'] . '"/>' . "\n";
echo '<title type="html"><![CDATA[' . $row['title'] . ']]></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'] : '');
@@ -800,7 +810,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',
@@ -932,7 +942,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',
@@ -1097,7 +1107,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 +1146,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');
}
@@ -1261,8 +1271,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',
@@ -1334,8 +1344,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 +1391,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()
@@ -1434,7 +1442,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/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index 5c1876d006..524a28561e 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -88,11 +88,11 @@ class acm
if (!phpbb_is_writable($this->cache_dir))
{
// We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload())
- die($this->cache_dir . ' is NOT writable.');
+ die('Fatal: ' . $this->cache_dir . ' is NOT writable.');
exit;
}
- die('Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx);
+ die('Fatal: Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx);
exit;
}
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index 2b706394c4..0644b38eb1 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -213,7 +213,7 @@ class acp_bbcodes
$bbcode_id = NUM_CORE_BBCODES + 1;
}
- if ($bbcode_id > 1511)
+ if ($bbcode_id > BBCODE_LIMIT)
{
trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING);
}
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index c2cb2f9c11..598b390302 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -1055,14 +1055,14 @@ class acp_language
$iso_src .= htmlspecialchars_decode($row['lang_author']);
$compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt');
- // index.html files
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.html');
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.html');
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.html');
+ // index.htm files
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.htm');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.htm');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.htm');
if (sizeof($mod_files))
{
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.html');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.htm');
}
$compress->close();
@@ -1217,7 +1217,7 @@ $lang = array_merge($lang, array(
';
// Language files in language root directory
- $this->main_files = array("common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");
+ $this->main_files = array("captcha_qa.$phpEx", "captcha_recaptcha.$phpEx", "common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");
}
/**
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index b8712b2a3d..60cebe3c08 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -529,7 +529,7 @@ class acp_main
);
$log_data = array();
- $log_count = 0;
+ $log_count = false;
if ($auth->acl_get('a_viewlogs'))
{
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 2288a0728b..2e43b0545a 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -512,7 +512,7 @@ class acp_profile
else if ($field_type == FIELD_INT && $key == 'field_default_value')
{
// Permit an empty string
- if (request_var('field_default_value', '') === '')
+ if ($action == 'create' && request_var('field_default_value', '') === '')
{
$var = '';
}
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 2ccc728031..37cf8d1f72 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -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
@@ -1587,23 +1587,23 @@ parse_css_file = {PARSE_CSS_FILE}
{
case 'style':
$sql_from = STYLES_TABLE;
- $sql_select = 'style_name';
+ $sql_select = 'style_id, style_name, template_id, theme_id, imageset_id';
$sql_where = 'AND style_active = 1';
break;
case 'template':
$sql_from = STYLES_TEMPLATE_TABLE;
- $sql_select = 'template_name, template_path, template_storedb';
+ $sql_select = 'template_id, template_name, template_path, template_storedb';
break;
case 'theme':
$sql_from = STYLES_THEME_TABLE;
- $sql_select = 'theme_name, theme_path, theme_storedb';
+ $sql_select = 'theme_id, theme_name, theme_path, theme_storedb';
break;
case 'imageset':
$sql_from = STYLES_IMAGESET_TABLE;
- $sql_select = 'imageset_name, imageset_path';
+ $sql_select = 'imageset_id, imageset_name, imageset_path';
break;
}
@@ -1633,37 +1633,14 @@ parse_css_file = {PARSE_CSS_FILE}
trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $sql = "SELECT {$mode}_id, {$mode}_name
- FROM $sql_from
- WHERE {$mode}_id <> $style_id
- $sql_where
- ORDER BY {$mode}_name ASC";
- $result = $db->sql_query($sql);
-
- $s_options = '';
-
- if ($row = $db->sql_fetchrow($result))
- {
- do
- {
- $s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>';
- }
- while ($row = $db->sql_fetchrow($result));
- }
- else
- {
- trigger_error($user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);
- }
- $db->sql_freeresult($result);
-
if ($update)
{
- $sql = "DELETE FROM $sql_from
- WHERE {$mode}_id = $style_id";
- $db->sql_query($sql);
-
if ($mode == 'style')
{
+ $sql = "DELETE FROM $sql_from
+ WHERE {$mode}_id = $style_id";
+ $db->sql_query($sql);
+
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $new_id
WHERE user_style = $style_id";
@@ -1678,19 +1655,19 @@ parse_css_file = {PARSE_CSS_FILE}
{
set_config('default_style', $new_id);
}
+
+ // Remove the components
+ $components = array('template', 'theme', 'imageset');
+ foreach ($components as $component)
+ {
+ $new_id = request_var('new_' . $component . '_id', 0);
+ $component_id = $style_row[$component . '_id'];
+ $this->remove_component($component, $component_id, $new_id, $style_id);
+ }
}
else
{
- if ($mode == 'imageset')
- {
- $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . "
- WHERE imageset_id = $style_id";
- $db->sql_query($sql);
- }
- $sql = 'UPDATE ' . STYLES_TABLE . "
- SET {$mode}_id = $new_id
- WHERE {$mode}_id = $style_id";
- $db->sql_query($sql);
+ $this->remove_component($mode, $style_id, $new_id);
}
$cache->destroy('sql', STYLES_TABLE);
@@ -1700,11 +1677,12 @@ parse_css_file = {PARSE_CSS_FILE}
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
}
+ $this->display_component_options($mode, $style_row[$mode . '_id'], $style_row);
+
$this->page_title = 'DELETE_' . $l_prefix;
$template->assign_vars(array(
'S_DELETE' => true,
- 'S_REPLACE_OPTIONS' => $s_options,
'L_TITLE' => $user->lang[$this->page_title],
'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
@@ -1718,6 +1696,202 @@ parse_css_file = {PARSE_CSS_FILE}
'NAME' => $style_row[$mode . '_name'],
)
);
+
+ if ($mode == 'style')
+ {
+ $template->assign_vars(array(
+ 'S_DELETE_STYLE' => true,
+ ));
+ }
+ }
+
+ /**
+ * Remove template/theme/imageset entry from the database
+ */
+ function remove_component($component, $component_id, $new_id, $style_id = false)
+ {
+ global $db;
+
+ if (($new_id == 0) || ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id))))
+ {
+ // We can not delete the template, as the user wants to keep the component or an other template is inheriting from this one.
+ return;
+ }
+
+ $component_in_use = array();
+ if ($component != 'style')
+ {
+ $component_in_use = $this->component_in_use($component, $component_id, $style_id);
+ }
+
+ if (($new_id == -1) && !empty($component_in_use))
+ {
+ // We can not delete the component, as it is still in use
+ return;
+ }
+
+ if ($component == 'imageset')
+ {
+ $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . "
+ WHERE imageset_id = $component_id";
+ $db->sql_query($sql);
+ }
+
+ switch ($component)
+ {
+ case 'template':
+ $sql_from = STYLES_TEMPLATE_TABLE;
+ break;
+
+ case 'theme':
+ $sql_from = STYLES_THEME_TABLE;
+ break;
+
+ case 'imageset':
+ $sql_from = STYLES_IMAGESET_TABLE;;
+ break;
+ }
+
+ $sql = "DELETE FROM $sql_from
+ WHERE {$component}_id = $component_id";
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . STYLES_TABLE . "
+ SET {$component}_id = $new_id
+ WHERE {$component}_id = $component_id";
+ $db->sql_query($sql);
+ }
+
+ /**
+ * Display the options which can be used to replace a style/template/theme/imageset
+ */
+ function display_component_options($component, $component_id, $style_row = false, $style_id = false)
+ {
+ global $db, $template, $user;
+
+ $component_in_use = array();
+ if ($component != 'style')
+ {
+ $component_in_use = $this->component_in_use($component, $component_id, $style_id);
+ }
+
+ $sql_where = '';
+ switch ($component)
+ {
+ case 'style':
+ $sql_from = STYLES_TABLE;
+ $sql_where = 'WHERE style_active = 1';
+ break;
+
+ case 'template':
+ $sql_from = STYLES_TEMPLATE_TABLE;
+ $sql_where = 'WHERE template_inherits_id <> ' . $component_id;
+ break;
+
+ case 'theme':
+ $sql_from = STYLES_THEME_TABLE;
+ break;
+
+ case 'imageset':
+ $sql_from = STYLES_IMAGESET_TABLE;
+ break;
+ }
+
+ $s_options = '';
+ if (($component != 'style') && empty($component_in_use))
+ {
+ $sql = "SELECT {$component}_id, {$component}_name
+ FROM $sql_from
+ WHERE {$component}_id = {$component_id}";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $s_options .= '<option value="-1" selected="selected">' . $user->lang['DELETE_' . strtoupper($component)] . '</option>';
+ $s_options .= '<option value="0">' . sprintf($user->lang['KEEP_' . strtoupper($component)], $row[$component . '_name']) . '</option>';
+ }
+ else
+ {
+ $sql = "SELECT {$component}_id, {$component}_name
+ FROM $sql_from
+ $sql_where
+ ORDER BY {$component}_name ASC";
+ $result = $db->sql_query($sql);
+
+ $s_keep_option = $s_options = '';
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row[$component . '_id'] != $component_id)
+ {
+ $s_options .= '<option value="' . $row[$component . '_id'] . '">' . sprintf($user->lang['REPLACE_WITH_OPTION'], $row[$component . '_name']) . '</option>';
+ }
+ else if ($component != 'style')
+ {
+ $s_keep_option = '<option value="0" selected="selected">' . sprintf($user->lang['KEEP_' . strtoupper($component)], $row[$component . '_name']) . '</option>';
+ }
+ }
+ $db->sql_freeresult($result);
+ $s_options = $s_keep_option . $s_options;
+ }
+
+ if (!$style_row)
+ {
+ $template->assign_var('S_REPLACE_' . strtoupper($component) . '_OPTIONS', $s_options);
+ }
+ else
+ {
+ $template->assign_var('S_REPLACE_OPTIONS', $s_options);
+ if ($component == 'style')
+ {
+ $components = array('template', 'theme', 'imageset');
+ foreach ($components as $component)
+ {
+ $this->display_component_options($component, $style_row[$component . '_id'], false, $component_id, true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Check whether the component is still used by another style or component
+ */
+ function component_in_use($component, $component_id, $style_id = false)
+ {
+ global $db;
+
+ $component_in_use = array();
+
+ if ($style_id)
+ {
+ $sql = 'SELECT style_id, style_name
+ FROM ' . STYLES_TABLE . "
+ WHERE {$component}_id = {$component_id}
+ AND style_id <> {$style_id}
+ ORDER BY style_name ASC";
+ }
+ else
+ {
+ $sql = 'SELECT style_id, style_name
+ FROM ' . STYLES_TABLE . "
+ WHERE {$component}_id = {$component_id}
+ ORDER BY style_name ASC";
+ }
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $component_in_use[] = $row['style_name'];
+ }
+ $db->sql_freeresult($result);
+
+ if ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id)))
+ {
+ foreach ($conflicts as $temp_id => $conflict_data)
+ {
+ $component_in_use[] = $conflict_data['template_name'];
+ }
+ }
+
+ return $component_in_use;
}
/**
diff --git a/phpBB/includes/captcha/captcha_gd_wave.php b/phpBB/includes/captcha/captcha_gd_wave.php
index f706c98d43..27422513d9 100644
--- a/phpBB/includes/captcha/captcha_gd_wave.php
+++ b/phpBB/includes/captcha/captcha_gd_wave.php
@@ -62,8 +62,8 @@ class captcha
'y' => mt_rand(10, 17)
),
'lower_left' => array(
- 'x' => mt_rand($img_x - 5, $img_x - 45),
- 'y' => mt_rand($img_y - 0, $img_y - 15)
+ 'x' => mt_rand($img_x - 45, $img_x - 5),
+ 'y' => mt_rand($img_y - 15, $img_y - 0),
),
);
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 90440f74b8..ea34eb8e81 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -173,6 +173,9 @@ define('BBCODE_UID_LEN', 8);
// Number of core BBCodes
define('NUM_CORE_BBCODES', 12);
+// BBCode hard limit
+define('BBCODE_LIMIT', 1511);
+
// Smiley hard limit
define('SMILEY_LIMIT', 1000);
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 6f60dd5dad..7e3f15ed1d 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('');
}
@@ -471,8 +498,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/postgres.php b/phpBB/includes/db/postgres.php
index 4360c790a1..bb116e0763 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('');
}
@@ -371,8 +394,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 @@
+<?php
+/**
+*
+* @package phpBB
+* @version $Id$
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+class phpbb_error_collector
+{
+ var $errors;
+
+ function phpbb_error_collector()
+ {
+ $this->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 .= "<br />\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 fb90ee5f50..6a2d132175 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2635,8 +2635,14 @@ function send_status_line($code, $message)
}
else
{
- if (isset($_SERVER['HTTP_VERSION']))
+ if (!empty($_SERVER['SERVER_PROTOCOL']))
{
+ $version = $_SERVER['SERVER_PROTOCOL'];
+ }
+ else if (!empty($_SERVER['HTTP_VERSION']))
+ {
+ // I cannot remember where I got this from.
+ // This code path may never be reachable in reality.
$version = $_SERVER['HTTP_VERSION'];
}
else
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 2aa12adb2e..cb0cf34e69 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2506,6 +2506,7 @@ function cache_moderators()
/**
* View log
+* If $log_count is set to false, we will skip counting all entries in the database.
*/
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '')
{
@@ -2761,16 +2762,19 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
}
}
- $sql = 'SELECT COUNT(l.log_id) AS total_entries
- FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
- WHERE l.log_type = $log_type
- AND l.user_id = u.user_id
- AND l.log_time >= $limit_days
- $sql_keywords
- $sql_forum";
- $result = $db->sql_query($sql);
- $log_count = (int) $db->sql_fetchfield('total_entries');
- $db->sql_freeresult($result);
+ if ($log_count !== false)
+ {
+ $sql = 'SELECT COUNT(l.log_id) AS total_entries
+ FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
+ WHERE l.log_type = $log_type
+ AND l.user_id = u.user_id
+ AND l.log_time >= $limit_days
+ $sql_keywords
+ $sql_forum";
+ $result = $db->sql_query($sql);
+ $log_count = (int) $db->sql_fetchfield('total_entries');
+ $db->sql_freeresult($result);
+ }
return;
}
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 72331a73c6..271039f415 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1479,7 +1479,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
break;
case 'delete_first_post':
- $sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username, u.user_colour
+ $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
@@ -1493,7 +1493,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$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'])) . "'";
+ $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'];
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 90341cd926..0420aa70ab 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -482,44 +482,6 @@ function user_delete($mode, $user_id, $post_username = false)
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
- $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
- FROM ' . POSTS_TABLE . "
- WHERE poster_id = $user_id
- GROUP BY topic_id";
- $result = $db->sql_query($sql);
-
- $topic_id_ary = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_id_ary[$row['topic_id']] = $row['total_posts'];
- }
- $db->sql_freeresult($result);
-
- if (sizeof($topic_id_ary))
- {
- $sql = 'SELECT topic_id, topic_replies, topic_replies_real
- FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
- $result = $db->sql_query($sql);
-
- $del_topic_ary = array();
- while ($row = $db->sql_fetchrow($result))
- {
- if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
- {
- $del_topic_ary[] = $row['topic_id'];
- }
- }
- $db->sql_freeresult($result);
-
- if (sizeof($del_topic_ary))
- {
- $sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary);
- $db->sql_query($sql);
- }
- }
-
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index 50e14b9336..af262baa29 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -350,7 +350,7 @@ function mcp_front_view($id, $mode, $action)
// Add forum_id 0 for global announcements
$forum_list[] = 0;
- $log_count = 0;
+ $log_count = false;
$log = array();
view_log('mod', $log, $log_count, 5, 0, $forum_list);
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index 7098b4bbce..de7f3e63ee 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -227,10 +227,10 @@ function mcp_post_details($id, $mode, $action)
// Get User Notes
$log_data = array();
- $log_count = 0;
+ $log_count = false;
view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']);
- if ($log_count)
+ if (!empty($log_data))
{
$template->assign_var('S_USER_NOTES', true);
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 5f5b39fe27..d803f8d799 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -583,6 +583,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
@@ -619,12 +626,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;
}
@@ -1966,6 +1967,7 @@ class user extends session
$key_found = $num;
}
+ break;
}
}
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 6b7172ca2b..bd7bf89854 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -169,6 +169,7 @@ function view_folder($id, $mode, $folder_id, $folder)
'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/install/database_update.php b/phpBB/install/database_update.php
index 25b50c724e..01048520d2 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -227,7 +227,7 @@ if (empty($config['dbms_version']))
set_config('dbms_version', $db->sql_server_info(true));
}
-// Firebird update from Firebord 2.0 to 2.1+ required?
+// Firebird update from Firebird 2.0 to 2.1+ required?
if ($db->sql_layer == 'firebird')
{
// We do not trust any PHP5 function enabled, we will simply test for a function new in 2.1
@@ -916,6 +916,15 @@ function database_update_info()
'3.0.7-PL1' => array(),
// No changes from 3.0.8-RC1 to 3.0.8
'3.0.8-RC1' => array(),
+
+ // Changes from 3.0.8 to 3.0.9-RC1
+ '3.0.8' => array(
+ 'change_columns' => array(
+ BBCODES_TABLE => array(
+ 'bbcode_id' => array('USINT', 0),
+ ),
+ ),
+ ),
);
}
@@ -1858,6 +1867,30 @@ function change_database_data(&$no_updates, $version)
// No changes from 3.0.8-RC1 to 3.0.8
case '3.0.8-RC1':
break;
+
+ // Changes from 3.0.8 to 3.0.9-RC1
+ case '3.0.8':
+ // Update file extension group names to use language strings, again.
+ $sql = 'SELECT group_id, group_name
+ FROM ' . EXTENSION_GROUPS_TABLE . '
+ WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql_ary = array(
+ 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_'
+ );
+
+ $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE group_id = ' . $row['group_id'];
+ _sql($sql, $errored, $error_ary);
+ }
+ $db->sql_freeresult($result);
+
+ $no_updates = false;
+ break;
}
}
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 2dd58584f4..9fe0c8aed5 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1882,7 +1882,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/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index 19b1b4f0f7..eeaec4ccf6 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -110,7 +110,7 @@ CREATE TABLE phpbb_banlist (
# Table: 'phpbb_bbcodes'
CREATE TABLE phpbb_bbcodes (
- bbcode_id tinyint(3) DEFAULT '0' NOT NULL,
+ bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
bbcode_tag varbinary(16) DEFAULT '' NOT NULL,
bbcode_helpline blob NOT NULL,
display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 3b70630a9e..3a3b4ab2fd 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -110,7 +110,7 @@ CREATE TABLE phpbb_banlist (
# Table: 'phpbb_bbcodes'
CREATE TABLE phpbb_bbcodes (
- bbcode_id tinyint(3) DEFAULT '0' NOT NULL,
+ bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
bbcode_tag varchar(16) DEFAULT '' NOT NULL,
bbcode_helpline varchar(255) DEFAULT '' NOT NULL,
display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index d577fce46c..9c25af2512 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -254,7 +254,7 @@ END;
Table: 'phpbb_bbcodes'
*/
CREATE TABLE phpbb_bbcodes (
- bbcode_id number(3) DEFAULT '0' NOT NULL,
+ bbcode_id number(4) DEFAULT '0' NOT NULL,
bbcode_tag varchar2(16) DEFAULT '' ,
bbcode_helpline varchar2(765) DEFAULT '' ,
display_on_posting number(1) DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index 50b3979adb..a2d4dc3e0b 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -213,7 +213,7 @@ CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude);
Table: 'phpbb_bbcodes'
*/
CREATE TABLE phpbb_bbcodes (
- bbcode_id INT2 DEFAULT '0' NOT NULL,
+ bbcode_id INT2 DEFAULT '0' NOT NULL CHECK (bbcode_id >= 0),
bbcode_tag varchar(16) DEFAULT '' NOT NULL,
bbcode_helpline varchar(255) DEFAULT '' NOT NULL,
display_on_posting INT2 DEFAULT '0' NOT NULL CHECK (display_on_posting >= 0),
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 355af802ef..ade523a7f3 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -743,15 +743,15 @@ INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_orde
INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', '{L_REPORT_OTHER}', 4);
# -- extension_groups
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_IMAGES}', 1, 1, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_ARCHIVES}', 0, 1, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_PLAIN_TEXT}', 0, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_DOCUMENTS}', 0, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_REAL_MEDIA}', 3, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_WINDOWS_MEDIA}', 2, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_FLASH_FILES}', 5, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_QUICKTIME_MEDIA}', 6, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_DOWNLOADABLE_FILES}', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('REAL_MEDIA', 3, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('WINDOWS_MEDIA', 2, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('QUICKTIME_MEDIA', 6, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, 1, '', 0, '');
# -- extensions
INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif');
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index 7ee821d395..8661bb7578 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -108,7 +108,7 @@ CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude);
# Table: 'phpbb_bbcodes'
CREATE TABLE phpbb_bbcodes (
- bbcode_id tinyint(3) NOT NULL DEFAULT '0',
+ bbcode_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
bbcode_tag varchar(16) NOT NULL DEFAULT '',
bbcode_helpline varchar(255) NOT NULL DEFAULT '',
display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '0',
diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php
index f161a7e6e6..8f65b3ef5f 100644
--- a/phpBB/language/en/acp/styles.php
+++ b/phpBB/language/en/acp/styles.php
@@ -78,7 +78,7 @@ $lang = array_merge($lang, array(
'DELETE_IMAGESET' => 'Delete imageset',
'DELETE_IMAGESET_EXPLAIN' => 'Here you can remove the selected imageset from the database. Please note that there is no undo capability. It is recommended that you first export your set for possible future use.',
'DELETE_STYLE' => 'Delete style',
- 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. You cannot remove all the style elements from here. These must be deleted individually via their respective forms. Take care when deleting styles, there is no undo facility.',
+ 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. Take care in deleting styles, there is no undo capability.',
'DELETE_TEMPLATE' => 'Delete template',
'DELETE_TEMPLATE_EXPLAIN' => 'Here you can remove the selected template set from the database. Please note that there is no undo capability. It is recommended that you first export your set for possible future use.',
'DELETE_THEME' => 'Delete theme',
@@ -285,11 +285,14 @@ $lang = array_merge($lang, array(
'INSTALLED_TEMPLATE' => 'Installed templates',
'INSTALLED_THEME' => 'Installed themes',
+ 'KEEP_IMAGESET' => 'Keep "%s" imageset',
+ 'KEEP_TEMPLATE' => 'Keep "%s" template',
+ 'KEEP_THEME' => 'Keep "%s" theme',
+
'LINE_SPACING' => 'Line spacing',
'LOCALISED_IMAGES' => 'Localised',
'LOCATION_DISABLED_EXPLAIN' => 'This setting is inherited and cannot be changed.',
-
'NO_CLASS' => 'Cannot find class in stylesheet.',
'NO_IMAGESET' => 'Cannot find imageset on filesystem.',
'NO_IMAGE' => 'No image',
@@ -322,6 +325,7 @@ $lang = array_merge($lang, array(
'REPLACE_TEMPLATE_EXPLAIN' => 'This template set will replace the one you are deleting in any styles that use it.',
'REPLACE_THEME' => 'Replace theme with',
'REPLACE_THEME_EXPLAIN' => 'This theme will replace the one you are deleting in any styles that use it.',
+ 'REPLACE_WITH_OPTION' => 'Replace with "%s"',
'REQUIRES_IMAGESET' => 'This style requires the %s imageset to be installed.',
'REQUIRES_TEMPLATE' => 'This style requires the %s template set to be installed.',
'REQUIRES_THEME' => 'This style requires the %s theme to be installed.',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 7368026136..d05abc6a0e 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1360,8 +1360,8 @@ $lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_lo
$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set'];
$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set);
-// Page title & action URL, include session_id for security purpose
-$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&amp;f=$forum_id", true, $user->session_id);
+// Page title & action URL
+$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&amp;f=$forum_id");
$s_action .= ($topic_id) ? "&amp;t=$topic_id" : '';
$s_action .= ($post_id) ? "&amp;p=$post_id" : '';
diff --git a/phpBB/styles/prosilver/template/mcp_post.html b/phpBB/styles/prosilver/template/mcp_post.html
index 04e24cd1f9..9d4997e576 100644
--- a/phpBB/styles/prosilver/template/mcp_post.html
+++ b/phpBB/styles/prosilver/template/mcp_post.html
@@ -72,8 +72,8 @@
<form method="post" id="mcp_approve" action="{U_APPROVE_ACTION}">
<p class="rules">
- <input class="button1" type="submit" value="{L_APPROVE}" name="action[approve]" /> &nbsp;
- <input class="button2" type="submit" value="{L_DISAPPROVE}" name="action[disapprove]" />
+ <input class="button2" type="submit" value="{L_DISAPPROVE}" name="action[disapprove]" /> &nbsp;
+ <input class="button1" type="submit" value="{L_APPROVE}" name="action[approve]" />
<input type="hidden" name="post_id_list[]" value="{POST_ID}" />
{S_FORM_TOKEN}
</p>
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)
}
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/forum_fn.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js"></script>
<!-- ENDIF -->
<h2 class="solo">{L_FIND_USERNAME}</h2>
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index e537aabf56..51fff0735a 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -46,12 +46,9 @@
var onload_functions = new Array();
var onunload_functions = new Array();
- <!-- IF S_USER_PM_POPUP -->
- if ({S_NEW_PM})
- {
- var url = '{UA_POPUP_PM}';
- window.open(url.replace(/&amp;/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
- }
+ <!-- IF S_USER_PM_POPUP and S_NEW_PM -->
+ var url = '{UA_POPUP_PM}';
+ window.open(url.replace(/&amp;/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
<!-- ENDIF -->
/**
@@ -84,8 +81,8 @@
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/styleswitcher.js"></script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/forum_fn.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/styleswitcher.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js"></script>
<link href="{T_THEME_PATH}/print.css" rel="stylesheet" type="text/css" media="print" title="printonly" />
<link href="{T_STYLESHEET_LINK}" rel="stylesheet" type="text/css" media="screen, projection" />
diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html
index 5d21229611..19d55d1a4a 100644
--- a/phpBB/styles/prosilver/template/posting_buttons.html
+++ b/phpBB/styles/prosilver/template/posting_buttons.html
@@ -38,7 +38,7 @@
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/editor.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/editor.js"></script>
<!-- IF S_BBCODE_ALLOWED -->
<div id="colour_palette" style="display: none;">
diff --git a/phpBB/styles/prosilver/template/posting_smilies.html b/phpBB/styles/prosilver/template/posting_smilies.html
index fdd0d7ada1..86ac24aa53 100644
--- a/phpBB/styles/prosilver/template/posting_smilies.html
+++ b/phpBB/styles/prosilver/template/posting_smilies.html
@@ -6,7 +6,7 @@
var text_name = 'message';
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/editor.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/editor.js"></script>
<h2>{L_SMILIES}</h2>
<div class="panel">
diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html
index 66aae004a0..9cc8060762 100644
--- a/phpBB/styles/prosilver/template/simple_header.html
+++ b/phpBB/styles/prosilver/template/simple_header.html
@@ -46,8 +46,8 @@
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/styleswitcher.js"></script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/forum_fn.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/styleswitcher.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js"></script>
<link href="{T_THEME_PATH}/print.css" rel="stylesheet" type="text/css" media="print" title="printonly" />
<link href="{T_STYLESHEET_LINK}" rel="stylesheet" type="text/css" media="screen, projection" />
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index 3f215def72..f7747ba73c 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -652,7 +652,7 @@ fieldset.polls dd div {
}
.online {
- background-image: url("{T_IMAGESET_LANG_PATH}/icon_user_online.gif");
+ background-image: url("{IMG_ICON_USER_ONLINE_SRC}");
}
/*
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 48f6202c4f..be4c7b5b4c 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -28,11 +28,8 @@
<script type="text/javascript">
// <![CDATA[
-<!-- IF S_USER_PM_POPUP -->
- if ({S_NEW_PM})
- {
- popup('{UA_POPUP_PM}', 400, 225, '_phpbbprivmsg');
- }
+<!-- IF S_USER_PM_POPUP and S_NEW_PM -->
+ popup('{UA_POPUP_PM}', 400, 225, '_phpbbprivmsg');
<!-- ENDIF -->
function popup(url, width, height, name)
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 @@
// ]]>
</script>
- <script type="text/javascript" src="{T_TEMPLATE_PATH}/editor.js"></script>
+ <script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/editor.js"></script>
<!-- IF S_BBCODE_ALLOWED -->
<input type="button" class="btnbbcode" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px;" onclick="bbstyle(0)" onmouseover="helpline('b')" onmouseout="helpline('tip')" />
diff --git a/phpBB/styles/subsilver2/template/posting_smilies.html b/phpBB/styles/subsilver2/template/posting_smilies.html
index 2586530e55..fcab578bd9 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';
// ]]>
</script>
-<script type="text/javascript" src="{T_TEMPLATE_PATH}/editor.js"></script>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/editor.js"></script>
<table width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 498088c5c8..bc839066a5 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1547,6 +1547,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'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&amp;mode=warn_post&amp;f=' . $forum_id . '&amp;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,
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1fba323277..6f3c93a374 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
@@ -30,3 +34,4 @@ require_once $phpbb_root_path . 'includes/constants.php';
require_once 'test_framework/phpbb_test_case_helpers.php';
require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
+require_once 'test_framework/phpbb_database_test_connection_manager.php';
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index 987de5cbff..533416f14b 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_dbal_select_test extends phpbb_database_test_case
{
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index a24b6efcc4..4709d45fa5 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_dbal_write_test extends phpbb_database_test_case
{
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 2ac46f7090..738d1eaaba 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -53,9 +53,16 @@ class phpbb_mock_cache
$test->assertEquals($data, $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['mysqli_version']);
+ }
+
+ $test->assertEquals($data, $cache_data);
}
}
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 2d7d42f82a..47089cb94b 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -7,9 +7,16 @@
*
*/
-require_once '../phpBB/includes/functions.php';
-require_once '../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
+/**
+* Extends the session class to overwrite the setting of cookies.
+*
+* The session class directly writes cookie headers making it impossible to
+* test it without warnings about sent headers. This class only stores cookie
+* data for later verification.
+*/
class phpbb_mock_session_testable extends session
{
private $_cookies = array();
diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php
index 9410deaf64..5a756dcef8 100644
--- a/tests/network/checkdnsrr_test.php
+++ b/tests/network/checkdnsrr_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
/**
* @group slow
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index fa519f134c..115c55e4e2 100644
--- a/tests/random/gen_rand_string_test.php
+++ b/tests/random/gen_rand_string_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_random_gen_rand_string_test extends phpbb_test_case
{
diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php
index 93c761c8d0..fa9104e71d 100644
--- a/tests/regex/censor_test.php
+++ b/tests/regex/censor_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_censor_test extends phpbb_test_case
{
diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php
index 5d6e207cbb..0695b801d5 100644
--- a/tests/regex/email_test.php
+++ b/tests/regex/email_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_email_test extends phpbb_test_case
{
diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php
index 735a2c4384..9829547508 100644
--- a/tests/regex/ipv4_test.php
+++ b/tests/regex/ipv4_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_ipv4_test extends phpbb_test_case
{
diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php
index 187588f861..1b2018403c 100644
--- a/tests/regex/ipv6_test.php
+++ b/tests/regex/ipv6_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_ipv6_test extends phpbb_test_case
{
diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php
index 246cbf549c..c3a336063a 100644
--- a/tests/regex/url_test.php
+++ b/tests/regex/url_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_url_test extends phpbb_test_case
{
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 0901b43920..fa17b1909f 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_request_request_var_test extends phpbb_test_case
{
diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php
index ff0ab4d1bb..71c7a3a397 100644
--- a/tests/security/extract_current_page_test.php
+++ b/tests/security/extract_current_page_test.php
@@ -7,10 +7,10 @@
*
*/
-require_once __DIR__ . '/base.php';
+require_once dirname(__FILE__) . '/base.php';
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
class phpbb_security_extract_current_page_test extends phpbb_security_test_base
{
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index c53414e7df..70ba8527b1 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -7,10 +7,10 @@
*
*/
-require_once __DIR__ . '/base.php';
+require_once dirname(__FILE__) . '/base.php';
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
class phpbb_security_redirect_test extends phpbb_security_test_base
{
diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php
new file mode 100644
index 0000000000..3080121978
--- /dev/null
+++ b/tests/session/continue_test.php
@@ -0,0 +1,117 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/testable_factory.php';
+
+class phpbb_session_continue_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml');
+ }
+
+ static public function session_begin_attempts()
+ {
+ return array(
+ array(
+ 'bar_session', '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(),
+ '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',
+ array(
+ array('session_id' => '__new_session_id__', 'session_user_id' => 1), // use generated SID
+ array('session_id' => 'bar_session', 'session_user_id' => 4),
+ ),
+ array(
+ 'u' => array('1', null),
+ 'k' => array(null, 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.',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider session_begin_attempts
+ */
+ public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $ip, $expected_sessions, $expected_cookies, $message)
+ {
+ $db = $this->new_dbal();
+ $session_factory = new phpbb_session_testable_factory;
+ $session_factory->set_cookies(array(
+ '_sid' => $session_id,
+ '_u' => $user_id,
+ ));
+ $session_factory->merge_config_data(array(
+ 'session_length' => time(), // need to do this to allow sessions started at time 0
+ ));
+ $session_factory->merge_server_data(array(
+ 'HTTP_USER_AGENT' => $user_agent,
+ 'REMOTE_ADDR' => $ip,
+ ));
+
+ $session = $session_factory->get_session($db);
+ $session->page = array('page' => 'page', 'forum' => 0);
+
+ $session->session_begin();
+
+ $sql = 'SELECT session_id, session_user_id
+ FROM phpbb_sessions
+ ORDER BY session_user_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,
+ $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_empty.xml b/tests/session/fixtures/sessions_empty.xml
index 66fa585b18..f94337314e 100644
--- a/tests/session/fixtures/sessions_empty.xml
+++ b/tests/session/fixtures/sessions_empty.xml
@@ -16,4 +16,10 @@
<value>bar</value>
</row>
</table>
+ <table name="phpbb_sessions">
+ <column>session_id</column>
+ <column>session_user_id</column>
+ <column>session_ip</column>
+ <column>session_browser</column>
+ </table>
</dataset>
diff --git a/tests/session/init_test.php b/tests/session/init_test.php
new file mode 100644
index 0000000000..1181fab636
--- /dev/null
+++ b/tests/session/init_test.php
@@ -0,0 +1,56 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/testable_factory.php';
+
+class phpbb_session_init_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
+ }
+
+ // also see security/extract_current_page.php
+
+ public function test_login_session_create()
+ {
+ $db = $this->new_dbal();
+ $session_factory = new phpbb_session_testable_factory;
+
+ $session = $session_factory->get_session($db);
+ $session->page = array('page' => 'page', 'forum' => 0);
+
+ $session->session_create(3);
+
+ $sql = 'SELECT session_user_id
+ FROM phpbb_sessions';
+
+ $this->assertSqlResultEquals(
+ array(array('session_user_id' => 3)),
+ $sql,
+ 'Check if exacly one session for user id 3 was created'
+ );
+
+ $cookie_expire = $session->time_now + 31536000; // default is one year
+
+ $session->check_cookies($this, array(
+ 'u' => array(null, $cookie_expire),
+ 'k' => array(null, $cookie_expire),
+ 'sid' => array($session->session_id, $cookie_expire),
+ ));
+
+ global $SID, $_SID;
+ $this->assertEquals($session->session_id, $_SID);
+ $this->assertEquals('?sid=' . $session->session_id, $SID);
+
+ $session_factory->check($this);
+ }
+}
+
diff --git a/tests/session/session_continue.php b/tests/session/session_continue.php
deleted file mode 100644
index 58956c18a9..0000000000
--- a/tests/session/session_continue.php
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-require_once 'test_framework/framework.php';
-require_once 'mock/cache.php';
-require_once 'mock/session_testable.php';
-
-class phpbb_session_continue_test extends phpbb_database_test_case
-{
- public function getDataSet()
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml');
- }
-
- static public function session_begin_attempts()
- {
- return array(
- array(
- 'bar_session', '4', 'user agent',
- array(
- array('session_id' => 'anon_session', 'session_user_id' => 1),
- array('session_id' => 'bar_session', 'session_user_id' => 4)
- ),
- array(),
- 'Check if no new session was created',
- ),
- array(
- 'anon_session', '4', 'user agent',
- array(
- array('session_id' => 'bar_session', 'session_user_id' => 4),
- array('session_id' => null, 'session_user_id' => 1) // use generated SID
- ),
- array(
- 'u' => array('1', null),
- 'k' => array(null, null),
- 'sid' => array($_SID, null),
- ),
- 'Check if an anonymous new session was created',
- ),
- );
- }
-
- /**
- * @dataProvider session_begin_attempts
- */
- public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $expected_sessions, $expected_cookies, $message)
- {
- $session = new phpbb_mock_session_testable;
- $session->page = array('page' => 'page', 'forum' => 0);
-
- // set up all the global variables used in session_create
- global $SID, $_SID, $db, $config, $cache;
-
- $config = $this->get_config();
- $db = $this->new_dbal();
- $cache_data = array(
- '_bots' => array(),
- );
- $cache = new phpbb_mock_cache;
- $SID = $_SID = null;
-
- $_COOKIE['_sid'] = $session_id;
- $_COOKIE['_u'] = $user_id;
- $_SERVER['HTTP_USER_AGENT'] = $user_agent;
-
- $config['session_length'] = time(); // need to do this to allow sessions started at time 0
- $session->session_begin();
-
- $sql = 'SELECT session_id, session_user_id
- FROM phpbb_sessions';
-
- // 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;
- }
- }
-
- $this->assertResultEquals(
- $sql,
- $expected_sessions,
- 'Check if no new session was created'
- );
-
- $session->check_cookies($this, $expected_cookies);
-
- $cache->check($this, $cache_data);
- }
- static public function get_config()
- {
- return array(
- 'allow_autologin' => false,
- 'auth_method' => 'db',
- 'forwarded_for_check' => true,
- 'active_sessions' => 0, // disable
- 'rand_seed' => 'foo',
- 'rand_seed_last_update' => 0,
- 'max_autologin_time' => 0,
- 'session_length' => 100,
- 'form_token_lifetime' => 100,
- 'cookie_name' => '',
- 'limit_load' => 0,
- 'limit_search_load' => 0,
- 'ip_check' => 3,
- 'browser_check' => 1,
- );
- }
-}
-
diff --git a/tests/session/session_init.php b/tests/session/session_init.php
deleted file mode 100644
index f6fa564880..0000000000
--- a/tests/session/session_init.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-require_once 'test_framework/framework.php';
-require_once 'mock/cache.php';
-require_once 'mock/session_testable.php';
-
-class phpbb_session_init_test extends phpbb_database_test_case
-{
- public function getDataSet()
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
- }
-
- // also see security/extract_current_page.php
-
- public function test_login_session_create()
- {
- $session = new phpbb_mock_session_testable;
- $session->page = array('page' => 'page', 'forum' => 0);
-
- // set up all the global variables used in session_create
- global $SID, $_SID, $db, $config, $cache;
-
- $config = $this->get_config();
- $db = $this->new_dbal();
- $cache_data = array(
- '_bots' => array(),
- );
- $cache = new phpbb_mock_cache;
- $SID = $_SID = null;
-
- $session->session_create(3);
-
- $sql = 'SELECT session_user_id
- FROM phpbb_sessions';
-
- $this->assertResultEquals(
- $sql,
- array(array('session_user_id' => 3)),
- 'Check if exacly one session for user id 3 was created'
- );
-
- $cookie_expire = $session->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000);
-
- $session->check_cookies($this, array(
- 'u' => array(null, $cookie_expire),
- 'k' => array(null, $cookie_expire),
- 'sid' => array($_SID, $cookie_expire),
- ));
-
- $cache->check($this, $cache_data);
- }
-
- static public function get_config()
- {
- return array(
- 'allow_autologin' => false,
- 'auth_method' => 'db',
- 'forwarded_for_check' => true,
- 'active_sessions' => 0, // disable
- 'rand_seed' => 'foo',
- 'rand_seed_last_update' => 0,
- 'max_autologin_time' => 0,
- 'session_length' => 100,
- 'form_token_lifetime' => 100,
- );
- }
-}
-
diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php
new file mode 100644
index 0000000000..f3ef19a257
--- /dev/null
+++ b/tests/session/testable_factory.php
@@ -0,0 +1,171 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/session_testable.php';
+
+/**
+* This class exists to setup an instance of phpbb's session class for testing.
+*
+* The session class has rather complex dependencies, so in order to make its
+* tests more * understandable and to make its dependencies more visible this
+* factory class sets up all the necessary global state & variable contents.
+*/
+class phpbb_session_testable_factory
+{
+ protected $config_data;
+ protected $cache_data;
+ protected $cookies;
+
+ protected $config;
+ protected $cache;
+
+ /**
+ * Initialises the factory with a set of default config and cache values.
+ */
+ public function __construct()
+ {
+ // default configuration values
+ $this->config_data = array(
+ 'allow_autologin' => false,
+ 'auth_method' => 'db',
+ 'forwarded_for_check' => true,
+ 'active_sessions' => 0, // disable
+ 'rand_seed' => 'foo',
+ 'rand_seed_last_update' => 0,
+ 'max_autologin_time' => 0,
+ 'session_length' => 100,
+ 'form_token_lifetime' => 100,
+ 'cookie_name' => '',
+ 'limit_load' => 0,
+ 'limit_search_load' => 0,
+ 'ip_check' => 3,
+ 'browser_check' => 1,
+ );
+
+ $this->cache_data = array(
+ '_bots' => array(),
+ );
+
+ $this->cookies = array();
+
+ $this->server_data = $_SERVER;
+ }
+
+ /**
+ * Retrieve the configured session class instance
+ *
+ * @param dbal $dbal The database connection to use for session data
+ * @return phpbb_mock_session_testable A session instance
+ */
+ public function get_session(dbal $dbal)
+ {
+ // set up all the global variables used by session
+ global $SID, $_SID, $db, $config, $cache;
+
+ $config = $this->config = $this->get_config_data();
+ $db = $dbal;
+
+ $cache = $this->cache = new phpbb_mock_cache($this->get_cache_data());
+ $SID = $_SID = null;
+
+ $_COOKIE = $this->cookies;
+ $_SERVER = $this->server_data;
+
+ $session = new phpbb_mock_session_testable;
+ return $session;
+ }
+
+ /**
+ * Set the cookies which should be present in the request data.
+ *
+ * @param array $cookies The cookie data, structured like $_COOKIE contents.
+ */
+ public function set_cookies(array $cookies)
+ {
+ $this->cookies = $cookies;
+ }
+
+ /**
+ * Check if the cache used for the generated session contains correct data.
+ *
+ * @param PHPUnit_Framework_Assert $test The test case to call assert methods
+ * on
+ */
+ public function check(PHPUnit_Framework_Assert $test)
+ {
+ $this->cache->check($test, $this->get_cache_data());
+ }
+
+ /**
+ * Merge config data with the current config data to be supplied to session.
+ *
+ * New values overwrite new ones.
+ *
+ * @param array $config_data The config data to merge with previous data
+ */
+ public function merge_config_data(array $config_data)
+ {
+ $this->config_data = array_merge($this->config_data, $config_data);
+ }
+
+ /**
+ * Retrieve the entire config data to be passed to the session.
+ *
+ * @return array Configuration
+ */
+ public function get_config_data()
+ {
+ return $this->config_data;
+ }
+
+ /**
+ * Merge the cache contents with more data.
+ *
+ * New values overwrite old ones.
+ *
+ * @param array $cache_data The additional cache data
+ */
+ public function merge_cache_data(array $cache_data)
+ {
+ $this->cache_data = array_merge($this->cache_data, $cache_data);
+ }
+
+ /**
+ * Retrieve the entire cache data to be passed to the session.
+ *
+ * @return array Cache contents
+ */
+ public function get_cache_data()
+ {
+ return $this->cache_data;
+ }
+
+ /**
+ * Merge the current server info ($_SERVER) with more data.
+ *
+ * New values overwrite old ones.
+ *
+ * @param array $server_data The additional server variables
+ */
+ public function merge_server_data($server_data)
+ {
+ return $this->server_data = array_merge($this->server_data, $server_data);
+ }
+
+ /**
+ * Retrieve all server variables to be passed to the session.
+ *
+ * @return array Server variables
+ */
+ public function get_server_data()
+ {
+ return $this->server_data;
+ }
+}
+
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 35df17e4c6..33c82d53ad 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/template.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/template.php';
class phpbb_template_template_test extends phpbb_test_case
{
@@ -343,8 +343,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);
@@ -394,11 +393,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);
@@ -409,21 +406,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;
}
@@ -437,17 +427,16 @@ class phpbb_template_template_test extends phpbb_test_case
false,
'insert',
<<<EOT
-outer - 0/4 - before
-outer - 1/4
-middle - 0/2
-middle - 1/2
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0 - before
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting before on top level block',
@@ -458,17 +447,16 @@ EOT
true,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/4
-middle - 0/2
-middle - 1/2
-outer - 3/4 - after
+outer - 0
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3 - after
EOT
,
'Test inserting after on top level block',
@@ -479,17 +467,16 @@ EOT
1,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4 - pos #1
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0
+middle - 0
+middle - 1
+outer - 1 - pos #1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
@@ -500,172 +487,27 @@ EOT
0,
'change',
<<<EOT
-outer - 0/3 - pos #1
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
+outer - 0 - pos #1
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'after'),
- true,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3
-middle - 2/3 - after
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting after on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'pos #1'),
- 1,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3 - pos #1
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting at pos 1 on nested block',
- ),
- array(
- 'outer[1].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/4 - before
-middle - 1/4
-middle - 2/4
-middle - 3/4
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block (pos 1)',
- ),
- array(
- 'outer[].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
- array(
- 'outer.middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
);
}
-/*
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
-*/
-
/**
* @dataProvider alter_block_array_data
*/
public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
{
- $this->markTestIncomplete('Alter Block Test is broken');
-
$this->template->set_filenames(array('test' => 'loop_nested.html'));
// @todo Change this
@@ -675,12 +517,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 @@
-<!-- INCLUDEPHP ../templates/_dummy_include.php.inc -->
+<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->
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 @@
<!-- BEGIN outer -->
- {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
+ outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
<!-- BEGIN middle -->
- {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
+ middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
<!-- END middle -->
<!-- END outer -->
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index a325855da4..e1b368dcea 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -9,7 +9,7 @@
abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_TestCase
{
- private static $already_connected;
+ static private $already_connected;
protected $test_case_helpers;
@@ -38,66 +38,6 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
return $this->test_case_helpers;
}
- public function get_dbms_data($dbms)
- {
- $available_dbms = array(
- 'firebird' => array(
- 'SCHEMA' => 'firebird',
- 'DELIM' => ';;',
- 'PDO' => 'firebird',
- ),
- 'mysqli' => array(
- 'SCHEMA' => 'mysql_41',
- 'DELIM' => ';',
- 'PDO' => 'mysql',
- ),
- 'mysql' => array(
- 'SCHEMA' => 'mysql',
- 'DELIM' => ';',
- 'PDO' => 'mysql',
- ),
- 'mssql' => array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'odbc',
- ),
- 'mssql_odbc'=> array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'odbc',
- ),
- 'mssqlnative' => array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'sqlsrv',
- ),
- 'oracle' => array(
- 'SCHEMA' => 'oracle',
- 'DELIM' => '/',
- 'PDO' => 'oci',
- ),
- 'postgres' => array(
- 'SCHEMA' => 'postgres',
- 'DELIM' => ';',
- 'PDO' => 'pgsql',
- ),
- 'sqlite' => array(
- 'SCHEMA' => 'sqlite',
- 'DELIM' => ';',
- 'PDO' => 'sqlite2',
- ),
- );
-
- if (isset($available_dbms[$dbms]))
- {
- return $available_dbms[$dbms];
- }
- else
- {
- trigger_error('Database unsupported', E_USER_ERROR);
- }
- }
-
public function get_database_config()
{
if (isset($_SERVER['PHPBB_TEST_DBMS']))
@@ -111,9 +51,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '',
);
}
- else if (file_exists(__DIR__ . '/../test_config.php'))
+ else if (file_exists(dirname(__FILE__) . '/../test_config.php'))
{
- include(__DIR__ . '/../test_config.php');
+ include(dirname(__FILE__) . '/../test_config.php');
return array(
'dbms' => $dbms,
@@ -129,7 +69,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
// Silently use sqlite
return array(
'dbms' => 'sqlite',
- 'dbhost' => __DIR__ . '/../phpbb_unit_tests.sqlite2', // filename
+ 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
'dbport' => '',
'dbname' => '',
'dbuser' => '',
@@ -142,232 +82,26 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
- // NOTE: This function is not the same as split_sql_file from functions_install
- public function split_sql_file($sql, $dbms)
- {
- $dbms_data = $this->get_dbms_data($dbms);
-
- $sql = str_replace("\r" , '', $sql);
- $data = preg_split('/' . preg_quote($dbms_data['DELIM'], '/') . '$/m', $sql);
-
- $data = array_map('trim', $data);
-
- // The empty case
- $end_data = end($data);
-
- if (empty($end_data))
- {
- unset($data[key($data)]);
- }
-
- if ($dbms == 'sqlite')
- {
- // remove comment lines starting with # - they are not proper sqlite
- // syntax and break sqlite2
- foreach ($data as $i => $query)
- {
- $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
- }
- }
-
- return $data;
- }
-
- /**
- * Retrieves a list of all tables from the database.
- *
- * @param PDO $pdo
- * @param string $dbms
- * @return array(string)
- */
- function get_tables($pdo, $dbms)
- {
- switch ($pdo)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $sql = 'SHOW TABLES';
- break;
-
- case 'sqlite':
- $sql = 'SELECT name
- FROM sqlite_master
- WHERE type = "table"';
- break;
-
- case 'mssql':
- case 'mssql_odbc':
- case 'mssqlnative':
- $sql = "SELECT name
- FROM sysobjects
- WHERE type='U'";
- break;
-
- case 'postgres':
- $sql = 'SELECT relname
- FROM pg_stat_user_tables';
- break;
-
- case 'firebird':
- $sql = 'SELECT rdb$relation_name
- FROM rdb$relations
- WHERE rdb$view_source is null
- AND rdb$system_flag = 0';
- break;
-
- case 'oracle':
- $sql = 'SELECT table_name
- FROM USER_TABLES';
- break;
- }
-
- $result = $pdo->query($sql);
-
- $tables = array();
- while ($row = $result->fetch(PDO::FETCH_NUM))
- {
- $tables[] = current($row);
- }
-
- return $tables;
- }
-
- /**
- * Returns a PDO connection for the configured database.
- *
- * @param array $config The database configuration
- * @param array $dbms Information on the used DBMS.
- * @param bool $use_db Whether the DSN should be tied to a
- * particular database making it impossible
- * to delete that database.
- * @return PDO The PDO database connection.
- */
- public function new_pdo($config, $dbms, $use_db)
- {
- $dsn = $dbms['PDO'] . ':';
-
- switch ($dbms['PDO'])
- {
- case 'sqlite2':
- $dsn .= $config['dbhost'];
- break;
-
- case 'sqlsrv':
- // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress
- // works for example, further parameters can still be appended using ;x=y
- $dsn .= 'Server=';
- // no break -> rest like ODBC
- case 'odbc':
- // for ODBC assume dbhost is a suitable DSN
- // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress;
- $dsn .= $config['dbhost'];
-
- if ($use_db)
- {
- $dsn .= ';Database=' . $config['dbname'];
- }
- break;
-
- default:
- $dsn .= 'host=' . $config['dbhost'];
-
- if ($use_db)
- {
- $dsn .= ';dbname=' . $config['dbname'];
- }
- break;
- }
-
- $pdo = new PDO($dsn, $config['dbuser'], $config['dbpasswd']);;
-
- // good for debug
- // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- return $pdo;
- }
-
- private function recreate_db($config, $dbms)
- {
- switch ($config['dbms'])
- {
- case 'sqlite':
- if (file_exists($config['dbhost']))
- {
- unlink($config['dbhost']);
- }
- break;
-
- default:
- $pdo = $this->new_pdo($config, $dbms, false);
-
- try
- {
- $pdo->exec('DROP DATABASE ' . $config['dbname']);
- }
- catch (PDOException $e)
- {
- // try to delete all tables if dropping the database was not possible.
- foreach ($this->get_tables() as $table)
- {
- try
- {
- $pdo->exec('DROP TABLE ' . $table);
- }
- catch (PDOException $e){} // ignore non-existent tables
- }
- }
-
- $pdo->exec('CREATE DATABASE ' . $config['dbname']);
- break;
- }
- }
-
- private function load_schema($pdo, $config, $dbms)
- {
- if ($config['dbms'] == 'mysql')
- {
- $sth = $pdo->query('SELECT VERSION() AS version');
- $row = $sth->fetch(PDO::FETCH_ASSOC);
-
- if (version_compare($row['version'], '4.1.3', '>='))
- {
- $dbms['SCHEMA'] .= '_41';
- }
- else
- {
- $dbms['SCHEMA'] .= '_40';
- }
- }
-
- $sql = $this->split_sql_file(file_get_contents(__DIR__ . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']);
-
- foreach ($sql as $query)
- {
- $pdo->exec($query);
- }
- }
-
public function getConnection()
{
$config = $this->get_database_config();
- $dbms = $this->get_dbms_data($config['dbms']);
+
+ $manager = $this->create_connection_manager($config);
if (!self::$already_connected)
{
- $this->recreate_db($config, $dbms);
+ $manager->recreate_db();
}
- $pdo = $this->new_pdo($config, $dbms, true);
+ $manager->connect();
if (!self::$already_connected)
{
- $this->load_schema($pdo, $config, $dbms);
-
+ $manager->load_schema();
self::$already_connected = true;
}
- return $this->createDefaultDBConnection($pdo, 'testdb');
+ return $this->createDefaultDBConnection($manager->get_pdo(), 'testdb');
}
public function new_dbal()
@@ -376,7 +110,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$config = $this->get_database_config();
- require_once __DIR__ . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
+ require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
$dbal = 'dbal_' . $config['dbms'];
$db = new $dbal();
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
@@ -399,4 +133,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
}
+
+ protected function create_connection_manager($config)
+ {
+ return new phpbb_database_test_connection_manager($config);
+ }
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
new file mode 100644
index 0000000000..a7559e2183
--- /dev/null
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -0,0 +1,346 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_database_test_connection_manager
+{
+ private $config;
+ private $dbms;
+ private $pdo;
+
+ /**
+ * Constructor
+ *
+ * @param array $config Tests database configuration as returned by
+ * phpbb_database_test_case::get_database_config()
+ */
+ public function __construct($config)
+ {
+ $this->config = $config;
+ $this->dbms = $this->get_dbms_data($this->config['dbms']);
+ }
+
+ /**
+ * Return the current PDO instance
+ */
+ public function get_pdo()
+ {
+ return $this->pdo;
+ }
+
+ /**
+ * Creates a PDO connection for the configured database.
+ *
+ * @param bool $use_db Whether the DSN should be tied to a
+ * particular database making it impossible
+ * to delete that database.
+ */
+ public function connect($use_db = true)
+ {
+ $dsn = $this->dbms['PDO'] . ':';
+
+ switch ($this->dbms['PDO'])
+ {
+ case 'sqlite2':
+ $dsn .= $this->config['dbhost'];
+ break;
+
+ case 'sqlsrv':
+ // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress
+ // works for example, further parameters can still be appended using ;x=y
+ $dsn .= 'Server=';
+ // no break -> rest like ODBC
+ case 'odbc':
+ // for ODBC assume dbhost is a suitable DSN
+ // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress;
+ $dsn .= $this->config['dbhost'];
+
+ if ($use_db)
+ {
+ $dsn .= ';Database=' . $this->config['dbname'];
+ }
+ break;
+
+ default:
+ $dsn .= 'host=' . $this->config['dbhost'];
+
+ if ($use_db)
+ {
+ $dsn .= ';dbname=' . $this->config['dbname'];
+ }
+ break;
+ }
+
+ try
+ {
+ $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ }
+ catch (PDOException $e)
+ {
+ $cleaned_dsn = str_replace($this->config['dbpasswd'], '*password*', $dsn);
+ throw new Exception("Unable do connect to $cleaned_dsn using PDO with error: {$e->getMessage()}");
+ }
+
+ // good for debug
+ // $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ }
+
+ /**
+ * Load the phpBB database schema into the database
+ */
+ public function load_schema()
+ {
+ $this->ensure_connected(__METHOD__);
+
+ $directory = dirname(__FILE__) . '/../../phpBB/install/schemas/';
+ $this->load_schema_from_file($directory);
+ }
+
+ /**
+ * Drop the database if it exists and re-create it
+ *
+ * Note: This does not load the schema, and it is suggested
+ * to re-connect after calling to get use_db isolation.
+ */
+ public function recreate_db()
+ {
+ switch ($this->config['dbms'])
+ {
+ case 'sqlite':
+ if (file_exists($this->config['dbhost']))
+ {
+ unlink($this->config['dbhost']);
+ }
+ break;
+
+ default:
+ $this->connect(false);
+
+ try
+ {
+ $this->pdo->exec('DROP DATABASE ' . $this->config['dbname']);
+ }
+ catch (PDOException $e)
+ {
+ // try to delete all tables if dropping the database was not possible.
+ foreach ($this->get_tables() as $table)
+ {
+ $this->pdo->exec('DROP TABLE ' . $table);
+ }
+ }
+
+ $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']);
+ break;
+ }
+ }
+
+ /**
+ * Retrieves a list of all tables from the database.
+ *
+ * @return array(string)
+ */
+ public function get_tables()
+ {
+ $this->ensure_connected(__METHOD__);
+
+ switch ($this->config['dbms'])
+ {
+ case 'mysql':
+ case 'mysql4':
+ case 'mysqli':
+ $sql = 'SHOW TABLES';
+ break;
+
+ case 'sqlite':
+ $sql = 'SELECT name
+ FROM sqlite_master
+ WHERE type = "table"';
+ break;
+
+ case 'mssql':
+ case 'mssql_odbc':
+ case 'mssqlnative':
+ $sql = "SELECT name
+ FROM sysobjects
+ WHERE type='U'";
+ break;
+
+ case 'postgres':
+ $sql = 'SELECT relname
+ FROM pg_stat_user_tables';
+ break;
+
+ case 'firebird':
+ $sql = 'SELECT rdb$relation_name
+ FROM rdb$relations
+ WHERE rdb$view_source is null
+ AND rdb$system_flag = 0';
+ break;
+
+ case 'oracle':
+ $sql = 'SELECT table_name
+ FROM USER_TABLES';
+ break;
+ }
+
+ $result = $this->pdo->query($sql);
+
+ $tables = array();
+ while ($row = $result->fetch(PDO::FETCH_NUM))
+ {
+ $tables[] = current($row);
+ }
+
+ return $tables;
+ }
+
+ /**
+ * Throw an exception if not connected
+ */
+ protected function ensure_connected($method_name)
+ {
+ if (null === $this->pdo)
+ {
+ throw new Exception(sprintf('You must connect before calling %s', $method_name));
+ }
+ }
+
+ /**
+ * Compile the correct schema filename (as per create_schema_files) and
+ * load it into the database.
+ */
+ protected function load_schema_from_file($directory)
+ {
+ $schema = $this->dbms['SCHEMA'];
+
+ if ($this->config['dbms'] == 'mysql')
+ {
+ $sth = $this->pdo->query('SELECT VERSION() AS version');
+ $row = $sth->fetch(PDO::FETCH_ASSOC);
+
+ if (version_compare($row['version'], '4.1.3', '>='))
+ {
+ $schema .= '_41';
+ }
+ else
+ {
+ $schema .= '_40';
+ }
+ }
+
+ $filename = $directory . $schema . '_schema.sql';
+ $sql = $this->split_sql(file_get_contents($filename));
+
+ foreach ($sql as $query)
+ {
+ $this->pdo->exec($query);
+ }
+ }
+
+ /**
+ * Split contents of an SQL file into an array of SQL statements
+ *
+ * Note: This method is not the same as split_sql_file from functions_install.
+ *
+ * @param string $sql Raw contents of an SQL file
+ *
+ * @return Array of runnable SQL statements
+ */
+ protected function split_sql($sql)
+ {
+ $sql = str_replace("\r" , '', $sql);
+ $data = preg_split('/' . preg_quote($this->dbms['DELIM'], '/') . '$/m', $sql);
+
+ $data = array_map('trim', $data);
+
+ // The empty case
+ $end_data = end($data);
+
+ if (empty($end_data))
+ {
+ unset($data[key($data)]);
+ }
+
+ if ($this->config['dbms'] == 'sqlite')
+ {
+ // remove comment lines starting with # - they are not proper sqlite
+ // syntax and break sqlite2
+ foreach ($data as $i => $query)
+ {
+ $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Map a phpBB dbms driver name to dbms data array
+ */
+ protected function get_dbms_data($dbms)
+ {
+ $available_dbms = array(
+ 'firebird' => array(
+ 'SCHEMA' => 'firebird',
+ 'DELIM' => ';;',
+ 'PDO' => 'firebird',
+ ),
+ 'mysqli' => array(
+ 'SCHEMA' => 'mysql_41',
+ 'DELIM' => ';',
+ 'PDO' => 'mysql',
+ ),
+ 'mysql' => array(
+ 'SCHEMA' => 'mysql',
+ 'DELIM' => ';',
+ 'PDO' => 'mysql',
+ ),
+ 'mssql' => array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'odbc',
+ ),
+ 'mssql_odbc'=> array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'odbc',
+ ),
+ 'mssqlnative' => array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'sqlsrv',
+ ),
+ 'oracle' => array(
+ 'SCHEMA' => 'oracle',
+ 'DELIM' => '/',
+ 'PDO' => 'oci',
+ ),
+ 'postgres' => array(
+ 'SCHEMA' => 'postgres',
+ 'DELIM' => ';',
+ 'PDO' => 'pgsql',
+ ),
+ 'sqlite' => array(
+ 'SCHEMA' => 'sqlite',
+ 'DELIM' => ';',
+ 'PDO' => 'sqlite2',
+ ),
+ );
+
+ if (isset($available_dbms[$dbms]))
+ {
+ return $available_dbms[$dbms];
+ }
+ else
+ {
+ $message = "Supplied dbms \"$dbms\" is not a valid phpBB dbms, must be one of: ";
+ $message .= implode(', ', array_keys($available_dbms));
+ throw new Exception($message);
+ }
+ }
+}
diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php
index 75a35daf82..29b982d709 100644
--- a/tests/text_processing/make_clickable_test.php
+++ b/tests/text_processing/make_clickable_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/functions_content.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
class phpbb_text_processing_make_clickable_test extends phpbb_test_case
{
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
new file mode 100644
index 0000000000..6c60583a7b
--- /dev/null
+++ b/tests/user/lang_test.php
@@ -0,0 +1,58 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
+
+class phpbb_user_lang_test extends phpbb_test_case
+{
+ public function test_user_lang_sprintf()
+ {
+ $user = new user;
+ $user->lang = array(
+ 'FOO' => 'BAR',
+ 'BARZ' => 'PENG',
+ 'EMPTY' => '',
+ 'ZERO' => '0',
+ 'STR' => '%d %s, %d topics',
+ 'STR2' => '%d foos',
+ 'ARRY' => array(
+ 0 => 'No posts', // 0
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 2+
+ ),
+ );
+
+ // No param
+ $this->assertEquals($user->lang('FOO'), 'BAR');
+ $this->assertEquals($user->lang('EMPTY'), '');
+ $this->assertEquals($user->lang('ZERO'), '0');
+
+ // Invalid index
+ $this->assertEquals($user->lang('VOID'), 'VOID');
+
+ // Unnecessary param
+ $this->assertEquals($user->lang('FOO', 2), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR');
+
+ // String
+ $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics');
+ $this->assertEquals($user->lang('STR2', 64), '64 foos');
+
+ // Array
+ $this->assertEquals($user->lang('ARRY', 0), 'No posts');
+ $this->assertEquals($user->lang('ARRY', 1), '1 post');
+ $this->assertEquals($user->lang('ARRY', 2), '2 posts');
+ $this->assertEquals($user->lang('ARRY', 123), '123 posts');
+
+ // Bug PHPBB3-9949
+ $this->assertEquals($user->lang('ARRY', 1, 2), '1 post');
+ $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
+ }
+}
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
index 9a9011c0fe..38b4ec1b6b 100644
--- a/tests/utf/normalizer_test.php
+++ b/tests/utf/normalizer_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_normalizer.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php';
/**
* @group slow
@@ -16,8 +16,8 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
{
static public function setUpBeforeClass()
{
- self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', __DIR__.'/data');
- self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', __DIR__.'/data');
+ self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', dirname(__FILE__).'/data');
+ self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', dirname(__FILE__).'/data');
}
public function test_normalizer()
@@ -62,7 +62,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
$tested_chars = array();
- $fp = fopen(__DIR__.'/data/NormalizationTest.txt', 'rb');
+ $fp = fopen(dirname(__FILE__).'/data/NormalizationTest.txt', 'rb');
while (!feof($fp))
{
$line = fgets($fp);
@@ -117,7 +117,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
*/
public function test_invariants(array $tested_chars)
{
- $fp = fopen(__DIR__.'/data/UnicodeData.txt', 'rb');
+ $fp = fopen(dirname(__FILE__).'/data/UnicodeData.txt', 'rb');
while (!feof($fp))
{
diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php
index 148297ad4b..e5a771eafa 100644
--- a/tests/utf/utf8_clean_string_test.php
+++ b/tests/utf/utf8_clean_string_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_utf_utf8_clean_string_test extends phpbb_test_case
{
diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php
index fbc947b92a..03fa9dc38c 100644
--- a/tests/utf/utf8_wordwrap_test.php
+++ b/tests/utf/utf8_wordwrap_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case
{