aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xbuild/build_diff.php6
-rwxr-xr-xbuild/package.php10
-rw-r--r--build/webpi/install/mssql.sql39
-rw-r--r--build/webpi/install/mysql.sql15
-rw-r--r--build/webpi/manifest.xml13
-rw-r--r--build/webpi/parameters.xml226
-rwxr-xr-xgit-tools/hooks/pre-commit75
-rwxr-xr-xgit-tools/hooks/prepare-commit-msg34
-rw-r--r--phpBB/adm/style/acp_users_overview.html2
-rwxr-xr-xphpBB/develop/fix_files.sh2
-rw-r--r--phpBB/docs/CHANGELOG.html26
-rw-r--r--phpBB/docs/INSTALL.html4
-rw-r--r--phpBB/feed.php46
-rw-r--r--phpBB/includes/acm/acm_memcache.php14
-rw-r--r--phpBB/includes/acp/acp_attachments.php9
-rw-r--r--phpBB/includes/acp/acp_board.php4
-rw-r--r--phpBB/includes/acp/acp_database.php1
-rw-r--r--phpBB/includes/acp/acp_forums.php7
-rw-r--r--phpBB/includes/acp/acp_language.php4
-rw-r--r--phpBB/includes/acp/acp_profile.php1
-rw-r--r--phpBB/includes/acp/acp_reasons.php1
-rw-r--r--phpBB/includes/acp/acp_styles.php4
-rw-r--r--phpBB/includes/acp/acp_users.php29
-rw-r--r--phpBB/includes/constants.php2
-rw-r--r--phpBB/includes/db/postgres.php9
-rw-r--r--phpBB/includes/functions.php121
-rw-r--r--phpBB/includes/functions_admin.php8
-rw-r--r--phpBB/includes/functions_compress.php4
-rw-r--r--phpBB/includes/functions_display.php2
-rw-r--r--phpBB/includes/functions_posting.php6
-rw-r--r--phpBB/includes/functions_profile_fields.php1
-rw-r--r--phpBB/includes/functions_upload.php25
-rw-r--r--phpBB/includes/message_parser.php2
-rw-r--r--phpBB/includes/session.php10
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php2
-rw-r--r--phpBB/install/convertors/convert_phpbb20.php4
-rw-r--r--phpBB/install/database_update.php47
-rw-r--r--phpBB/install/install_update.php52
-rw-r--r--phpBB/install/schemas/schema_data.sql2
-rw-r--r--phpBB/language/en/acp/attachments.php12
-rw-r--r--phpBB/language/en/acp/board.php2
-rw-r--r--phpBB/language/en/email/admin_welcome_inactive.txt2
-rw-r--r--phpBB/language/en/install.php12
-rw-r--r--phpBB/posting.php4
-rw-r--r--phpBB/search.php1
-rw-r--r--phpBB/styles/prosilver/template/mcp_reports.html2
-rw-r--r--phpBB/styles/prosilver/template/quickreply_editor.html2
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_history.html5
-rw-r--r--phpBB/viewforum.php24
-rw-r--r--phpBB/viewtopic.php12
-rw-r--r--phpBB/web.config27
-rw-r--r--tests/all_tests.php56
-rw-r--r--tests/dbal/all_tests.php40
-rw-r--r--tests/dbal/dbal.php328
-rw-r--r--tests/dbal/fixtures/three_users.xml19
-rw-r--r--tests/request/all_tests.php41
-rw-r--r--tests/request/request_var.php180
-rw-r--r--tests/security/all_tests.php86
-rw-r--r--tests/security/extract_current_page.php53
-rw-r--r--tests/security/redirect.php58
-rw-r--r--tests/template/all_tests.php40
-rw-r--r--tests/template/template.php671
-rw-r--r--tests/template/templates/_dummy_include.php3
-rw-r--r--tests/template/templates/basic.html20
-rw-r--r--tests/template/templates/define.html8
-rw-r--r--tests/template/templates/expressions.html86
-rw-r--r--tests/template/templates/if.html11
-rw-r--r--tests/template/templates/include.html1
-rw-r--r--tests/template/templates/includephp.html1
-rw-r--r--tests/template/templates/lang.html3
-rw-r--r--tests/template/templates/loop.html21
-rw-r--r--tests/template/templates/loop_advanced.html19
-rw-r--r--tests/template/templates/loop_nested.html8
-rw-r--r--tests/template/templates/loop_vars.html21
-rw-r--r--tests/template/templates/php.html1
-rw-r--r--tests/template/templates/variable.html1
-rw-r--r--tests/test_framework/framework.php39
-rw-r--r--tests/test_framework/phpbb_database_test_case.php168
-rw-r--r--tests/test_framework/phpbb_test_case.php27
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php97
-rw-r--r--tests/text_processing/all_tests.php41
-rw-r--r--tests/text_processing/make_clickable.php106
-rw-r--r--tests/utf/all_tests.php43
-rw-r--r--tests/utf/utf8_clean_string_test.php32
-rw-r--r--tests/utf/utf8_wordwrap_test.php84
86 files changed, 3218 insertions, 171 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..3e0f454e0c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+phpBB/cache/*.php
+*~ \ No newline at end of file
diff --git a/build/build_diff.php b/build/build_diff.php
index ab3bb774b7..ef815bc0c3 100755
--- a/build/build_diff.php
+++ b/build/build_diff.php
@@ -11,9 +11,9 @@
// CONFIG - Begin
$substitute_old = '3.0.6';
-$substitute_new = '3.0.7-RC1';
+$substitute_new = '3.0.7-PL1';
$simple_name_old = 'phpbb306';
-$simple_name_new = 'phpbb307-RC1';
+$simple_name_new = 'phpbb307-PL1';
$echo_changes = false;
// Set this to true to just compress the changes and do not build them again
// This should be used for building custom modified txt file. ;)
@@ -405,4 +405,4 @@ function run_command($command)
echo "\n- Command Run: " . $command . "\n";
}
-?> \ No newline at end of file
+?>
diff --git a/build/package.php b/build/package.php
index 0620d4c6c2..a0da6404c6 100755
--- a/build/package.php
+++ b/build/package.php
@@ -15,7 +15,7 @@
// If RC8 drops remove the install/data directory
//$versions = array('3.0.2', '3.0.3-RC1', '3.0.3', '3.0.4-RC1', '3.0.4', '3.0.5-RC1', '3.0.5', '3.0.6-RC1', '3.0.6-RC2', '3.0.6-RC3');
//$versions = array('3.0.2', '3.0.3', '3.0.4', '3.0.5', '3.0.6', '3.0.7-RC1', '3.0.7');
-$versions = array('3.0.2', '3.0.3-RC1', '3.0.3', '3.0.4-RC1', '3.0.4', '3.0.5-RC1', '3.0.5', '3.0.6-RC1', '3.0.6-RC2', '3.0.6-RC3', '3.0.6-RC4', '3.0.6', '3.0.7-RC1');
+$versions = array('3.0.2', '3.0.3', '3.0.4', '3.0.5', '3.0.6', '3.0.7-RC1', '3.0.7-RC2', '3.0.7', '3.0.7-PL1');
$verbose = false;
require('build_helper.php');
@@ -518,6 +518,14 @@ foreach ($compress_programs as $extension => $compress_command)
$package->run_command('md5sum ./release_files/' . $package->get('release_filename') . '.' . $extension . ' > ./release_files/' . $package->get('release_filename') . '.' . $extension . '.md5');
}
+// Microsoft Web PI packaging
+$package->begin_status('Packaging phpBB for Microsoft WebPI');
+$file = './release_files/' . $package->get('release_filename') . '.webpi.zip';
+$package->run_command("rm -v $file");
+$package->run_command('cp -p ./release_files/' . $package->get('release_filename') . ".zip $file");
+$package->run_command('cd ./../webpi && ' . $compress_programs['zip'] . " ./../new_version/$file *");
+$package->run_command("md5sum $file > $file.md5");
+
// verify results
chdir($package->locations['root']);
$package->begin_status('********** Verifying packages **********');
diff --git a/build/webpi/install/mssql.sql b/build/webpi/install/mssql.sql
new file mode 100644
index 0000000000..9c0b46678a
--- /dev/null
+++ b/build/webpi/install/mssql.sql
@@ -0,0 +1,39 @@
+/**********************************************************************/
+/* Install.SQL */
+/* Creates a login and makes the user a member of db roles */
+/* */
+/**********************************************************************/
+
+-- Declare variables for database name, username and password
+DECLARE @dbName sysname,
+ @dbUser sysname,
+ @dbPwd nvarchar(max);
+
+-- Set variables for database name, username and password
+SET @dbName = 'PlaceHolderForDb';
+SET @dbUser = 'PlaceHolderForUser';
+SET @dbPwd = 'PlaceHolderForPassword';
+
+DECLARE @cmd nvarchar(max)
+
+-- Create login
+IF( SUSER_SID(@dbUser) is null )
+BEGIN
+ print '-- Creating login '
+ SET @cmd = N'CREATE LOGIN ' + quotename(@dbUser) + N' WITH PASSWORD ='''+ replace(@dbPwd, '''', '''''') + N''''
+ EXEC(@cmd)
+END
+
+-- Create database user and map to login
+-- and add user to the datareader, datawriter, ddladmin and securityadmin roles
+--
+SET @cmd = N'USE ' + quotename(@DBName) + N';
+IF( NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = ''' + replace(@dbUser, '''', '''''') + N'''))
+BEGIN
+ print ''-- Creating user'';
+ CREATE USER ' + quotename(@dbUser) + N' FOR LOGIN ' + quotename(@dbUser) + N';
+ print ''-- Adding user'';
+ EXEC sp_addrolemember ''db_owner'', ''' + replace(@dbUser, '''', '''''') + N''';
+END'
+EXEC(@cmd)
+GO
diff --git a/build/webpi/install/mysql.sql b/build/webpi/install/mysql.sql
new file mode 100644
index 0000000000..5c9d8cd922
--- /dev/null
+++ b/build/webpi/install/mysql.sql
@@ -0,0 +1,15 @@
+USE PlaceHolderForDb$$
+
+DROP PROCEDURE IF EXISTS add_user $$
+
+CREATE PROCEDURE add_user()
+BEGIN
+DECLARE EXIT HANDLER FOR 1044 BEGIN END;
+GRANT ALL PRIVILEGES ON PlaceHolderForDb.* to 'PlaceHolderForUser'@'PlaceHolderForServer' IDENTIFIED BY 'PlaceHolderForPassword';
+FLUSH PRIVILEGES;
+END
+$$
+
+CALL add_user() $$
+
+DROP PROCEDURE IF EXISTS add_user $$
diff --git a/build/webpi/manifest.xml b/build/webpi/manifest.xml
new file mode 100644
index 0000000000..947377893b
--- /dev/null
+++ b/build/webpi/manifest.xml
@@ -0,0 +1,13 @@
+<msdeploy.iisapp>
+ <iisapp path="phpBB3" />
+
+ <dbmysql path="install/mysql.sql" commandDelimiter="$$" removeCommandDelimiter="true" />
+
+ <dbfullsql path="install/mssql.sql" />
+
+ <setAcl path="phpBB3/cache" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
+ <setAcl path="phpBB3/files" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
+ <setAcl path="phpBB3/store" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
+ <setAcl path="phpBB3/images/avatars/upload" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
+ <setAcl path="phpBB3/config.php" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" setAclResourceType="File" />
+</msdeploy.iisapp>
diff --git a/build/webpi/parameters.xml b/build/webpi/parameters.xml
new file mode 100644
index 0000000000..994247e48e
--- /dev/null
+++ b/build/webpi/parameters.xml
@@ -0,0 +1,226 @@
+<parameters>
+ <parameter
+ name="AppPath"
+ defaultValue="Default Web Site/phpBB3"
+ tags="iisapp">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="iisapp"
+ match="phpBB3" />
+ </parameter>
+
+ <parameter
+ name="aclCache"
+ description="Sets the ACL on the cache/ folder"
+ defaultValue="{AppPath}/cache"
+ tags="Hidden">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="setAcl"
+ match="phpBB3/cache" />
+ </parameter>
+
+ <parameter
+ name="aclFiles"
+ description="Sets the ACL on the files/ folder"
+ defaultValue="{AppPath}/files"
+ tags="Hidden">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="setAcl"
+ match="phpBB3/files" />
+ </parameter>
+
+ <parameter
+ name="aclStore"
+ description="Sets the ACL on the store/ folder"
+ defaultValue="{AppPath}/store"
+ tags="Hidden">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="setAcl"
+ match="phpBB3/store" />
+ </parameter>
+
+ <parameter
+ name="aclAvatarUpload"
+ description="Sets the ACL on the avatars/upload/ folder"
+ defaultValue="{AppPath}/images/avatars/upload"
+ tags="Hidden">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="setAcl"
+ match="phpBB3/images/avatars/upload" />
+ </parameter>
+
+ <parameter
+ name="aclConfig"
+ description="Sets the ACL on the config.php file"
+ defaultValue="{AppPath}/config.php"
+ tags="Hidden">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="setAcl"
+ match="phpBB3/config.php" />
+ </parameter>
+
+ <parameter
+ name="DatabaseServer"
+ description="Enter the database server"
+ defaultValue=".\SQLExpress"
+ tags="SQL, dbServer" >
+ </parameter>
+
+ <parameter
+ name="DatabaseName"
+ description="Database name for your application."
+ defaultValue="phpbb"
+ tags="SQL, dbName">
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mssql.sql"
+ match="PlaceHolderForDb" />
+ </parameter>
+
+ <parameter
+ name="DatabaseAdministrator"
+ description="Database server administartor username."
+ defaultValue="sa"
+ tags="SQL, DbAdminUsername" >
+ </parameter>
+
+ <parameter
+ name="DatabaseAdministratorPassword"
+ description="Database server administrator password."
+ tags="Password,SQL,DbAdminPassword">
+ </parameter>
+
+ <parameter
+ name="Database Username"
+ description="Username to access your database."
+ defaultValue="phpbb"
+ tags="SQL, DbUsername">
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mssql.sql"
+ match="PlaceHolderForUser" />
+ </parameter>
+
+ <parameter
+ name="Database Password"
+ description="Password for your phpBB database. (Must be at least 8 characters, contain at least one lower case letter, one upper case letter and one digit)"
+ tags="New, Password,SQL, DbUserPassword">
+
+ <parameterValidation
+ type = "RegularExpression"
+ validationString = "^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$" />
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mssql.sql"
+ match="PlaceHolderForPassword" />
+ </parameter>
+
+ <parameter
+ name="ConnectionString"
+ description="Automatically sets the connection string for the connection request."
+ defaultValue="Server={DatabaseServer};Database={DatabaseName};uid={DatabaseAdministrator};Pwd={DatabaseAdministratorPassword};"
+ tags="Hidden,SQLConnectionString,Validate">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="dbfullsql"
+ match="install/mssql.sql" />
+ </parameter>
+
+ <parameter
+ name="SQL Database type"
+ description="SQL database type"
+ defaultValue="mssql"
+ tags="SQL,Hidden">
+ </parameter>
+
+ <parameter
+ name="MySQL Database Server"
+ description="Enter the hostname"
+ defaultValue="localhost"
+ tags="MySQL, dbServer">
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mysql.sql"
+ match="PlaceHolderForServer" />
+ </parameter>
+
+ <parameter
+ name="Application Database Name"
+ description="Database Name for your application."
+ defaultValue="phpbb"
+ tags="MySQL, dbName">
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mysql.sql"
+ match="PlaceHolderForDb" />
+ </parameter>
+
+ <parameter
+ name="MySQL Database Administrator"
+ description="Database administrator username."
+ defaultValue="root"
+ tags="MySQL, DbAdminUsername" >
+ </parameter>
+
+ <parameter
+ name="MySQL Database Administrator Password"
+ description="Database administrator password."
+ tags="Password,MySQL,DbAdminPassword" >
+ </parameter>
+
+ <parameter
+ name="phpBB Database Username"
+ description="Username to access your phpBB database."
+ defaultValue="phpbb"
+ tags="MySQL, DbUsername">
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mysql.sql"
+ match="PlaceHolderForUser" />
+ </parameter>
+
+ <parameter
+ name="MySQL Database Password"
+ description="Password for your phpBB database. (Minimum 4 characters)"
+ tags="New, Password,MySQL,DbUserPassword">
+
+ <parameterValidation
+ type = "RegularExpression"
+ validationString = "^.{4,}$" />
+
+ <parameterEntry
+ type="TextFile"
+ scope="install/mysql.sql"
+ match="PlaceHolderForPassword" />
+ </parameter>
+
+ <parameter
+ name="MySQLConnectionString"
+ description="Automatically sets the connection string for the connection request."
+ defaultValue="Server={MySQL Database Server};Database={Application Database Name};uid={MySQL Database Administrator};Pwd={MySQL Database Administrator Password};"
+ tags="Hidden,MySQLConnectionString,Validate">
+
+ <parameterEntry
+ type="ProviderPath"
+ scope="dbmysql"
+ match="install/mysql.sql" />
+ </parameter>
+</parameters>
diff --git a/git-tools/hooks/pre-commit b/git-tools/hooks/pre-commit
new file mode 100755
index 0000000000..9719b91746
--- /dev/null
+++ b/git-tools/hooks/pre-commit
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# A hook to disallow php syntax errors to be committed
+# by running php -l (lint) on them. It requires php-cli
+# to be installed.
+#
+# This is a pre-commit hook.
+#
+# To install this you can either copy or symlink it to
+# $GIT_DIR/hooks, example:
+#
+# ln -s ../../git-tools/hooks/pre-commit \\
+# .git/hooks/pre-commit
+
+# NOTE: this is run through /usr/bin/env
+PHP_BIN=php
+
+# necessary check for initial commit
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+error=0
+errors=""
+
+# dash does not support $'\n':
+# http://forum.soft32.com/linux2/Bug-409179-DASH-Settings-IFS-work-properly-ftopict70039.html
+IFS='
+'
+# get a list of staged files
+for line in $(git diff-index --cached --full-index $against)
+do
+ # split needed values
+ sha=$(echo $line | cut -d' ' -f4)
+ temp=$(echo $line | cut -d' ' -f5)
+ status=$(echo $temp | cut -d' ' -f1)
+ filename=$(echo $temp | cut -d' ' -f2)
+
+ # file extension
+ ext=$(echo $filename | sed 's/^.*\.//')
+
+ # only check files with php extension
+ if [ $ext != "php" ]
+ then
+ continue
+ fi
+
+ # do not check deleted files
+ if [ $status = "D" ]
+ then
+ continue
+ fi
+
+ # check the staged file content for syntax errors
+ # using php -l (lint)
+ result=$(git cat-file -p $sha | /usr/bin/env $PHP_BIN -l 2>/dev/null)
+ if [ $? -ne 0 ]
+ then
+ error=1
+ # Swap back in correct filenames
+ errors=$(echo "$errors"; echo "$result" |sed -e "s@in - on@in $filename on@g")
+ fi
+done
+unset IFS
+
+if [ $error -eq 1 ]
+then
+ echo -e "PHP Syntax check failed:";
+ echo -e "$errors" | grep "^Parse error:"
+ exit 1
+fi
diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg
new file mode 100755
index 0000000000..033cb187c7
--- /dev/null
+++ b/git-tools/hooks/prepare-commit-msg
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# A hook to add [$branch] to the beginning of a commit message
+# if certain conditions are met.
+#
+# This is a prepare-commit-msg hook.
+#
+# To install this you can either copy or symlink it to
+# $GIT_DIR/hooks, example:
+#
+# ln -s ../../git-tools/hooks/prepare-commit-msg \\
+# .git/hooks/prepare-commit-msg
+
+# get branch name
+branch="$(git symbolic-ref HEAD)"
+
+# exit if no branch name is present
+# (eg. detached HEAD)
+if [ $? -ne 0 ]
+then
+ exit
+fi
+
+# strip off refs/heads/
+branch="$(echo "$branch" | sed "s/refs\/heads\///g")"
+
+# add [branchname] to commit message
+# * only run when normal commit is made (without -m or -F;
+# not a merge, etc.)
+# * also make sure the branch name begins with bug/ or feature/
+if [ "$2" = "" ]
+then
+ echo "[$branch] $(cat "$1")" > "$1"
+fi
diff --git a/phpBB/adm/style/acp_users_overview.html b/phpBB/adm/style/acp_users_overview.html
index d48cfa57be..7d9a0f27d3 100644
--- a/phpBB/adm/style/acp_users_overview.html
+++ b/phpBB/adm/style/acp_users_overview.html
@@ -148,6 +148,6 @@
{S_FORM_TOKEN}
</p>
</fieldset>
- <!-- ENDIF -->
</form>
+ <!-- ENDIF -->
<!-- ENDIF -->
diff --git a/phpBB/develop/fix_files.sh b/phpBB/develop/fix_files.sh
index d2207289dc..bf58e49e5f 100755
--- a/phpBB/develop/fix_files.sh
+++ b/phpBB/develop/fix_files.sh
@@ -14,7 +14,7 @@ find . > FILELIST.$$
grep -sv FILELIST FILELIST.$$ > FILELIST2.$$
grep -sv $(basename $0) FILELIST2.$$ > FILELIST.$$
grep -sv "^\.$" FILELIST.$$ > FILELIST2.$$
-file -f FILELIST2.$$ |grep text | sed -e 's/^\([^\:]*\)\:.*$/\1/' > FILELIST
+file -f FILELIST2.$$ |grep text | grep -v icon_textbox_search.gif | sed -e 's/^\([^\:]*\)\:.*$/\1/' > FILELIST
file -f FILELIST2.$$ |grep -sv text | sed -e 's/^\([^\:]*\)\:.*$/Not Modifying file: \1/'
rm FILELIST2.$$
rm FILELIST.$$
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 4e9adaa1f9..36dc3d037c 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -53,6 +53,7 @@
<ol>
<li><a href="#changelog">Changelog</a>
<ol style="list-style-type: lower-roman;">
+ <li><a href="#v307">Changes since 3.0.7-PL1</a></li>
<li><a href="#v307">Changes since 3.0.7</a></li>
<li><a href="#v306">Changes since 3.0.6</a></li>
<li><a href="#v305">Changes since 3.0.5</a></li>
@@ -88,7 +89,7 @@
<div class="content">
- <a name="v307"></a><h3>1.i. Changes since 3.0.7</h3>
+ <a name="v307-pl1"></a><h3>1.i. Changes since 3.0.7-PL1</h3>
<ul>
<li>[Fix] Correctly sort database backup file list by date on database restore page. (Bug #57385)</li>
@@ -97,7 +98,30 @@
<li>[Fix] No longer return the character O in generated random strings and passwords. (Bug #57345)</li>
<li>[Fix] Allow redirect() function to redirect across directories. (Bug #56965)</li>
<li>[Fix] Add terminating semicolons to JavaScript code. (Bug #58085 - Patch by nn-)</li>
+ <li>[Fix] Minor language fixes. (Bug #54855)</li>
+ <li>[Fix] Parsing urls in signatures properly uses config settings. (Bug #57105)</li>
+ <li>[Fix] Allow multibyte keys in request_var(). (Bug #51555)</li>
+ <li>[Fix] Fix inclusion check for captcha garbage collection (Bug #59425)</li>
+ <li>[Fix] Prevent wrong tar archive type detection. (Bug #12531)</li>
+ <li>[Fix] Correct redirection after login to forum not in web root (Bug #58755)</li>
+ <li>[Fix] Allow setting parent forums regardless of permission settings. (Bug #57415)</li>
+ <li>[Fix] Redirect search engines that access pages with SIDs in the URL. (Bug #58025)</li>
+ <li>[Fix] Fix incorrect ampersand encoding in redirect parameter. (Bug #58465)</li>
+ <li>[Fix] Fix open_basedir issues when accessing styles- and language-management. (Bug #59135)</li>
+ <li>[Fix] Fix table binding issues with PostgreSQL in board-wide feed. (Bug #58425)</li>
+ <li>[Fix] Only show unapproved posts in ATOM Feeds for moderators (Bug #58695)</li>
+ <li>[Fix] Various XHTML mistakes in ACP (Bug #58745)</li>
+ <li>[Fix] Fix dead link in MCP on reports for global announcements in prosilver. (Bug #9512)</li>
+ <li>[Fix] Fix broken links for reports on active topics, when the topic is in a subforum. (Bug #9047)</li>
<li>[Feature] Support for Microsoft's Native SQL Server Driver for PHP (Bug #57055 - Patch by Chris Pucci at Microsoft)</li>
+ <li>[Feature] The memcache acm plugin now supports multiple memcache servers.</li>
+ <li>[Feature] Show note for moderators on unapproved posts/topics with unapproved posts in ATOM Feed (Bug #9511)</li>
+ </ul>
+
+ <a name="v307"></a><h3>1.i. Changes since 3.0.7</h3>
+
+ <ul>
+ <li>[Sec] Do not expose forum content of forums with ACL entries but no actual permission in ATOM Feeds. (Bug #58595)</li>
</ul>
<a name="v306"></a><h3>1.ii. Changes since 3.0.6</h3>
diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html
index c924bb6078..982c28571e 100644
--- a/phpBB/docs/INSTALL.html
+++ b/phpBB/docs/INSTALL.html
@@ -273,7 +273,7 @@
<p>This package is meant for those wanting to only replace changed files from a previous version to the latest version. This package normally contains the changed files from up to five previous versions.</p>
- <p>This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have <samp>3.0.5</samp> you should select the phpBB-3.0.6_to_3.0.7.zip/tar.gz file.</p>
+ <p>This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have <samp>3.0.6</samp> you should select the phpBB-3.0.6_to_3.0.7-PL1.zip/tar.gz file.</p>
<p>The directory structure has been preserved enabling you (if you wish) to simply upload the contents of the archive to the appropriate location on your server, i.e. simply overwrite the existing files with the new versions. Do not forget that if you have installed any MODs these files will overwrite the originals possibly destroying them in the process. You will need to re-add MODs to any affected file before uploading.</p>
@@ -285,7 +285,7 @@
<p>The patch file is one solution for those with many Modifications (MODs) or other changes who do not want to re-add them back to all the changed files if they use the method explained above. To use this you will need command line access to a standard UNIX type <strong>patch</strong> application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the <a href="#update_auto">Automatic update package</a> explained below. It is also the recommended update method.</p>
- <p>A number of patch files are provided to allow you to update from previous stable releases. Select the correct patch, e.g. if your current version is 3.0.6 you need the phpBB-3.0.6_to_3.0.7.patch file. Place the correct patch in the parent directory containing the phpBB3 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: <strong>patch -cl -d [PHPBB DIRECTORY] -p1 &lt; [PATCH NAME]</strong> (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB3, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.</p>
+ <p>A number of patch files are provided to allow you to update from previous stable releases. Select the correct patch, e.g. if your current version is 3.0.5 you need the phpBB-3.0.6_to_3.0.7-PL1.patch file. Place the correct patch in the parent directory containing the phpBB3 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: <strong>patch -cl -d [PHPBB DIRECTORY] -p1 &lt; [PATCH NAME]</strong> (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB3, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.</p>
<p>If you do get failures you should look at using the <a href="#update_files">Changed files only</a> package to replace the files which failed to patch, please note that you will need to manually re-add any Modifications (MODs) to these particular files. Alternatively if you know how you can examine the .rej files to determine what failed where and make manual adjustments to the relevant source.</p>
diff --git a/phpBB/feed.php b/phpBB/feed.php
index 1832efbc61..88c30c5d4f 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -522,7 +522,7 @@ class phpbb_feed_base
if (!isset($forum_ids))
{
- $forum_ids = array_keys($auth->acl_getf('f_read'));
+ $forum_ids = array_keys($auth->acl_getf('f_read', true));
}
return $forum_ids;
@@ -535,12 +535,30 @@ class phpbb_feed_base
if (!isset($forum_ids))
{
- $forum_ids = array_keys($auth->acl_getf('m_approve'));
+ $forum_ids = array_keys($auth->acl_getf('m_approve', true));
}
return $forum_ids;
}
+ function is_moderator_approve_forum($forum_id)
+ {
+ static $forum_ids;
+
+ if (!isset($forum_ids))
+ {
+ $forum_ids = array_flip($this->get_moderator_approve_forums());
+ }
+
+ if (!$forum_id)
+ {
+ // Global announcement, your a moderator in any forum than it's okay.
+ return (!empty($forum_ids)) ? true : false;
+ }
+
+ return (isset($forum_ids[$forum_id])) ? true : false;
+ }
+
function get_excluded_forums()
{
global $db, $cache;
@@ -677,7 +695,8 @@ 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['post_time'])
+ . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : '');
}
}
}
@@ -719,8 +738,9 @@ class phpbb_feed_topic_base extends phpbb_feed_base
{
$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->lang['REPLIES'] . ' ' . $row['topic_replies']
- . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'];
+ . ' ' . $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'] : '');
}
}
}
@@ -780,11 +800,11 @@ 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_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_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',
USERS_TABLE => 'u',
+ POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
@@ -912,7 +932,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_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_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',
@@ -994,7 +1014,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
if (!$this->topic_data['topic_approved'])
{
// Also require m_approve
- $in_fid_ary = array_intersect($in_fid_ary, array_keys($auth->acl_getf('m_approve')));
+ $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums());
if (empty($in_fid_ary))
{
@@ -1077,7 +1097,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_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_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',
@@ -1241,7 +1261,7 @@ 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_views, t.topic_time,
+ 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',
'FROM' => array(
TOPICS_TABLE => 't',
@@ -1314,7 +1334,7 @@ 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_views, t.topic_time,
+ 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',
'FROM' => array(
TOPICS_TABLE => 't',
@@ -1412,7 +1432,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base
$this->sql = array(
'SELECT' => 'f.forum_id, f.forum_name,
- t.topic_id, t.topic_title, t.topic_replies, t.topic_views,
+ 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',
'FROM' => array(
diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php
index 52b8832749..e54fa36c38 100644
--- a/phpBB/includes/acm/acm_memcache.php
+++ b/phpBB/includes/acm/acm_memcache.php
@@ -37,6 +37,12 @@ if (!defined('PHPBB_ACM_MEMCACHE_HOST'))
define('PHPBB_ACM_MEMCACHE_HOST', 'localhost');
}
+if (!defined('PHPBB_ACM_MEMCACHE'))
+{
+ //can define multiple servers with host1/port1,host2/port2 format
+ define('PHPBB_ACM_MEMCACHE', PHPBB_ACM_MEMCACHE_HOST . '/' . PHPBB_ACM_MEMCACHE_PORT);
+}
+
/**
* ACM for Memcached
* @package acm
@@ -54,7 +60,11 @@ class acm extends acm_memory
parent::acm_memory();
$this->memcache = new Memcache;
- $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT);
+ foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u)
+ {
+ $parts = explode('/', $u);
+ $this->memcache->addServer(trim($parts[0]), trim($parts[1]));
+ }
$this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0;
}
@@ -125,4 +135,4 @@ class acm extends acm_memory
}
}
-?> \ No newline at end of file
+?>
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 25e51814c4..980558c830 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -90,6 +90,7 @@ class acp_attachments
$s_assigned_groups = array();
while ($row = $db->sql_fetchrow($result))
{
+ $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
$s_assigned_groups[$row['cat_id']][] = $row['group_name'];
}
$db->sql_freeresult($result);
@@ -494,6 +495,10 @@ class acp_attachments
$sql = 'SELECT group_id
FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'";
+ if ($group_id)
+ {
+ $sql .= ' AND group_id <> ' . $group_id;
+ }
$result = $db->sql_query($sql);
if ($db->sql_fetchrow($result))
@@ -551,6 +556,7 @@ class acp_attachments
$group_id = $db->sql_nextid();
}
+ $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name;
add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name);
}
@@ -858,7 +864,7 @@ class acp_attachments
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$row['group_id']}",
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;g={$row['group_id']}",
- 'GROUP_NAME' => $row['group_name'],
+ 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'],
'CATEGORY' => $cat_lang[$row['cat_id']],
)
);
@@ -1118,6 +1124,7 @@ class acp_attachments
$group_name = array();
while ($row = $db->sql_fetchrow($result))
{
+ $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
$group_name[] = $row;
}
$db->sql_freeresult($result);
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index a5feac1902..7680d8996c 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -888,8 +888,8 @@ class acp_board
$old_tz = $user->timezone;
$old_dst = $user->dst;
- $user->timezone = $config['board_timezone'];
- $user->dst = $config['board_dst'];
+ $user->timezone = $config['board_timezone'] * 3600;
+ $user->dst = $config['board_dst'] * 3600;
$dateformat_options = '';
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index abfad2b90b..0582d6204e 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -394,6 +394,7 @@ class acp_database
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false)
{
$db->sql_query($sql);
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index bde59ec870..7b7671573e 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -1705,6 +1705,9 @@ class acp_forums
)
);
+ // Amount of rows we select and delete in one iteration.
+ $batch_size = 500;
+
foreach ($tables_ary as $field => $tables)
{
$start = 0;
@@ -1714,7 +1717,7 @@ class acp_forums
$sql = "SELECT $field
FROM " . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id;
- $result = $db->sql_query_limit($sql, 500, $start);
+ $result = $db->sql_query_limit($sql, $batch_size, $start);
$ids = array();
while ($row = $db->sql_fetchrow($result))
@@ -1733,7 +1736,7 @@ class acp_forums
}
}
}
- while ($row);
+ while (sizeof($ids) == $batch_size);
}
unset($ids);
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index fedae6fe67..c2cb2f9c11 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -1120,12 +1120,12 @@ class acp_language
{
while (($file = readdir($dp)) !== false)
{
- if (!is_dir($phpbb_root_path . 'language/' . $file))
+ if ($file[0] == '.' || !is_dir($phpbb_root_path . 'language/' . $file))
{
continue;
}
- if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt"))
+ if (file_exists("{$phpbb_root_path}language/$file/iso.txt"))
{
if (!in_array($file, $installed))
{
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index fc08c7e8e8..2288a0728b 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -1480,6 +1480,7 @@ class acp_profile
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
// We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
$sql = 'ALTER TABLE [' . PROFILE_FIELDS_DATA_TABLE . "] ADD [$field_ident] ";
diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php
index 8d7bc88769..dbc9fcb6cc 100644
--- a/phpBB/includes/acp/acp_reasons.php
+++ b/phpBB/includes/acp/acp_reasons.php
@@ -233,6 +233,7 @@ class acp_reasons
// Standard? What's that?
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
// Change the reports using this reason to 'other'
$sql = "DECLARE @ptrval binary(16)
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index d2a0f9210f..3310560c73 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -643,13 +643,13 @@ parse_css_file = {PARSE_CSS_FILE}
{
while (($file = readdir($dp)) !== false)
{
- if (!is_dir($phpbb_root_path . 'styles/' . $file))
+ if ($file[0] == '.' || !is_dir($phpbb_root_path . 'styles/' . $file))
{
continue;
}
$subpath = ($mode != 'style') ? "$mode/" : '';
- if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg"))
+ if (file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg"))
{
if ($cfg = file("{$phpbb_root_path}styles/$file/$subpath$mode.cfg"))
{
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 4905840e02..bd64f1e89e 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -105,7 +105,7 @@ class acp_users
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, 1);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -1550,6 +1550,31 @@ class acp_users
WHERE user_id = $user_id";
$db->sql_query($sql);
+ // Check if user has an active session
+ if ($user_row['session_id'])
+ {
+ // We'll update the session if user_allow_viewonline has changed and the user is a bot
+ // Or if it's a regular user and the admin set it to hide the session
+ if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE
+ || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline'])
+ {
+ // We also need to check if the user has the permission to cloak.
+ $user_auth = new auth();
+ $user_auth->acl($user_row);
+
+ $session_sql_ary = array(
+ 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true,
+ );
+
+ $sql = 'UPDATE ' . SESSIONS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . "
+ WHERE session_user_id = $user_id";
+ $db->sql_query($sql);
+
+ unset($user_auth);
+ }
+ }
+
trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
}
@@ -2084,7 +2109,7 @@ class acp_users
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, 1);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index f58b29d232..8d31eaba7f 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -25,7 +25,7 @@ if (!defined('IN_PHPBB'))
*/
// phpBB Version
-define('PHPBB_VERSION', '3.0.7');
+define('PHPBB_VERSION', '3.0.7-PL1');
// QA-related
// define('PHPBB_QA', 1);
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index d117e8c948..b3139b3d79 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -76,7 +76,14 @@ class dbal_postgres extends dbal
$this->persistency = $persistency;
- $this->db_connect_id = ($this->persistency) ? @pg_pconnect($connect_string, $new_link) : @pg_connect($connect_string, $new_link);
+ if ($this->persistency)
+ {
+ $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
+ }
+ else
+ {
+ $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
+ }
if ($this->db_connect_id)
{
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index e8f45b654f..01f17fa521 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -114,7 +114,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
{
$_v = null;
}
- set_var($_k, $_k, $sub_key_type);
+ set_var($_k, $_k, $sub_key_type, $multibyte);
set_var($var[$k][$_k], $_v, $sub_type, $multibyte);
}
}
@@ -175,11 +175,8 @@ function set_config_count($config_name, $increment, $is_dynamic = false)
switch ($db->sql_layer)
{
case 'firebird':
- $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))';
- break;
-
case 'postgres':
- $sql_update = 'int4(config_value) + ' . (int) $increment;
+ $sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))';
break;
// MySQL, SQlite, mssql, mssql_odbc, oracle
@@ -2139,8 +2136,8 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
global $_SID, $_EXTRA_URL, $phpbb_hook;
- // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly.
- // They could mimick most of what is within this function
+ // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately.
+ // They could mimic most of what is within this function
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
{
if ($phpbb_hook->hook_return(__FUNCTION__))
@@ -2297,6 +2294,8 @@ function redirect($url, $return = false, $disable_cd_check = false)
{
global $db, $cache, $config, $user, $phpbb_root_path;
+ $failover_flag = false;
+
if (empty($user->lang))
{
$user->add_lang('common');
@@ -2344,65 +2343,69 @@ function redirect($url, $return = false, $disable_cd_check = false)
if (!file_exists($pathinfo['dirname']))
{
// fallback to "last known user page"
+ // at least this way we know the user does not leave the phpBB root
$url = generate_board_url() . '/' . $user->page['page'];
- break;
+ $failover_flag = true;
}
}
- // Is the uri pointing to the current directory?
- if ($pathinfo['dirname'] == '.')
+ if (!$failover_flag)
{
- $url = str_replace('./', '', $url);
-
- // Strip / from the beginning
- if ($url && substr($url, 0, 1) == '/')
+ // Is the uri pointing to the current directory?
+ if ($pathinfo['dirname'] == '.')
{
- $url = substr($url, 1);
- }
+ $url = str_replace('./', '', $url);
- if ($user->page['page_dir'])
- {
- $url = generate_board_url() . '/' . $user->page['page_dir'] . '/' . $url;
+ // Strip / from the beginning
+ if ($url && substr($url, 0, 1) == '/')
+ {
+ $url = substr($url, 1);
+ }
+
+ if ($user->page['page_dir'])
+ {
+ $url = generate_board_url() . '/' . $user->page['page_dir'] . '/' . $url;
+ }
+ else
+ {
+ $url = generate_board_url() . '/' . $url;
+ }
}
else
{
- $url = generate_board_url() . '/' . $url;
- }
- }
- else
- {
- // Used ./ before, but $phpbb_root_path is working better with urls within another root path
- $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path)));
- $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
- $intersection = array_intersect_assoc($root_dirs, $page_dirs);
+ // Used ./ before, but $phpbb_root_path is working better with urls within another root path
+ $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path)));
+ $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
+ $intersection = array_intersect_assoc($root_dirs, $page_dirs);
- $root_dirs = array_diff_assoc($root_dirs, $intersection);
- $page_dirs = array_diff_assoc($page_dirs, $intersection);
+ $root_dirs = array_diff_assoc($root_dirs, $intersection);
+ $page_dirs = array_diff_assoc($page_dirs, $intersection);
- $dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
+ $dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
- // Strip / from the end
- if ($dir && substr($dir, -1, 1) == '/')
- {
- $dir = substr($dir, 0, -1);
- }
+ // Strip / from the end
+ if ($dir && substr($dir, -1, 1) == '/')
+ {
+ $dir = substr($dir, 0, -1);
+ }
- // Strip / from the beginning
- if ($dir && substr($dir, 0, 1) == '/')
- {
- $dir = substr($dir, 1);
- }
+ // Strip / from the beginning
+ if ($dir && substr($dir, 0, 1) == '/')
+ {
+ $dir = substr($dir, 1);
+ }
- $url = str_replace($pathinfo['dirname'] . '/', '', $url);
+ $url = str_replace($pathinfo['dirname'] . '/', '', $url);
- // Strip / from the beginning
- if (substr($url, 0, 1) == '/')
- {
- $url = substr($url, 1);
- }
+ // Strip / from the beginning
+ if (substr($url, 0, 1) == '/')
+ {
+ $url = substr($url, 1);
+ }
- $url = (!empty($dir) ? $dir . '/' : '') . $url;
- $url = generate_board_url() . '/' . $url;
+ $url = (!empty($dir) ? $dir . '/' : '') . $url;
+ $url = generate_board_url() . '/' . $url;
+ }
}
}
@@ -3403,13 +3406,14 @@ function phpbb_checkdnsrr($host, $type = '')
{
$type = (!$type) ? 'MX' : $type;
- if (DIRECTORY_SEPARATOR == '\\')
+ // Call checkdnsrr() if available. This is also the case on Windows with PHP 5.3 or later.
+ if (function_exists('checkdnsrr'))
+ {
+ // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain)
+ return checkdnsrr($host . '.', $type);
+ }
+ else if (DIRECTORY_SEPARATOR == '\\' && function_exists('exec'))
{
- if (!function_exists('exec'))
- {
- return NULL;
- }
-
// @exec('nslookup -retry=1 -timout=1 -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output);
@exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host) . '.', $output);
@@ -3435,11 +3439,6 @@ function phpbb_checkdnsrr($host, $type = '')
return false;
}
- else if (function_exists('checkdnsrr'))
- {
- // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain)
- return (checkdnsrr($host . '.', $type)) ? true : false;
- }
return NULL;
}
@@ -4251,7 +4250,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_TOPIC_ID' => $topic_id,
'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)),
- 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&amp;', '&', build_url()))),
+ 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false,
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 93244be55c..4cd2962e3b 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -96,16 +96,12 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$right = $row['right_id'];
$disabled = false;
- if (!$ignore_acl && $auth->acl_get('f_list', $row['forum_id']))
+ if (!$ignore_acl && $auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id']))
{
if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id'])))
{
$disabled = true;
}
- else if (!$only_acl_post && !$auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id']))
- {
- $disabled = true;
- }
}
else if (!$ignore_acl)
{
@@ -675,7 +671,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
$db->sql_transaction('begin');
- $table_ary = array(TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
+ $table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
foreach ($table_ary as $table)
{
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index f17c780a65..f422eaa8c1 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -502,8 +502,8 @@ class compress_tar extends compress
function compress_tar($mode, $file, $type = '')
{
$type = (!$type) ? $file : $type;
- $this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false;
- $this->isbz = (strpos($type, '.tar.bz2') !== false) ? true : false;
+ $this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type);
+ $this->isbz = preg_match('#\.tar\.bz2$#', $type);
$this->mode = &$mode;
$this->file = &$file;
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index f49aa42324..ea77551fc4 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -660,7 +660,7 @@ function topic_generate_pagination($replies, $url)
$times = 1;
for ($j = 0; $j < $replies + 1; $j += $per_page)
{
- $pagination .= '<a href="' . $url . '&amp;start=' . $j . '">' . $times . '</a>';
+ $pagination .= '<a href="' . $url . ($j == 0 ? '' : '&amp;start=' . $j) . '">' . $times . '</a>';
if ($times == 1 && $total_pages > 5)
{
$pagination .= ' ... ';
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 49ea382411..4cb3941ce0 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -85,10 +85,10 @@ function generate_smilies($mode, $forum_id)
if ($mode == 'window')
{
- $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height
+ $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height, MIN(smiley_order) AS min_smiley_order
FROM ' . SMILIES_TABLE . '
GROUP BY smiley_url, smiley_width, smiley_height
- ORDER BY MIN(smiley_order)';
+ ORDER BY min_smiley_order';
$result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600);
}
else
@@ -1146,7 +1146,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
}
}
- unset($rowset[$i]);
+ unset($rowset[$post_list[$i]]);
}
if ($mode == 'topic_review')
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 61e3587158..fa1cc98e10 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -366,6 +366,7 @@ class custom_profile
case 'sqlite':
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
$right_delim = ']';
$left_delim = '[';
break;
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 054af29045..51fed45ebd 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -775,7 +775,18 @@ class fileupload
{
if ($get_info)
{
- $data .= @fread($fsock, 1024);
+ $block = @fread($fsock, 1024);
+ $filesize += strlen($block);
+
+ if ($this->max_filesize && $filesize > $this->max_filesize)
+ {
+ $max_filesize = get_formatted_filesize($this->max_filesize, false);
+
+ $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
+ return $file;
+ }
+
+ $data .= $block;
}
else
{
@@ -791,6 +802,18 @@ class fileupload
{
$upload_ary['type'] = rtrim(str_replace('content-type: ', '', strtolower($line)));
}
+ else if ($this->max_filesize && stripos($line, 'content-length: ') !== false)
+ {
+ $length = (int) str_replace('content-length: ', '', strtolower($line));
+
+ if ($length && $length > $this->max_filesize)
+ {
+ $max_filesize = get_formatted_filesize($this->max_filesize, false);
+
+ $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
+ return $file;
+ }
+ }
else if (stripos($line, '404 not found') !== false)
{
$file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 50aad8588a..952b55cc8c 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -300,7 +300,7 @@ class bbcode_firstpass extends bbcode
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
{
- $stats = @getimagesize($in);
+ $stats = @getimagesize(htmlspecialchars_decode($in));
if ($stats === false)
{
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 11f1896332..0a01b4e73b 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -83,7 +83,7 @@ class session
$query_string = trim(implode('&', $use_args));
// basenamed page name (for example: index.php)
- $page_name = basename($script_name);
+ $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name);
$page_name = urlencode(htmlspecialchars($page_name));
// current directory within the phpBB root (for example: adm)
@@ -608,6 +608,12 @@ 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;
}
@@ -977,7 +983,7 @@ class session
}
// only called from CRON; should be a safe workaround until the infrastructure gets going
- if (!class_exists('captcha_factory'))
+ if (!class_exists('phpbb_captcha_factory'))
{
include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx);
}
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 4d72d45f81..b596e72c41 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1054,7 +1054,7 @@ function compose_pm($id, $mode, $action)
'S_COMPOSE_PM' => true,
'S_EDIT_POST' => ($action == 'edit'),
'S_SHOW_PM_ICONS' => $s_pm_icons,
- 'S_BBCODE_ALLOWED' => $bbcode_status,
+ 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0,
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php
index 1d6b79bbec..dfade990d2 100644
--- a/phpBB/install/convertors/convert_phpbb20.php
+++ b/phpBB/install/convertors/convert_phpbb20.php
@@ -32,7 +32,7 @@ unset($dbpasswd);
$convertor_data = array(
'forum_name' => 'phpBB 2.0.x',
'version' => '1.0.3',
- 'phpbb_version' => '3.0.7',
+ 'phpbb_version' => '3.0.7-PL1',
'author' => '<a href="http://www.phpbb.com/">phpBB Group</a>',
'dbms' => $dbms,
'dbhost' => $dbhost,
@@ -83,7 +83,7 @@ $tables = array(
* 'table_format' => 'file',
* 'filename' => 'NAME OF FILE', // If the file is not in the root directory, the path needs to be added with no leading slash
* 'array_name' => 'NAME OF ARRAY', // Only used if the configuration file stores the setting in an array.
-* 'settings' => array(
+* 'settings' => array(
* 'board_email' => 'SUPPORT_EMAIL', // target config name => source target name
* )
* );
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index df8aadfdb2..47d261dc46 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -911,6 +911,10 @@ function database_update_info()
'3.0.7-RC1' => array(),
// No changes from 3.0.7-RC2 to 3.0.7
'3.0.7-RC2' => array(),
+ // No changes from 3.0.7 to 3.0.7-PL1
+ '3.0.7' => array(),
+ // No changes from 3.0.7-PL1 to 3.0.8-RC1
+ '3.0.7-PL1' => array(),
);
}
@@ -921,7 +925,7 @@ function database_update_info()
*****************************************************************************/
function change_database_data(&$no_updates, $version)
{
- global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;
+ global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $user;
switch ($version)
{
@@ -1642,6 +1646,47 @@ function change_database_data(&$no_updates, $version)
// No changes from 3.0.7-RC2 to 3.0.7
case '3.0.7-RC2':
break;
+
+ // No changes from 3.0.7 to 3.0.7-PL1
+ case '3.0.7':
+ break;
+
+ // Changes from 3.0.7-PL1 to 3.0.8-RC1
+ case '3.0.7-PL1':
+ $user->add_lang('acp/attachments');
+ $extension_groups = array(
+ $user->lang['EXT_GROUP_ARCHIVES'] => 'ARCHIVES',
+ $user->lang['EXT_GROUP_DOCUMENTS'] => 'DOCUMENTS',
+ $user->lang['EXT_GROUP_DOWNLOADABLE_FILES'] => 'DOWNLOADABLE_FILES',
+ $user->lang['EXT_GROUP_FLASH_FILES'] => 'FLASH_FILES',
+ $user->lang['EXT_GROUP_IMAGES'] => 'IMAGES',
+ $user->lang['EXT_GROUP_PLAIN_TEXT'] => 'PLAIN_TEXT',
+ $user->lang['EXT_GROUP_QUICKTIME_MEDIA'] => 'QUICKTIME_MEDIA',
+ $user->lang['EXT_GROUP_REAL_MEDIA'] => 'REAL_MEDIA',
+ $user->lang['EXT_GROUP_WINDOWS_MEDIA'] => 'WINDOWS_MEDIA',
+ );
+
+ $sql = 'SELECT group_id, group_name
+ FROM ' . EXTENSION_GROUPS_TABLE;
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (isset($extension_groups[$row['group_name']]))
+ {
+ $sql_ary = array(
+ 'group_name' => $extension_groups[$row['group_name']],
+ );
+ $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE group_id = ' . (int) $row['group_id'];
+ _sql($sql, $errored, $error_ary);
+ }
+ }
+ $db->sql_freeresult($result);
+
+
+ $no_updates = false;
+ break;
}
}
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index a5e54a354a..e717fe3dd4 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -72,7 +72,7 @@ class install_update extends module
function main($mode, $sub)
{
- global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth;
+ global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
$this->tpl_name = 'install_update';
$this->page_title = 'UPDATE_INSTALLATION';
@@ -119,7 +119,17 @@ class install_update extends module
$user->session_begin();
$auth->acl($user->data);
- $user->setup('install');
+ // Overwrite user's language with the selected one.
+ // Config needs to be changed to ensure that guests also get the selected language.
+ $config_default_lang = $config['default_lang'];
+ $config['default_lang'] = $language;
+ $user->data['user_lang'] = $language;
+
+ $user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting'));
+
+ // Reset the default_lang
+ $config['default_lang'] = $config_default_lang;
+ unset($config_default_lang);
// If we are within the intro page we need to make sure we get up-to-date version info
if ($sub == 'intro')
@@ -133,6 +143,14 @@ class install_update extends module
// still, the acp template is never stored in the database
$user->theme['template_storedb'] = false;
+ $template->assign_vars(array(
+ 'S_USER_LANG' => $user->lang['USER_LANG'],
+ 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
+ 'S_CONTENT_ENCODING' => 'UTF-8',
+ 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
+ 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
+ ));
+
// Get current and latest version
if (($latest_version = $cache->get('_version_info')) === false)
{
@@ -234,7 +252,7 @@ class install_update extends module
$template->assign_vars(array(
'S_INTRO' => true,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=version_check"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=version_check"),
));
// Make sure the update list is destroyed.
@@ -250,8 +268,8 @@ class install_update extends module
'S_UP_TO_DATE' => $up_to_date,
'S_VERSION_CHECK' => true,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check"),
- 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_db"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"),
+ 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_db"),
'LATEST_VERSION' => $this->latest_version,
'CURRENT_VERSION' => $this->current_version)
@@ -305,8 +323,8 @@ class install_update extends module
'S_DB_UPDATE' => true,
'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->update_info['version']['to']) ? true : false,
'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&amp;language=' . $user->data['user_lang']),
- 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_db"),
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check"),
+ 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_db"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"),
));
break;
@@ -363,7 +381,7 @@ class install_update extends module
// Refresh the page if we are still not finished...
if ($update_list['status'] != -1)
{
- $refresh_url = append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check");
+ $refresh_url = append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check");
meta_refresh(2, $refresh_url);
$template->assign_vars(array(
@@ -427,7 +445,7 @@ class install_update extends module
$file_part = $filename;
}
- $diff_url = append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check&amp;action=diff&amp;status=$status&amp;file=" . urlencode($file_struct['filename']));
+ $diff_url = append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check&amp;action=diff&amp;status=$status&amp;file=" . urlencode($file_struct['filename']));
if (isset($file_struct['as_expected']) && $file_struct['as_expected'])
{
@@ -475,9 +493,9 @@ class install_update extends module
'S_FILE_CHECK' => true,
'S_ALL_UP_TO_DATE' => $all_up_to_date,
'S_VERSION_UP_TO_DATE' => $up_to_date,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check"),
- 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_files"),
- 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_db"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"),
+ 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files"),
+ 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_db"),
));
if ($all_up_to_date)
@@ -690,7 +708,7 @@ class install_update extends module
$params[] = 'download=1';
}
- $redirect_url = append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_files&amp;" . implode('&amp;', $params));
+ $redirect_url = append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files&amp;" . implode('&amp;', $params));
meta_refresh(3, $redirect_url);
$template->assign_vars(array(
@@ -831,7 +849,7 @@ class install_update extends module
$template->assign_vars(array(
'S_DOWNLOAD_FILES' => true,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_files"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files"),
'RADIO_BUTTONS' => $radio_buttons,
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
@@ -945,8 +963,8 @@ class install_update extends module
'S_FTP_UPLOAD' => true,
'UPLOAD_METHOD' => $method,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_files"),
- 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=update_files&amp;download=1"),
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files"),
+ 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files&amp;download=1"),
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
@@ -1079,7 +1097,7 @@ class install_update extends module
$template->assign_vars(array(
'S_UPLOAD_SUCCESS' => true,
- 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&amp;sub=file_check"))
+ 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"))
);
return;
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 38088b291d..e815615eef 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -509,7 +509,7 @@ INSERT INTO phpbb_styles_theme (theme_name, theme_copyright, theme_path, theme_s
# -- Forums
INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_FIRST_CATEGORY}', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 'AA0000', 972086460, '', '', '', '', '', '', '', 0, 0, '');
-INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '');
+INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48);
# -- Users / Anonymous user
INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0);
diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php
index f6369b6739..1821b8c867 100644
--- a/phpBB/language/en/acp/attachments.php
+++ b/phpBB/language/en/acp/attachments.php
@@ -85,7 +85,7 @@ $lang = array_merge($lang, array(
'DISPLAY_INLINED_EXPLAIN' => 'If set to No image attachments will show as a link.',
'DISPLAY_ORDER' => 'Attachment display order',
'DISPLAY_ORDER_EXPLAIN' => 'Display attachments ordered by time.',
-
+
'EDIT_EXTENSION_GROUP' => 'Edit extension group',
'EXCLUDE_ENTERED_IP' => 'Enable this to exclude the entered IP/hostname.',
'EXCLUDE_FROM_ALLOWED_IP' => 'Exclude IP from allowed IPs/hostnames',
@@ -97,6 +97,16 @@ $lang = array_merge($lang, array(
'EXTENSION_GROUP_DELETED' => 'Extension group successfully deleted.',
'EXTENSION_GROUP_EXIST' => 'The extension group %s already exists.',
+ 'EXT_GROUP_ARCHIVES' => 'Archives',
+ 'EXT_GROUP_DOCUMENTS' => 'Documents',
+ 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files',
+ 'EXT_GROUP_FLASH_FILES' => 'Flash Files',
+ 'EXT_GROUP_IMAGES' => 'Images',
+ 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text',
+ 'EXT_GROUP_QUICKTIME_MEDIA' => 'Quicktime Media',
+ 'EXT_GROUP_REAL_MEDIA' => 'Real Media',
+ 'EXT_GROUP_WINDOWS_MEDIA' => 'Windows Media',
+
'GO_TO_EXTENSIONS' => 'Go to extension management screen',
'GROUP_NAME' => 'Group name',
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index ce57b07eae..52389d85b9 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -211,7 +211,7 @@ $lang = array_merge($lang, array(
'NEW_MEMBER_POST_LIMIT' => 'New member post limit',
'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the <em>Newly Registered Users</em> group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. <strong>A value of 0 disables this feature.</strong>',
'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default',
- 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes and a new member post limit is specified newly registered users will be not only put into the <em>Newly Registered Users</em> group, but this group also being their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.',
+ 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes, and a new member post limit is specified, newly registered users will not only be put into the <em>Newly Registered Users</em> group, but this group will also be their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.',
'ACC_ADMIN' => 'By Admin',
'ACC_DISABLE' => 'Disable',
diff --git a/phpBB/language/en/email/admin_welcome_inactive.txt b/phpBB/language/en/email/admin_welcome_inactive.txt
index e0970d3ff3..30b3aae852 100644
--- a/phpBB/language/en/email/admin_welcome_inactive.txt
+++ b/phpBB/language/en/email/admin_welcome_inactive.txt
@@ -10,7 +10,7 @@ Username: {USERNAME}
Board URL: {U_BOARD}
----------------------------
-Your account is currently inactive and will need to be approved by an administrator before you can log in. Another email will be sent when this has occured.
+Your account is currently inactive and will need to be approved by an administrator before you can log in. Another email will be sent when this has occurred.
Your password has been securely stored in our database and cannot be retrieved. In the event that it is forgotten, you will be able to reset it using the email address associated with your account.
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index 1c27e2f40d..4e58de8d90 100644
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -128,7 +128,7 @@ $lang = array_merge($lang, array(
'DB_ERR_QUERY_FIRST_TABLE' => 'Error while executing <var>query_first</var>, %s (“%s”).',
'DB_ERR_SELECT' => 'Error while running <code>SELECT</code> query.',
'DB_HOST' => 'Database server hostname or DSN',
- 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs.',
+ 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs. On PostgreSQL, use localhost to connect to the local server via UNIX domain socket and 127.0.0.1 to connect via TCP.',
'DB_NAME' => 'Database name',
'DB_PASSWORD' => 'Database password',
'DB_PORT' => 'Database server port',
@@ -586,16 +586,6 @@ $lang = array_merge($lang, array(
'DEFAULT_INSTALL_POST' => 'This is an example post in your phpBB3 installation. Everything seems to be working. You may delete this post if you like and continue to set up your board. During the installation process your first category and your first forum are assigned an appropriate set of permissions for the predefined usergroups administrators, bots, global moderators, guests, registered users and registered COPPA users. If you also choose to delete your first category and your first forum, do not forget to assign permissions for all these usergroups for all new categories and forums you create. It is recommended to rename your first category and your first forum and copy permissions from these while creating new categories and forums. Have fun!',
- 'EXT_GROUP_ARCHIVES' => 'Archives',
- 'EXT_GROUP_DOCUMENTS' => 'Documents',
- 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files',
- 'EXT_GROUP_FLASH_FILES' => 'Flash Files',
- 'EXT_GROUP_IMAGES' => 'Images',
- 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text',
- 'EXT_GROUP_QUICKTIME_MEDIA' => 'Quicktime Media',
- 'EXT_GROUP_REAL_MEDIA' => 'Real Media',
- 'EXT_GROUP_WINDOWS_MEDIA' => 'Windows Media',
-
'FORUMS_FIRST_CATEGORY' => 'Your first category',
'FORUMS_TEST_FORUM_DESC' => 'Description of your first forum.',
'FORUMS_TEST_FORUM_TITLE' => 'Your first forum',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 6a95dce489..1f593df561 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1152,7 +1152,7 @@ if (!sizeof($error) && $preview)
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;
// Not sure about parameters for bbcode/smilies/urls... in signatures
- $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']);
+ $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);
$preview_signature = $parse_sig->message;
unset($parse_sig);
}
@@ -1420,7 +1420,7 @@ $template->assign_vars(array(
'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false,
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false,
- 'S_BBCODE_ALLOWED' => $bbcode_status,
+ 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0,
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
diff --git a/phpBB/search.php b/phpBB/search.php
index ab2221a96e..7a9ab82f93 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -1155,6 +1155,7 @@ if ($auth->acl_get('a_search'))
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
$sql = 'SELECT search_time, search_keywords
FROM ' . SEARCH_RESULTS_TABLE . '
WHERE DATALENGTH(search_keywords) > 0
diff --git a/phpBB/styles/prosilver/template/mcp_reports.html b/phpBB/styles/prosilver/template/mcp_reports.html
index 649154deb4..eefb24ee91 100644
--- a/phpBB/styles/prosilver/template/mcp_reports.html
+++ b/phpBB/styles/prosilver/template/mcp_reports.html
@@ -54,7 +54,7 @@
</dt>
<dd class="moderation">
<span>{postrow.REPORTER_FULL} &laquo; {postrow.REPORT_TIME}<br />
- {L_FORUM}: <a href="{postrow.U_VIEWFORUM}">{postrow.FORUM_NAME}</a></span>
+ <!-- IF postrow.U_VIEWFORUM -->{L_FORUM}: <a href="{postrow.U_VIEWFORUM}">{postrow.FORUM_NAME}</a><!-- ELSE -->{postrow.FORUM_NAME}<!-- ENDIF --></span>
</dd>
<!-- ENDIF -->
<dd class="mark"><input type="checkbox" name="report_id_list[]" value="{postrow.REPORT_ID}" /></dd>
diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html
index 8a5b8aeb16..ea07c2e6d8 100644
--- a/phpBB/styles/prosilver/template/quickreply_editor.html
+++ b/phpBB/styles/prosilver/template/quickreply_editor.html
@@ -61,7 +61,7 @@
{S_FORM_TOKEN}
{QR_HIDDEN_FIELDS}
<input type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" class="button1" />&nbsp;
- <input type="submit" accesskey="f" tabindex="6" name="full_editor" value="{L_FULL_EDITOR}" class="button2" />&nbsp;
+ <input type="submit" accesskey="f" tabindex="7" name="full_editor" value="{L_FULL_EDITOR}" class="button2" />&nbsp;
</fieldset>
<a href="" class="right-box up" onclick="hide_qr(false); return false;" title="{L_COLLAPSE_QR}">{L_COLLAPSE_QR}</a>
<span class="corners-bottom"><span></span></span></div>
diff --git a/phpBB/styles/prosilver/template/ucp_pm_history.html b/phpBB/styles/prosilver/template/ucp_pm_history.html
index 88efcf95be..bcd6a75397 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_history.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_history.html
@@ -5,6 +5,11 @@
</h3>
<div id="topicreview">
+ <script type="text/javascript">
+ // <![CDATA[
+ bbcodeEnabled = {S_BBCODE_ALLOWED};
+ // ]]>
+ </script>
<!-- BEGIN history_row -->
<div class="post <!-- IF history_row.S_ROW_COUNT is even -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner"><span class="corners-top"><span></span></span>
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 95c142d865..d18508ccbc 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -151,7 +151,7 @@ $template->set_filenames(array(
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);
$template->assign_vars(array(
- 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&amp;start=$start"),
+ 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
));
// Not postable forum or showing active topics?
@@ -302,7 +302,7 @@ $template->assign_vars(array(
'S_WATCH_FORUM_LINK' => $s_watching_forum['link'],
'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'],
'S_WATCHING_FORUM' => $s_watching_forum['is_watching'],
- 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&amp;start=$start"),
+ 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&amp;start=$start")),
'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'fid[]=' . $forum_id),
'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
@@ -311,7 +311,7 @@ $template->assign_vars(array(
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&amp;f=' . $forum_id) : '',
- 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . "&amp;start=$start"),
+ 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start == 0) ? '' : "&amp;start=$start")),
'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&amp;f=$forum_id&amp;mark=topics") : '',
));
@@ -592,12 +592,14 @@ if (sizeof($topic_list))
{
$row = &$rowset[$topic_id];
+ $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id;
+
// This will allow the style designer to output a different header
// or even separate the list of announcements from sticky and normal topics
$s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
// Replies
- $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
+ $replies = ($auth->acl_get('m_approve', $topic_forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
if ($row['topic_status'] == ITEM_MOVED)
{
@@ -614,16 +616,16 @@ if (sizeof($topic_list))
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
// Generate all the URIs ...
- $view_topic_url_params = 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&amp;t=' . $topic_id;
+ $view_topic_url_params = 'f=' . $topic_forum_id . '&amp;t=' . $topic_id;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
- $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false;
- $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false;
+ $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false;
+ $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
// Send vars to template
$template->assign_block_vars('topicrow', array(
- 'FORUM_ID' => $forum_id,
+ 'FORUM_ID' => $topic_forum_id,
'TOPIC_ID' => $topic_id,
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
@@ -651,13 +653,13 @@ if (sizeof($topic_list))
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
- 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
+ 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
'S_TOPIC_TYPE' => $row['topic_type'],
'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
'S_UNREAD_TOPIC' => $unread_topic,
- 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false,
+ 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $topic_forum_id)) ? true : false,
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
'S_POSTS_UNAPPROVED' => $posts_unapproved,
'S_HAS_POLL' => ($row['poll_start']) ? true : false,
@@ -672,7 +674,7 @@ if (sizeof($topic_list))
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,
- 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $forum_id . '&amp;t=' . $topic_id, true, $user->session_id),
+ 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $topic_forum_id . '&amp;t=' . $topic_id, true, $user->session_id),
'U_MCP_QUEUE' => $u_mcp_queue,
'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 29c4e5cdc1..8e0521522d 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -477,7 +477,7 @@ if ($start < 0 || $start >= $total_posts)
}
// General Viewtopic URL for return links
-$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
+$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
// Are we watching this topic?
$s_watching_topic = array(
@@ -601,7 +601,7 @@ $template->assign_vars(array(
'PAGINATION' => $pagination,
'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start),
'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
- 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',
+ 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',
'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
@@ -630,9 +630,9 @@ $template->assign_vars(array(
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,
'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
- 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start"),
+ 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start")),
'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
- 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
+ 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . "&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
'S_VIEWTOPIC' => true,
'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
@@ -722,7 +722,7 @@ if (!empty($topic_data['poll_start']))
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))
{
- $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
+ $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start"));
meta_refresh(5, $redirect_url);
if (!sizeof($voted_id))
@@ -805,7 +805,7 @@ if (!empty($topic_data['poll_start']))
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
$db->sql_query($sql);
- $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
+ $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start"));
meta_refresh(5, $redirect_url);
trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
diff --git a/phpBB/web.config b/phpBB/web.config
new file mode 100644
index 0000000000..128fe3c98f
--- /dev/null
+++ b/phpBB/web.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <system.webServer>
+ <security>
+ <requestFiltering>
+ <hiddenSegments>
+ <add segment="cache" />
+ <add segment="files" />
+ <add segment="store" />­
+ <add segment="config.php" />
+ <add segment="common.php" />
+ </hiddenSegments>
+ </requestFiltering>
+ </security>
+ </system.webServer>
+ <location path="images/avatars">
+ <system.webServer>
+ <security>
+ <requestFiltering>
+ <hiddenSegments>
+ <add segment="upload" />
+ </hiddenSegments>
+ </requestFiltering>
+ </security>
+ </system.webServer>
+ </location>
+</configuration>
diff --git a/tests/all_tests.php b/tests/all_tests.php
new file mode 100644
index 0000000000..e693427809
--- /dev/null
+++ b/tests/all_tests.php
@@ -0,0 +1,56 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+error_reporting(E_ALL);
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'utf/all_tests.php';
+require_once 'request/all_tests.php';
+require_once 'security/all_tests.php';
+require_once 'template/all_tests.php';
+require_once 'text_processing/all_tests.php';
+require_once 'dbal/all_tests.php';
+
+// exclude the test directory from code coverage reports
+PHPUnit_Util_Filter::addDirectoryToFilter('./');
+
+class phpbb_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB');
+
+ $suite->addTest(phpbb_utf_all_tests::suite());
+ $suite->addTest(phpbb_request_all_tests::suite());
+ $suite->addTest(phpbb_security_all_tests::suite());
+ $suite->addTest(phpbb_template_all_tests::suite());
+ $suite->addTest(phpbb_text_processing_all_tests::suite());
+ $suite->addTest(phpbb_dbal_all_tests::suite());
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_all_tests::main')
+{
+ phpbb_all_tests::main();
+}
+
diff --git a/tests/dbal/all_tests.php b/tests/dbal/all_tests.php
new file mode 100644
index 0000000000..7aee0f6b16
--- /dev/null
+++ b/tests/dbal/all_tests.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_dbal_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'dbal/dbal.php';
+
+class phpbb_dbal_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Database Abstraction Layer');
+
+ $suite->addTestSuite('phpbb_dbal_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main')
+{
+ phpbb_dbal_all_tests::main();
+}
diff --git a/tests/dbal/dbal.php b/tests/dbal/dbal.php
new file mode 100644
index 0000000000..f90b5efeb5
--- /dev/null
+++ b/tests/dbal/dbal.php
@@ -0,0 +1,328 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_dbal_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml');
+ }
+
+ public static function return_on_error_select_data()
+ {
+ return array(
+ array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))),
+ array('phpbb_users', "username_clean = 'phpBB'", array()),
+ array('phpbb_users', 'username_clean syntax_error', false),
+ array('phpbb_users', 'column_not_exists = 2', false),
+ array('table_not_exists', 'column_not_exists = 2', false),
+ );
+ }
+
+ /**
+ * @dataProvider return_on_error_select_data
+ */
+ public function test_return_on_error_select($table, $where, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $db->sql_return_on_error(true);
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM ' . $table . '
+ WHERE ' . $where . '
+ ORDER BY user_id ASC');
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+ }
+
+ public static function fetchrow_data()
+ {
+ return array(
+ array('', array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array('user_id = 2', array(array('username_clean' => 'foobar'))),
+ array("username_clean = 'bertie'", array(array('username_clean' => 'bertie'))),
+ array("username_clean = 'phpBB'", array()),
+ );
+ }
+
+ /**
+ * @dataProvider fetchrow_data
+ */
+ public function test_fetchrow($where, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $ary[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected, $ary);
+ }
+
+ /**
+ * @dataProvider fetchrow_data
+ */
+ public function test_fetchrowset($where, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
+ public static function fetchfield_data()
+ {
+ return array(
+ array('', array('barfoo', 'foobar', 'bertie')),
+ array('user_id = 2', array('foobar')),
+ array("username_clean = 'bertie'", array('bertie')),
+ );
+ }
+
+ /**
+ * @dataProvider fetchfield_data
+ */
+ public function test_fetchfield($where, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $ary = array();
+ while ($row = $db->sql_fetchfield('username_clean'))
+ {
+ $ary[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected, $ary);
+ }
+
+ public static function query_limit_data()
+ {
+ return array(
+ array(0, 0, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array(0, 1, array(array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array(1, 0, array(array('username_clean' => 'barfoo'))),
+ array(1, 1, array(array('username_clean' => 'foobar'))),
+ array(1, 2, array(array('username_clean' => 'bertie'))),
+ array(2, 0, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array(2, 2, array(array('username_clean' => 'bertie'))),
+ array(2, 5, array()),
+ array(10, 1, array(array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array(10, 5, array()),
+ );
+ }
+
+ /**
+ * @dataProvider query_limit_data
+ */
+ public function test_query_limit($total, $offset, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $result = $db->sql_query_limit('SELECT username_clean
+ FROM phpbb_users
+ ORDER BY user_id ASC', $total, $offset);
+
+ $ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $ary[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected, $ary);
+ }
+
+ public static function like_expression_data()
+ {
+ // * = any_char; # = one_char
+ return array(
+ array('barfoo', array(array('username_clean' => 'barfoo'))),
+ array('bar', array()),
+ array('bar*', array(array('username_clean' => 'barfoo'))),
+ array('*bar*', array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('*b*', array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array('b*r', array()),
+ array('b*e', array(array('username_clean' => 'bertie'))),
+ array('#b*e', array()),
+ array('b####e', array(array('username_clean' => 'bertie'))),
+ );
+ }
+
+ /**
+ * @dataProvider like_expression_data
+ */
+ public function test_like_expression($like_expression, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $like_expression = str_replace('*', $db->any_char, $like_expression);
+ $like_expression = str_replace('#', $db->one_char, $like_expression);
+ $where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : '';
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
+ public static function in_set_data()
+ {
+ return array(
+ array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))),
+ array('user_id', 3, false, true, array(array('username_clean' => 'bertie'))),
+ array('user_id', 3, true, false, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', 3, true, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', '3', false, false, array(array('username_clean' => 'bertie'))),
+ array('user_id', '3', false, true, array(array('username_clean' => 'bertie'))),
+ array('user_id', '3', true, false, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', '3', true, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', array(3), false, false, array(array('username_clean' => 'bertie'))),
+ array('user_id', array(3), false, true, array(array('username_clean' => 'bertie'))),
+ array('user_id', array(3), true, false, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', array(3), true, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'))),
+ array('user_id', array(1, 3), false, false, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'bertie'))),
+ array('user_id', array(1, 3), false, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'bertie'))),
+ array('user_id', array(1, 3), true, false, array(array('username_clean' => 'foobar'))),
+ array('user_id', array(1, 3), true, true, array(array('username_clean' => 'foobar'))),
+ array('user_id', '', false, false, array()),
+ array('user_id', '', false, true, array()),
+ array('user_id', '', true, false, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array('user_id', '', true, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+ array('user_id', array(), false, true, array()),
+ array('user_id', array(), true, true, array(array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))),
+
+ // These here would throw errors and therefor $result should be false.
+ array('user_id', array(), false, false, false, true),
+ array('user_id', array(), true, false, false, true),
+ );
+ }
+
+ /**
+ * @dataProvider in_set_data
+ */
+ public function test_in_set($field, $array, $negate, $allow_empty_set, $expected, $catch_error = false)
+ {
+ $db = $this->new_dbal();
+
+ if ($catch_error)
+ {
+ $db->sql_return_on_error(true);
+ }
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ WHERE ' . $db->sql_in_set($field, $array, $negate, $allow_empty_set) . '
+ ORDER BY user_id ASC');
+
+ if ($catch_error)
+ {
+ $db->sql_return_on_error(false);
+ }
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
+ public static function build_array_data()
+ {
+ return array(
+ array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))),
+ array(array('username_clean' => 'barfoo', 'user_id' => 1), array(array('username_clean' => 'barfoo'))),
+ array(array('username_clean' => 'barfoo', 'user_id' => 2), array()),
+
+ // These here would throw errors and therefor $result should be false.
+ array(array(), false, true),
+ array('no_array', false, true),
+ array(0, false, true),
+ );
+ }
+
+ /**
+ * @dataProvider build_array_data
+ */
+ public function test_build_array($assoc_ary, $expected, $catch_error = false)
+ {
+ $db = $this->new_dbal();
+
+ if ($catch_error)
+ {
+ $db->sql_return_on_error(true);
+ }
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ WHERE ' . $db->sql_build_array('SELECT', $assoc_ary) . '
+ ORDER BY user_id ASC');
+
+ if ($catch_error)
+ {
+ $db->sql_return_on_error(false);
+ }
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+}
+
diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml
new file mode 100644
index 0000000000..a6789f4a01
--- /dev/null
+++ b/tests/dbal/fixtures/three_users.xml
@@ -0,0 +1,19 @@
+<?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>barfoo</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>foobar</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>bertie</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/request/all_tests.php b/tests/request/all_tests.php
new file mode 100644
index 0000000000..1ee3029b36
--- /dev/null
+++ b/tests/request/all_tests.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_request_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'request/request_var.php';
+
+class phpbb_request_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Request Parameter Handling');
+
+ $suite->addTestSuite('phpbb_request_request_var_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_request_all_tests::main')
+{
+ phpbb_request_all_tests::main();
+}
+
diff --git a/tests/request/request_var.php b/tests/request/request_var.php
new file mode 100644
index 0000000000..b1dacef3fd
--- /dev/null
+++ b/tests/request/request_var.php
@@ -0,0 +1,180 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_request_request_var_test extends phpbb_test_case
+{
+ /**
+ * @dataProvider request_variables
+ */
+ public function test_post($variable_value, $default, $multibyte, $expected)
+ {
+ $variable_name = 'name';
+ $this->unset_variables($variable_name);
+
+ $_POST[$variable_name] = $variable_value;
+ $_REQUEST[$variable_name] = $variable_value;
+
+ $result = request_var($variable_name, $default, $multibyte);
+
+ $label = 'Requesting POST variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
+ $this->assertEquals($expected, $result, $label);
+ }
+
+ /**
+ * @dataProvider request_variables
+ */
+ public function test_get($variable_value, $default, $multibyte, $expected)
+ {
+ $variable_name = 'name';
+ $this->unset_variables($variable_name);
+
+ $_GET[$variable_name] = $variable_value;
+ $_REQUEST[$variable_name] = $variable_value;
+
+ $result = request_var($variable_name, $default, $multibyte);
+
+ $label = 'Requesting GET variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
+ $this->assertEquals($expected, $result, $label);
+ }
+
+ /**
+ * @dataProvider request_variables
+ */
+ public function test_cookie($variable_value, $default, $multibyte, $expected)
+ {
+ $variable_name = 'name';
+ $this->unset_variables($variable_name);
+
+ $_GET[$variable_name] = false;
+ $_POST[$variable_name] = false;
+ $_REQUEST[$variable_name] = false;
+ $_COOKIE[$variable_name] = $variable_value;
+
+ $result = request_var($variable_name, $default, $multibyte, true);
+
+ $label = 'Requesting COOKIE variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
+ $this->assertEquals($expected, $result, $label);
+ }
+
+ /**
+ * Helper for unsetting globals
+ */
+ private function unset_variables($var)
+ {
+ unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]);
+ }
+
+ public static function request_variables()
+ {
+ return array(
+ // strings
+ array('abc', '', false, 'abc'),
+ array(' some spaces ', '', true, 'some spaces'),
+ array("\r\rsome\rcarriage\r\rreturns\r", '', true, "some\ncarriage\n\nreturns"),
+ array("\n\nsome\ncarriage\n\nreturns\n", '', true, "some\ncarriage\n\nreturns"),
+ array("\r\n\r\nsome\r\ncarriage\r\n\r\nreturns\r\n", '', true, "some\ncarriage\n\nreturns"),
+ array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', true, "we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters"),
+ array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', false, "we??rd???ch??r??acters"),
+ array("Some <html> \"entities\" like &", '', true, "Some &lt;html&gt; &quot;entities&quot; like &amp;"),
+
+ // integers
+ array('1234', 0, false, 1234),
+ array('abc', 12, false, 0),
+ array('324abc', 0, false, 324),
+
+ // string to array
+ array('123', array(0), false, array()),
+ array('123', array(''), false, array()),
+
+ // 1 dimensional arrays
+ array(
+ // input:
+ array('123', 'abc'),
+ // default:
+ array(''),
+ false,
+ // expected:
+ array('123', 'abc')
+ ),
+ array(
+ // input:
+ array('123', 'abc'),
+ // default:
+ array(999),
+ false,
+ // expected:
+ array(123, 0)
+ ),
+ array(
+ // input:
+ array('xyz' => '123', 'abc' => 'abc'),
+ // default:
+ array('' => ''),
+ false,
+ // expected:
+ array('xyz' => '123', 'abc' => 'abc')
+ ),
+ array(
+ // input:
+ array('xyz' => '123', 'abc' => 'abc'),
+ // default:
+ array('' => 0),
+ false,
+ // expected:
+ array('xyz' => 123, 'abc' => 0)
+ ),
+
+ // 2 dimensional arrays
+ array(
+ // input:
+ '',
+ // default:
+ array(array(0)),
+ false,
+ // expected:
+ array()
+ ),
+ array(
+ // input:
+ array(
+ 'xyz' => array('123', 'def'),
+ 'abc' => 'abc'
+ ),
+ // default:
+ array('' => array('')),
+ false,
+ // expected:
+ array(
+ 'xyz' => array('123', 'def'),
+ 'abc' => array()
+ )
+ ),
+ array(
+ // input:
+ array(
+ 'xyz' => array('123', 'def'),
+ 'abc' => 'abc'
+ ),
+ // default:
+ array('' => array(0)),
+ false,
+ // expected:
+ array(
+ 'xyz' => array(123, 0),
+ 'abc' => array()
+ )
+ ),
+ );
+ }
+
+}
+
diff --git a/tests/security/all_tests.php b/tests/security/all_tests.php
new file mode 100644
index 0000000000..8e3916733f
--- /dev/null
+++ b/tests/security/all_tests.php
@@ -0,0 +1,86 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_security_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'security/extract_current_page.php';
+require_once 'security/redirect.php';
+
+class phpbb_security_all_tests extends PHPUnit_Framework_TestSuite
+{
+ /**
+ * Set up the required user object and server variables for the suites
+ */
+ protected function setUp()
+ {
+ global $user, $phpbb_root_path;
+
+ // Put this into a global function being run by every test to init a proper user session
+ $_SERVER['HTTP_HOST'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_ADDR'] = '127.0.0.1';
+ $_SERVER['SERVER_PORT'] = 80;
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+ $_SERVER['QUERY_STRING'] = '';
+ $_SERVER['REQUEST_URI'] = '/tests/';
+ $_SERVER['SCRIPT_NAME'] = '/tests/index.php';
+ $_SERVER['PHP_SELF'] = '/tests/index.php';
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
+
+/*
+ [HTTP_ACCEPT_ENCODING] => gzip,deflate
+ [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
+ DOCUMENT_ROOT] => /var/www/
+ [SCRIPT_FILENAME] => /var/www/tests/index.php
+*/
+
+ // Set no user and trick a bit to circumvent errors
+ $user = new user();
+ $user->lang = true;
+ $user->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
+ $user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
+ $user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
+ $user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
+ $user->page = session::extract_current_page($phpbb_root_path);
+ }
+
+ protected function tearDown()
+ {
+ global $user;
+ $user = NULL;
+ }
+
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ // I bet there is a better method calling this... :)
+ $suite = new phpbb_security_all_tests('phpBB Security Fixes');
+
+ $suite->addTestSuite('phpbb_security_extract_current_page_test');
+ $suite->addTestSuite('phpbb_security_redirect_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_security_all_tests::main')
+{
+ phpbb_security_all_tests::main();
+}
diff --git a/tests/security/extract_current_page.php b/tests/security/extract_current_page.php
new file mode 100644
index 0000000000..8c72fe1440
--- /dev/null
+++ b/tests/security/extract_current_page.php
@@ -0,0 +1,53 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/functions.php';
+require_once '../phpBB/includes/session.php';
+
+class phpbb_security_extract_current_page_test extends phpbb_test_case
+{
+ public static function security_variables()
+ {
+ return array(
+ array('http://localhost/phpBB/index.php', 'mark=forums&x="><script>alert(/XSS/);</script>', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'),
+ array('http://localhost/phpBB/index.php', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'),
+ );
+ }
+
+ /**
+ * @dataProvider security_variables
+ */
+ public function test_query_string_php_self($url, $query_string, $expected)
+ {
+ $_SERVER['PHP_SELF'] = $url;
+ $_SERVER['QUERY_STRING'] = $query_string;
+
+ $result = session::extract_current_page('./');
+
+ $label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.';
+ $this->assertEquals($expected, $result['query_string'], $label);
+ }
+
+ /**
+ * @dataProvider security_variables
+ */
+ public function test_query_string_request_uri($url, $query_string, $expected)
+ {
+ $_SERVER['REQUEST_URI'] = $url . '?' . $query_string;
+ $_SERVER['QUERY_STRING'] = $query_string;
+
+ $result = session::extract_current_page('./');
+
+ $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.';
+ $this->assertEquals($expected, $result['query_string'], $label);
+ }
+}
+
diff --git a/tests/security/redirect.php b/tests/security/redirect.php
new file mode 100644
index 0000000000..37b0a5bb41
--- /dev/null
+++ b/tests/security/redirect.php
@@ -0,0 +1,58 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/functions.php';
+require_once '../phpBB/includes/session.php';
+
+class phpbb_security_redirect_test extends phpbb_test_case
+{
+ public static function provider()
+ {
+ // array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false))
+ return array(
+ array('data://x', false, 'http://localhost/phpBB'),
+ array('bad://localhost/phpBB/index.php', 'Tried to redirect to potentially insecure url.', false),
+ array('http://www.otherdomain.com/somescript.php', false, 'http://localhost/phpBB'),
+ array("http://localhost/phpBB/memberlist.php\n\rConnection: close", 'Tried to redirect to potentially insecure url.', false),
+ array('javascript:test', false, 'http://localhost/phpBB/../tests/javascript:test'),
+ array('http://localhost/phpBB/index.php;url=', 'Tried to redirect to potentially insecure url.', false),
+ );
+ }
+
+ protected function setUp()
+ {
+ $GLOBALS['config'] = array(
+ 'force_server_vars' => '0',
+ );
+ }
+
+ /**
+ * @dataProvider provider
+ */
+ public function test_redirect($test, $expected_error, $expected_result)
+ {
+ global $user;
+
+ if ($expected_error !== false)
+ {
+ $this->setExpectedTriggerError(E_USER_ERROR, $expected_error);
+ }
+
+ $result = redirect($test, true);
+
+ // only verify result if we did not expect an error
+ if ($expected_error === false)
+ {
+ $this->assertEquals($expected_result, $result);
+ }
+ }
+}
+
diff --git a/tests/template/all_tests.php b/tests/template/all_tests.php
new file mode 100644
index 0000000000..ea258c1680
--- /dev/null
+++ b/tests/template/all_tests.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_template_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'template/template.php';
+
+class phpbb_template_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Template Engine');
+
+ $suite->addTestSuite('phpbb_template_template_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_template_all_tests::main')
+{
+ phpbb_template_all_tests::main();
+}
diff --git a/tests/template/template.php b/tests/template/template.php
new file mode 100644
index 0000000000..145fe8de61
--- /dev/null
+++ b/tests/template/template.php
@@ -0,0 +1,671 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/template.php';
+
+class phpbb_template_template_test extends phpbb_test_case
+{
+ private $template;
+ private $template_path;
+
+ // Keep the contents of the cache for debugging?
+ const PRESERVE_CACHE = true;
+
+ private function display($handle)
+ {
+ // allow the templates to throw notices
+ $error_level = error_reporting();
+ error_reporting($error_level & ~E_NOTICE);
+
+ ob_start();
+ $this->assertTrue($this->template->display($handle, false));
+
+ // reset error level
+ error_reporting($error_level);
+
+ return self::trim_template_result(ob_get_clean());
+ }
+
+ private static function trim_template_result($result)
+ {
+ return str_replace("\n\n", "\n", implode("\n", array_map('trim', explode("\n", trim($result)))));
+ }
+
+ private function setup_engine()
+ {
+ $this->template_path = dirname(__FILE__) . '/templates';
+ $this->template = new template();
+ $this->template->set_custom_template($this->template_path, 'tests');
+ }
+
+ protected function setUp()
+ {
+ // Test the engine can be used
+ $this->setup_engine();
+
+ if (!is_writable(dirname($this->template->cachepath)))
+ {
+ $this->markTestSkipped("Template cache directory is not writable.");
+ }
+
+ foreach (glob($this->template->cachepath . '*') as $file)
+ {
+ unlink($file);
+ }
+
+ $GLOBALS['config'] = array(
+ 'load_tplcompile' => true,
+ 'tpl_allow_php' => false,
+ );
+ }
+
+ protected function tearDown()
+ {
+ if (is_object($this->template))
+ {
+ foreach (glob($this->template->cachepath . '*') as $file)
+ {
+ unlink($file);
+ }
+ }
+ }
+
+ /**
+ * @todo put test data into templates/xyz.test
+ */
+ public static function template_data()
+ {
+ return array(
+ /*
+ array(
+ '', // File
+ array(), // vars
+ array(), // block vars
+ array(), // destroy
+ '', // Expected result
+ ),
+ */
+ array(
+ 'basic.html',
+ array(),
+ array(),
+ array(),
+ "pass\npass\n<!-- DUMMY var -->",
+ ),
+ array(
+ 'variable.html',
+ array('VARIABLE' => 'value'),
+ array(),
+ array(),
+ 'value',
+ ),
+ array(
+ 'if.html',
+ array(),
+ array(),
+ array(),
+ '0',
+ ),
+ array(
+ 'if.html',
+ array('S_VALUE' => true),
+ array(),
+ array(),
+ "1\n0",
+ ),
+ array(
+ 'if.html',
+ array('S_VALUE' => true, 'S_OTHER_VALUE' => true),
+ array(),
+ array(),
+ '1',
+ ),
+ array(
+ 'if.html',
+ array('S_VALUE' => false, 'S_OTHER_VALUE' => true),
+ array(),
+ array(),
+ '2',
+ ),
+ array(
+ 'loop.html',
+ array(),
+ array(),
+ array(),
+ "noloop\nnoloop",
+ ),
+ array(
+ 'loop.html',
+ array(),
+ array('loop' => array(array())),
+ array(),
+ "loop\nloop",
+ ),
+ array(
+ 'loop.html',
+ array(),
+ array('loop' => array(array(), array()), 'loop.block' => array(array())),
+ array(),
+ "loop\nloop\nloop\nloop",
+ ),
+ array(
+ 'loop.html',
+ array(),
+ array('loop' => array(array(), array()), 'loop.block' => array(array()), 'block' => array(array(), array())),
+ array(),
+ "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
+ ),
+ array(
+ 'loop_vars.html',
+ array(),
+ array('loop' => array(array('VARIABLE' => 'x'))),
+ array(),
+ "first\n0\nx\nset\nlast",
+ ),/* no nested top level loops
+ array(
+ 'loop_vars.html',
+ array(),
+ array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))),
+ array(),
+ "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast",
+ ),
+ array(
+ 'loop_vars.html',
+ array(),
+ array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
+ array(),
+ "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast\n0\n\n1\nlast inner\ninner loop",
+ ),*/
+ array(
+ 'loop_advanced.html',
+ array(),
+ array('loop' => array(array(), array(), array(), array(), array(), array(), array())),
+ array(),
+ "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
+ ),
+ array(
+ 'define.html',
+ array(),
+ array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
+ array(),
+ "xyz\nabc",
+ ),
+ array(
+ 'expressions.html',
+ array(),
+ array(),
+ array(),
+ trim(str_repeat("pass", 39)),
+ ),
+ array(
+ 'php.html',
+ array(),
+ array(),
+ array(),
+ '',
+ ),
+ array(
+ 'include.html',
+ array('VARIABLE' => 'value'),
+ array(),
+ array(),
+ 'value',
+ ),
+ array(
+ 'loop_vars.html',
+ array(),
+ array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
+ array('loop'),
+ '',
+ ),/* no top level nested loops
+ array(
+ 'loop_vars.html',
+ array(),
+ array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
+ array('loop.inner'),
+ "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast",
+ ),*/
+ array(
+ 'lang.html',
+ array(),
+ array(),
+ array(),
+ "{ VARIABLE }\n{ VARIABLE }",
+ ),
+ array(
+ 'lang.html',
+ array('L_VARIABLE' => "Value'"),
+ array(),
+ array(),
+ "Value'\nValue\'",
+ ),
+ array(
+ 'lang.html',
+ array('LA_VARIABLE' => "Value'"),
+ array(),
+ array(),
+ "{ VARIABLE }\nValue'",
+ ),
+ );
+ }
+
+ public function test_missing_file()
+ {
+ $filename = 'file_not_found.html';
+
+ $this->template->set_filenames(array('test' => $filename));
+ $this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
+
+ $expecting = sprintf('template->_tpl_load_file(): File %s does not exist or is empty', realpath($this->template_path . '/../') . '/templates/' . $filename);
+ $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
+
+ $this->display('test');
+ }
+
+ public function test_empty_file()
+ {
+ $expecting = 'template->set_filenames: Empty filename specified for test';
+
+ $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
+ $this->template->set_filenames(array('test' => ''));
+ }
+
+ public function test_invalid_handle()
+ {
+ $expecting = 'template->_tpl_load(): No file specified for handle test';
+ $this->setExpectedTriggerError(E_USER_ERROR, $expecting);
+
+ $this->display('test');
+ }
+
+ private function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file)
+ {
+ $this->template->set_filenames(array('test' => $file));
+ $this->template->assign_vars($vars);
+
+ foreach ($block_vars as $block => $loops)
+ {
+ foreach ($loops as $_vars)
+ {
+ $this->template->assign_block_vars($block, $_vars);
+ }
+ }
+
+ foreach ($destroy as $block)
+ {
+ $this->template->destroy_block_vars($block);
+ }
+
+ try
+ {
+ $this->assertEquals($expected, $this->display('test'), "Testing $file");
+ $this->assertFileExists($cache_file);
+ }
+ catch (ErrorException $e)
+ {
+ if (file_exists($cache_file))
+ {
+ copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
+ }
+
+ throw $e;
+ }
+
+ // For debugging
+ if (self::PRESERVE_CACHE)
+ {
+ copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
+ }
+ }
+
+ /**
+ * @dataProvider template_data
+ */
+ public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
+ {
+ global $phpEx;
+ $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx;
+
+ $this->assertFileNotExists($cache_file);
+
+ $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
+
+ // Reset the engine state
+ $this->setup_engine();
+
+ $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
+ }
+
+ /**
+ * @dataProvider template_data
+ */
+ public function test_assign_display($file, array $vars, array $block_vars, array $destroy, $expected)
+ {
+ $this->template->set_filenames(array(
+ 'test' => $file,
+ 'container' => 'variable.html',
+ ));
+ $this->template->assign_vars($vars);
+
+ foreach ($block_vars as $block => $loops)
+ {
+ foreach ($loops as $_vars)
+ {
+ $this->template->assign_block_vars($block, $_vars);
+ }
+ }
+
+ foreach ($destroy as $block)
+ {
+ $this->template->destroy_block_vars($block);
+ }
+
+ $this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
+
+ $this->template->assign_display('test', 'VARIABLE', false);
+ $this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
+ }
+
+ public function test_php()
+ {
+ global $phpEx;
+
+ $GLOBALS['config']['tpl_allow_php'] = true;
+
+ $cache_file = $this->template->cachepath . 'php.html.' . $phpEx;
+
+ $this->assertFileNotExists($cache_file);
+
+ $this->run_template('php.html', array(), array(), array(), 'test', $cache_file);
+
+ $GLOBALS['config']['tpl_allow_php'] = false;
+ }
+
+ public function test_includephp()
+ {
+ $this->markTestIncomplete('Include PHP test file paths are broken');
+
+ $GLOBALS['config']['tpl_allow_php'] = true;
+
+ $cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT;
+
+ $cwd = getcwd();
+ chdir(dirname(__FILE__) . '/templates');
+
+ $this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file);
+
+ $this->template->set_filenames(array('test' => 'includephp.html'));
+ $this->assertEquals('testing included php', $this->display('test'), "Testing $file");
+
+ chdir($cwd);
+
+ $GLOBALS['config']['tpl_allow_php'] = false;
+ }
+
+ public static function alter_block_array_data()
+ {
+ return array(
+ array(
+ 'outer',
+ array('VARIABLE' => 'before'),
+ false,
+ 'insert',
+ <<<EOT
+outer - 0/4 - before
+outer - 1/4
+middle - 0/2
+middle - 1/2
+outer - 2/4
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 3/4
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting before on top level block',
+ ),
+ array(
+ 'outer',
+ array('VARIABLE' => 'after'),
+ true,
+ 'insert',
+ <<<EOT
+outer - 0/4
+middle - 0/2
+middle - 1/2
+outer - 1/4
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/4
+middle - 0/2
+middle - 1/2
+outer - 3/4 - after
+EOT
+,
+ 'Test inserting after on top level block',
+ ),
+ array(
+ 'outer',
+ array('VARIABLE' => 'pos #1'),
+ 1,
+ 'insert',
+ <<<EOT
+outer - 0/4
+middle - 0/2
+middle - 1/2
+outer - 1/4 - pos #1
+outer - 2/4
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 3/4
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting at 1 on top level block',
+ ),
+ array(
+ 'outer',
+ array('VARIABLE' => 'pos #1'),
+ 0,
+ 'change',
+ <<<EOT
+outer - 0/3 - pos #1
+middle - 0/2
+middle - 1/2
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting at 1 on top level block',
+ ),
+ array(
+ 'outer[0].middle',
+ array('VARIABLE' => 'before'),
+ false,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/3 - before
+middle - 1/3
+middle - 2/3
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting before on nested block',
+ ),
+ array(
+ 'outer[0].middle',
+ array('VARIABLE' => 'after'),
+ true,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/3
+middle - 1/3
+middle - 2/3 - after
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting after on nested block',
+ ),
+ array(
+ 'outer[0].middle',
+ array('VARIABLE' => 'pos #1'),
+ 1,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/3
+middle - 1/3 - pos #1
+middle - 2/3
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting at pos 1 on nested block',
+ ),
+ array(
+ 'outer[1].middle',
+ array('VARIABLE' => 'before'),
+ false,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/2
+middle - 1/2
+outer - 1/3
+middle - 0/4 - before
+middle - 1/4
+middle - 2/4
+middle - 3/4
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+ 'Test inserting before on nested block (pos 1)',
+ ),
+ array(
+ 'outer[].middle',
+ array('VARIABLE' => 'before'),
+ false,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/2
+middle - 1/2
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/3 - before
+middle - 1/3
+middle - 2/3
+EOT
+,
+ 'Test inserting before on nested block (end)',
+ ),
+ array(
+ 'outer.middle',
+ array('VARIABLE' => 'before'),
+ false,
+ 'insert',
+ <<<EOT
+outer - 0/3
+middle - 0/2
+middle - 1/2
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/3 - before
+middle - 1/3
+middle - 2/3
+EOT
+,
+ 'Test inserting before on nested block (end)',
+ ),
+ );
+ }
+
+/*
+ <<<EOT
+outer - 0/3
+middle - 0/2
+middle - 1/2
+outer - 1/3
+middle - 0/3
+middle - 1/3
+middle - 2/3
+outer - 2/3
+middle - 0/2
+middle - 1/2
+EOT
+,
+*/
+
+ /**
+ * @dataProvider alter_block_array_data
+ */
+ public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
+ {
+ $this->markTestIncomplete('Alter Block Test is broken');
+
+ $this->template->set_filenames(array('test' => 'loop_nested.html'));
+
+ // @todo Change this
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer', array());
+ $this->template->assign_block_vars('outer.middle', array());
+ $this->template->assign_block_vars('outer.middle', array());
+
+ $this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification');
+
+ $this->template->alter_block_array($alter_block, $vararray, $key, $mode);
+ $this->assertEquals($expect, $this->display('test'), $description);
+ }
+}
+
diff --git a/tests/template/templates/_dummy_include.php b/tests/template/templates/_dummy_include.php
new file mode 100644
index 0000000000..1de5dddf59
--- /dev/null
+++ b/tests/template/templates/_dummy_include.php
@@ -0,0 +1,3 @@
+<?php
+
+echo "testing included php";
diff --git a/tests/template/templates/basic.html b/tests/template/templates/basic.html
new file mode 100644
index 0000000000..c1dd690260
--- /dev/null
+++ b/tests/template/templates/basic.html
@@ -0,0 +1,20 @@
+<!-- IF S_FALSE -->
+fail
+<!-- ENDIF -->
+<!-- IF S_TRUE -->
+pass
+<!-- ENDIF -->
+<!-- IF S_FALSE -->
+fail
+<!-- ELSEIF S_FALSE and not S_TRUE -->
+fail
+<!-- ELSE -->
+pass
+<!-- ENDIF -->
+<!-- BEGIN empty -->
+fail
+<!-- BEGINELSE -->
+pass
+<!-- END empty -->
+
+<!-- DUMMY var -->
diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html
new file mode 100644
index 0000000000..82237d21a3
--- /dev/null
+++ b/tests/template/templates/define.html
@@ -0,0 +1,8 @@
+<!-- DEFINE $VALUE = 'xyz' -->
+{$VALUE}
+<!-- DEFINE $VALUE = 'abc' -->
+{$VALUE}
+<!-- UNDEFINE $VALUE -->
+{$VALUE}
+<!-- DEFINE $VALUE -->
+
diff --git a/tests/template/templates/expressions.html b/tests/template/templates/expressions.html
new file mode 100644
index 0000000000..c40d967dab
--- /dev/null
+++ b/tests/template/templates/expressions.html
@@ -0,0 +1,86 @@
+<!-- IF 10 is even -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 is even -->fail<!-- ELSE -->pass<!-- ENDIF -->
+
+<!-- IF not 390 is even -->fail<!-- ELSE -->pass<!-- ENDIF -->
+
+<!-- IF 9 is odd -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 32 is odd -->fail<!-- ELSE -->pass<!-- ENDIF -->
+
+<!-- IF 32 is div by 16 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 10 is not even -->fail<!-- ELSE -->pass<!-- ENDIF -->
+
+<!-- IF 24 == 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 24 eq 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF ((((((24 == 24)))))) -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 24 != 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 24 <> 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 24 ne 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 24 neq 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 10 lt 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 10 < 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 10 le 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 10 lte 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 10 <= 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 20 le 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 20 lte 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 20 <= 20 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 9 gt 1 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 > 1 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 9 >= 1 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 gte 1 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 ge 1 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 >= 9 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 gte 9 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 9 ge 9 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF true && (10 > 4) -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF true and (10 > 4) -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF false || true -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF false or true -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF !false -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF not false -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF not not not false -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+
+<!-- IF 6 % 4 == 2 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+
+<!-- IF 24 mod 12 == 0 -->pass<!-- ELSE -->fail<!-- ENDIF -->
diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html
new file mode 100644
index 0000000000..c502e52f51
--- /dev/null
+++ b/tests/template/templates/if.html
@@ -0,0 +1,11 @@
+<!-- IF S_VALUE -->
+1
+<!-- ELSEIF S_OTHER_VALUE -->
+2
+<!-- ELSE -->
+0
+<!-- ENDIF -->
+
+<!-- IF (S_VALUE > S_OTHER_VALUE) -->
+0
+<!-- ENDIF -->
diff --git a/tests/template/templates/include.html b/tests/template/templates/include.html
new file mode 100644
index 0000000000..730d713d65
--- /dev/null
+++ b/tests/template/templates/include.html
@@ -0,0 +1 @@
+<!-- INCLUDE variable.html -->
diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html
new file mode 100644
index 0000000000..3e13fa33fa
--- /dev/null
+++ b/tests/template/templates/includephp.html
@@ -0,0 +1 @@
+<!-- INCLUDEPHP ../templates/_dummy_include.php -->
diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html
new file mode 100644
index 0000000000..2b5ea1cafe
--- /dev/null
+++ b/tests/template/templates/lang.html
@@ -0,0 +1,3 @@
+{L_VARIABLE}
+
+{LA_VARIABLE}
diff --git a/tests/template/templates/loop.html b/tests/template/templates/loop.html
new file mode 100644
index 0000000000..de1a10004d
--- /dev/null
+++ b/tests/template/templates/loop.html
@@ -0,0 +1,21 @@
+<!-- BEGIN loop -->
+loop
+<!-- BEGINELSE -->
+noloop
+<!-- END loop -->
+
+<!-- IF .loop -->
+loop
+<!-- ELSE -->
+noloop
+<!-- ENDIF -->
+
+<!-- IF .loop == 2 -->
+loop
+<!-- ENDIF -->
+
+<!-- BEGIN loop -->
+<!-- BEGIN !block -->
+loop#{loop.S_ROW_COUNT}-block#{block.S_ROW_COUNT}
+<!-- END !block -->
+<!-- END loop -->
diff --git a/tests/template/templates/loop_advanced.html b/tests/template/templates/loop_advanced.html
new file mode 100644
index 0000000000..c75fe55f03
--- /dev/null
+++ b/tests/template/templates/loop_advanced.html
@@ -0,0 +1,19 @@
+<!-- BEGIN loop -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(0) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(0,-1) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(1) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(1,1) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(0,1) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(2,4) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(0,-7) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(-2,6) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
+x
+<!-- BEGIN loop(-2,-1) -->{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW}<!-- END loop -->
diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html
new file mode 100644
index 0000000000..571df97b4c
--- /dev/null
+++ b/tests/template/templates/loop_nested.html
@@ -0,0 +1,8 @@
+<!-- BEGIN outer -->
+ {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
+
+ <!-- BEGIN middle -->
+ {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
+
+ <!-- END middle -->
+<!-- END outer -->
diff --git a/tests/template/templates/loop_vars.html b/tests/template/templates/loop_vars.html
new file mode 100644
index 0000000000..4f02fd2e6c
--- /dev/null
+++ b/tests/template/templates/loop_vars.html
@@ -0,0 +1,21 @@
+<!-- BEGIN loop -->
+<!-- IF loop.S_FIRST_ROW -->first<!-- ENDIF -->
+
+{loop.S_ROW_COUNT}
+
+{loop.VARIABLE}
+
+<!-- IF loop.VARIABLE -->set<!-- ENDIF -->
+
+<!-- IF loop.S_LAST_ROW -->
+last
+<!-- ENDIF -->
+<!-- BEGIN inner -->
+
+{inner.S_ROW_COUNT}
+
+<!-- IF inner.S_LAST_ROW and inner.S_ROW_COUNT and inner.S_NUM_ROWS -->last inner<!-- ENDIF -->
+
+<!-- END inner -->
+<!-- END loop -->
+<!-- IF .loop.inner -->inner loop<!-- ENDIF -->
diff --git a/tests/template/templates/php.html b/tests/template/templates/php.html
new file mode 100644
index 0000000000..07a260cdb3
--- /dev/null
+++ b/tests/template/templates/php.html
@@ -0,0 +1 @@
+<!-- PHP -->echo "test";<!-- ENDPHP -->
diff --git a/tests/template/templates/variable.html b/tests/template/templates/variable.html
new file mode 100644
index 0000000000..f68f91597c
--- /dev/null
+++ b/tests/template/templates/variable.html
@@ -0,0 +1 @@
+{VARIABLE}
diff --git a/tests/test_framework/framework.php b/tests/test_framework/framework.php
new file mode 100644
index 0000000000..abdcd1ad79
--- /dev/null
+++ b/tests/test_framework/framework.php
@@ -0,0 +1,39 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../phpBB/';
+$phpEx = 'php';
+$table_prefix = '';
+
+// If we are on PHP >= 6.0.0 we do not need some code
+if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
+{
+ define('STRIP', false);
+}
+else
+{
+ @set_magic_quotes_runtime(0);
+ define('STRIP', (get_magic_quotes_gpc()) ? true : false);
+}
+
+require_once $phpbb_root_path . 'includes/constants.php';
+
+// require at least PHPUnit 3.3.0
+require_once 'PHPUnit/Runner/Version.php';
+if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<'))
+{
+ trigger_error('PHPUnit >= 3.3.0 required');
+}
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Extensions/Database/TestCase.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';
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
new file mode 100644
index 0000000000..d558874c6f
--- /dev/null
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -0,0 +1,168 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_TestCase
+{
+ protected $test_case_helpers;
+
+ public function init_test_case_helpers()
+ {
+ if (!$this->test_case_helpers)
+ {
+ $this->test_case_helpers = new phpbb_test_case_helpers($this);
+ }
+ }
+
+ 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' => 'odbc',
+ ),
+ 'oracle' => array(
+ 'SCHEMA' => 'oracle',
+ 'DELIM' => '/',
+ 'PDO' => 'oci',
+ ),
+ 'postgres' => array(
+ 'SCHEMA' => 'postgres',
+ 'DELIM' => ';',
+ 'PDO' => 'pgsql',
+ ),
+ 'sqlite' => array(
+ 'SCHEMA' => 'sqlite',
+ 'DELIM' => ';',
+ 'PDO' => 'sqlite',
+ ),
+ );
+
+ if (isset($available_dbms[$dbms]))
+ {
+ return $available_dbms[$dbms];
+ }
+ else
+ {
+ trigger_error('Database unsupported', E_USER_ERROR);
+ }
+ }
+
+ function split_sql_file($sql, $delimiter)
+ {
+ $sql = str_replace("\r" , '', $sql);
+ $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
+
+ $data = array_map('trim', $data);
+
+ // The empty case
+ $end_data = end($data);
+
+ if (empty($end_data))
+ {
+ unset($data[key($data)]);
+ }
+
+ return $data;
+ }
+
+ public function getConnection()
+ {
+ static $already_connected;
+
+ $this->init_test_case_helpers();
+ $database_config = $this->test_case_helpers->get_database_config();
+
+ $dbms_data = $this->get_dbms_data($database_config['dbms']);
+
+ if ($already_connected)
+ {
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+ }
+ else
+ {
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';', $database_config['dbuser'], $database_config['dbpasswd']);
+
+ try
+ {
+ $pdo->exec('DROP DATABASE ' . $database_config['dbname']);
+ }
+ catch (PDOException $e){} // ignore non existent db
+
+ $pdo->exec('CREATE DATABASE ' . $database_config['dbname']);
+
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+
+ if ($database_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_data['SCHEMA'] .= '_41';
+ }
+ else
+ {
+ $dbms_data['SCHEMA'] .= '_40';
+ }
+
+ unset($row, $sth);
+ }
+
+ $sql_query = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms_data['SCHEMA']}_schema.sql"), $dbms_data['DELIM']);
+
+ foreach ($sql_query as $sql)
+ {
+ $pdo->exec($sql);
+ }
+
+ $already_connected = true;
+ }
+
+ return $this->createDefaultDBConnection($pdo, 'testdb');
+ }
+
+ public function new_dbal()
+ {
+ $this->init_test_case_helpers();
+ return $this->test_case_helpers->new_dbal();
+ }
+
+ public function setExpectedTriggerError($errno, $message = '')
+ {
+ $this->init_test_case_helpers();
+ $this->test_case_helpers->setExpectedTriggerError($errno, $message);
+ }
+}
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
new file mode 100644
index 0000000000..af867b29ff
--- /dev/null
+++ b/tests/test_framework/phpbb_test_case.php
@@ -0,0 +1,27 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_test_case extends PHPUnit_Framework_TestCase
+{
+ protected $test_case_helpers;
+
+ public function init_test_case_helpers()
+ {
+ if (!$this->test_case_helpers)
+ {
+ $this->test_case_helpers = new phpbb_test_case_helpers($this);
+ }
+ }
+
+ public function setExpectedTriggerError($errno, $message = '')
+ {
+ $this->init_test_case_helpers();
+ $this->test_case_helpers->setExpectedTriggerError($errno, $message);
+ }
+}
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
new file mode 100644
index 0000000000..0c5932e1ad
--- /dev/null
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -0,0 +1,97 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_test_case_helpers
+{
+ protected $expectedTriggerError = false;
+
+ protected $test_case;
+
+ public function __construct($test_case)
+ {
+ $this->test_case = $test_case;
+ }
+
+ public function get_database_config()
+ {
+ static $show_error = true;
+
+ if (!file_exists('test_config.php'))
+ {
+ if ($show_error)
+ {
+ $show_error = false;
+ }
+ else
+ {
+ $this->test_case->markTestSkipped('Missing test_config.php: See first error.');
+ return;
+ }
+
+ trigger_error("You have to create a test_config.php like this:
+\"<?php
+\$dbms = 'mysqli';
+\$dbhost = 'localhost';
+\$dbport = '';
+\$dbname = 'database';
+\$dbuser = 'user';
+\$dbpasswd = 'password';
+\"
+
+NOTE: The database is dropped and recreated with the phpbb-db-schema! Do NOT specify a database with important data.", E_USER_ERROR);
+ }
+ include('test_config.php');
+
+ return array(
+ 'dbms' => $dbms,
+ 'dbhost' => $dbhost,
+ 'dbport' => $dbport,
+ 'dbname' => $dbname,
+ 'dbuser' => $dbuser,
+ 'dbpasswd' => $dbpasswd,
+ );
+ }
+
+ public function new_dbal()
+ {
+ global $phpbb_root_path, $phpEx;
+ $config = $this->get_database_config();
+
+ require_once '../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']);
+
+ return $db;
+ }
+
+ public function setExpectedTriggerError($errno, $message = '')
+ {
+ $exceptionName = '';
+ switch ($errno)
+ {
+ case E_NOTICE:
+ case E_STRICT:
+ PHPUnit_Framework_Error_Notice::$enabled = true;
+ $exceptionName = 'PHPUnit_Framework_Error_Notice';
+ break;
+
+ case E_WARNING:
+ PHPUnit_Framework_Error_Warning::$enabled = true;
+ $exceptionName = 'PHPUnit_Framework_Error_Warning';
+ break;
+
+ default:
+ $exceptionName = 'PHPUnit_Framework_Error';
+ break;
+ }
+ $this->expectedTriggerError = true;
+ $this->test_case->setExpectedException($exceptionName, (string) $message, $errno);
+ }
+}
diff --git a/tests/text_processing/all_tests.php b/tests/text_processing/all_tests.php
new file mode 100644
index 0000000000..5e759c72ee
--- /dev/null
+++ b/tests/text_processing/all_tests.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_text_processing_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'text_processing/make_clickable.php';
+
+class phpbb_text_processing_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Text Processing Tools');
+
+ $suite->addTestSuite('phpbb_text_processing_make_clickable_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_text_processing_all_tests::main')
+{
+ phpbb_text_processing_all_tests::main();
+}
+
diff --git a/tests/text_processing/make_clickable.php b/tests/text_processing/make_clickable.php
new file mode 100644
index 0000000000..a667dd705e
--- /dev/null
+++ b/tests/text_processing/make_clickable.php
@@ -0,0 +1,106 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/functions.php';
+require_once '../phpBB/includes/functions_content.php';
+
+class phpbb_text_processing_make_clickable_test extends phpbb_test_case
+{
+ public static function make_clickable_data()
+ {
+ // value => whether it should work
+ $prefix_texts = array(
+ '' => true,
+ "np \n" => true,
+ 'bp text ' => true,
+ 'cp text>' => true,
+ 'ep text.' => array('w' => false), // doesn't work for www. type urls, but for everything else
+ );
+ $suffix_texts = array(
+ '' => true,
+ "\n ns" => true,
+ ' bs text.' => true,
+ '&gt;cs text' => true,
+ '&quot;ds text' => true,
+ '. es text.' => true,
+ ', fs text.' => true,
+ );
+
+ $urls = array(
+ 'http://example.com' => array('tag' => 'm', 'url' => false, 'text' => false), // false means same as key
+ 'http://example.com/' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://example.com/path?query=abc' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://example.com/1' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://example.com/some/very/long/path/with/over/55/characters?and=a&amp;long=query&amp;too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&amp;too=1'),
+ 'http://localhost' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://localhost/#abc' => array('tag' => 'm', 'url' => false, 'text' => false),
+
+ 'www.example.com/path/' => array('tag' => 'w', 'url' => 'http://www.example.com/path/', 'text' => false),
+ 'randomwww.example.com/path/' => false,
+
+ 'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false),
+ 'http://thisdomain.org/1' => array('tag' => 'l', 'url' => false, 'text' => '1'),
+ 'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'),
+
+ 'javascript:www.example.com/' => false,
+ );
+
+ $test_data = array();
+
+ // run the test for each combination
+ foreach ($prefix_texts as $prefix => $prefix_success)
+ {
+ foreach ($suffix_texts as $suffix => $suffix_success)
+ {
+ foreach ($urls as $url => $url_type)
+ {
+ $input = $prefix . $url . $suffix;
+ // no valid url => no change
+ $output = $input;
+
+ if (
+ ($prefix_success && $suffix_success && is_array($url_type)) &&
+ // handle except syntax for prefix/suffix
+ (!is_array($prefix_success) || !isset($prefix_success[$url_type['tag']]) || $prefix_success[$url_type['tag']] == true) &&
+ (!is_array($suffix_success) || !isset($suffix_success[$url_type['tag']]) || $suffix_success[$url_type['tag']] == true)
+ )
+ {
+ // false means it's the same as the url, less typing
+ $url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url;
+ $url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url;
+
+ $class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink';
+
+ // replace the url with the desired output format
+ $output = $prefix . '<!-- ' . $url_type['tag'] . ' --><a class="' . $class . '" href="' . $url_type['url'] . '">' . $url_type['text'] . '</a><!-- ' . $url_type['tag'] . ' -->' . $suffix;
+ }
+ $test_data[] = array($input, $output);
+ }
+ }
+ }
+
+ return $test_data;
+ }
+
+ /**
+ * @dataProvider make_clickable_data
+ */
+ public function test_make_clickable($input, $expected)
+ {
+ $result = make_clickable($input, 'http://thisdomain.org');
+
+ $label = 'Making text clickable: ' . $input;
+ $this->assertEquals($expected, $result, $label);
+ }
+
+}
+
diff --git a/tests/utf/all_tests.php b/tests/utf/all_tests.php
new file mode 100644
index 0000000000..0d5d44d695
--- /dev/null
+++ b/tests/utf/all_tests.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_utf_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'utf/utf8_wordwrap_test.php';
+require_once 'utf/utf8_clean_string_test.php';
+
+class phpbb_utf_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Unicode Transformation Format');
+
+ $suite->addTestSuite('phpbb_utf_utf8_wordwrap_test');
+ $suite->addTestSuite('phpbb_utf_utf8_clean_string_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_utf_all_tests::main')
+{
+ phpbb_utf_all_tests::main();
+}
+
diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php
new file mode 100644
index 0000000000..870ad76fc4
--- /dev/null
+++ b/tests/utf/utf8_clean_string_test.php
@@ -0,0 +1,32 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/utf/utf_tools.php';
+
+class phpbb_utf_utf8_clean_string_test extends phpbb_test_case
+{
+ public static function cleanable_strings()
+ {
+ return array(
+ array('MiXed CaSe', 'mixed case', 'Checking case folding'),
+ array(' many spaces ', 'many spaces', 'Checking whitespace reduction'),
+ array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", 'weird characters', 'Checking confusables replacement'),
+ );
+ }
+
+ /**
+ * @dataProvider cleanable_strings
+ */
+ public function test_utf8_clean_string($input, $output, $label)
+ {
+ $this->assertEquals($output, utf8_clean_string($input), $label);
+ }
+}
+
diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php
new file mode 100644
index 0000000000..ef1165a897
--- /dev/null
+++ b/tests/utf/utf8_wordwrap_test.php
@@ -0,0 +1,84 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/utf/utf_tools.php';
+
+class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case
+{
+ public function test_utf8_wordwrap_ascii()
+ {
+ // if the input is all ascii it should work exactly like php's wordwrap
+
+ $text = 'The quick brown fox jumped over the lazy dog.';
+
+ $php_wordwrap = wordwrap($text, 20);
+ $phpbb_utf8_wordwrap = utf8_wordwrap($text, 20);
+ $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, "Checking ASCII standard behaviour with length 20");
+
+ $php_wordwrap = wordwrap($text, 30, "<br />\n");
+ $phpbb_utf8_wordwrap = utf8_wordwrap($text, 30, "<br />\n");
+ $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, "Checking ASCII special break string with length 30");
+
+ $text = 'A very long woooooooooooord.';
+
+ $php_wordwrap = wordwrap($text, 8, "\n");
+ $phpbb_utf8_wordwrap = utf8_wordwrap($text, 8, "\n");
+ $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, 'Checking ASCII not cutting long words');
+
+ $php_wordwrap = wordwrap($text, 8, "\n", true);
+ $phpbb_utf8_wordwrap = utf8_wordwrap($text, 8, "\n", true);
+ $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, 'Checking ASCII cutting long words');
+ }
+
+ /**
+ * Helper function that generates meaningless greek text
+ */
+ private function turn_into_greek($string)
+ {
+ $greek_chars = array("\xCE\x90", "\xCE\x91", "\xCE\x92", "\xCE\x93", "\xCE\x94", "\xCE\x95", "\xCE\x96", "\xCE\x97", "\xCE\x98", "\xCE\x99");
+
+ $greek = '';
+ for ($i = 0, $n = strlen($string); $i < $n; $i++)
+ {
+ // replace each number with the character from the array
+ if (ctype_digit($string[$i]))
+ {
+ $greek .= $greek_chars[(int) $string[$i]];
+ }
+ else
+ {
+ $greek .= $string[$i];
+ }
+ }
+
+ return $greek;
+ }
+
+ public function test_utf8_wordwrap_utf8()
+ {
+ $text = "0123456 0123 012345 01234";
+ $greek = $this->turn_into_greek($text);
+
+ $expected = $this->turn_into_greek(wordwrap($text, 10));
+ $phpbb_utf8_wordwrap = utf8_wordwrap($greek, 10);
+ $this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 standard behaviour with length 10');
+ }
+
+ public function test_utf8_wordwrap_utf8_cut()
+ {
+ $text = "0123456 0123 012345 01234";
+ $greek = $this->turn_into_greek($text);
+
+ $expected = $this->turn_into_greek(wordwrap($text, 5, "\n", true));
+ $phpbb_utf8_wordwrap = utf8_wordwrap($greek, 5, "\n", true);
+ $this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 cutting long words');
+ }
+}
+