aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xgit-tools/hooks/commit-msg41
-rwxr-xr-xgit-tools/hooks/prepare-commit-msg4
-rwxr-xr-xgit-tools/merge.php175
-rw-r--r--phpBB/common.php5
-rw-r--r--phpBB/cron.php96
-rw-r--r--phpBB/docs/AUTHORS23
-rw-r--r--phpBB/docs/INSTALL.html7
-rw-r--r--phpBB/docs/coding-guidelines.html7
-rw-r--r--phpBB/docs/nginx.sample.conf33
-rw-r--r--phpBB/includes/acm/acm_redis.php155
-rw-r--r--phpBB/includes/acp/acp_disallow.php12
-rw-r--r--phpBB/includes/acp/acp_icons.php4
-rw-r--r--phpBB/includes/acp/acp_search.php18
-rw-r--r--phpBB/includes/acp/acp_styles.php2
-rw-r--r--phpBB/includes/captcha/captcha_gd.php54
-rw-r--r--phpBB/includes/db/dbal.php10
-rw-r--r--phpBB/includes/db/firebird.php49
-rw-r--r--phpBB/includes/db/mssqlnative.php12
-rw-r--r--phpBB/includes/db/oracle.php3
-rw-r--r--phpBB/includes/db/postgres.php36
-rw-r--r--phpBB/includes/error_collector.php61
-rw-r--r--phpBB/includes/functions.php14
-rw-r--r--phpBB/includes/functions_user.php51
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php2
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php2
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/install/install_install.php2
-rw-r--r--phpBB/language/en/acp/posting.php7
-rw-r--r--phpBB/language/en/common.php3
-rw-r--r--phpBB/memberlist.php30
-rw-r--r--phpBB/styles/prosilver/template/attachment.html4
-rw-r--r--phpBB/styles/prosilver/template/ucp_groups_manage.html2
-rw-r--r--phpBB/styles/prosilver/template/viewforum_body.html2
-rw-r--r--phpBB/styles/subsilver2/template/attachment.html4
-rw-r--r--phpBB/viewtopic.php2
-rw-r--r--tests/bootstrap.php4
-rw-r--r--tests/mock/cache.php5
-rw-r--r--tests/regex/password_complexity_test.php81
-rw-r--r--tests/security/hash_test.php21
-rw-r--r--tests/session/continue_test.php14
-rw-r--r--tests/session/fixtures/sessions_full.xml4
-rw-r--r--tests/template/template_test.php247
-rw-r--r--tests/template/templates/includephp.html2
-rw-r--r--tests/template/templates/loop_nested.html4
45 files changed, 916 insertions, 404 deletions
diff --git a/.gitignore b/.gitignore
index c417bf01c1..8298f5a894 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
*~
phpunit.xml
phpBB/cache/*.php
+phpBB/cache/queue.php.lock
phpBB/config.php
phpBB/files/*
+phpBB/images/avatars/gallery/*
phpBB/images/avatars/upload/*
phpBB/store/*
tests/phpbb_unit_tests.sqlite2
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg
index a6777ff9c9..4f6ae71d4b 100755
--- a/git-tools/hooks/commit-msg
+++ b/git-tools/hooks/commit-msg
@@ -55,12 +55,24 @@ quit()
fi
}
-msg=$(grep -nE '.{81,}' "$1");
+# Check for empty commit message
+if ! grep -qv '^#' "$1"
+then
+ # Commit message is empty (or contains only comments).
+ # Let git handle this.
+ # It will abort with a message like so:
+ #
+ # Aborting commit due to empty commit message.
+ exit 0
+fi
+
+msg=$(grep -v '^#' "$1" |grep -nE '.{81,}')
if [ $? -eq 0 ]
then
- echo "The following lines are greater than 80 characters long:\n" >&2;
- echo $msg >&2;
+ echo "The following lines are greater than 80 characters long:" >&2;
+ echo >&2
+ echo "$msg" >&2;
quit $ERR_LENGTH;
fi
@@ -107,7 +119,19 @@ do
case $expect in
"header")
err=$ERR_HEADER;
- echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
+ echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] .+$"
+ result=$?
+ if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
+ then
+ # Don't be too strict.
+ # Commits may be temporary, intended to be squashed later.
+ # Just issue a warning here.
+ echo "Warning: heading should be a sentence beginning with a capital letter." 1>&2
+ echo "You entered:" 1>&2
+ echo "$line" 1>&2
+ fi
+ # restore exit code
+ (exit $result)
;;
"empty")
err=$ERR_EMPTY;
@@ -128,6 +152,10 @@ do
# Should not end up here
false
;;
+ "possibly-eof")
+ # Allow empty and/or comment lines at the end
+ ! tail -n +"$i" "$1" |grep -qvE '^($|#)'
+ ;;
"comment")
echo "$line" | grep -Eq "^#";
;;
@@ -188,7 +216,7 @@ do
in_description=1;
;;
"footer")
- expecting="footer eof";
+ expecting="footer possibly-eof";
if [ "$tickets" = "" ]
then
tickets="$line";
@@ -199,6 +227,9 @@ do
"comment")
# Comments should expect the same thing again
;;
+ "possibly-eof")
+ expecting="eof";
+ ;;
*)
echo "Unrecognised token $expect" >&2;
quit 254;
diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg
index 2bf25e58a4..11d2b6b2f2 100755
--- a/git-tools/hooks/prepare-commit-msg
+++ b/git-tools/hooks/prepare-commit-msg
@@ -35,8 +35,8 @@ then
# Branch is prefixed with 'ticket/', append ticket ID to message
if [ "$branch" != "${branch##ticket/}" ];
then
- tail="\n\nPHPBB3-${branch##ticket/}";
+ tail="$(printf "\n\nPHPBB3-${branch##ticket/}")";
fi
- echo "[$branch]$tail $(cat "$1")" > "$1"
+ echo "[$branch] $tail$(cat "$1")" > "$1"
fi
diff --git a/git-tools/merge.php b/git-tools/merge.php
new file mode 100755
index 0000000000..cbd84b896f
--- /dev/null
+++ b/git-tools/merge.php
@@ -0,0 +1,175 @@
+#!/usr/bin/env php
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+function show_usage()
+{
+ $filename = basename(__FILE__);
+
+ echo "$filename merges a github pull request.\n";
+ echo "\n";
+
+ echo "Usage: [php] $filename -p pull_request_id [OPTIONS]\n";
+ echo "\n";
+
+ echo "Options:\n";
+ echo " -p pull_request_id The pull request id to be merged (mandatory)\n";
+ echo " -r remote Remote of upstream, defaults to 'upstream' (optional)\n";
+ echo " -d Outputs the commands instead of running them (optional)\n";
+ echo " -h This help text\n";
+
+ exit(2);
+}
+
+// Handle arguments
+$opts = getopt('p:r:dh');
+
+if (empty($opts) || isset($opts['h']))
+{
+ show_usage();
+}
+
+$pull_id = get_arg($opts, 'p', '');
+$remote = get_arg($opts, 'r', 'upstream');
+$dry_run = !get_arg($opts, 'd', true);
+
+try
+{
+ exit(work($pull_id, $remote));
+}
+catch (RuntimeException $e)
+{
+ echo $e->getMessage();
+ exit($e->getCode());
+}
+
+function work($pull_id, $remote)
+{
+ // Get some basic data
+ $pull = get_pull('phpbb', 'phpbb3', $pull_id);
+
+ if (!$pull_id)
+ {
+ show_usage();
+ }
+
+ if ($pull['state'] != 'open')
+ {
+ throw new RuntimeException(sprintf("Error: pull request is closed\n",
+ $target_branch), 5);
+ }
+
+ $pull_user = $pull['head'][0];
+ $pull_branch = $pull['head'][1];
+ $target_branch = $pull['base'][1];
+
+ switch ($target_branch)
+ {
+ case 'develop-olympus':
+ run("git checkout develop-olympus");
+ run("git pull $remote develop-olympus");
+
+ add_remote($pull_user, 'phpbb3');
+ run("git fetch $pull_user");
+ run("git merge --no-ff $pull_user/$pull_branch");
+ run("phpunit");
+
+ run("git checkout develop");
+ run("git pull $remote develop");
+ run("git merge --no-ff develop-olympus");
+ run("phpunit");
+ break;
+
+ case 'develop':
+ run("git checkout develop");
+ run("git pull $remote develop");
+
+ add_remote($pull_user, 'phpbb3');
+ run("git fetch $pull_user");
+ run("git merge --no-ff $pull_user/$pull_branch");
+ run("phpunit");
+ break;
+
+ default:
+ throw new RuntimeException(sprintf("Error: pull request target branch '%s' is not a main branch\n",
+ $target_branch), 5);
+ break;
+ }
+}
+
+function add_remote($username, $repository, $pushable = false)
+{
+ $url = get_repository_url($username, $repository, false);
+ run("git remote add $username $url", true);
+
+ if ($pushable)
+ {
+ $ssh_url = get_repository_url($username, $repository, true);
+ run("git remote set-url --push $username $ssh_url");
+ }
+}
+
+function get_repository_url($username, $repository, $ssh = false)
+{
+ $url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/';
+
+ return $url_base . $username . '/' . $repository . '.git';
+}
+
+function api_request($query)
+{
+ $contents = file_get_contents("http://github.com/api/v2/json/$query");
+
+ if ($contents === false)
+ {
+ throw new RuntimeException("Error: failed to retrieve pull request data\n", 4);
+ }
+
+ return json_decode($contents);
+}
+
+function get_pull($username, $repository, $pull_id)
+{
+ $request = api_request("pulls/$username/$repository/$pull_id");
+
+ $pull = $request->pull;
+
+ $pull_data = array(
+ 'base' => array($pull->base->user->login, $pull->base->ref),
+ 'head' => array($pull->head->user->login, $pull->head->ref),
+ 'state' => $pull->state,
+ );
+
+ return $pull_data;
+}
+
+function get_arg($array, $index, $default)
+{
+ return isset($array[$index]) ? $array[$index] : $default;
+}
+
+function run($cmd, $ignore_fail = false)
+{
+ global $dry_run;
+
+ if (!empty($dry_run))
+ {
+ echo "$cmd\n";
+ }
+ else
+ {
+ passthru(escapeshellcmd($cmd), $status);
+
+ if ($status != 0 && !$ignore_fail)
+ {
+ throw new RuntimeException(sprintf("Error: command '%s' failed with status %s'\n",
+ $cmd, $status), 6);
+ }
+ }
+}
diff --git a/phpBB/common.php b/phpBB/common.php
index c8b2fb9609..ae174c8441 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -118,11 +118,6 @@ else
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
}
-if (defined('IN_CRON'))
-{
- $phpbb_root_path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
-}
-
if (file_exists($phpbb_root_path . 'config.' . $phpEx))
{
require($phpbb_root_path . 'config.' . $phpEx);
diff --git a/phpBB/cron.php b/phpBB/cron.php
index 3993a149b5..8000066c92 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -21,7 +21,6 @@ $user->session_begin(false);
$auth->acl($user->data);
$cron_type = request_var('cron_type', '');
-$use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
// Output transparent gif
header('Cache-Control: no-cache');
@@ -30,10 +29,9 @@ header('Content-length: 43');
echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
-// test without flush ;)
-// flush();
+// Flush here to prevent browser from showing the page as loading while running cron.
+flush();
-//
if (!isset($config['cron_lock']))
{
set_config('cron_lock', '0', true);
@@ -79,23 +77,10 @@ switch ($cron_type)
break;
}
- // A user reported using the mail() function while using shutdown does not work. We do not want to risk that.
- if ($use_shutdown_function && !$config['smtp_delivery'])
- {
- $use_shutdown_function = false;
- }
-
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
$queue = new queue();
- if ($use_shutdown_function)
- {
- register_shutdown_function(array(&$queue, 'process'));
- }
- else
- {
- $queue->process();
- }
+ $queue->process();
break;
@@ -106,14 +91,7 @@ switch ($cron_type)
break;
}
- if ($use_shutdown_function)
- {
- register_shutdown_function(array(&$cache, 'tidy'));
- }
- else
- {
- $cache->tidy();
- }
+ $cache->tidy();
break;
@@ -138,14 +116,7 @@ switch ($cron_type)
break;
}
- if ($use_shutdown_function)
- {
- register_shutdown_function(array(&$search, 'tidy'));
- }
- else
- {
- $search->tidy();
- }
+ $search->tidy();
break;
@@ -158,14 +129,7 @@ switch ($cron_type)
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
- if ($use_shutdown_function)
- {
- register_shutdown_function('tidy_warnings');
- }
- else
- {
- tidy_warnings();
- }
+ tidy_warnings();
break;
@@ -178,14 +142,7 @@ switch ($cron_type)
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
- if ($use_shutdown_function)
- {
- register_shutdown_function('tidy_database');
- }
- else
- {
- tidy_database();
- }
+ tidy_database();
break;
@@ -196,14 +153,7 @@ switch ($cron_type)
break;
}
- if ($use_shutdown_function)
- {
- register_shutdown_function(array(&$user, 'session_gc'));
- }
- else
- {
- $user->session_gc();
- }
+ $user->session_gc();
break;
@@ -230,26 +180,12 @@ switch ($cron_type)
if ($row['prune_days'])
{
- if ($use_shutdown_function)
- {
- register_shutdown_function('auto_prune', $row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
- }
- else
- {
- auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
- }
+ auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
}
if ($row['prune_viewed'])
{
- if ($use_shutdown_function)
- {
- register_shutdown_function('auto_prune', $row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
- }
- else
- {
- auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
- }
+ auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
}
}
@@ -257,16 +193,8 @@ switch ($cron_type)
}
// Unloading cache and closing db after having done the dirty work.
-if ($use_shutdown_function)
-{
- register_shutdown_function('unlock_cron');
- register_shutdown_function('garbage_collection');
-}
-else
-{
- unlock_cron();
- garbage_collection();
-}
+unlock_cron();
+garbage_collection();
exit;
diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS
index 1dfb80141c..83feca009b 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -22,20 +22,18 @@ involved in phpBB.
phpBB Lead Developer: naderman (Nils Adermann)
-phpBB Developers: A_Jelly_Doughnut (Josh Woody)
- Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
+phpBB Developers: Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
APTX (Marek A. R.)
bantu (Andreas Fischer)
- dhn (Dominik Dröscher)
+ ckwalsh (Cullen Walsh)
igorw (Igor Wiedler)
kellanved (Henry Sudhof)
nickvergessen (Joas Schilling)
+ nn- (Oleg Pudeyev)
rxu (Ruslan Uzdenov)
- Terrafrost (Jim Wigginton)
ToonArmy (Chris Smith)
-Contributions by: Brainy (Cullen Walsh)
- leviatan21 (Gabriel Vazquez)
+Contributions by: leviatan21 (Gabriel Vazquez)
Raimon (Raimon Meuldijk)
Xore (Robert Hetzler)
@@ -47,11 +45,14 @@ phpBB Project Manager: theFinn (James Atkinson) [Founder - 04/2007]
phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005]
-phpBB Developers: Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
- BartVB (Bart van Bragt) [11/2000 - 03/2006]
- DavidMJ (David M.) [12/2005 - 08/2009]
- GrahamJE (Graham Eames) [09/2005 - 11/2006]
- Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
+phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
+ Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
+ BartVB (Bart van Bragt) [11/2000 - 03/2006]
+ DavidMJ (David M.) [12/2005 - 08/2009]
+ dhn (Dominik Dröscher) [05/2007 - 01/2011]
+ GrahamJE (Graham Eames) [09/2005 - 11/2006]
+ TerraFrost (Jim Wigginton) [04/2009 - 01/2011]
+ Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
-- Copyrights --
diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html
index 4af185beb3..9f635fe50b 100644
--- a/phpBB/docs/INSTALL.html
+++ b/phpBB/docs/INSTALL.html
@@ -79,6 +79,7 @@
<li><a href="#postinstall">Important (security related) post-Install tasks for all installation methods</a>
<ol style="list-style-type: lower-roman;">
<li><a href="#avatars">Uploadable avatars</a></li>
+ <li><a href="#webserver_configuration">Webserver configuration</a></li>
</ol>
</li>
<li><a href="#disclaimer">Disclaimer</a></li>
@@ -408,6 +409,12 @@
<p>Please be aware that setting a directories permissions to global write access is a potential security issue. While it is unlikely that anything nasty will occur (such as all the avatars being deleted) there are always people out there to cause trouble. Therefore you should monitor this directory and if possible make regular backups.</p>
+<a name="webserver_configuration"></a><h3>6.ii. Webserver configuration</h3>
+
+ <p>Depending on your web server you may have to configure your server to deny web access to the <code>cache/</code>, <code>files/</code>, <code>store/</code> and other directories. This is to prevent users from accessing sensitive files.</p>
+
+ <p>For <strong>apache</strong> there are <code>.htaccess</code> files already in place to do this for you. For other webservers you will have to adjust the configuration yourself. Sample files for <strong>nginx</strong> and <strong>lighttpd</strong> to help you get started may be found in docs directory.</p>
+
</div>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 7434fa4870..cd3c09f6fb 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -240,6 +240,11 @@ PHPBB_ACM_MEMCACHE_PORT (overwrite memcached port, default is 11211)
PHPBB_ACM_MEMCACHE_COMPRESS (overwrite memcached compress setting, default is disabled)
PHPBB_ACM_MEMCACHE_HOST (overwrite memcached host name, default is localhost)
+PHPBB_ACM_REDIS_HOST (overwrite redis host name, default is localhost)
+PHPBB_ACM_REDIS_PORT (overwrite redis port, default is 6379)
+PHPBB_ACM_REDIS_PASSWORD (overwrite redis password, default is empty)
+PHPBB_ACM_REDIS_DB (overwrite redis default database)
+
PHPBB_QA (Set board to QA-Mode, which means the updater also checks for RC-releases)
</pre></div>
@@ -1018,7 +1023,7 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<h4>General function usage: </h4>
- <p>Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistant over the code.</p>
+ <p>Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistent over the code.</p>
<ul>
<li>
diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf
index 2a11e057c5..40b6ee76da 100644
--- a/phpBB/docs/nginx.sample.conf
+++ b/phpBB/docs/nginx.sample.conf
@@ -10,14 +10,23 @@ http {
gzip_vary on;
gzip_http_version 1.1;
gzip_min_length 700;
+
+ # Compression levels over 6 do not give an appreciable improvement
+ # in compression ratio, but take more resources.
gzip_comp_level 6;
- gzip_disable "MSIE [1-6]\.";
+
+ # IE 6 and lower do not support gzip with Vary correctly.
+ gzip_disable "msie6";
+ # Before nginx 0.7.63:
+ #gzip_disable "MSIE [1-6]\.";
# Catch-all server for requests to invalid hosts.
# Also catches vulnerability scanners probing IP addresses.
- # Should be first.
server {
- listen 80;
+ # default specifies that this block is to be used when
+ # no other block matches.
+ listen 80 default;
+
server_name bogus;
return 444;
root /var/empty;
@@ -26,14 +35,20 @@ http {
# If you have domains with and without www prefix,
# redirect one to the other.
server {
- listen 80;
+ # Default port is 80.
+ #listen 80;
+
server_name myforums.com;
- rewrite ^(.*)$ http://www.myforums.com$1 permanent;
+
+ # A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites:
+ rewrite ^ http://www.myforums.com$request_uri permanent;
+ # Equivalent to:
+ #rewrite ^(.*)$ http://www.myforums.com$1 permanent;
}
# The actual board domain.
server {
- listen 80;
+ #listen 80;
server_name www.myforums.com;
root /path/to/phpbb;
@@ -45,8 +60,10 @@ http {
# Deny access to internal phpbb files.
location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) {
- internal;
deny all;
+ # deny was ignored before 0.8.40 for connections over IPv6.
+ # Use internal directive to prohibit access on older versions.
+ internal;
}
# Pass the php scripts to fastcgi server specified in upstream declaration.
@@ -60,8 +77,8 @@ http {
# Deny access to version control system directories.
location ~ /\.svn|/\.git {
- internal;
deny all;
+ internal;
}
}
diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php
new file mode 100644
index 0000000000..8954b9d0e7
--- /dev/null
+++ b/phpBB/includes/acm/acm_redis.php
@@ -0,0 +1,155 @@
+<?php
+/**
+*
+* @package acm
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+// Include the abstract base
+if (!class_exists('acm_memory'))
+{
+ require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
+}
+
+if (!defined('PHPBB_ACM_REDIS_PORT'))
+{
+ define('PHPBB_ACM_REDIS_PORT', 6379);
+}
+
+if (!defined('PHPBB_ACM_REDIS_HOST'))
+{
+ define('PHPBB_ACM_REDIS_HOST', 'localhost');
+}
+
+if (!defined('PHPBB_ACM_REDIS'))
+{
+ //can define multiple servers with host1/port1,host2/port2 format
+ define('PHPBB_ACM_REDIS', PHPBB_ACM_REDIS_HOST . '/' . PHPBB_ACM_REDIS_PORT);
+}
+
+/**
+* ACM for Redis
+*
+* Compatible with the php extension phpredis available
+* at https://github.com/nicolasff/phpredis
+*
+* @package acm
+*/
+class acm extends acm_memory
+{
+ var $extension = 'redis';
+
+ var $redis;
+
+ function acm()
+ {
+ // Call the parent constructor
+ parent::acm_memory();
+
+ $this->redis = new Redis();
+ foreach (explode(',', PHPBB_ACM_REDIS) as $server)
+ {
+ $parts = explode('/', $server);
+ $this->redis->connect(trim($parts[0]), trim($parts[1]));
+ }
+
+ if (defined('PHPBB_ACM_REDIS_PASSWORD'))
+ {
+ if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD))
+ {
+ global $acm_type;
+
+ trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR);
+ }
+ }
+
+ $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
+ $this->redis->setOption(Redis::OPT_PREFIX, $this->key_prefix);
+
+ if (defined('PHPBB_ACM_REDIS_DB'))
+ {
+ if (!$this->redis->select(PHPBB_ACM_REDIS_DB))
+ {
+ global $acm_type;
+
+ trigger_error("Incorrect database for the ACM module $acm_type.", E_USER_ERROR);
+ }
+ }
+ }
+
+ /**
+ * Unload the cache resources
+ *
+ * @return void
+ */
+ function unload()
+ {
+ parent::unload();
+
+ $this->redis->close();
+ }
+
+ /**
+ * Purge cache data
+ *
+ * @return void
+ */
+ function purge()
+ {
+ $this->redis->flushDB();
+
+ parent::purge();
+ }
+
+ /**
+ * Fetch an item from the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @return mixed Cached data
+ */
+ function _read($var)
+ {
+ return $this->redis->get($var);
+ }
+
+ /**
+ * Store data in the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @param mixed $data Data to store
+ * @param int $ttl Time-to-live of cached data
+ * @return bool True if the operation succeeded
+ */
+ function _write($var, $data, $ttl = 2592000)
+ {
+ return $this->redis->setex($var, $ttl, $data);
+ }
+
+ /**
+ * Remove an item from the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @return bool True if the operation succeeded
+ */
+ function _delete($var)
+ {
+ if ($this->redis->delete($var) > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/phpBB/includes/acp/acp_disallow.php b/phpBB/includes/acp/acp_disallow.php
index 9549955cc8..e2176b7bcd 100644
--- a/phpBB/includes/acp/acp_disallow.php
+++ b/phpBB/includes/acp/acp_disallow.php
@@ -56,6 +56,18 @@ class acp_disallow
trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
+ $sql = 'SELECT disallow_id
+ FROM ' . DISALLOW_TABLE . "
+ WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if ($row)
+ {
+ trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+
$sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
$db->sql_query($sql);
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index 3d64a2acda..24f6cbbcbf 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -394,6 +394,10 @@ class acp_icons
{
// skip images where add wasn't checked
}
+ else if (!file_exists($phpbb_root_path . $img_path . '/' . $image))
+ {
+ $errors[$image] = 'SMILIE_NO_FILE';
+ }
else
{
if ($image_width[$image] == 0 || $image_height[$image] == 0)
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 930c8d2a26..0cd67b1c34 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -392,7 +392,18 @@ class acp_search
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
$result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ $buffer = $db->sql_buffer_nested_transactions();
+
+ if ($buffer)
+ {
+ $rows = $db->sql_fetchrowset($result);
+ $rows[] = false; // indicate end of array for while loop below
+
+ $db->sql_freeresult($result);
+ }
+
+ $i = 0;
+ while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result)))
{
// Indexing enabled for this forum or global announcement?
// Global announcements get indexed by default.
@@ -402,7 +413,10 @@ class acp_search
}
$row_count++;
}
- $db->sql_freeresult($result);
+ if (!$buffer)
+ {
+ $db->sql_freeresult($result);
+ }
$post_counter += $this->batch_size;
}
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 0f157ceff3..37cf8d1f72 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -716,7 +716,7 @@ parse_css_file = {PARSE_CSS_FILE}
$save_changes = (isset($_POST['save'])) ? true : false;
// make sure template_file path doesn't go upwards
- $template_file = str_replace('..', '.', $template_file);
+ $template_file = preg_replace('#\.{2,}#', '.', $template_file);
// Retrieve some information about the template
$sql = 'SELECT template_storedb, template_path, template_name
diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php
index 96e39af85b..5f24618aab 100644
--- a/phpBB/includes/captcha/captcha_gd.php
+++ b/phpBB/includes/captcha/captcha_gd.php
@@ -112,7 +112,7 @@ class captcha
$noise_bitmaps = $this->captcha_noise_bg_bitmaps();
for ($i = 0; $i < $code_len; ++$i)
{
- $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, count($noise_bitmaps['data'])));
+ $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, sizeof($noise_bitmaps['data'])));
list($min, $max) = $noise[$i]->range();
//$box = $noise[$i]->dimensions($sizes[$i]);
@@ -1669,32 +1669,32 @@ class captcha
'height' => 15,
'data' => array(
- 'A' => $chars['A'][mt_rand(0, min(count($chars['A']), $config['captcha_gd_fonts']) -1)],
- 'B' => $chars['B'][mt_rand(0, min(count($chars['B']), $config['captcha_gd_fonts']) -1)],
- 'C' => $chars['C'][mt_rand(0, min(count($chars['C']), $config['captcha_gd_fonts']) -1)],
- 'D' => $chars['D'][mt_rand(0, min(count($chars['D']), $config['captcha_gd_fonts']) -1)],
- 'E' => $chars['E'][mt_rand(0, min(count($chars['E']), $config['captcha_gd_fonts']) -1)],
- 'F' => $chars['F'][mt_rand(0, min(count($chars['F']), $config['captcha_gd_fonts']) -1)],
- 'G' => $chars['G'][mt_rand(0, min(count($chars['G']), $config['captcha_gd_fonts']) -1)],
- 'H' => $chars['H'][mt_rand(0, min(count($chars['H']), $config['captcha_gd_fonts']) -1)],
- 'I' => $chars['I'][mt_rand(0, min(count($chars['I']), $config['captcha_gd_fonts']) -1)],
- 'J' => $chars['J'][mt_rand(0, min(count($chars['J']), $config['captcha_gd_fonts']) -1)],
- 'K' => $chars['K'][mt_rand(0, min(count($chars['K']), $config['captcha_gd_fonts']) -1)],
- 'L' => $chars['L'][mt_rand(0, min(count($chars['L']), $config['captcha_gd_fonts']) -1)],
- 'M' => $chars['M'][mt_rand(0, min(count($chars['M']), $config['captcha_gd_fonts']) -1)],
- 'N' => $chars['N'][mt_rand(0, min(count($chars['N']), $config['captcha_gd_fonts']) -1)],
- 'O' => $chars['O'][mt_rand(0, min(count($chars['O']), $config['captcha_gd_fonts']) -1)],
- 'P' => $chars['P'][mt_rand(0, min(count($chars['P']), $config['captcha_gd_fonts']) -1)],
- 'Q' => $chars['Q'][mt_rand(0, min(count($chars['Q']), $config['captcha_gd_fonts']) -1)],
- 'R' => $chars['R'][mt_rand(0, min(count($chars['R']), $config['captcha_gd_fonts']) -1)],
- 'S' => $chars['S'][mt_rand(0, min(count($chars['S']), $config['captcha_gd_fonts']) -1)],
- 'T' => $chars['T'][mt_rand(0, min(count($chars['T']), $config['captcha_gd_fonts']) -1)],
- 'U' => $chars['U'][mt_rand(0, min(count($chars['U']), $config['captcha_gd_fonts']) -1)],
- 'V' => $chars['V'][mt_rand(0, min(count($chars['V']), $config['captcha_gd_fonts']) -1)],
- 'W' => $chars['W'][mt_rand(0, min(count($chars['W']), $config['captcha_gd_fonts']) -1)],
- 'X' => $chars['X'][mt_rand(0, min(count($chars['X']), $config['captcha_gd_fonts']) -1)],
- 'Y' => $chars['Y'][mt_rand(0, min(count($chars['Y']), $config['captcha_gd_fonts']) -1)],
- 'Z' => $chars['Z'][mt_rand(0, min(count($chars['Z']), $config['captcha_gd_fonts']) -1)],
+ 'A' => $chars['A'][mt_rand(0, min(sizeof($chars['A']), $config['captcha_gd_fonts']) -1)],
+ 'B' => $chars['B'][mt_rand(0, min(sizeof($chars['B']), $config['captcha_gd_fonts']) -1)],
+ 'C' => $chars['C'][mt_rand(0, min(sizeof($chars['C']), $config['captcha_gd_fonts']) -1)],
+ 'D' => $chars['D'][mt_rand(0, min(sizeof($chars['D']), $config['captcha_gd_fonts']) -1)],
+ 'E' => $chars['E'][mt_rand(0, min(sizeof($chars['E']), $config['captcha_gd_fonts']) -1)],
+ 'F' => $chars['F'][mt_rand(0, min(sizeof($chars['F']), $config['captcha_gd_fonts']) -1)],
+ 'G' => $chars['G'][mt_rand(0, min(sizeof($chars['G']), $config['captcha_gd_fonts']) -1)],
+ 'H' => $chars['H'][mt_rand(0, min(sizeof($chars['H']), $config['captcha_gd_fonts']) -1)],
+ 'I' => $chars['I'][mt_rand(0, min(sizeof($chars['I']), $config['captcha_gd_fonts']) -1)],
+ 'J' => $chars['J'][mt_rand(0, min(sizeof($chars['J']), $config['captcha_gd_fonts']) -1)],
+ 'K' => $chars['K'][mt_rand(0, min(sizeof($chars['K']), $config['captcha_gd_fonts']) -1)],
+ 'L' => $chars['L'][mt_rand(0, min(sizeof($chars['L']), $config['captcha_gd_fonts']) -1)],
+ 'M' => $chars['M'][mt_rand(0, min(sizeof($chars['M']), $config['captcha_gd_fonts']) -1)],
+ 'N' => $chars['N'][mt_rand(0, min(sizeof($chars['N']), $config['captcha_gd_fonts']) -1)],
+ 'O' => $chars['O'][mt_rand(0, min(sizeof($chars['O']), $config['captcha_gd_fonts']) -1)],
+ 'P' => $chars['P'][mt_rand(0, min(sizeof($chars['P']), $config['captcha_gd_fonts']) -1)],
+ 'Q' => $chars['Q'][mt_rand(0, min(sizeof($chars['Q']), $config['captcha_gd_fonts']) -1)],
+ 'R' => $chars['R'][mt_rand(0, min(sizeof($chars['R']), $config['captcha_gd_fonts']) -1)],
+ 'S' => $chars['S'][mt_rand(0, min(sizeof($chars['S']), $config['captcha_gd_fonts']) -1)],
+ 'T' => $chars['T'][mt_rand(0, min(sizeof($chars['T']), $config['captcha_gd_fonts']) -1)],
+ 'U' => $chars['U'][mt_rand(0, min(sizeof($chars['U']), $config['captcha_gd_fonts']) -1)],
+ 'V' => $chars['V'][mt_rand(0, min(sizeof($chars['V']), $config['captcha_gd_fonts']) -1)],
+ 'W' => $chars['W'][mt_rand(0, min(sizeof($chars['W']), $config['captcha_gd_fonts']) -1)],
+ 'X' => $chars['X'][mt_rand(0, min(sizeof($chars['X']), $config['captcha_gd_fonts']) -1)],
+ 'Y' => $chars['Y'][mt_rand(0, min(sizeof($chars['Y']), $config['captcha_gd_fonts']) -1)],
+ 'Z' => $chars['Z'][mt_rand(0, min(sizeof($chars['Z']), $config['captcha_gd_fonts']) -1)],
'1' => array(
array(0,0,0,1,1,0,0,0,0),
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 5d8d5fbd47..d7860fc8bc 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -242,6 +242,16 @@ class dbal
}
/**
+ * Returns whether results of a query need to be buffered to run a transaction while iterating over them.
+ *
+ * @return bool Whether buffering is required.
+ */
+ function sql_buffer_nested_transaction()
+ {
+ return false;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 6f60dd5dad..7e3f15ed1d 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -28,6 +28,7 @@ class dbal_firebird extends dbal
var $last_query_text = '';
var $service_handle = false;
var $affected_rows = 0;
+ var $connect_error = '';
/**
* Connect to server
@@ -53,9 +54,35 @@ class dbal_firebird extends dbal
$use_database = $this->server . ':' . $this->dbname;
}
- $this->db_connect_id = ($this->persistency) ? @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
+ if ($this->persistency)
+ {
+ if (!function_exists('ibase_pconnect'))
+ {
+ $this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3);
+ }
+ else
+ {
+ if (!function_exists('ibase_connect'))
+ {
+ $this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3);
+ }
- $this->service_handle = (function_exists('ibase_service_attach') && $this->server) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
+ // Do not call ibase_service_attach if connection failed,
+ // otherwise error message from ibase_(p)connect call will be clobbered.
+ if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server)
+ {
+ $this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword);
+ }
+ else
+ {
+ $this->service_handle = false;
+ }
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
@@ -471,8 +498,24 @@ class dbal_firebird extends dbal
*/
function _sql_error()
{
+ // Need special handling here because ibase_errmsg returns
+ // connection errors, however if the interbase extension
+ // is not installed then ibase_errmsg does not exist and
+ // we cannot call it.
+ if (function_exists('ibase_errmsg'))
+ {
+ $msg = @ibase_errmsg();
+ if (!$msg)
+ {
+ $msg = $this->connect_error;
+ }
+ }
+ else
+ {
+ $msg = $this->connect_error;
+ }
return array(
- 'message' => @ibase_errmsg(),
+ 'message' => $msg,
'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '')
);
}
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 7ed4146f27..e057e7fe74 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -50,7 +50,7 @@ class result_mssqlnative
}
}
- $this->m_row_count = count($this->m_rows);
+ $this->m_row_count = sizeof($this->m_rows);
}
private function array_to_obj($array, &$obj)
@@ -259,6 +259,14 @@ class dbal_mssqlnative extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ function sql_buffer_nested_transaction()
+ {
+ return true;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -628,7 +636,7 @@ class dbal_mssqlnative extends dbal
return false;
}
}
-
+
/**
* Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter.
*/
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index c8a9a5f604..62b36aa8bf 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -269,11 +269,12 @@ class dbal_oracle extends dbal
{
$cols = explode(', ', $regs[2]);
+ preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
+
/* The code inside this comment block breaks clob handling, but does allow the
database restore script to work. If you want to allow no posts longer than 4KB
and/or need the db restore script, uncomment this.
- preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
if (sizeof($cols) !== sizeof($vals))
{
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index 4360c790a1..bb116e0763 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -18,6 +18,11 @@ if (!defined('IN_PHPBB'))
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
+if (!class_exists('phpbb_error_collector'))
+{
+ include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
+}
+
/**
* PostgreSQL Database Abstraction Layer
* Minimum Requirement is Version 7.3+
@@ -26,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_postgres extends dbal
{
var $last_query_text = '';
+ var $connect_error = '';
/**
* Connect to server
@@ -81,13 +87,29 @@ class dbal_postgres extends dbal
if ($this->persistency)
{
+ if (!function_exists('pg_pconnect'))
+ {
+ $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?';
+ return $this->sql_error('');
+ }
+ $collector = new phpbb_error_collector;
+ $collector->install();
$this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
}
else
{
+ if (!function_exists('pg_connect'))
+ {
+ $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?';
+ return $this->sql_error('');
+ }
+ $collector = new phpbb_error_collector;
+ $collector->install();
$this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
}
+ $collector->uninstall();
+
if ($this->db_connect_id)
{
if (version_compare($this->sql_server_info(true), '8.2', '>='))
@@ -102,6 +124,7 @@ class dbal_postgres extends dbal
return $this->db_connect_id;
}
+ $this->connect_error = $collector->format_errors();
return $this->sql_error('');
}
@@ -371,8 +394,19 @@ class dbal_postgres extends dbal
*/
function _sql_error()
{
+ // pg_last_error only works when there is an established connection.
+ // Connection errors have to be tracked by us manually.
+ if ($this->db_connect_id)
+ {
+ $message = @pg_last_error($this->db_connect_id);
+ }
+ else
+ {
+ $message = $this->connect_error;
+ }
+
return array(
- 'message' => (!$this->db_connect_id) ? @pg_last_error() : @pg_last_error($this->db_connect_id),
+ 'message' => $message,
'code' => ''
);
}
diff --git a/phpBB/includes/error_collector.php b/phpBB/includes/error_collector.php
new file mode 100644
index 0000000000..55834f354c
--- /dev/null
+++ b/phpBB/includes/error_collector.php
@@ -0,0 +1,61 @@
+<?php
+/**
+*
+* @package phpBB
+* @version $Id$
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+class phpbb_error_collector
+{
+ var $errors;
+
+ function phpbb_error_collector()
+ {
+ $this->errors = array();
+ }
+
+ function install()
+ {
+ set_error_handler(array(&$this, 'error_handler'));
+ }
+
+ function uninstall()
+ {
+ restore_error_handler();
+ }
+
+ function error_handler($errno, $msg_text, $errfile, $errline)
+ {
+ $this->errors[] = array($errno, $msg_text, $errfile, $errline);
+ }
+
+ function format_errors()
+ {
+ $text = '';
+ foreach ($this->errors as $error)
+ {
+ if (!empty($text))
+ {
+ $text .= "<br />\n";
+ }
+ list($errno, $msg_text, $errfile, $errline) = $error;
+ $text .= "Errno $errno: $msg_text";
+ if (defined('DEBUG_EXTRA') || defined('IN_INSTALL'))
+ {
+ $text .= " at $errfile line $errline";
+ }
+ }
+ return $text;
+ }
+}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 398a02380b..585e23b2ee 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -175,10 +175,14 @@ function set_config_count($config_name, $increment, $is_dynamic = false)
switch ($db->sql_layer)
{
case 'firebird':
- case 'postgres':
$sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))';
break;
+ case 'postgres':
+ // Need to cast to text first for PostgreSQL 7.x
+ $sql_update = 'CAST(CAST(config_value::text as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))';
+ break;
+
// MySQL, SQlite, mssql, mssql_odbc, oracle
default:
$sql_update = 'config_value + ' . (int) $increment;
@@ -236,8 +240,8 @@ function unique_id($extra = 'c')
if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10)))
{
- set_config('rand_seed', $config['rand_seed'], true);
set_config('rand_seed_last_update', time(), true);
+ set_config('rand_seed', $config['rand_seed'], true);
$dss_seeded = true;
}
@@ -512,7 +516,7 @@ function _hash_crypt_private($password, $setting, &$itoa64)
$output = '*';
// Check for correct hash
- if (substr($setting, 0, 3) != '$H$')
+ if (substr($setting, 0, 3) != '$H$' && substr($setting, 0, 3) != '$P$')
{
return $output;
}
@@ -4257,7 +4261,7 @@ function phpbb_http_login($param)
if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0)
{
list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2);
- }
+ }
if (!is_null($username) && !is_null($password))
{
@@ -4607,7 +4611,7 @@ function page_footer($run_cron = true)
// Call cron-type script
$call_cron = false;
- if (!defined('IN_CRON') && $run_cron && !$config['board_disable'])
+ if (!defined('IN_CRON') && $run_cron && !$config['board_disable'] && !$user->data['is_bot'])
{
$call_cron = true;
$time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time();
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0420aa70ab..89ce52dc39 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1422,6 +1422,31 @@ function validate_match($string, $optional = false, $match = '')
}
/**
+* Validate Language Pack ISO Name
+*
+* Tests whether a language name is valid and installed
+*
+* @param string $lang_iso The language string to test
+*
+* @return bool|string Either false if validation succeeded or
+* a string which will be used as the error message
+* (with the variable name appended)
+*/
+function validate_language_iso_name($lang_iso)
+{
+ global $db;
+
+ $sql = 'SELECT lang_id
+ FROM ' . LANG_TABLE . "
+ WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
+ $result = $db->sql_query($sql);
+ $lang_id = (int) $db->sql_fetchfield('lang_id');
+ $db->sql_freeresult($result);
+
+ return ($lang_id) ? false : 'WRONG_DATA';
+}
+
+/**
* Check to see if the username has been taken, or if it is disallowed.
* Also checks if it includes the " character, which we don't allow in usernames.
* Used for registering, changing names, and posting anonymously with a username
@@ -1580,8 +1605,9 @@ function validate_password($password)
{
global $config, $db, $user;
- if (!$password)
+ if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY')
{
+ // Password empty or no password complexity required.
return false;
}
@@ -1592,7 +1618,6 @@ function validate_password($password)
{
$upp = '\p{Lu}';
$low = '\p{Ll}';
- $let = '\p{L}';
$num = '\p{N}';
$sym = '[^\p{Lu}\p{Ll}\p{N}]';
$pcre = true;
@@ -1602,7 +1627,6 @@ function validate_password($password)
mb_regex_encoding('UTF-8');
$upp = '[[:upper:]]';
$low = '[[:lower:]]';
- $let = '[[:lower:][:upper:]]';
$num = '[[:digit:]]';
$sym = '[^[:upper:][:lower:][:digit:]]';
$mbstring = true;
@@ -1611,7 +1635,6 @@ function validate_password($password)
{
$upp = '[A-Z]';
$low = '[a-z]';
- $let = '[a-zA-Z]';
$num = '[0-9]';
$sym = '[^A-Za-z0-9]';
$pcre = true;
@@ -1621,22 +1644,22 @@ function validate_password($password)
switch ($config['pass_complex'])
{
- case 'PASS_TYPE_CASE':
- $chars[] = $low;
- $chars[] = $upp;
- break;
+ // No break statements below ...
+ // We require strong passwords in case pass_complex is not set or is invalid
+ default:
+
+ // Require mixed case letters, numbers and symbols
+ case 'PASS_TYPE_SYMBOL':
+ $chars[] = $sym;
+ // Require mixed case letters and numbers
case 'PASS_TYPE_ALPHA':
- $chars[] = $let;
$chars[] = $num;
- break;
- case 'PASS_TYPE_SYMBOL':
+ // Require mixed case letters
+ case 'PASS_TYPE_CASE':
$chars[] = $low;
$chars[] = $upp;
- $chars[] = $num;
- $chars[] = $sym;
- break;
}
if ($pcre)
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index b91636a9c8..d0cfa1ffd2 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -208,7 +208,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $author_id) : '',
'U_WWW' => (!empty($user_info['user_website'])) ? $user_info['user_website'] : '',
- 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '',
+ 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people' . urlencode($user_info['user_icq']) . '/' : '',
'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $author_id) : '',
'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&amp;.src=pg' : '',
'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $author_id) : '',
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index cc8565e69d..13167b2b3d 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -65,7 +65,7 @@ class ucp_prefs
$error = validate_data($data, array(
'dateformat' => array('string', false, 1, 30),
- 'lang' => array('match', false, '#^[a-z0-9_\-]{2,}$#i'),
+ 'lang' => array('language_iso_name'),
'tz' => array('num', false, -14, 14),
));
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 7fd99da55a..13b9945851 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -56,7 +56,7 @@ class ucp_register
{
$use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
- if (file_exists($user->lang_path . $use_lang . '/'))
+ if (!validate_language_iso_name($use_lang))
{
if ($change_lang)
{
@@ -210,7 +210,7 @@ class ucp_register
array('email')),
'email_confirm' => array('string', false, 6, 60),
'tz' => array('num', false, -14, 14),
- 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'),
+ 'lang' => array('language_iso_name'),
));
if (!check_form_key('ucp_register'))
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 2dd58584f4..9fe0c8aed5 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1882,7 +1882,7 @@ class install_install extends module
if (!$user_id)
{
- // If we can't insert this user then continue to the next one to avoid inconsistant data
+ // If we can't insert this user then continue to the next one to avoid inconsistent data
$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
continue;
}
diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php
index 443f4a3ea2..0fad400ea9 100644
--- a/phpBB/language/en/acp/posting.php
+++ b/phpBB/language/en/acp/posting.php
@@ -168,8 +168,9 @@ $lang = array_merge($lang, array(
'SMILIES_CONFIG' => 'Smiley configuration',
'SMILIES_DELETED' => 'The smiley has been removed successfully.',
'SMILIES_EDIT' => 'Edit smiley',
- 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.',
+ 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.',
'SMILIE_NO_EMOTION' => 'The smilie “%s” was ignored, as there was no emotion entered.',
+ 'SMILIE_NO_FILE' => 'The smilie “%s” was ignored, as the file is missing.',
'SMILIES_NONE_EDITED' => 'No smilies were updated.',
'SMILIES_ONE_EDITED' => 'The smiley has been updated successfully.',
'SMILIES_EDITED' => 'The smilies have been updated successfully.',
@@ -233,13 +234,13 @@ $lang = array_merge($lang, array(
// Disallow Usernames
$lang = array_merge($lang, array(
- 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *. Please note that you will not be allowed to specify any username that has already been registered, you must first delete that name then disallow it.',
+ 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *.',
'ADD_DISALLOW_EXPLAIN' => 'You can disallow a username using the wildcard character * to match any character.',
'ADD_DISALLOW_TITLE' => 'Add a disallowed username',
'DELETE_DISALLOW_EXPLAIN' => 'You can remove a disallowed username by selecting the username from this list and clicking submit.',
'DELETE_DISALLOW_TITLE' => 'Remove a disallowed username',
- 'DISALLOWED_ALREADY' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present.',
+ 'DISALLOWED_ALREADY' => 'The name you entered is already disallowed.',
'DISALLOWED_DELETED' => 'The disallowed username has been successfully removed.',
'DISALLOW_SUCCESSFUL' => 'The disallowed username has been successfully added.',
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index db60cbf227..731f674120 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -190,7 +190,7 @@ $lang = array_merge($lang, array(
'FORM_INVALID' => 'The submitted form was invalid. Try submitting again.',
'FORUM' => 'Forum',
'FORUMS' => 'Forums',
- 'FORUMS_MARKED' => 'All forums have been marked read.',
+ 'FORUMS_MARKED' => 'The selected forums have been marked read.',
'FORUM_CAT' => 'Forum category',
'FORUM_INDEX' => 'Board index',
'FORUM_LINK' => 'Forum link',
@@ -322,6 +322,7 @@ $lang = array_merge($lang, array(
'MARK' => 'Mark',
'MARK_ALL' => 'Mark all',
'MARK_FORUMS_READ' => 'Mark forums read',
+ 'MARK_SUBFORUMS_READ' => 'Mark subforums read',
'MB' => 'MB',
'MIB' => 'MiB',
'MCP' => 'Moderator Control Panel',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 2fa2d11ee1..589877305f 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1069,8 +1069,32 @@ switch ($mode)
$sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
$sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
$sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
- $sql_where .= (sizeof($joined) > 1 && isset($find_key_match[$joined_select])) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
- $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 && isset($find_key_match[$active_select])) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
+
+ if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3)
+ {
+ // Before PHP 5.1 an error value -1 can be returned instead of false.
+ // Theoretically gmmktime() can also legitimately return -1 as an actual timestamp.
+ // But since we do not pass the $second parameter to gmmktime(),
+ // an actual unix timestamp -1 cannot be returned in this case.
+ // Thus we can check whether it is -1 and treat -1 as an error.
+ $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]);
+
+ if ($joined_time !== false && $joined_time !== -1)
+ {
+ $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time;
+ }
+ }
+
+ if (isset($find_key_match[$active_select]) && sizeof($active) == 3 && $auth->acl_get('u_viewonline'))
+ {
+ $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
+
+ if ($active_time !== false && $active_time !== -1)
+ {
+ $sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time;
+ }
+ }
+
$sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
if ($search_group_id)
@@ -1692,7 +1716,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
'U_EMAIL' => $email,
'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '',
'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '',
- 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '',
+ 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '',
'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $user_id) : '',
'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&amp;.src=pg' : '',
'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $user_id) : '',
diff --git a/phpBB/styles/prosilver/template/attachment.html b/phpBB/styles/prosilver/template/attachment.html
index cc5aacff2f..4c0a326f1e 100644
--- a/phpBB/styles/prosilver/template/attachment.html
+++ b/phpBB/styles/prosilver/template/attachment.html
@@ -70,12 +70,12 @@
<embed src="{_file.U_VIEW_LINK}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{_file.WIDTH}" height="{_file.HEIGHT}" play="true" loop="true" quality="high" allowscriptaccess="never" allownetworking="internal"></embed>
</object>
<!-- ELSEIF _file.S_QUICKTIME_FILE -->
- <object id="qtstream_{_file.ATTACH_ID}" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="0" height="16">
+ <object id="qtstream_{_file.ATTACH_ID}" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="320" height="285">
<param name="src" value="{_file.U_DOWNLOAD_LINK}" />
<param name="controller" value="true" />
<param name="autoplay" value="false" />
<param name="type" value="video/quicktime" />
- <embed name="qtstream_{_file.ATTACH_ID}" src="{_file.U_DOWNLOAD_LINK}" pluginspage="http://www.apple.com/quicktime/download/" enablejavascript="true" controller="true" width="0" height="16" type="video/quicktime" autoplay="false"></embed>
+ <embed name="qtstream_{_file.ATTACH_ID}" src="{_file.U_DOWNLOAD_LINK}" pluginspage="http://www.apple.com/quicktime/download/" enablejavascript="true" controller="true" width="320" height="285" type="video/quicktime" autoplay="false"></embed>
</object>
<!-- ELSEIF _file.S_RM_FILE -->
<object id="rmstream_{_file.ATTACH_ID}" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="200" height="50">
diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html
index 2171250621..bce31431cb 100644
--- a/phpBB/styles/prosilver/template/ucp_groups_manage.html
+++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html
@@ -118,7 +118,7 @@
</thead>
<tbody>
<!-- ELSEIF member.S_APPROVED -->
- <!-- IF member.S_PENDING_SET -->
+ <!-- IF S_PENDING_SET -->
</tbody>
</table>
<!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html
index 12073a39d2..f4e80fd625 100644
--- a/phpBB/styles/prosilver/template/viewforum_body.html
+++ b/phpBB/styles/prosilver/template/viewforum_body.html
@@ -28,7 +28,7 @@
<!-- IF S_HAS_SUBFORUM -->
<!-- IF not S_IS_BOT and U_MARK_FORUMS -->
<ul class="linklist">
- <li class="rightside"><a href="{U_MARK_FORUMS}">{L_MARK_FORUMS_READ}</a></li>
+ <li class="rightside"><a href="{U_MARK_FORUMS}">{L_MARK_SUBFORUMS_READ}</a></li>
</ul>
<!-- ENDIF -->
<!-- INCLUDE forumlist_body.html -->
diff --git a/phpBB/styles/subsilver2/template/attachment.html b/phpBB/styles/subsilver2/template/attachment.html
index 833bd4d55f..b5b547b2e6 100644
--- a/phpBB/styles/subsilver2/template/attachment.html
+++ b/phpBB/styles/subsilver2/template/attachment.html
@@ -67,12 +67,12 @@
<embed src="{_file.U_VIEW_LINK}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{_file.WIDTH}" height="{_file.HEIGHT}" play="true" loop="true" quality="high" allowscriptaccess="never" allownetworking="internal"></embed>
</object>
<!-- ELSEIF _file.S_QUICKTIME_FILE -->
- <object id="qtstream_{_file.ATTACH_ID}" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="0" height="16">
+ <object id="qtstream_{_file.ATTACH_ID}" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="320" height="285">
<param name="src" value="{_file.U_DOWNLOAD_LINK}">
<param name="controller" value="true">
<param name="autoplay" value="false" />
<param name="type" value="video/quicktime">
- <embed name="qtstream_{_file.ATTACH_ID}" src="{_file.U_DOWNLOAD_LINK}" pluginspage="http://www.apple.com/quicktime/download/" enablejavascript="true" controller="true" width="0" height="16" type="video/quicktime" autoplay="false">
+ <embed name="qtstream_{_file.ATTACH_ID}" src="{_file.U_DOWNLOAD_LINK}" pluginspage="http://www.apple.com/quicktime/download/" enablejavascript="true" controller="true" width="320" height="285" type="video/quicktime" autoplay="false">
</object>
<!-- ELSEIF _file.S_RM_FILE -->
<object id="rmstream_{_file.ATTACH_ID}" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="200" height="50">
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index bc839066a5..53da7f539f 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1157,7 +1157,7 @@ while ($row = $db->sql_fetchrow($result))
if (!empty($row['user_icq']))
{
- $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'];
+ $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/';
$user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&amp;img=5" width="18" height="18" alt="" />';
}
else
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index c729c6e2d8..6f3c93a374 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,6 +12,10 @@ $phpbb_root_path = 'phpBB/';
$phpEx = 'php';
$table_prefix = 'phpbb_';
+if (!defined('E_DEPRECATED'))
+{
+ define('E_DEPRECATED', 8192);
+}
error_reporting(E_ALL & ~E_DEPRECATED);
// If we are on PHP >= 6.0.0 we do not need some code
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 738d1eaaba..11e525ff79 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -59,7 +59,12 @@ class phpbb_mock_cache
if ($ignore_db_info)
{
+ unset($cache_data['mssqlodbc_version']);
+ unset($cache_data['mssql_version']);
+ unset($cache_data['mysql_version']);
unset($cache_data['mysqli_version']);
+ unset($cache_data['pgsql_version']);
+ unset($cache_data['sqlite_version']);
}
$test->assertEquals($data, $cache_data);
diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php
new file mode 100644
index 0000000000..21e8d12a0a
--- /dev/null
+++ b/tests/regex/password_complexity_test.php
@@ -0,0 +1,81 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
+
+class phpbb_password_complexity_test extends phpbb_test_case
+{
+ public function password_complexity_test_data_positive()
+ {
+ return array(
+ array('12345', 'PASS_TYPE_ANY'),
+ array('qwerty', 'PASS_TYPE_ANY'),
+ array('QWERTY', 'PASS_TYPE_ANY'),
+ array('QwerTY', 'PASS_TYPE_ANY'),
+ array('q$erty', 'PASS_TYPE_ANY'),
+ array('qW$rty', 'PASS_TYPE_ANY'),
+
+ array('QwerTY', 'PASS_TYPE_CASE'),
+ array('QwerTY123', 'PASS_TYPE_ALPHA'),
+ array('QwerTY123$&', 'PASS_TYPE_SYMBOL'),
+
+ array('', 'PASS_TYPE_ANY'),
+ );
+ }
+
+ public function password_complexity_test_data_negative()
+ {
+ return array(
+ array('qwerty', 'PASS_TYPE_CASE'),
+ array('QWERTY', 'PASS_TYPE_CASE'),
+ array('123456', 'PASS_TYPE_CASE'),
+ array('#$&', 'PASS_TYPE_CASE'),
+ array('QTY123$', 'PASS_TYPE_CASE'),
+
+ array('qwerty', 'PASS_TYPE_ALPHA'),
+ array('QWERTY', 'PASS_TYPE_ALPHA'),
+ array('123456', 'PASS_TYPE_ALPHA'),
+ array('QwertY', 'PASS_TYPE_ALPHA'),
+ array('qwerty123', 'PASS_TYPE_ALPHA'),
+ array('QWERTY123', 'PASS_TYPE_ALPHA'),
+ array('#$&', 'PASS_TYPE_ALPHA'),
+ array('QTY123$', 'PASS_TYPE_ALPHA'),
+
+ array('qwerty', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY', 'PASS_TYPE_SYMBOL'),
+ array('123456', 'PASS_TYPE_SYMBOL'),
+ array('QwertY', 'PASS_TYPE_SYMBOL'),
+ array('qwerty123', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY123', 'PASS_TYPE_SYMBOL'),
+ array('#$&', 'PASS_TYPE_SYMBOL'),
+ array('qwerty123$', 'PASS_TYPE_SYMBOL'),
+ array('QWERTY123$', 'PASS_TYPE_SYMBOL'),
+ );
+ }
+
+ /**
+ * @dataProvider password_complexity_test_data_positive
+ */
+ public function test_password_complexity_positive($password, $mode)
+ {
+ global $config;
+ $config['pass_complex'] = $mode;
+ $this->assertFalse(validate_password($password));
+ }
+
+ /**
+ * @dataProvider password_complexity_test_data_negative
+ */
+ public function test_password_complexity_negative($password, $mode)
+ {
+ global $config;
+ $config['pass_complex'] = $mode;
+ $this->assertEquals('INVALID_CHARS', validate_password($password));
+ }
+}
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
new file mode 100644
index 0000000000..19a3822145
--- /dev/null
+++ b/tests/security/hash_test.php
@@ -0,0 +1,21 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_security_hash_test extends phpbb_test_case
+{
+ public function test_check_hash_with_phpass()
+ {
+ $this->assertTrue(phpbb_check_hash('test', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
+ $this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
+ $this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
+ }
+}
+
diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php
index 3080121978..6737562a0a 100644
--- a/tests/session/continue_test.php
+++ b/tests/session/continue_test.php
@@ -19,21 +19,25 @@ class phpbb_session_continue_test extends phpbb_database_test_case
static public function session_begin_attempts()
{
+ // The session_id field is defined as CHAR(32) in the database schema.
+ // Thus the data we put in session_id fields has to have a length of 32 characters on stricter DBMSes.
+ // Thus we fill those strings up with zeroes until they have a string length of 32.
+
return array(
array(
- 'bar_session', '4', 'user agent', '127.0.0.1',
+ 'bar_session000000000000000000000', '4', 'user agent', '127.0.0.1',
array(
- array('session_id' => 'anon_session', 'session_user_id' => 1),
- array('session_id' => 'bar_session', 'session_user_id' => 4),
+ array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1),
+ array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4),
),
array(),
'If a request comes with a valid session id with matching user agent and IP, no new session should be created.',
),
array(
- 'anon_session', '4', 'user agent', '127.0.0.1',
+ 'anon_session00000000000000000000', '4', 'user agent', '127.0.0.1',
array(
array('session_id' => '__new_session_id__', 'session_user_id' => 1), // use generated SID
- array('session_id' => 'bar_session', 'session_user_id' => 4),
+ array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4),
),
array(
'u' => array('1', null),
diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml
index 4559a08c55..bf6fc65997 100644
--- a/tests/session/fixtures/sessions_full.xml
+++ b/tests/session/fixtures/sessions_full.xml
@@ -22,13 +22,13 @@
<column>session_ip</column>
<column>session_browser</column>
<row>
- <value>anon_session</value>
+ <value>anon_session00000000000000000000</value>
<value>1</value>
<value>127.0.0.1</value>
<value>anonymous user agent</value>
</row>
<row>
- <value>bar_session</value>
+ <value>bar_session000000000000000000000</value>
<value>4</value>
<value>127.0.0.1</value>
<value>user agent</value>
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 1b2f35f210..33c82d53ad 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -343,8 +343,7 @@ class phpbb_template_template_test extends phpbb_test_case
*/
public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
{
- global $phpEx;
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx;
+ $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
@@ -394,11 +393,9 @@ class phpbb_template_template_test extends phpbb_test_case
public function test_php()
{
- global $phpEx;
-
$GLOBALS['config']['tpl_allow_php'] = true;
- $cache_file = $this->template->cachepath . 'php.html.' . $phpEx;
+ $cache_file = $this->template->cachepath . 'php.html.php';
$this->assertFileNotExists($cache_file);
@@ -409,21 +406,14 @@ class phpbb_template_template_test extends phpbb_test_case
public function test_includephp()
{
- $this->markTestIncomplete('Include PHP test file paths are broken');
-
$GLOBALS['config']['tpl_allow_php'] = true;
- $cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT;
-
- $cwd = getcwd();
- chdir(dirname(__FILE__) . '/templates');
+ $cache_file = $this->template->cachepath . 'includephp.html.php';
$this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file);
$this->template->set_filenames(array('test' => 'includephp.html'));
- $this->assertEquals('testing included php', $this->display('test'), "Testing $file");
-
- chdir($cwd);
+ $this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP");
$GLOBALS['config']['tpl_allow_php'] = false;
}
@@ -437,17 +427,16 @@ class phpbb_template_template_test extends phpbb_test_case
false,
'insert',
<<<EOT
-outer - 0/4 - before
-outer - 1/4
-middle - 0/2
-middle - 1/2
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0 - before
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting before on top level block',
@@ -458,17 +447,16 @@ EOT
true,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/4
-middle - 0/2
-middle - 1/2
-outer - 3/4 - after
+outer - 0
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3 - after
EOT
,
'Test inserting after on top level block',
@@ -479,17 +467,16 @@ EOT
1,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4 - pos #1
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0
+middle - 0
+middle - 1
+outer - 1 - pos #1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
@@ -500,172 +487,27 @@ EOT
0,
'change',
<<<EOT
-outer - 0/3 - pos #1
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
+outer - 0 - pos #1
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'after'),
- true,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3
-middle - 2/3 - after
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting after on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'pos #1'),
- 1,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3 - pos #1
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting at pos 1 on nested block',
- ),
- array(
- 'outer[1].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/4 - before
-middle - 1/4
-middle - 2/4
-middle - 3/4
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block (pos 1)',
- ),
- array(
- 'outer[].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
- array(
- 'outer.middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
);
}
-/*
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
-*/
-
/**
* @dataProvider alter_block_array_data
*/
public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
{
- $this->markTestIncomplete('Alter Block Test is broken');
-
$this->template->set_filenames(array('test' => 'loop_nested.html'));
// @todo Change this
@@ -675,12 +517,11 @@ EOT
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
- $this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
- $this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification');
+ $this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
$this->assertEquals($expect, $this->display('test'), $description);
diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html
index 117d4273f0..70ebdac0d0 100644
--- a/tests/template/templates/includephp.html
+++ b/tests/template/templates/includephp.html
@@ -1 +1 @@
-<!-- INCLUDEPHP ../templates/_dummy_include.php.inc -->
+<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->
diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html
index 571df97b4c..9b251cd453 100644
--- a/tests/template/templates/loop_nested.html
+++ b/tests/template/templates/loop_nested.html
@@ -1,8 +1,8 @@
<!-- BEGIN outer -->
- {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
+ outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
<!-- BEGIN middle -->
- {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
+ middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
<!-- END middle -->
<!-- END outer -->