aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--build/build.xml1
-rwxr-xr-xgit-tools/setup_github_network.php248
-rw-r--r--phpBB/adm/index.php6
-rw-r--r--phpBB/adm/style/acp_styles.html15
-rw-r--r--phpBB/adm/style/install_footer.html15
-rw-r--r--phpBB/adm/style/overall_footer.html15
-rw-r--r--phpBB/adm/style/simple_footer.html13
-rw-r--r--phpBB/develop/create_schema_files.php2
-rw-r--r--phpBB/develop/create_variable_overview.php2
-rw-r--r--phpBB/develop/mysql_upgrader.php3
-rw-r--r--phpBB/docs/AUTHORS2
-rw-r--r--phpBB/docs/CHANGELOG.html4
-rw-r--r--phpBB/docs/FAQ.html4
-rw-r--r--phpBB/docs/INSTALL.html4
-rw-r--r--phpBB/docs/README.html4
-rw-r--r--phpBB/docs/auth_api.html4
-rw-r--r--phpBB/docs/coding-guidelines.html4
-rw-r--r--phpBB/docs/hook_system.html4
-rw-r--r--phpBB/docs/nginx.sample.conf2
-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.php258
-rw-r--r--phpBB/includes/captcha/captcha_gd_wave.php4
-rw-r--r--phpBB/includes/constants.php3
-rw-r--r--phpBB/includes/db/dbal.php2
-rw-r--r--phpBB/includes/functions.php45
-rw-r--r--phpBB/includes/functions_admin.php24
-rw-r--r--phpBB/includes/functions_posting.php6
-rw-r--r--phpBB/includes/functions_upload.php4
-rw-r--r--phpBB/includes/functions_user.php40
-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/install/database_update.php37
-rw-r--r--phpBB/install/index.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/overall_footer.html11
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html10
-rw-r--r--phpBB/styles/prosilver/template/simple_footer.html12
-rw-r--r--phpBB/styles/prosilver/template/simple_header.html1
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html12
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_print.html13
-rw-r--r--phpBB/styles/prosilver/theme/colours.css18
-rw-r--r--phpBB/styles/prosilver/theme/links.css12
-rw-r--r--phpBB/styles/prosilver/theme/print.css4
-rw-r--r--phpBB/styles/subsilver2/template/overall_footer.html11
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html8
-rw-r--r--phpBB/styles/subsilver2/template/simple_footer.html13
-rw-r--r--phpBB/styles/subsilver2/template/simple_header.html1
-rw-r--r--phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html11
-rw-r--r--phpBB/styles/subsilver2/template/viewtopic_print.html11
-rw-r--r--phpBB/styles/subsilver2/theme/stylesheet.css14
-rw-r--r--phpunit.xml.all25
-rw-r--r--phpunit.xml.dist12
-rw-r--r--tests/RUNNING_TESTS.txt9
-rw-r--r--tests/bootstrap.php3
-rw-r--r--tests/dbal/select_test.php (renamed from tests/dbal/select.php)2
-rw-r--r--tests/dbal/write_test.php (renamed from tests/dbal/write.php)2
-rw-r--r--tests/mock/cache.php68
-rw-r--r--tests/mock/session_testable.php63
-rw-r--r--tests/network/checkdnsrr_test.php (renamed from tests/network/checkdnsrr.php)5
-rw-r--r--tests/random/gen_rand_string_test.php (renamed from tests/random/gen_rand_string.php)2
-rw-r--r--tests/regex/censor_test.php (renamed from tests/regex/censor.php)16
-rw-r--r--tests/regex/email_test.php (renamed from tests/regex/email.php)2
-rw-r--r--tests/regex/ipv4_test.php (renamed from tests/regex/ipv4.php)2
-rw-r--r--tests/regex/ipv6_test.php (renamed from tests/regex/ipv6.php)2
-rw-r--r--tests/regex/url_test.php (renamed from tests/regex/url.php)2
-rw-r--r--tests/request/request_var_test.php (renamed from tests/request/request_var.php)3
-rw-r--r--tests/security/extract_current_page_test.php (renamed from tests/security/extract_current_page.php)6
-rw-r--r--tests/security/redirect_test.php (renamed from tests/security/redirect.php)6
-rw-r--r--tests/session/continue_test.php117
-rw-r--r--tests/session/fixtures/sessions_empty.xml25
-rw-r--r--tests/session/fixtures/sessions_full.xml37
-rw-r--r--tests/session/init_test.php56
-rw-r--r--tests/session/testable_factory.php171
-rw-r--r--tests/template/template_test.php (renamed from tests/template/template.php)3
-rw-r--r--tests/test_framework/phpbb_database_test_case.php304
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php346
-rw-r--r--tests/text_processing/make_clickable_test.php (renamed from tests/text_processing/make_clickable.php)4
-rw-r--r--tests/user/lang_test.php58
-rw-r--r--tests/utf/data/.gitkeep0
-rw-r--r--tests/utf/normalizer_test.php318
-rw-r--r--tests/utf/utf8_clean_string_test.php2
-rw-r--r--tests/utf/utf8_wordwrap_test.php2
98 files changed, 2102 insertions, 657 deletions
diff --git a/.gitignore b/.gitignore
index 39b9e0a7f4..c417bf01c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ phpBB/images/avatars/upload/*
phpBB/store/*
tests/phpbb_unit_tests.sqlite2
tests/test_config.php
+tests/utf/data/*.txt
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/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_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/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html
index 4df43eaaa0..9b5494b8b6 100644
--- a/phpBB/adm/style/install_footer.html
+++ b/phpBB/adm/style/install_footer.html
@@ -6,20 +6,9 @@
</div>
</div>
</div>
-
- <!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
- // -->
-
+
<div id="page-footer">
- Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
+ Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
</div>
</div>
diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html
index 8af299ad57..03ca369562 100644
--- a/phpBB/adm/style/overall_footer.html
+++ b/phpBB/adm/style/overall_footer.html
@@ -6,21 +6,10 @@
</div>
</div>
</div>
-
- <!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
- // -->
-
+
<div id="page-footer">
<!-- IF S_COPYRIGHT_HTML -->
- Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
+ Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
<!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
<!-- ENDIF -->
diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html
index 65cf724c2f..7276fb4b63 100644
--- a/phpBB/adm/style/simple_footer.html
+++ b/phpBB/adm/style/simple_footer.html
@@ -2,21 +2,10 @@
<br /><br />
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-// -->
-
<div id="page-footer">
<!-- IF S_COPYRIGHT_HTML -->
- <br />Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
+ <br />Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
<!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
<!-- ENDIF -->
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/create_variable_overview.php b/phpBB/develop/create_variable_overview.php
index 3782f53e4c..b5ed090a75 100644
--- a/phpBB/develop/create_variable_overview.php
+++ b/phpBB/develop/create_variable_overview.php
@@ -528,7 +528,7 @@ foreach ($lang_fp as $filepointer)
$html_data .= '
<br><br>
-<div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
+<div class="copyright" align="center">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group</div>
<br clear="all" /></td>
</tr>
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 b3166313c3..1dfb80141c 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -1,6 +1,6 @@
/**
*
-* phpBB3 © Copyright 2000, 2002, 2005, 2007 phpBB Group
+* phpBB3 © Copyright phpBB Group
* http://www.phpbb.com
*
* This program is free software: you can redistribute it and/or modify
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 66915b18fa..253df4ac56 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="phpBB 3.0.x Changelog" />
<title>phpBB3 &bull; Changelog</title>
@@ -1676,7 +1676,7 @@
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/FAQ.html b/phpBB/docs/FAQ.html
index f91d4bc223..83d7a342e0 100644
--- a/phpBB/docs/FAQ.html
+++ b/phpBB/docs/FAQ.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="phpBB 3.0.x frequently asked questions" />
<title>phpBB3 &bull; FAQ</title>
@@ -328,7 +328,7 @@ I want to sue you because i think you host an illegal board!</h2>
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html
index 5857163759..4af185beb3 100644
--- a/phpBB/docs/INSTALL.html
+++ b/phpBB/docs/INSTALL.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="phpBB 3.0.x Installation, updating and conversion informations" />
<title>phpBB3 &bull; Install</title>
@@ -424,7 +424,7 @@
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html
index bb88fdc01f..7a0a42b34f 100644
--- a/phpBB/docs/README.html
+++ b/phpBB/docs/README.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="phpBB 3.0.x Readme" />
<title>phpBB3 &bull; Readme</title>
@@ -339,7 +339,7 @@
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/auth_api.html b/phpBB/docs/auth_api.html
index 8973582bdb..88618fa640 100644
--- a/phpBB/docs/auth_api.html
+++ b/phpBB/docs/auth_api.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="This is an explanation of how to use the phpBB auth/acl API" />
<title>phpBB3 &bull; Auth API</title>
@@ -275,7 +275,7 @@ $auth_admin = new auth_admin();
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 5a73554741..7434fa4870 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="Olympus coding guidelines document" />
<title>phpBB3 &bull; Coding Guidelines</title>
@@ -2369,7 +2369,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/hook_system.html b/phpBB/docs/hook_system.html
index 34055c4661..a5fad0d530 100644
--- a/phpBB/docs/hook_system.html
+++ b/phpBB/docs/hook_system.html
@@ -8,7 +8,7 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2007 phpBB Group" />
+<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="Hook System explanation" />
<title>phpBB3 &bull; Hook System</title>
@@ -867,7 +867,7 @@ function phpbb_hook_register(&amp;$hook)
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf
index a22a126ff4..2a11e057c5 100644
--- a/phpBB/docs/nginx.sample.conf
+++ b/phpBB/docs/nginx.sample.conf
@@ -45,6 +45,7 @@ http {
# Deny access to internal phpbb files.
location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) {
+ internal;
deny all;
}
@@ -59,6 +60,7 @@ http {
# Deny access to version control system directories.
location ~ /\.svn|/\.git {
+ internal;
deny all;
}
}
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..0f157ceff3 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -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/dbal.php b/phpBB/includes/db/dbal.php
index eeddf1f41b..5d8d5fbd47 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -767,7 +767,7 @@ class dbal
</div>
</div>
<div id="page-footer">
- Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
+ Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
</div>
</div>
</body>
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 69be1627cf..398a02380b 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1698,7 +1698,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
// Get list of the unread topics
- $last_mark = $user->data['user_lastmark'];
+ $last_mark = (int) $user->data['user_lastmark'];
$sql_array = array(
'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time',
@@ -1717,10 +1717,11 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
),
'WHERE' => "
+ t.topic_last_post_time > $last_mark AND
(
(tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR
(tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR
- (tt.mark_time IS NULL AND ft.mark_time IS NULL AND t.topic_last_post_time > $last_mark)
+ (tt.mark_time IS NULL AND ft.mark_time IS NULL)
)
$sql_extra
$sql_sort",
@@ -2630,8 +2631,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
@@ -3432,30 +3439,26 @@ function get_preg_expression($mode)
* Generate regexp for naughty words censoring
* Depends on whether installed PHP version supports unicode properties
*
-* @param string $word word template to be replaced
+* @param string $word word template to be replaced
+* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
*
* @return string $preg_expr regex to use with word censor
*/
-function get_censor_preg_expression($word)
+function get_censor_preg_expression($word, $use_unicode = true)
{
- static $unicode = null;
-
- if (empty($word))
- {
- return '';
- }
+ static $unicode_support = null;
// Check whether PHP version supports unicode properties
- if (is_null($unicode))
+ if (is_null($unicode_support))
{
- $unicode = ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) ? true : false;
+ $unicode_support = ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) ? true : false;
}
- if ($unicode)
- {
- // Unescape the asterisk to simplify further conversions
- $word = str_replace('\*', '*', preg_quote($word, '#'));
+ // Unescape the asterisk to simplify further conversions
+ $word = str_replace('\*', '*', preg_quote($word, '#'));
+ if ($use_unicode && $unicode_support)
+ {
// Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes
$word = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*+(?=[\p{Nd}\p{L}_])#iu', '#^\*+#', '#\*+$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $word);
@@ -3464,7 +3467,11 @@ function get_censor_preg_expression($word)
}
else
{
- $preg_expr = '#(?<!\S)(' . str_replace('\*', '\S*?', preg_quote($word, '#')) . ')(?!\S)#iu';
+ // Replace the asterisk inside the pattern, at the start and at the end of it with regexes
+ $word = preg_replace(array('#(?<=\S)\*+(?=\S)#iu', '#^\*+#', '#\*+$#'), array('(\x20*?\S*?)', '\S*?', '\S*?'), $word);
+
+ // Generate the final substitution
+ $preg_expr = '#(?<!\S)(' . $word . ')(?!\S)#iu';
}
return $preg_expr;
@@ -3834,7 +3841,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
- echo ' Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
+ echo ' Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group';
echo ' </div>';
echo '</div>';
echo '</body>';
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 6fd87db663..271039f415 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -388,7 +388,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
$upload = new fileupload();
- if ($config['check_attachment_content'])
+ if ($config['check_attachment_content'] && isset($config['mime_triggers']))
{
$upload->set_disallowed_content(explode('|', $config['mime_triggers']));
}
@@ -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_upload.php b/phpBB/includes/functions_upload.php
index 7f09cc1640..d5bbd80242 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -458,7 +458,7 @@ class fileerror extends filespec
class fileupload
{
var $allowed_extensions = array();
- var $disallowed_content = array();
+ var $disallowed_content = array('body', 'head', 'html', 'img', 'plaintext', 'a href', 'pre', 'script', 'table', 'title');
var $max_filesize = 0;
var $min_width = 0;
var $min_height = 0;
@@ -539,7 +539,7 @@ class fileupload
{
if ($disallowed_content !== false && is_array($disallowed_content))
{
- $this->disallowed_content = $disallowed_content;
+ $this->disallowed_content = array_diff($disallowed_content, array(''));
}
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f2c80705ba..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);
@@ -2080,7 +2042,7 @@ function avatar_upload($data, &$error)
// Init upload class
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
- $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], explode('|', $config['mime_triggers']));
+ $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], (isset($config['mime_triggers']) ? explode('|', $config['mime_triggers']) : false));
if (!empty($_FILES['uploadfile']['name']))
{
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/install/database_update.php b/phpBB/install/database_update.php
index 10308826e0..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
@@ -511,7 +511,7 @@ function _print_footer()
</div>
<div id="page-footer">
- Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
+ Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
</div>
</div>
@@ -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/index.php b/phpBB/install/index.php
index eb51ca5fb2..49c99da0d7 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -652,7 +652,7 @@ class module
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
- echo ' Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
+ echo ' Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group';
echo ' </div>';
echo '</div>';
echo '</body>';
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/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html
index aeb6dc9ba3..1a044b0ca1 100644
--- a/phpBB/styles/prosilver/template/overall_footer.html
+++ b/phpBB/styles/prosilver/template/overall_footer.html
@@ -19,17 +19,6 @@
<span class="corners-bottom"><span></span></span></div>
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-//-->
-
<div class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
<!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
<!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index e607b6f489..51fff0735a 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -8,7 +8,6 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />
@@ -47,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 -->
/**
diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html
index e64e209368..daeb786fcb 100644
--- a/phpBB/styles/prosilver/template/simple_footer.html
+++ b/phpBB/styles/prosilver/template/simple_footer.html
@@ -1,16 +1,6 @@
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
- The phpBB Group : 2006
-//-->
-
- <div class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; 2000, 2002, 2005, 2007 phpBB Group
+ <div class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
<!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
<!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF -->
</div>
diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html
index ef9b0a5573..9cc8060762 100644
--- a/phpBB/styles/prosilver/template/simple_header.html
+++ b/phpBB/styles/prosilver/template/simple_header.html
@@ -8,7 +8,6 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
index 45ee6d1fae..c69bb82382 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
@@ -105,16 +105,6 @@ hr.sep {
</table>
<hr width="85%" />
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-//-->
<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
<tr>
@@ -122,7 +112,7 @@ hr.sep {
<td align="{S_CONTENT_FLOW_END}"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
<tr>
- <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; 2000, 2002, 2005, 2007 phpBB Group<br />http://www.phpbb.com/</span></td>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; phpBB Group<br />http://www.phpbb.com/</span></td>
</tr>
</table>
diff --git a/phpBB/styles/prosilver/template/viewtopic_print.html b/phpBB/styles/prosilver/template/viewtopic_print.html
index 03102dd351..541c48a53d 100644
--- a/phpBB/styles/prosilver/template/viewtopic_print.html
+++ b/phpBB/styles/prosilver/template/viewtopic_print.html
@@ -8,7 +8,6 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="robots" content="noindex" />
@@ -43,19 +42,9 @@
<!-- END postrow -->
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-//-->
<div id="page-footer">
<div class="page-number">{S_TIMEZONE}<br />{PAGE_NUMBER}</div>
- <div class="copyright">Powered by phpBB &copy; 2000, 2002, 2005, 2007 phpBB Group<br />http://www.phpbb.com/</div>
+ <div class="copyright">Powered by phpBB &copy; phpBB Group<br />http://www.phpbb.com/</div>
</div>
</div>
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index 5d74ff9d8f..f7747ba73c 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -171,7 +171,7 @@ dl.details dd {
border-color: #4692BF;
}
-.pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active {
+.pagination span a, .pagination span a:link, .pagination span a:visited {
color: #5C758C;
background-color: #ECEDEE;
border-color: #B4BAC0;
@@ -183,6 +183,12 @@ dl.details dd {
color: #FFF;
}
+.pagination span a:active {
+ color: #5C758C;
+ background-color: #ECEDEE;
+ border-color: #B4BAC0;
+}
+
/* Pagination in viewforum for multipage topics */
.row .pagination {
background-image: url("{T_THEME_PATH}/images/icon_pages.gif");
@@ -304,12 +310,12 @@ a.topictitle:active {
color: #0D4473;
}
-.signature a, .signature a:visited, .signature a:active, .signature a:hover {
+.signature a, .signature a:visited, .signature a:hover, .signature a:active {
background-color: transparent;
}
/* Profile links */
-.postprofile a:link, .postprofile a:active, .postprofile a:visited, .postprofile dt.author a {
+.postprofile a:link, .postprofile a:visited, .postprofile dt.author a {
color: #105289;
}
@@ -317,6 +323,10 @@ a.topictitle:active {
color: #D31141;
}
+.postprofile a:active {
+ color: #105289;
+}
+
/* Profile searchresults */
.search .postprofile a {
color: #105289;
@@ -642,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/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css
index ea9ca8f4b1..a406114054 100644
--- a/phpBB/styles/prosilver/theme/links.css
+++ b/phpBB/styles/prosilver/theme/links.css
@@ -103,14 +103,14 @@ a.topictitle:active {
color: #404040;
}
-.signature a, .signature a:visited, .signature a:active, .signature a:hover {
+.signature a, .signature a:visited, .signature a:hover, .signature a:active {
border: none;
text-decoration: underline;
background-color: transparent;
}
/* Profile links */
-.postprofile a:link, .postprofile a:active, .postprofile a:visited, .postprofile dt.author a {
+.postprofile a:link, .postprofile a:visited, .postprofile dt.author a {
font-weight: bold;
color: #898989;
text-decoration: none;
@@ -121,6 +121,14 @@ a.topictitle:active {
color: #d3d3d3;
}
+/* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */
+/* See http://www.phpbb.com/bugs/phpbb3/59685 */
+.postprofile a:active {
+ font-weight: bold;
+ color: #898989;
+ text-decoration: none;
+}
+
/* Profile searchresults */
.search .postprofile a {
diff --git a/phpBB/styles/prosilver/theme/print.css b/phpBB/styles/prosilver/theme/print.css
index 68600b030b..2cfcd4da20 100644
--- a/phpBB/styles/prosilver/theme/print.css
+++ b/phpBB/styles/prosilver/theme/print.css
@@ -60,7 +60,7 @@ h3 { font-size: 14pt; margin-top: 1em; }
}
/* CSS2 Print tip from: http://www.alistapart.com/articles/goingtoprint/ */
-.postbody a:link, .postbody a:visited, .postbody a:active, .postbody a:hover {
+.postbody a:link, .postbody a:visited, .postbody a:hover, .postbody a:active {
text-decoration: underline;
padding: 0.1em 0.2em;
margin: -0.1em -0.2em;
@@ -141,4 +141,4 @@ div.spacer { clear: both; }
/* Accessibility tweaks: Mozilla.org */
.skip_link { display: none; }
-dl.codebox dt { display: none; } \ No newline at end of file
+dl.codebox dt { display: none; }
diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html
index 187d0f4366..b53fff9f7f 100644
--- a/phpBB/styles/subsilver2/template/overall_footer.html
+++ b/phpBB/styles/subsilver2/template/overall_footer.html
@@ -1,17 +1,6 @@
<!-- IF not S_IS_BOT -->{RUN_CRON_TASK}<!-- ENDIF -->
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-//-->
-
<div id="wrapfooter">
<!-- IF U_ACP --><span class="gensmall">[ <a href="{U_ACP}">{L_ACP}</a> ]</span><br /><br /><!-- ENDIF -->
<span class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 874beb8e2b..be4c7b5b4c 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -8,7 +8,6 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />
@@ -29,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/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html
index c8b69dd5ad..1bd146b599 100644
--- a/phpBB/styles/subsilver2/template/simple_footer.html
+++ b/phpBB/styles/subsilver2/template/simple_footer.html
@@ -1,19 +1,8 @@
</div>
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
- "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
- forums may be affected.
-
- The phpBB Group : 2006
-//-->
-
<div id="wrapfooter">
- <span class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; 2000, 2002, 2005, 2007 phpBB Group</span>
+ <span class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; phpBB Group</span>
</div>
</body>
diff --git a/phpBB/styles/subsilver2/template/simple_header.html b/phpBB/styles/subsilver2/template/simple_header.html
index bcef9a7059..b0dc908bc6 100644
--- a/phpBB/styles/subsilver2/template/simple_header.html
+++ b/phpBB/styles/subsilver2/template/simple_header.html
@@ -8,7 +8,6 @@
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
-<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
diff --git a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
index f1c59df1c8..eff4a2a7dd 100644
--- a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
+++ b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
@@ -107,15 +107,6 @@ hr.sep {
</table>
<hr width="85%" />
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line. If you
- refuse to include even this then support on our forums may be affected.
-
- The phpBB Group : 2006
-// -->
<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
<tr>
@@ -123,7 +114,7 @@ hr.sep {
<td align="{S_CONTENT_FLOW_END}"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
<tr>
- <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; 2000, 2002, 2005, 2007 phpBB Group<br />http://www.phpbb.com/</span></td>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; phpBB Group<br />http://www.phpbb.com/</span></td>
</tr>
</table>
diff --git a/phpBB/styles/subsilver2/template/viewtopic_print.html b/phpBB/styles/subsilver2/template/viewtopic_print.html
index cfd78b6fc7..38ec10fad8 100644
--- a/phpBB/styles/subsilver2/template/viewtopic_print.html
+++ b/phpBB/styles/subsilver2/template/viewtopic_print.html
@@ -121,15 +121,6 @@ hr.sep {
<!-- END postrow -->
<hr width="85%" />
-<!--
- We request you retain the full copyright notice below including the link to www.phpbb.com.
- This not only gives respect to the large amount of time given freely by the developers
- but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
- the full copyright we ask you at least leave in place the "Powered by phpBB" line. If you
- refuse to include even this then support on our forums may be affected.
-
- The phpBB Group : 2006
-// -->
<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
<tr>
@@ -137,7 +128,7 @@ hr.sep {
<td align="{S_CONTENT_FLOW_END}"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
<tr>
- <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; 2000, 2002, 2005, 2007 phpBB Group<br />http://www.phpbb.com/</span></td>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB &copy; phpBB Group<br />http://www.phpbb.com/</span></td>
</tr>
</table>
diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css
index 726efdca0a..c2b6718d87 100644
--- a/phpBB/styles/subsilver2/theme/stylesheet.css
+++ b/phpBB/styles/subsilver2/theme/stylesheet.css
@@ -210,13 +210,13 @@ p.topicdetails {
margin: 1px 0;
}
-.postreported, .postreported a:visited, .postreported a:hover, .postreported a:link, .postreported a:active {
+.postreported, .postreported a:link, .postreported a:visited, .postreported a:hover, .postreported a:active {
margin: 1px 0;
color: red;
font-weight:bold;
}
-.postapprove, .postapprove a:visited, .postapprove a:hover, .postapprove a:link, .postapprove a:active {
+.postapprove, .postapprove a:link, .postapprove a:visited, .postapprove a:hover, .postapprove a:active {
color: green;
font-weight:bold;
}
@@ -386,12 +386,13 @@ hr {
unicode-bidi: embed;
}
+/* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */
+/* See http://www.phpbb.com/bugs/phpbb3/59685 */
a:link {
color: #006597;
text-decoration: none;
}
-a:active,
a:visited {
color: #005784;
text-decoration: none;
@@ -402,6 +403,11 @@ a:hover {
text-decoration: underline;
}
+a:active {
+ color: #005784;
+ text-decoration: none;
+}
+
a.forumlink {
color: #069;
font-weight: bold;
@@ -667,4 +673,4 @@ pre {
.username-coloured {
font-weight: bold;
-} \ No newline at end of file
+}
diff --git a/phpunit.xml.all b/phpunit.xml.all
new file mode 100644
index 0000000000..1be2830729
--- /dev/null
+++ b/phpunit.xml.all
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="true"
+ backupStaticAttributes="true"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="phpBB Test Suite">
+ <directory suffix="_test.php">./tests/</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <blacklist>
+ <directory>./tests/</directory>
+ </blacklist>
+ </filter>
+</phpunit>
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index d1d8adbdd5..de8134da8e 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -2,7 +2,7 @@
<phpunit backupGlobals="true"
backupStaticAttributes="true"
- colors="false"
+ colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
@@ -13,10 +13,16 @@
>
<testsuites>
<testsuite name="phpBB Test Suite">
- <directory suffix=".php">./tests/</directory>
+ <directory suffix="_test.php">./tests/</directory>
</testsuite>
</testsuites>
-
+
+ <groups>
+ <exclude>
+ <group>slow</group>
+ </exclude>
+ </groups>
+
<filter>
<blacklist>
<directory>./tests/</directory>
diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt
index ac07978d3e..59197acc0f 100644
--- a/tests/RUNNING_TESTS.txt
+++ b/tests/RUNNING_TESTS.txt
@@ -50,6 +50,15 @@ Once the prerequisites are installed, run the tests from the project root direct
$ phpunit
+Slow tests
+--------------
+Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow.
+Thus these tests are in the `slow` group, which is excluded by default. You can
+enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you only
+want the slow tests, run:
+
+ $ phpunit --group slow
+
More Information
================
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 99f145e427..c729c6e2d8 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -10,7 +10,7 @@
define('IN_PHPBB', true);
$phpbb_root_path = 'phpBB/';
$phpEx = 'php';
-$table_prefix = '';
+$table_prefix = 'phpbb_';
error_reporting(E_ALL & ~E_DEPRECATED);
@@ -30,3 +30,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.php b/tests/dbal/select_test.php
index 987de5cbff..533416f14b 100644
--- a/tests/dbal/select.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.php b/tests/dbal/write_test.php
index a24b6efcc4..4709d45fa5 100644
--- a/tests/dbal/write.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
new file mode 100644
index 0000000000..738d1eaaba
--- /dev/null
+++ b/tests/mock/cache.php
@@ -0,0 +1,68 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_mock_cache
+{
+ public function __construct($data = array())
+ {
+ $this->data = $data;
+
+ if (!isset($this->data['_bots']))
+ {
+ $this->data['_bots'] = array();
+ }
+ }
+
+ public function get($var_name)
+ {
+ if (isset($this->data[$var_name]))
+ {
+ return $this->data[$var_name];
+ }
+
+ return false;
+ }
+
+ public function put($var_name, $var, $ttl = 0)
+ {
+ $this->data[$var_name] = $var;
+ }
+
+ /**
+ * Obtain active bots
+ */
+ public function obtain_bots()
+ {
+ return $this->data['_bots'];
+ }
+
+ public function set_bots($bots)
+ {
+ $this->data['_bots'] = $bots;
+ }
+
+ public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
+ {
+ $test->assertTrue(isset($this->data[$var_name]));
+ $test->assertEquals($data, $this->data[$var_name]);
+ }
+
+ public function check(PHPUnit_Framework_Assert $test, $data, $ignore_db_info = true)
+ {
+ $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
new file mode 100644
index 0000000000..47089cb94b
--- /dev/null
+++ b/tests/mock/session_testable.php
@@ -0,0 +1,63 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+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();
+
+ public function set_cookie($name, $data, $time)
+ {
+ $this->_cookies[$name] = array($data, $time);
+ }
+
+ /**
+ * Checks if the cookies were set correctly.
+ *
+ * @param PHPUnit_Framework_Assert test The test from which this is called
+ * @param array(string => mixed) cookies The cookie data to check against.
+ * The keys are cookie names, the values can either be null to
+ * check only the existance of the cookie, or an array(d, t),
+ * where d is the cookie data to check, or null to skip the
+ * check and t is the cookie time to check, or null to skip.
+ */
+ public function check_cookies(PHPUnit_Framework_Assert $test, $cookies)
+ {
+ $test->assertEquals(array_keys($cookies), array_keys($this->_cookies), 'Incorrect cookies were set');
+
+ foreach ($cookies as $name => $cookie)
+ {
+ if (!is_null($cookie))
+ {
+ $data = $cookie[0];
+ $time = $cookie[1];
+
+ if (!is_null($data))
+ {
+ $test->assertEquals($data, $this->_cookies[$name][0], "Cookie $name contains incorrect data");
+ }
+
+ if (!is_null($time))
+ {
+ $test->assertEquals($time, $this->_cookies[$name][1], "Cookie $name expires at the wrong time");
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/network/checkdnsrr.php b/tests/network/checkdnsrr_test.php
index 427132e508..5a756dcef8 100644
--- a/tests/network/checkdnsrr.php
+++ b/tests/network/checkdnsrr_test.php
@@ -7,8 +7,11 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+/**
+* @group slow
+*/
class phpbb_network_checkdnsrr_test extends phpbb_test_case
{
public function data_provider()
diff --git a/tests/random/gen_rand_string.php b/tests/random/gen_rand_string_test.php
index fa519f134c..115c55e4e2 100644
--- a/tests/random/gen_rand_string.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.php b/tests/regex/censor_test.php
index ae2d86e07e..fa9104e71d 100644
--- a/tests/regex/censor.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
{
@@ -31,9 +31,19 @@ class phpbb_regex_censor_test extends phpbb_test_case
/**
* @dataProvider censor_test_data
*/
- public function test_censor($pattern, $subject)
+ public function test_censor_unicode($pattern, $subject)
{
- $regex = get_censor_preg_expression($pattern);
+ $regex = get_censor_preg_expression($pattern, true);
+
+ $this->assertRegExp($regex, $subject);
+ }
+
+ /**
+ * @dataProvider censor_test_data
+ */
+ public function test_censor_no_unicode($pattern, $subject)
+ {
+ $regex = get_censor_preg_expression($pattern, false);
$this->assertRegExp($regex, $subject);
}
diff --git a/tests/regex/email.php b/tests/regex/email_test.php
index 5d6e207cbb..0695b801d5 100644
--- a/tests/regex/email.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.php b/tests/regex/ipv4_test.php
index 735a2c4384..9829547508 100644
--- a/tests/regex/ipv4.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.php b/tests/regex/ipv6_test.php
index 187588f861..1b2018403c 100644
--- a/tests/regex/ipv6.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.php b/tests/regex/url_test.php
index 246cbf549c..c3a336063a 100644
--- a/tests/regex/url.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.php b/tests/request/request_var_test.php
index 804e5d6390..fa17b1909f 100644
--- a/tests/request/request_var.php
+++ b/tests/request/request_var_test.php
@@ -7,7 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.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.php b/tests/security/extract_current_page_test.php
index ff0ab4d1bb..71c7a3a397 100644
--- a/tests/security/extract_current_page.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.php b/tests/security/redirect_test.php
index c53414e7df..70ba8527b1 100644
--- a/tests/security/redirect.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
new file mode 100644
index 0000000000..f94337314e
--- /dev/null
+++ b/tests/session/fixtures/sessions_empty.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username_clean</column>
+ <row>
+ <value>1</value>
+ <value>anonymous</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>foo</value>
+ </row>
+ <row>
+ <value>4</value>
+ <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/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml
new file mode 100644
index 0000000000..4559a08c55
--- /dev/null
+++ b/tests/session/fixtures/sessions_full.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username_clean</column>
+ <row>
+ <value>1</value>
+ <value>anonymous</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>foo</value>
+ </row>
+ <row>
+ <value>4</value>
+ <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>
+ <row>
+ <value>anon_session</value>
+ <value>1</value>
+ <value>127.0.0.1</value>
+ <value>anonymous user agent</value>
+ </row>
+ <row>
+ <value>bar_session</value>
+ <value>4</value>
+ <value>127.0.0.1</value>
+ <value>user agent</value>
+ </row>
+ </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/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.php b/tests/template/template_test.php
index 861adf63e8..1b2f35f210 100644
--- a/tests/template/template.php
+++ b/tests/template/template_test.php
@@ -7,7 +7,8 @@
*
*/
-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
{
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 9752ec2fe6..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']);
@@ -384,8 +118,24 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
return $db;
}
+ public function assertSqlResultEquals($expected, $sql, $message = '')
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query($sql);
+ $rows = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected, $rows, $message);
+ }
+
public function setExpectedTriggerError($errno, $message = '')
{
$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.php b/tests/text_processing/make_clickable_test.php
index 75a35daf82..29b982d709 100644
--- a/tests/text_processing/make_clickable.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/data/.gitkeep b/tests/utf/data/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/utf/data/.gitkeep
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
new file mode 100644
index 0000000000..38b4ec1b6b
--- /dev/null
+++ b/tests/utf/normalizer_test.php
@@ -0,0 +1,318 @@
+<?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/utf/utf_normalizer.php';
+
+/**
+* @group slow
+*/
+class phpbb_utf_normalizer_test extends phpbb_test_case
+{
+ static public function setUpBeforeClass()
+ {
+ 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()
+ {
+ $test_suite = array(
+ /**
+ * NFC
+ * c2 == NFC(c1) == NFC(c2) == NFC(c3)
+ * c4 == NFC(c4) == NFC(c5)
+ */
+ 'NFC' => array(
+ 'c2' => array('c1', 'c2', 'c3'),
+ 'c4' => array('c4', 'c5')
+ ),
+
+ /**
+ * NFD
+ * c3 == NFD(c1) == NFD(c2) == NFD(c3)
+ * c5 == NFD(c4) == NFD(c5)
+ */
+ 'NFD' => array(
+ 'c3' => array('c1', 'c2', 'c3'),
+ 'c5' => array('c4', 'c5')
+ ),
+
+ /**
+ * NFKC
+ * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
+ */
+ 'NFKC' => array(
+ 'c4' => array('c1', 'c2', 'c3', 'c4', 'c5')
+ ),
+
+ /**
+ * NFKD
+ * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
+ */
+ 'NFKD' => array(
+ 'c5' => array('c1', 'c2', 'c3', 'c4', 'c5')
+ )
+ );
+
+ $tested_chars = array();
+
+ $fp = fopen(dirname(__FILE__).'/data/NormalizationTest.txt', 'rb');
+ while (!feof($fp))
+ {
+ $line = fgets($fp);
+
+ if ($line[0] == '@')
+ {
+ continue;
+ }
+
+ if (!strpos(' 0123456789ABCDEF', $line[0]))
+ {
+ continue;
+ }
+
+ list($c1, $c2, $c3, $c4, $c5) = explode(';', $line);
+
+ if (!strpos($c1, ' '))
+ {
+ /**
+ * We are currently testing a single character, we add it to the list of
+ * characters we have processed so that we can exclude it when testing
+ * for invariants
+ */
+ $tested_chars[$c1] = 1;
+ }
+
+ foreach ($test_suite as $form => $serie)
+ {
+ foreach ($serie as $expected => $tests)
+ {
+ $hex_expected = ${$expected};
+ $utf_expected = $this->hexseq_to_utf($hex_expected);
+
+ foreach ($tests as $test)
+ {
+ $utf_result = $utf_expected;
+ call_user_func(array('utf_normalizer', $form), &$utf_result);
+
+ $hex_result = $this->utf_to_hexseq($utf_result);
+ $this->assertEquals($utf_expected, $utf_result, "$expected == $form($test) ($hex_expected != $hex_result)");
+ }
+ }
+ }
+ }
+ fclose($fp);
+
+ return $tested_chars;
+ }
+
+ /**
+ * @depends test_normalizer
+ */
+ public function test_invariants(array $tested_chars)
+ {
+ $fp = fopen(dirname(__FILE__).'/data/UnicodeData.txt', 'rb');
+
+ while (!feof($fp))
+ {
+ $line = fgets($fp, 1024);
+
+ if (!$pos = strpos($line, ';'))
+ {
+ continue;
+ }
+
+ $hex_tested = $hex_expected = substr($line, 0, $pos);
+
+ if (isset($tested_chars[$hex_tested]))
+ {
+ continue;
+ }
+
+ $utf_expected = $this->hex_to_utf($hex_expected);
+
+ if ($utf_expected >= UTF8_SURROGATE_FIRST
+ && $utf_expected <= UTF8_SURROGATE_LAST)
+ {
+ /**
+ * Surrogates are illegal on their own, we expect the normalizer
+ * to return a replacement char
+ */
+ $utf_expected = UTF8_REPLACEMENT;
+ $hex_expected = $this->utf_to_hexseq($utf_expected);
+ }
+
+ foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
+ {
+ $utf_result = $utf_expected;
+ call_user_func(array('utf_normalizer', $form), &$utf_result);
+ $hex_result = $this->utf_to_hexseq($utf_result);
+
+ $this->assertEquals($utf_expected, $utf_result, "$hex_expected == $form($hex_tested) ($hex_expected != $hex_result)");
+ }
+ }
+ fclose($fp);
+ }
+
+ /**
+ * Convert a UTF string to a sequence of codepoints in hexadecimal
+ *
+ * @param string $utf UTF string
+ * @return integer Unicode codepoints in hex
+ */
+ protected function utf_to_hexseq($str)
+ {
+ $pos = 0;
+ $len = strlen($str);
+ $ret = array();
+
+ while ($pos < $len)
+ {
+ $c = $str[$pos];
+ switch ($c & "\xF0")
+ {
+ case "\xC0":
+ case "\xD0":
+ $utf_char = substr($str, $pos, 2);
+ $pos += 2;
+ break;
+
+ case "\xE0":
+ $utf_char = substr($str, $pos, 3);
+ $pos += 3;
+ break;
+
+ case "\xF0":
+ $utf_char = substr($str, $pos, 4);
+ $pos += 4;
+ break;
+
+ default:
+ $utf_char = $c;
+ ++$pos;
+ }
+
+ $hex = dechex($this->utf_to_cp($utf_char));
+
+ if (!isset($hex[3]))
+ {
+ $hex = substr('000' . $hex, -4);
+ }
+
+ $ret[] = $hex;
+ }
+
+ return strtr(implode(' ', $ret), 'abcdef', 'ABCDEF');
+ }
+
+ /**
+ * Convert a UTF-8 char to its codepoint
+ *
+ * @param string $utf_char UTF-8 char
+ * @return integer Unicode codepoint
+ */
+ protected function utf_to_cp($utf_char)
+ {
+ switch (strlen($utf_char))
+ {
+ case 1:
+ return ord($utf_char);
+
+ case 2:
+ return ((ord($utf_char[0]) & 0x1F) << 6) | (ord($utf_char[1]) & 0x3F);
+
+ case 3:
+ return ((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F);
+
+ case 4:
+ return ((ord($utf_char[0]) & 0x07) << 18) | ((ord($utf_char[1]) & 0x3F) << 12) | ((ord($utf_char[2]) & 0x3F) << 6) | (ord($utf_char[3]) & 0x3F);
+
+ default:
+ throw new RuntimeException('UTF-8 chars can only be 1-4 bytes long');
+ }
+ }
+
+ /**
+ * Return a UTF string formed from a sequence of codepoints in hexadecimal
+ *
+ * @param string $seq Sequence of codepoints, separated with a space
+ * @return string UTF-8 string
+ */
+ protected function hexseq_to_utf($seq)
+ {
+ return implode('', array_map(array($this, 'hex_to_utf'), explode(' ', $seq)));
+ }
+
+ /**
+ * Convert a codepoint in hexadecimal to a UTF-8 char
+ *
+ * @param string $hex Codepoint, in hexadecimal
+ * @return string UTF-8 char
+ */
+ protected function hex_to_utf($hex)
+ {
+ return $this->cp_to_utf(hexdec($hex));
+ }
+
+ /**
+ * Convert a codepoint to a UTF-8 char
+ *
+ * @param integer $cp Unicode codepoint
+ * @return string UTF-8 string
+ */
+ protected function cp_to_utf($cp)
+ {
+ if ($cp > 0xFFFF)
+ {
+ return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7FF)
+ {
+ return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7F)
+ {
+ return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else
+ {
+ return chr($cp);
+ }
+ }
+
+ // chunked download helper
+ static protected function download($url, $to)
+ {
+ $target = $to . '/' . basename($url);
+
+ if (file_exists($target))
+ {
+ return;
+ }
+
+ if (!$fpr = fopen($url, 'rb'))
+ {
+ throw new RuntimeException("Failed to download $url");
+ }
+
+ if (!$fpw = fopen($target, 'wb'))
+ {
+ throw new RuntimeException("Failed to open $target for writing");
+ }
+
+ $chunk = 32768;
+
+ while (!feof($fpr))
+ {
+ fwrite($fpw, fread($fpr, $chunk));
+ }
+ fclose($fpr);
+ fclose($fpw);
+ }
+}
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
{