mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-17 16:58:51 +00:00
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/11600
This commit is contained in:
commit
68f001aaaf
83 changed files with 3337 additions and 1541 deletions
|
@ -124,19 +124,34 @@ function get_repository_url($username, $repository, $ssh = false)
|
|||
|
||||
function api_request($query)
|
||||
{
|
||||
$contents = file_get_contents("http://github.com/api/v2/json/$query");
|
||||
return api_url_request("https://api.github.com/$query?per_page=100");
|
||||
}
|
||||
|
||||
function api_url_request($url)
|
||||
{
|
||||
$contents = file_get_contents($url, false, stream_context_create(array(
|
||||
'http' => array(
|
||||
'header' => "User-Agent: phpBB/1.0\r\n",
|
||||
),
|
||||
)));
|
||||
|
||||
if ($contents === false)
|
||||
{
|
||||
throw new RuntimeException("Error: failed to retrieve pull request data\n", 4);
|
||||
}
|
||||
$contents = json_decode($contents);
|
||||
|
||||
return json_decode($contents);
|
||||
if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0)
|
||||
{
|
||||
throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4);
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
function get_pull($username, $repository, $pull_id)
|
||||
{
|
||||
$request = api_request("pulls/$username/$repository/$pull_id");
|
||||
$request = api_request("repos/$username/$repository/pulls/$pull_id");
|
||||
|
||||
$pull = $request->pull;
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@ function show_usage()
|
|||
echo "$filename adds repositories of a github network as remotes to a local git repository.\n";
|
||||
echo "\n";
|
||||
|
||||
echo "Usage: [php] $filename -s collaborators|organisation|contributors|network [OPTIONS]\n";
|
||||
echo "Usage: [php] $filename -s collaborators|organisation|contributors|forks [OPTIONS]\n";
|
||||
echo "\n";
|
||||
|
||||
echo "Scopes:\n";
|
||||
echo " collaborators Repositories of people who have push access to the specified repository\n";
|
||||
echo " contributors Repositories of people who have contributed to the specified repository\n";
|
||||
echo " organisation Repositories of members of the organisation at github\n";
|
||||
echo " network All repositories of the whole github network\n";
|
||||
echo " forks All repositories of the whole github network\n";
|
||||
echo "\n";
|
||||
|
||||
echo "Options:\n";
|
||||
|
@ -55,31 +55,31 @@ exit(work($scope, $username, $repository, $developer));
|
|||
function work($scope, $username, $repository, $developer)
|
||||
{
|
||||
// Get some basic data
|
||||
$network = get_network($username, $repository);
|
||||
$forks = get_forks($username, $repository);
|
||||
$collaborators = get_collaborators($username, $repository);
|
||||
|
||||
if ($network === false || $collaborators === false)
|
||||
if ($forks === false || $collaborators === false)
|
||||
{
|
||||
echo "Error: failed to retrieve network or collaborators\n";
|
||||
echo "Error: failed to retrieve forks or collaborators\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch ($scope)
|
||||
{
|
||||
case 'collaborators':
|
||||
$remotes = array_intersect_key($network, $collaborators);
|
||||
$remotes = array_intersect_key($forks, $collaborators);
|
||||
break;
|
||||
|
||||
case 'organisation':
|
||||
$remotes = array_intersect_key($network, get_organisation_members($username));
|
||||
$remotes = array_intersect_key($forks, get_organisation_members($username));
|
||||
break;
|
||||
|
||||
case 'contributors':
|
||||
$remotes = array_intersect_key($network, get_contributors($username, $repository));
|
||||
$remotes = array_intersect_key($forks, get_contributors($username, $repository));
|
||||
break;
|
||||
|
||||
case 'network':
|
||||
$remotes = $network;
|
||||
case 'forks':
|
||||
$remotes = $forks;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -145,26 +145,66 @@ function get_repository_url($username, $repository, $ssh = false)
|
|||
|
||||
function api_request($query)
|
||||
{
|
||||
$contents = file_get_contents("http://github.com/api/v2/json/$query");
|
||||
return api_url_request("https://api.github.com/$query?per_page=100");
|
||||
}
|
||||
|
||||
function api_url_request($url)
|
||||
{
|
||||
$contents = file_get_contents($url, false, stream_context_create(array(
|
||||
'http' => array(
|
||||
'header' => "User-Agent: phpBB/1.0\r\n",
|
||||
),
|
||||
)));
|
||||
|
||||
$sub_request_result = array();
|
||||
// Check headers for pagination links
|
||||
if (!empty($http_response_header))
|
||||
{
|
||||
foreach ($http_response_header as $header_element)
|
||||
{
|
||||
// Find Link Header which gives us a link to the next page
|
||||
if (strpos($header_element, 'Link: ') === 0)
|
||||
{
|
||||
list($head, $header_content) = explode(': ', $header_element);
|
||||
foreach (explode(', ', $header_content) as $links)
|
||||
{
|
||||
list($url, $rel) = explode('; ', $links);
|
||||
if ($rel == 'rel="next"')
|
||||
{
|
||||
// Found a next link, follow it and merge the results
|
||||
$sub_request_result = api_url_request(substr($url, 1, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($contents === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return json_decode($contents);
|
||||
$contents = json_decode($contents);
|
||||
|
||||
if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0)
|
||||
{
|
||||
throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4);
|
||||
}
|
||||
|
||||
return ($sub_request_result) ? array_merge($sub_request_result, $contents) : $contents;
|
||||
}
|
||||
|
||||
function get_contributors($username, $repository)
|
||||
{
|
||||
$request = api_request("repos/show/$username/$repository/contributors");
|
||||
$request = api_request("repos/$username/$repository/stats/contributors");
|
||||
if ($request === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$usernames = array();
|
||||
foreach ($request->contributors as $contributor)
|
||||
foreach ($request as $contribution)
|
||||
{
|
||||
$usernames[$contributor->login] = $contributor->login;
|
||||
$usernames[$contribution->author->login] = $contribution->author->login;
|
||||
}
|
||||
|
||||
return $usernames;
|
||||
|
@ -172,14 +212,14 @@ function get_contributors($username, $repository)
|
|||
|
||||
function get_organisation_members($username)
|
||||
{
|
||||
$request = api_request("organizations/$username/public_members");
|
||||
$request = api_request("orgs/$username/public_members");
|
||||
if ($request === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$usernames = array();
|
||||
foreach ($request->users as $member)
|
||||
foreach ($request as $member)
|
||||
{
|
||||
$usernames[$member->login] = $member->login;
|
||||
}
|
||||
|
@ -189,35 +229,35 @@ function get_organisation_members($username)
|
|||
|
||||
function get_collaborators($username, $repository)
|
||||
{
|
||||
$request = api_request("repos/show/$username/$repository/collaborators");
|
||||
$request = api_request("repos/$username/$repository/collaborators");
|
||||
if ($request === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$usernames = array();
|
||||
foreach ($request->collaborators as $collaborator)
|
||||
foreach ($request as $collaborator)
|
||||
{
|
||||
$usernames[$collaborator] = $collaborator;
|
||||
$usernames[$collaborator->login] = $collaborator->login;
|
||||
}
|
||||
|
||||
return $usernames;
|
||||
}
|
||||
|
||||
function get_network($username, $repository)
|
||||
function get_forks($username, $repository)
|
||||
{
|
||||
$request = api_request("repos/show/$username/$repository/network");
|
||||
$request = api_request("repos/$username/$repository/forks");
|
||||
if ($request === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$usernames = array();
|
||||
foreach ($request->network as $network)
|
||||
foreach ($request as $fork)
|
||||
{
|
||||
$usernames[$network->owner] = array(
|
||||
'username' => $network->owner,
|
||||
'repository' => $network->name,
|
||||
$usernames[$fork->owner->login] = array(
|
||||
'username' => $fork->owner->login,
|
||||
'repository' => $fork->name,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -243,8 +243,8 @@
|
|||
<td style="text-align: center;">{items.EMOTION}</td>
|
||||
<!-- ENDIF -->
|
||||
<td style="text-align: right; white-space: nowrap;">
|
||||
<!-- IF items.S_FIRST_ROW and not PREVIOUS_PAGE -->{ICON_MOVE_UP_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_UP}">{ICON_MOVE_UP}</a><!-- ENDIF -->
|
||||
<!-- IF items.S_LAST_ROW and not NEXT_PAGE -->{ICON_MOVE_DOWN_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a><!-- ENDIF -->
|
||||
<!-- IF items.S_FIRST_ROW and not U_PREVIOUS_PAGE -->{ICON_MOVE_UP_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_UP}">{ICON_MOVE_UP}</a><!-- ENDIF -->
|
||||
<!-- IF items.S_LAST_ROW and not U_NEXT_PAGE -->{ICON_MOVE_DOWN_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a><!-- ENDIF -->
|
||||
<a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
37
phpBB/config/auth_providers.yml
Normal file
37
phpBB/config/auth_providers.yml
Normal file
|
@ -0,0 +1,37 @@
|
|||
services:
|
||||
auth.provider_collection:
|
||||
class: phpbb_di_service_collection
|
||||
arguments:
|
||||
- @service_container
|
||||
tags:
|
||||
- { name: service_collection, tag: auth.provider }
|
||||
auth.provider.db:
|
||||
class: phpbb_auth_provider_db
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @config
|
||||
- @request
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: auth.provider }
|
||||
auth.provider.apache:
|
||||
class: phpbb_auth_provider_apache
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @config
|
||||
- @request
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: auth.provider }
|
||||
auth.provider.ldap:
|
||||
class: phpbb_auth_provider_ldap
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @config
|
||||
- @user
|
||||
tags:
|
||||
- { name: auth.provider }
|
|
@ -5,6 +5,7 @@ imports:
|
|||
- { resource: migrator.yml }
|
||||
- { resource: avatars.yml }
|
||||
- { resource: feed.yml }
|
||||
- { resource: auth_providers.yml }
|
||||
|
||||
services:
|
||||
auth:
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<!-- BEGIN DOCUMENT -->
|
||||
|
||||
<p>Thank you for downloading phpBB3. This README will guide through the basics of installation and operation of phpBB3. Please ensure you read this and the accompanying documentation fully <strong>before</strong> proceeding with the installation.</p>
|
||||
<p>Thank you for downloading phpBB3. This README will guide you through the basics of installation and operation of phpBB3. Please ensure you read this and the accompanying documentation fully <strong>before</strong> proceeding with the installation.</p>
|
||||
|
||||
<h1>Readme</h1>
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
</ol>
|
||||
</li>
|
||||
<li><a href="#status">Status of this version</a></li>
|
||||
<li><a href="#bugs">Reporting Bugs</a>
|
||||
<li><a href="#bugs">Reporting bugs</a>
|
||||
<ol style="list-style-type: lower-roman;">
|
||||
<li><a href="#securitybugs">Security related bugs</a></li>
|
||||
</ol>
|
||||
|
@ -84,12 +84,11 @@
|
|||
<div class="inner"><span class="corners-top"><span></span></span>
|
||||
|
||||
<div class="content">
|
||||
|
||||
<p>Installation, update and conversion instructions can be found in the <a href="INSTALL.html">INSTALL</a> document contained in this distribution. If you are intending to convert from a previous phpBB 2.0.x or 3.0.x installation we highly recommend you backup any existing data before proceeding!</p>
|
||||
<p>Installation, update and conversion instructions can be found in the <a href="INSTALL.html">INSTALL</a> document in this directory. If you are intending on converting from a phpBB 2.0.x or 3.0.x installation we highly recommend that you backup any existing data before proceeding!</p>
|
||||
|
||||
<p>Users of phpBB 3.0 and 3.1 Beta versions cannot directly update.</p>
|
||||
|
||||
<p>Please note that we won't support the following installation types:</p>
|
||||
<p>Please note that we don't support the following installation types:</p>
|
||||
<ul>
|
||||
<li>Updates from phpBB 3.0 Beta versions to phpBB 3.0 RC1 and higher</li>
|
||||
<li>Updates from phpBB 3.1 Beta versions to phpBB 3.1 RC1 and higher</li>
|
||||
|
@ -103,8 +102,8 @@
|
|||
<li>Updates from phpBB 3.0 RC1 and 3.1 RC1 to the latest version</li>
|
||||
<li>Note: if using the <em>Automatic Update Package</em>, updates are supported from phpBB 3.0.2 onward. To update a pre-3.0.2 installation, first update to 3.0.2 and then update to the current version.</li>
|
||||
<li>Conversions from phpBB 2.0.x to the latest version</li>
|
||||
<li>New installations of phpBB 3.0.x - always only the latest released version</li>
|
||||
<li>New installations of phpBB 3.1.x - always only the latest released version</li>
|
||||
<li>New installations of phpBB 3.0.x - only the latest released version</li>
|
||||
<li>New installations of phpBB 3.1.x - only the latest released version</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
@ -131,7 +130,7 @@
|
|||
|
||||
<p>For more information about language packs, please see: <a href="http://www.phpbb.com/languages/">http://www.phpbb.com/languages/</a></p>
|
||||
|
||||
<p>This is the <em>official</em> location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. So please, do not ask for help in these cases!</p>
|
||||
<p>This is the <em>official</em> location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. Please do not ask for support if you download a language pack from a 3rd party site.</p>
|
||||
|
||||
<p>Installation of these packages is straightforward: simply download the required language pack, uncompress (unzip) it and via FTP transfer the included <code>language</code> and <code>styles</code> folders to the root of your board installation. The language can then be installed via the Administration Control Panel of your board: <code>System tab -> General Tasks -> Language packs</code>. A more detailed description of the process is in the Knowledge Base article, <a href="http://www.phpbb.com/kb/article/how-to-install-a-language-pack/">How to Install a Language Pack</a>.</p>
|
||||
|
||||
|
@ -175,15 +174,15 @@
|
|||
|
||||
<div class="content">
|
||||
|
||||
<p>phpBB3 can seem a little daunting to new users in places, particularly with regard the permission system. The first thing you should do is check the <a href="FAQ.html">FAQ</a> which covers a few basic getting started questions. If you need additional help there are several places you should look.</p>
|
||||
<p>phpBB3 can sometimes seem a little daunting to new users, particularly with regards to the permission system. The first thing you should do is check the <a href="FAQ.html">FAQ</a>, which covers a few basic getting started questions. If you need additional help there are several places you can find it.</p>
|
||||
|
||||
<a name="docs"></a><h3>3.i. phpBB3 Documentation</h3>
|
||||
|
||||
<p>A comprehensive documentation is now available online and can be accessed from the following location:</p>
|
||||
<p>Comprehensive documentation is now available on the phpBB website:</p>
|
||||
|
||||
<p><a href="http://www.phpbb.com/support/documentation/3.0/">http://www.phpbb.com/support/documentation/3.0/</a></p>
|
||||
|
||||
<p>This covers everything from installation through setting permissions and managing users.</p>
|
||||
<p>This covers everything from installation to setting permissions and managing users.</p>
|
||||
|
||||
<a name="kb"></a><h3>3.ii. Knowledge Base</h3>
|
||||
|
||||
|
@ -197,7 +196,7 @@
|
|||
|
||||
<p><a href="http://www.phpbb.com/community/">http://www.phpbb.com/community/</a></p>
|
||||
|
||||
<p>If you do seek help via our forums please be sure to do a Search before posting. This may well save both you and us time and allow the developer, moderator and support groups to spend more time responding to people with unknown issues and problems. Please also remember that phpBB is an entirely volunteer effort, no one receives any compensation for the time they give, this includes moderators as well as developers. So please be respectful and mindful when awaiting responses.</p>
|
||||
<p>If you do seek help via our forums please be sure to do a search before posting; if someone has experienced the issue before, then you may find that your question has already been answered. Please remember that phpBB is entirely staffed by volunteers, no one receives any compensation for the time they give, including moderators as well as developers; please be respectful and mindful when awaiting responses and receiving support.</p>
|
||||
|
||||
<a name="irc"></a><h3>3.iv Internet Relay Chat</h3>
|
||||
|
||||
|
@ -268,7 +267,7 @@
|
|||
|
||||
<p>The relevant database type/version is listed within the administration control panel.</p>
|
||||
|
||||
<p>Please also be as detailed as you can in your report, if possible list the steps required to duplicate the problem. If you have a patch that fixes the issue, please attach it to the ticket or submit a pull request <a href="https://github.com/phpbb/phpbb3">on GitHub</a>.</p>
|
||||
<p>Please be as detailed as you can in your report, and if possible, list the steps required to duplicate the problem. If you have a patch that fixes the issue, please attach it to the ticket or submit a pull request to our repository <a href="https://github.com/phpbb/phpbb3">on GitHub</a>.</p>
|
||||
|
||||
<p>If you create a patch, it is very much appreciated (but not required) if you follow the phpBB coding guidelines. Please note that the coding guidelines are somewhat different between different versions of phpBB. For phpBB 3.1.x the coding guidelines may be found here: <a href="http://area51.phpbb.com/docs/31x/coding-guidelines.html">http://area51.phpbb.com/docs/31x/coding-guidelines.html</a></p>
|
||||
|
||||
|
@ -299,8 +298,8 @@
|
|||
<p>This list is not complete but does represent those bugs which may affect users on a wider scale. Other bugs listed in the tracker have typically been shown to be limited to certain setups or methods of installation, updating and/or conversions.</p>
|
||||
|
||||
<ul>
|
||||
<li>Conversions may fail to complete on large boards under some hosts</li>
|
||||
<li>Updates may fail to complete on large update sets under some hosts</li>
|
||||
<li>Conversions may fail to complete on large boards under some hosts.</li>
|
||||
<li>Updates may fail to complete on large update sets under some hosts.</li>
|
||||
<li>Smilies placed directly after bbcode tags will not get parsed. Smilies always need to be separated by spaces.</li>
|
||||
</ul>
|
||||
|
||||
|
@ -322,7 +321,7 @@
|
|||
|
||||
<p>phpBB 3.1.x takes advantage of new features added in PHP 5.3. We recommend that you upgrade to the latest stable release of PHP5 to run phpBB. The minimum version required is PHP 5.3.3.</p>
|
||||
|
||||
<p>Please remember that running any application on a developmental version of PHP can lead to strange/unexpected results which may appear to be bugs in the application (which may not be true). Therefore we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a developmental version of PHP please check any bugs you find on a system running a stable release before submitting.</p>
|
||||
<p>Please remember that running any application on a development (unstable, e.g. a beta release) version of PHP can lead to strange/unexpected results which may appear to be bugs in the application. Therefore, we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a development version of PHP please check any bugs you find on a system running a stable release before submitting.</p>
|
||||
|
||||
<p>This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 8.x, Oracle 8, SQLite 2 and Firebird. Versions of PHP used range from 5.3.x to 5.4.x without problem.</p>
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ else if ($download_id)
|
|||
phpbb_increment_downloads($db, $attachment['attach_id']);
|
||||
}
|
||||
|
||||
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower($user->browser), 'msie') !== false) && (strpos(strtolower($user->browser), 'msie 8.0') === false)))
|
||||
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && (strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7))
|
||||
{
|
||||
wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']);
|
||||
file_gc();
|
||||
|
|
|
@ -522,84 +522,54 @@ class acp_board
|
|||
if ($mode == 'auth')
|
||||
{
|
||||
// Retrieve a list of auth plugins and check their config values
|
||||
$auth_plugins = array();
|
||||
|
||||
$dp = @opendir($phpbb_root_path . 'includes/auth');
|
||||
|
||||
if ($dp)
|
||||
{
|
||||
while (($file = readdir($dp)) !== false)
|
||||
{
|
||||
if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
|
||||
{
|
||||
$auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
|
||||
}
|
||||
}
|
||||
closedir($dp);
|
||||
|
||||
sort($auth_plugins);
|
||||
}
|
||||
$auth_providers = $phpbb_container->get('auth.provider_collection');
|
||||
|
||||
$updated_auth_settings = false;
|
||||
$old_auth_config = array();
|
||||
foreach ($auth_plugins as $method)
|
||||
foreach ($auth_providers as $provider)
|
||||
{
|
||||
if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
|
||||
if ($fields = $provider->acp($this->new_config))
|
||||
{
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'acp_' . $method;
|
||||
if (function_exists($method))
|
||||
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
||||
foreach ($fields['config'] as $field)
|
||||
{
|
||||
if ($fields = $method($this->new_config))
|
||||
if (!isset($config[$field]))
|
||||
{
|
||||
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
||||
foreach ($fields['config'] as $field)
|
||||
{
|
||||
if (!isset($config[$field]))
|
||||
{
|
||||
set_config($field, '');
|
||||
}
|
||||
|
||||
if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$old_auth_config[$field] = $this->new_config[$field];
|
||||
$config_value = $cfg_array[$field];
|
||||
$this->new_config[$field] = $config_value;
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$updated_auth_settings = true;
|
||||
set_config($field, $config_value);
|
||||
}
|
||||
}
|
||||
set_config($field, '');
|
||||
}
|
||||
|
||||
if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$old_auth_config[$field] = $this->new_config[$field];
|
||||
$config_value = $cfg_array[$field];
|
||||
$this->new_config[$field] = $config_value;
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$updated_auth_settings = true;
|
||||
set_config($field, $config_value);
|
||||
}
|
||||
unset($fields);
|
||||
}
|
||||
}
|
||||
unset($fields);
|
||||
}
|
||||
|
||||
if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
|
||||
{
|
||||
$method = basename($cfg_array['auth_method']);
|
||||
if ($method && in_array($method, $auth_plugins))
|
||||
if (array_key_exists('auth.provider.' . $method, $auth_providers))
|
||||
{
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'init_' . $method;
|
||||
if (function_exists($method))
|
||||
$provider = $auth_providers['auth.provider.' . $method];
|
||||
if ($error = $provider->init())
|
||||
{
|
||||
if ($error = $method())
|
||||
foreach ($old_auth_config as $config_name => $config_value)
|
||||
{
|
||||
foreach ($old_auth_config as $config_name => $config_value)
|
||||
{
|
||||
set_config($config_name, $config_value);
|
||||
}
|
||||
trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
set_config($config_name, $config_value);
|
||||
}
|
||||
trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
set_config('auth_method', basename($cfg_array['auth_method']));
|
||||
}
|
||||
|
@ -683,24 +653,17 @@ class acp_board
|
|||
{
|
||||
$template->assign_var('S_AUTH', true);
|
||||
|
||||
foreach ($auth_plugins as $method)
|
||||
foreach ($auth_providers as $provider)
|
||||
{
|
||||
if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
|
||||
{
|
||||
$method = 'acp_' . $method;
|
||||
if (function_exists($method))
|
||||
{
|
||||
$fields = $method($this->new_config);
|
||||
$fields = $provider->acp($this->new_config);
|
||||
|
||||
if ($fields['tpl'])
|
||||
{
|
||||
$template->assign_block_vars('auth_tpl', array(
|
||||
'TPL' => $fields['tpl'])
|
||||
);
|
||||
}
|
||||
unset($fields);
|
||||
}
|
||||
if ($fields['tpl'])
|
||||
{
|
||||
$template->assign_block_vars('auth_tpl', array(
|
||||
'TPL' => $fields['tpl'],
|
||||
));
|
||||
}
|
||||
unset($fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -710,26 +673,16 @@ class acp_board
|
|||
*/
|
||||
function select_auth_method($selected_method, $key = '')
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
global $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$auth_plugins = array();
|
||||
$auth_providers = $phpbb_container->get('auth.provider_collection');
|
||||
|
||||
$dp = @opendir($phpbb_root_path . 'includes/auth');
|
||||
|
||||
if (!$dp)
|
||||
foreach($auth_providers as $key => $value)
|
||||
{
|
||||
return '';
|
||||
$auth_plugins[] = str_replace('auth.provider.', '', $key);
|
||||
}
|
||||
|
||||
while (($file = readdir($dp)) !== false)
|
||||
{
|
||||
if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
|
||||
{
|
||||
$auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
|
||||
}
|
||||
}
|
||||
closedir($dp);
|
||||
|
||||
sort($auth_plugins);
|
||||
|
||||
$auth_select = '';
|
||||
|
|
|
@ -124,6 +124,8 @@ class acp_captcha
|
|||
'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id),
|
||||
'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(),
|
||||
'CAPTCHA_SELECT' => $captcha_select,
|
||||
|
||||
'U_ACTION' => $this->u_action,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,7 +591,7 @@ class acp_groups
|
|||
|
||||
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
|
||||
if (!$update)
|
||||
if (isset($phpbb_avatar_manager) && !$update)
|
||||
{
|
||||
// Merge any avatar errors into the primary error array
|
||||
$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
|
||||
|
|
|
@ -21,6 +21,7 @@ if (!defined('IN_PHPBB'))
|
|||
class acp_permission_roles
|
||||
{
|
||||
var $u_action;
|
||||
protected $auth_admin;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ class acp_permission_roles
|
|||
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
|
||||
|
||||
$auth_admin = new auth_admin();
|
||||
$this->auth_admin = new auth_admin();
|
||||
|
||||
$user->add_lang('acp/permissions');
|
||||
add_permission_language();
|
||||
|
@ -210,7 +211,7 @@ class acp_permission_roles
|
|||
}
|
||||
|
||||
// Now add the auth settings
|
||||
$auth_admin->acl_set_role($role_id, $auth_settings);
|
||||
$this->auth_admin->acl_set_role($role_id, $auth_settings);
|
||||
|
||||
$role_name = (!empty($user->lang[$role_name])) ? $user->lang[$role_name] : $role_name;
|
||||
add_log('admin', 'LOG_' . strtoupper($permission_type) . 'ROLE_' . strtoupper($action), $role_name);
|
||||
|
@ -343,7 +344,7 @@ class acp_permission_roles
|
|||
// Get users/groups/forums using this preset...
|
||||
if ($action == 'edit')
|
||||
{
|
||||
$hold_ary = $auth_admin->get_role_mask($role_id);
|
||||
$hold_ary = $this->auth_admin->get_role_mask($role_id);
|
||||
|
||||
if (sizeof($hold_ary))
|
||||
{
|
||||
|
@ -354,7 +355,7 @@ class acp_permission_roles
|
|||
'L_ROLE_ASSIGNED_TO' => sprintf($user->lang['ROLE_ASSIGNED_TO'], $role_name))
|
||||
);
|
||||
|
||||
$auth_admin->display_role_mask($hold_ary);
|
||||
$this->auth_admin->display_role_mask($hold_ary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,8 +446,8 @@ class acp_permission_roles
|
|||
'S_DISPLAY_ROLE_MASK' => true)
|
||||
);
|
||||
|
||||
$hold_ary = $auth_admin->get_role_mask($display_item);
|
||||
$auth_admin->display_role_mask($hold_ary);
|
||||
$hold_ary = $this->auth_admin->get_role_mask($display_item);
|
||||
$this->auth_admin->display_role_mask($hold_ary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,7 +463,7 @@ class acp_permission_roles
|
|||
$auth_options = array(0 => $auth_options);
|
||||
|
||||
// Making use of auth_admin method here (we do not really want to change two similar code fragments)
|
||||
auth_admin::build_permission_array($auth_options, $content_array, $categories, $key_sort_array);
|
||||
$this->auth_admin->build_permission_array($auth_options, $content_array, $categories, $key_sort_array);
|
||||
|
||||
$content_array = $content_array[0];
|
||||
|
||||
|
@ -500,8 +501,6 @@ class acp_permission_roles
|
|||
{
|
||||
global $db;
|
||||
|
||||
$auth_admin = new auth_admin();
|
||||
|
||||
// Get complete auth array
|
||||
$sql = 'SELECT auth_option, auth_option_id
|
||||
FROM ' . ACL_OPTIONS_TABLE . "
|
||||
|
@ -529,19 +528,19 @@ class acp_permission_roles
|
|||
$db->sql_freeresult($result);
|
||||
|
||||
// Get role assignments
|
||||
$hold_ary = $auth_admin->get_role_mask($role_id);
|
||||
$hold_ary = $this->auth_admin->get_role_mask($role_id);
|
||||
|
||||
// Re-assign permissions
|
||||
foreach ($hold_ary as $forum_id => $forum_ary)
|
||||
{
|
||||
if (isset($forum_ary['users']))
|
||||
{
|
||||
$auth_admin->acl_set('user', $forum_id, $forum_ary['users'], $auth_settings, 0, false);
|
||||
$this->auth_admin->acl_set('user', $forum_id, $forum_ary['users'], $auth_settings, 0, false);
|
||||
}
|
||||
|
||||
if (isset($forum_ary['groups']))
|
||||
{
|
||||
$auth_admin->acl_set('group', $forum_id, $forum_ary['groups'], $auth_settings, 0, false);
|
||||
$this->auth_admin->acl_set('group', $forum_id, $forum_ary['groups'], $auth_settings, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,6 +562,6 @@ class acp_permission_roles
|
|||
WHERE role_id = ' . $role_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$auth_admin->acl_clear_prefetch();
|
||||
$this->auth_admin->acl_clear_prefetch();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -927,15 +927,14 @@ class phpbb_auth
|
|||
*/
|
||||
function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
|
||||
{
|
||||
global $config, $db, $user, $phpbb_root_path, $phpEx;
|
||||
global $config, $db, $user, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$method = trim(basename($config['auth_method']));
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'login_' . $method;
|
||||
if (function_exists($method))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
if ($provider)
|
||||
{
|
||||
$login = $method($username, $password, $user->ip, $user->browser, $user->forwarded_for);
|
||||
$login = $provider->login($username, $password);
|
||||
|
||||
// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
|
||||
if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE)
|
||||
|
|
|
@ -1,247 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Apache auth plug-in for phpBB3
|
||||
*
|
||||
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
|
||||
*
|
||||
* @package login
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the user is identified to apache
|
||||
* Only allow changing authentication to apache if the user is identified
|
||||
* Called in acp_board while setting authentication plugins
|
||||
*
|
||||
* @return boolean|string false if the user is identified and else an error message
|
||||
*/
|
||||
function init_apache()
|
||||
{
|
||||
global $user, $request;
|
||||
|
||||
if (!$request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER) || $user->data['username'] !== htmlspecialchars_decode($request->server('PHP_AUTH_USER')))
|
||||
{
|
||||
return $user->lang['APACHE_SETUP_BEFORE_USE'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login function
|
||||
*/
|
||||
function login_apache(&$username, &$password)
|
||||
{
|
||||
global $db, $request;
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$php_auth_user = htmlspecialchars_decode($request->server('PHP_AUTH_USER'));
|
||||
$php_auth_pw = htmlspecialchars_decode($request->server('PHP_AUTH_PW'));
|
||||
|
||||
if (!empty($php_auth_user) && !empty($php_auth_pw))
|
||||
{
|
||||
if ($php_auth_user !== $username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// this is the user's first login so create an empty profile
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE,
|
||||
'error_msg' => false,
|
||||
'user_row' => user_row_apache($php_auth_user, $php_auth_pw),
|
||||
);
|
||||
}
|
||||
|
||||
// Not logged into apache
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Autologin function
|
||||
*
|
||||
* @return array containing the user row or empty if no auto login should take place
|
||||
*/
|
||||
function autologin_apache()
|
||||
{
|
||||
global $db, $request;
|
||||
|
||||
if (!$request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$php_auth_user = htmlspecialchars_decode($request->server('PHP_AUTH_USER'));
|
||||
$php_auth_pw = htmlspecialchars_decode($request->server('PHP_AUTH_PW'));
|
||||
|
||||
if (!empty($php_auth_user) && !empty($php_auth_pw))
|
||||
{
|
||||
set_var($php_auth_user, $php_auth_user, 'string', true);
|
||||
set_var($php_auth_pw, $php_auth_pw, 'string', true);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row;
|
||||
}
|
||||
|
||||
if (!function_exists('user_add'))
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// create the user if he does not exist yet
|
||||
user_add(user_row_apache($php_auth_user, $php_auth_pw));
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates an array which can be passed to the user_add function in order to create a user
|
||||
*/
|
||||
function user_row_apache($username, $password)
|
||||
{
|
||||
global $db, $config, $user;
|
||||
// first retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
|
||||
AND group_type = " . GROUP_SPECIAL;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
// generate user account data
|
||||
return array(
|
||||
'username' => $username,
|
||||
'user_password' => phpbb_hash($password),
|
||||
'user_email' => '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => USER_NORMAL,
|
||||
'user_ip' => $user->ip,
|
||||
'user_new' => ($config['new_member_post_limit']) ? 1 : 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The session validation function checks whether the user is still logged in
|
||||
*
|
||||
* @return boolean true if the given user is authenticated or false if the session should be closed
|
||||
*/
|
||||
function validate_session_apache(&$user)
|
||||
{
|
||||
global $request;
|
||||
|
||||
// Check if PHP_AUTH_USER is set and handle this case
|
||||
if ($request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
$php_auth_user = $request->server('PHP_AUTH_USER');
|
||||
|
||||
return ($php_auth_user === $user['username']) ? true : false;
|
||||
}
|
||||
|
||||
// PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not)
|
||||
if ($user['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -1,289 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Database auth plug-in for phpBB3
|
||||
*
|
||||
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
|
||||
*
|
||||
* This is for authentication via the integrated user table
|
||||
*
|
||||
* @package login
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login function
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $ip IP address the login is taking place from. Used to
|
||||
* limit the number of login attempts per IP address.
|
||||
* @param string $browser The user agent used to login
|
||||
* @param string $forwarded_for X_FORWARDED_FOR header sent with login request
|
||||
* @return array A associative array of the format
|
||||
* array(
|
||||
* 'status' => status constant
|
||||
* 'error_msg' => string
|
||||
* 'user_row' => array
|
||||
* )
|
||||
*/
|
||||
function login_db($username, $password, $ip = '', $browser = '', $forwarded_for = '')
|
||||
{
|
||||
global $db, $config;
|
||||
global $request;
|
||||
|
||||
// Auth plugins get the password untrimmed.
|
||||
// For compatibility we trim() here.
|
||||
$password = trim($password);
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$username_clean = utf8_clean_string($username);
|
||||
|
||||
$sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $db->sql_escape($username_clean) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (($ip && !$config['ip_login_limit_use_forwarded']) ||
|
||||
($forwarded_for && $config['ip_login_limit_use_forwarded']))
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) AS attempts
|
||||
FROM ' . LOGIN_ATTEMPT_TABLE . '
|
||||
WHERE attempt_time > ' . (time() - (int) $config['ip_login_limit_time']);
|
||||
if ($config['ip_login_limit_use_forwarded'])
|
||||
{
|
||||
$sql .= " AND attempt_forwarded_for = '" . $db->sql_escape($forwarded_for) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= " AND attempt_ip = '" . $db->sql_escape($ip) . "' ";
|
||||
}
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$attempts = (int) $db->sql_fetchfield('attempts');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$attempt_data = array(
|
||||
'attempt_ip' => $ip,
|
||||
'attempt_browser' => trim(substr($browser, 0, 149)),
|
||||
'attempt_forwarded_for' => $forwarded_for,
|
||||
'attempt_time' => time(),
|
||||
'user_id' => ($row) ? (int) $row['user_id'] : 0,
|
||||
'username' => $username,
|
||||
'username_clean' => $username_clean,
|
||||
);
|
||||
$sql = 'INSERT INTO ' . LOGIN_ATTEMPT_TABLE . $db->sql_build_array('INSERT', $attempt_data);
|
||||
$result = $db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attempts = 0;
|
||||
}
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
if ($config['ip_login_limit_max'] && $attempts >= $config['ip_login_limit_max'])
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$show_captcha = ($config['max_login_attempts'] && $row['user_login_attempts'] >= $config['max_login_attempts']) ||
|
||||
($config['ip_login_limit_max'] && $attempts >= $config['ip_login_limit_max']);
|
||||
|
||||
// If there are too much login attempts, we need to check for an confirm image
|
||||
// Every auth module is able to define what to do by itself...
|
||||
if ($show_captcha)
|
||||
{
|
||||
// Visual Confirmation handling
|
||||
if (!class_exists('phpbb_captcha_factory', false))
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
include ($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
|
||||
}
|
||||
|
||||
$captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_LOGIN);
|
||||
$vc_response = $captcha->validate($row);
|
||||
if ($vc_response)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$captcha->reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the password convert flag is set we need to convert it
|
||||
if ($row['user_pass_convert'])
|
||||
{
|
||||
// enable super globals to get literal value
|
||||
// this is needed to prevent unicode normalization
|
||||
$super_globals_disabled = $request->super_globals_disabled();
|
||||
if ($super_globals_disabled)
|
||||
{
|
||||
$request->enable_super_globals();
|
||||
}
|
||||
|
||||
// in phpBB2 passwords were used exactly as they were sent, with addslashes applied
|
||||
$password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : '';
|
||||
$password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format;
|
||||
$password_new_format = $request->variable('password', '', true);
|
||||
|
||||
if ($super_globals_disabled)
|
||||
{
|
||||
$request->disable_super_globals();
|
||||
}
|
||||
|
||||
if ($password == $password_new_format)
|
||||
{
|
||||
if (!function_exists('utf8_to_cp1252'))
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx);
|
||||
}
|
||||
|
||||
// cp1252 is phpBB2's default encoding, characters outside ASCII range might work when converted into that encoding
|
||||
// plain md5 support left in for conversions from other systems.
|
||||
if ((strlen($row['user_password']) == 34 && (phpbb_check_hash(md5($password_old_format), $row['user_password']) || phpbb_check_hash(md5(utf8_to_cp1252($password_old_format)), $row['user_password'])))
|
||||
|| (strlen($row['user_password']) == 32 && (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password'])))
|
||||
{
|
||||
$hash = phpbb_hash($password_new_format);
|
||||
|
||||
// Update the password in the users table to the new format and remove user_pass_convert flag
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_password = \'' . $db->sql_escape($hash) . '\',
|
||||
user_pass_convert = 0
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$row['user_pass_convert'] = 0;
|
||||
$row['user_password'] = $hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Although we weren't able to convert this password we have to
|
||||
// increase login attempt count to make sure this cannot be exploited
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = user_login_attempts + 1
|
||||
WHERE user_id = ' . (int) $row['user_id'] . '
|
||||
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
|
||||
$db->sql_query($sql);
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD_CONVERT,
|
||||
'error_msg' => 'LOGIN_ERROR_PASSWORD_CONVERT',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check password ...
|
||||
if (!$row['user_pass_convert'] && phpbb_check_hash($password, $row['user_password']))
|
||||
{
|
||||
// Check for old password hash...
|
||||
if (strlen($row['user_password']) == 32)
|
||||
{
|
||||
$hash = phpbb_hash($password);
|
||||
|
||||
// Update the password in the users table to the new format
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_password = '" . $db->sql_escape($hash) . "',
|
||||
user_pass_convert = 0
|
||||
WHERE user_id = {$row['user_id']}";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$row['user_password'] = $hash;
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . '
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
if ($row['user_login_attempts'] != 0)
|
||||
{
|
||||
// Successful, reset login attempts (the user passed all stages)
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = 0
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login... set user_login_attempts to zero...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Password incorrect - increase login attempts
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = user_login_attempts + 1
|
||||
WHERE user_id = ' . (int) $row['user_id'] . '
|
||||
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Give status about wrong password...
|
||||
return array(
|
||||
'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => ($show_captcha) ? 'LOGIN_ERROR_ATTEMPTS' : 'LOGIN_ERROR_PASSWORD',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
|
@ -1,350 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* LDAP auth plug-in for phpBB3
|
||||
*
|
||||
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
|
||||
*
|
||||
* @package login
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to ldap server
|
||||
* Only allow changing authentication to ldap if we can connect to the ldap server
|
||||
* Called in acp_board while setting authentication plugins
|
||||
*/
|
||||
function init_ldap()
|
||||
{
|
||||
global $config, $user;
|
||||
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return $user->lang['LDAP_NO_LDAP_EXTENSION'];
|
||||
}
|
||||
|
||||
$config['ldap_port'] = (int) $config['ldap_port'];
|
||||
if ($config['ldap_port'])
|
||||
{
|
||||
$ldap = @ldap_connect($config['ldap_server'], $config['ldap_port']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ldap = @ldap_connect($config['ldap_server']);
|
||||
}
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return $user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
if ($config['ldap_user'] || $config['ldap_password'])
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password'])))
|
||||
{
|
||||
return $user->lang['LDAP_INCORRECT_USER_PASSWORD'];
|
||||
}
|
||||
}
|
||||
|
||||
// ldap_connect only checks whether the specified server is valid, so the connection might still fail
|
||||
$search = @ldap_search(
|
||||
$ldap,
|
||||
htmlspecialchars_decode($config['ldap_base_dn']),
|
||||
ldap_user_filter($user->data['username']),
|
||||
(empty($config['ldap_email'])) ?
|
||||
array(htmlspecialchars_decode($config['ldap_uid'])) :
|
||||
array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])),
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
if ($search === false)
|
||||
{
|
||||
return $user->lang['LDAP_SEARCH_FAILED'];
|
||||
}
|
||||
|
||||
$result = @ldap_get_entries($ldap, $search);
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
|
||||
if (!is_array($result) || sizeof($result) < 2)
|
||||
{
|
||||
return sprintf($user->lang['LDAP_NO_IDENTITY'], $user->data['username']);
|
||||
}
|
||||
|
||||
if (!empty($config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($config['ldap_email'])]))
|
||||
{
|
||||
return $user->lang['LDAP_NO_EMAIL'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login function
|
||||
*/
|
||||
function login_ldap(&$username, &$password)
|
||||
{
|
||||
global $db, $config, $user;
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_LDAP_EXTENSION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$config['ldap_port'] = (int) $config['ldap_port'];
|
||||
if ($config['ldap_port'])
|
||||
{
|
||||
$ldap = @ldap_connect($config['ldap_server'], $config['ldap_port']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ldap = @ldap_connect($config['ldap_server']);
|
||||
}
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_SERVER_CONNECTION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
if ($config['ldap_user'] || $config['ldap_password'])
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password'])))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_SERVER_CONNECTION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$search = @ldap_search(
|
||||
$ldap,
|
||||
htmlspecialchars_decode($config['ldap_base_dn']),
|
||||
ldap_user_filter($username),
|
||||
(empty($config['ldap_email'])) ?
|
||||
array(htmlspecialchars_decode($config['ldap_uid'])) :
|
||||
array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])),
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
$ldap_result = @ldap_get_entries($ldap, $search);
|
||||
|
||||
if (is_array($ldap_result) && sizeof($ldap_result) > 1)
|
||||
{
|
||||
if (@ldap_bind($ldap, $ldap_result[0]['dn'], htmlspecialchars_decode($password)))
|
||||
{
|
||||
@ldap_close($ldap);
|
||||
|
||||
$sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
unset($ldap_result);
|
||||
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login... set user_login_attempts to zero...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
|
||||
AND group_type = " . GROUP_SPECIAL;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
// generate user account data
|
||||
$ldap_user_row = array(
|
||||
'username' => $username,
|
||||
'user_password' => phpbb_hash($password),
|
||||
'user_email' => (!empty($config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($config['ldap_email'])][0]) : '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => USER_NORMAL,
|
||||
'user_ip' => $user->ip,
|
||||
'user_new' => ($config['new_member_post_limit']) ? 1 : 0,
|
||||
);
|
||||
|
||||
unset($ldap_result);
|
||||
|
||||
// this is the user's first login so create an empty profile
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE,
|
||||
'error_msg' => false,
|
||||
'user_row' => $ldap_user_row,
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($ldap_result);
|
||||
@ldap_close($ldap);
|
||||
|
||||
// Give status about wrong password...
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'LOGIN_ERROR_PASSWORD',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a filter string for ldap_search to find a user
|
||||
*
|
||||
* @param $username string Username identifying the searched user
|
||||
*
|
||||
* @return string A filter string for ldap_search
|
||||
*/
|
||||
function ldap_user_filter($username)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$filter = '(' . $config['ldap_uid'] . '=' . ldap_escape(htmlspecialchars_decode($username)) . ')';
|
||||
if ($config['ldap_user_filter'])
|
||||
{
|
||||
$_filter = ($config['ldap_user_filter'][0] == '(' && substr($config['ldap_user_filter'], -1) == ')') ? $config['ldap_user_filter'] : "({$config['ldap_user_filter']})";
|
||||
$filter = "(&{$filter}{$_filter})";
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes an LDAP AttributeValue
|
||||
*/
|
||||
function ldap_escape($string)
|
||||
{
|
||||
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to output any required fields in the authentication
|
||||
* admin panel. It also defines any required configuration table fields.
|
||||
*/
|
||||
function acp_ldap(&$new)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$tpl = '
|
||||
|
||||
<dl>
|
||||
<dt><label for="ldap_server">' . $user->lang['LDAP_SERVER'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_SERVER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="' . $new['ldap_server'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_port">' . $user->lang['LDAP_PORT'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_PORT_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="' . $new['ldap_port'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_dn">' . $user->lang['LDAP_DN'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_DN_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="' . $new['ldap_base_dn'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_uid">' . $user->lang['LDAP_UID'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_UID_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="' . $new['ldap_uid'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user_filter">' . $user->lang['LDAP_USER_FILTER'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_USER_FILTER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="' . $new['ldap_user_filter'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_email">' . $user->lang['LDAP_EMAIL'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_EMAIL_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="email" id="ldap_email" size="40" name="config[ldap_email]" value="' . $new['ldap_email'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user">' . $user->lang['LDAP_USER'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_USER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="' . $new['ldap_user'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_password">' . $user->lang['LDAP_PASSWORD'] . $user->lang['COLON'] . '</label><br /><span>' . $user->lang['LDAP_PASSWORD_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="' . $new['ldap_password'] . '" autocomplete="off" /></dd>
|
||||
</dl>
|
||||
';
|
||||
|
||||
// These are fields required in the config table
|
||||
return array(
|
||||
'tpl' => $tpl,
|
||||
'config' => array('ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password')
|
||||
);
|
||||
}
|
275
phpBB/includes/auth/provider_apache.php
Normal file
275
phpBB/includes/auth/provider_apache.php
Normal file
|
@ -0,0 +1,275 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package auth
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apache authentication provider for phpBB3
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
|
||||
{
|
||||
/**
|
||||
* Apache Authentication Constructor
|
||||
*
|
||||
* @param phpbb_db_driver $db
|
||||
* @param phpbb_config $config
|
||||
* @param phpbb_request $request
|
||||
* @param phpbb_user $user
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')))
|
||||
{
|
||||
return $this->user->lang['APACHE_SETUP_BEFORE_USE'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function login($username, $password)
|
||||
{
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'));
|
||||
$php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW'));
|
||||
|
||||
if (!empty($php_auth_user) && !empty($php_auth_pw))
|
||||
{
|
||||
if ($php_auth_user !== $username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// this is the user's first login so create an empty profile
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE,
|
||||
'error_msg' => false,
|
||||
'user_row' => user_row_apache($php_auth_user, $php_auth_pw),
|
||||
);
|
||||
}
|
||||
|
||||
// Not logged into apache
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'));
|
||||
$php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW'));
|
||||
|
||||
if (!empty($php_auth_user) && !empty($php_auth_pw))
|
||||
{
|
||||
set_var($php_auth_user, $php_auth_user, 'string', true);
|
||||
set_var($php_auth_pw, $php_auth_pw, 'string', true);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row;
|
||||
}
|
||||
|
||||
if (!function_exists('user_add'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
}
|
||||
|
||||
// create the user if he does not exist yet
|
||||
user_add(user_row_apache($php_auth_user, $php_auth_pw));
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates an array which can be passed to the user_add
|
||||
* function in order to create a user
|
||||
*
|
||||
* @param string $username The username of the new user.
|
||||
* @param string $password The password of the new user.
|
||||
* @return array Contains data that can be passed directly to
|
||||
* the user_add function.
|
||||
*/
|
||||
private function user_row($username, $password)
|
||||
{
|
||||
// first retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "'
|
||||
AND group_type = " . GROUP_SPECIAL;
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
// generate user account data
|
||||
return array(
|
||||
'username' => $username,
|
||||
'user_password' => phpbb_hash($password),
|
||||
'user_email' => '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => USER_NORMAL,
|
||||
'user_ip' => $this->user->ip,
|
||||
'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
// Check if PHP_AUTH_USER is set and handle this case
|
||||
if ($this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER))
|
||||
{
|
||||
$php_auth_user = $this->request->server('PHP_AUTH_USER');
|
||||
|
||||
return ($php_auth_user === $user['username']) ? true : false;
|
||||
}
|
||||
|
||||
// PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not)
|
||||
if ($user['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
337
phpBB/includes/auth/provider_db.php
Normal file
337
phpBB/includes/auth/provider_db.php
Normal file
|
@ -0,0 +1,337 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package auth
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database authentication provider for phpBB3
|
||||
*
|
||||
* This is for authentication via the integrated user table
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
||||
{
|
||||
|
||||
/**
|
||||
* Database Authentication Constructor
|
||||
*
|
||||
* @param phpbb_db_driver $db
|
||||
* @param phpbb_config $config
|
||||
* @param phpbb_request $request
|
||||
* @param phpbb_user $user
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function login($username, $password)
|
||||
{
|
||||
// Auth plugins get the password untrimmed.
|
||||
// For compatibility we trim() here.
|
||||
$password = trim($password);
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$username_clean = utf8_clean_string($username);
|
||||
|
||||
$sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $this->db->sql_escape($username_clean) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (($this->user->ip && !$this->config['ip_login_limit_use_forwarded']) ||
|
||||
($this->user->forwarded_for && $this->config['ip_login_limit_use_forwarded']))
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) AS attempts
|
||||
FROM ' . LOGIN_ATTEMPT_TABLE . '
|
||||
WHERE attempt_time > ' . (time() - (int) $this->config['ip_login_limit_time']);
|
||||
if ($this->config['ip_login_limit_use_forwarded'])
|
||||
{
|
||||
$sql .= " AND attempt_forwarded_for = '" . $this->db->sql_escape($this->user->forwarded_for) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= " AND attempt_ip = '" . $this->db->sql_escape($this->user->ip) . "' ";
|
||||
}
|
||||
|
||||
$result = $this->db->sql_query($sql);
|
||||
$attempts = (int) $this->db->sql_fetchfield('attempts');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$attempt_data = array(
|
||||
'attempt_ip' => $this->user->ip,
|
||||
'attempt_browser' => trim(substr($this->user->browser, 0, 149)),
|
||||
'attempt_forwarded_for' => $this->user->forwarded_for,
|
||||
'attempt_time' => time(),
|
||||
'user_id' => ($row) ? (int) $row['user_id'] : 0,
|
||||
'username' => $username,
|
||||
'username_clean' => $username_clean,
|
||||
);
|
||||
$sql = 'INSERT INTO ' . LOGIN_ATTEMPT_TABLE . $this->db->sql_build_array('INSERT', $attempt_data);
|
||||
$result = $this->db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attempts = 0;
|
||||
}
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
if ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max'])
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) ||
|
||||
($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']);
|
||||
|
||||
// If there are too many login attempts, we need to check for a confirm image
|
||||
// Every auth module is able to define what to do by itself...
|
||||
if ($show_captcha)
|
||||
{
|
||||
// Visual Confirmation handling
|
||||
if (!class_exists('phpbb_captcha_factory', false))
|
||||
{
|
||||
include ($this->phpbb_root_path . 'includes/captcha/captcha_factory.' . $this->php_ext);
|
||||
}
|
||||
|
||||
$captcha = phpbb_captcha_factory::get_instance($this->config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_LOGIN);
|
||||
$vc_response = $captcha->validate($row);
|
||||
if ($vc_response)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$captcha->reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the password convert flag is set we need to convert it
|
||||
if ($row['user_pass_convert'])
|
||||
{
|
||||
// enable super globals to get literal value
|
||||
// this is needed to prevent unicode normalization
|
||||
$super_globals_disabled = $this->request->super_globals_disabled();
|
||||
if ($super_globals_disabled)
|
||||
{
|
||||
$this->request->enable_super_globals();
|
||||
}
|
||||
|
||||
// in phpBB2 passwords were used exactly as they were sent, with addslashes applied
|
||||
$password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : '';
|
||||
$password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format;
|
||||
$password_new_format = $this->request->variable('password', '', true);
|
||||
|
||||
if ($super_globals_disabled)
|
||||
{
|
||||
$this->request->disable_super_globals();
|
||||
}
|
||||
|
||||
if ($password == $password_new_format)
|
||||
{
|
||||
if (!function_exists('utf8_to_cp1252'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/utf/data/recode_basic.' . $this->php_ext);
|
||||
}
|
||||
|
||||
// cp1252 is phpBB2's default encoding, characters outside ASCII range might work when converted into that encoding
|
||||
// plain md5 support left in for conversions from other systems.
|
||||
if ((strlen($row['user_password']) == 34 && (phpbb_check_hash(md5($password_old_format), $row['user_password']) || phpbb_check_hash(md5(utf8_to_cp1252($password_old_format)), $row['user_password'])))
|
||||
|| (strlen($row['user_password']) == 32 && (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password'])))
|
||||
{
|
||||
$hash = phpbb_hash($password_new_format);
|
||||
|
||||
// Update the password in the users table to the new format and remove user_pass_convert flag
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_password = \'' . $this->db->sql_escape($hash) . '\',
|
||||
user_pass_convert = 0
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$row['user_pass_convert'] = 0;
|
||||
$row['user_password'] = $hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Although we weren't able to convert this password we have to
|
||||
// increase login attempt count to make sure this cannot be exploited
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = user_login_attempts + 1
|
||||
WHERE user_id = ' . (int) $row['user_id'] . '
|
||||
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD_CONVERT,
|
||||
'error_msg' => 'LOGIN_ERROR_PASSWORD_CONVERT',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check password ...
|
||||
if (!$row['user_pass_convert'] && phpbb_check_hash($password, $row['user_password']))
|
||||
{
|
||||
// Check for old password hash...
|
||||
if (strlen($row['user_password']) == 32)
|
||||
{
|
||||
$hash = phpbb_hash($password);
|
||||
|
||||
// Update the password in the users table to the new format
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_password = '" . $this->db->sql_escape($hash) . "',
|
||||
user_pass_convert = 0
|
||||
WHERE user_id = {$row['user_id']}";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$row['user_password'] = $hash;
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . '
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($row['user_login_attempts'] != 0)
|
||||
{
|
||||
// Successful, reset login attempts (the user passed all stages)
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = 0
|
||||
WHERE user_id = ' . $row['user_id'];
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login... set user_login_attempts to zero...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Password incorrect - increase login attempts
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_login_attempts = user_login_attempts + 1
|
||||
WHERE user_id = ' . (int) $row['user_id'] . '
|
||||
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
// Give status about wrong password...
|
||||
return array(
|
||||
'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => ($show_captcha) ? 'LOGIN_ERROR_ATTEMPTS' : 'LOGIN_ERROR_PASSWORD',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
93
phpBB/includes/auth/provider_interface.php
Normal file
93
phpBB/includes/auth/provider_interface.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package auth
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface authentication provider classes have to implement.
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
interface phpbb_auth_provider_interface
|
||||
{
|
||||
/**
|
||||
* Checks whether the user is currently identified to the authentication
|
||||
* provider.
|
||||
* Called in acp_board while setting authentication plugins.
|
||||
* Changing to an authentication provider will not be permitted in acp_board
|
||||
* if there is an error.
|
||||
*
|
||||
* @return boolean|string False if the user is identified, otherwise an
|
||||
* error message, or null if not implemented.
|
||||
*/
|
||||
public function init();
|
||||
|
||||
/**
|
||||
* Performs login.
|
||||
*
|
||||
* @param string $username The name of the user being authenticated.
|
||||
* @param string $password The password of the user.
|
||||
* @return array An associative array of the format:
|
||||
* array(
|
||||
* 'status' => status constant
|
||||
* 'error_msg' => string
|
||||
* 'user_row' => array
|
||||
* )
|
||||
*/
|
||||
public function login($username, $password);
|
||||
|
||||
/**
|
||||
* Autologin function
|
||||
*
|
||||
* @return array|null containing the user row, empty if no auto login
|
||||
* should take place, or null if not impletmented.
|
||||
*/
|
||||
public function autologin();
|
||||
|
||||
/**
|
||||
* This function is used to output any required fields in the authentication
|
||||
* admin panel. It also defines any required configuration table fields.
|
||||
*
|
||||
* @param array $new Contains the new configuration values that have
|
||||
* been set in acp_board.
|
||||
* @return array|null Returns null if not implemented or an array of the
|
||||
* form:
|
||||
* array(
|
||||
* 'tpl' => string
|
||||
* 'config' => array
|
||||
* )
|
||||
*/
|
||||
public function acp($new);
|
||||
|
||||
/**
|
||||
* Performs additional actions during logout.
|
||||
*
|
||||
* @param array $data An array corresponding to
|
||||
* phpbb_session::data
|
||||
* @param boolean $new_session True for a new session, false for no new
|
||||
* session.
|
||||
*/
|
||||
public function logout($data, $new_session);
|
||||
|
||||
/**
|
||||
* The session validation function checks whether the user is still logged
|
||||
* into phpBB.
|
||||
*
|
||||
* @param array $user
|
||||
* @return boolean true if the given user is authenticated, false if the
|
||||
* session should be closed, or null if not implemented.
|
||||
*/
|
||||
public function validate_session($user);
|
||||
}
|
386
phpBB/includes/auth/provider_ldap.php
Normal file
386
phpBB/includes/auth/provider_ldap.php
Normal file
|
@ -0,0 +1,386 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package auth
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database authentication provider for phpBB3
|
||||
*
|
||||
* This is for authentication via the integrated user table
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
|
||||
{
|
||||
/**
|
||||
* LDAP Authentication Constructor
|
||||
*
|
||||
* @param phpbb_db_driver $db
|
||||
* @param phpbb_config $config
|
||||
* @param phpbb_user $user
|
||||
*/
|
||||
public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return $this->user->lang['LDAP_NO_LDAP_EXTENSION'];
|
||||
}
|
||||
|
||||
$this->config['ldap_port'] = (int) $this->config['ldap_port'];
|
||||
if ($this->config['ldap_port'])
|
||||
{
|
||||
$ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ldap = @ldap_connect($this->config['ldap_server']);
|
||||
}
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return $this->user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
if ($this->config['ldap_user'] || $this->config['ldap_password'])
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password'])))
|
||||
{
|
||||
return $this->user->lang['LDAP_INCORRECT_USER_PASSWORD'];
|
||||
}
|
||||
}
|
||||
|
||||
// ldap_connect only checks whether the specified server is valid, so the connection might still fail
|
||||
$search = @ldap_search(
|
||||
$ldap,
|
||||
htmlspecialchars_decode($this->config['ldap_base_dn']),
|
||||
$this->ldap_user_filter($this->user->data['username']),
|
||||
(empty($this->config['ldap_email'])) ?
|
||||
array(htmlspecialchars_decode($this->config['ldap_uid'])) :
|
||||
array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])),
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
if ($search === false)
|
||||
{
|
||||
return $this->user->lang['LDAP_SEARCH_FAILED'];
|
||||
}
|
||||
|
||||
$result = @ldap_get_entries($ldap, $search);
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
|
||||
if (!is_array($result) || sizeof($result) < 2)
|
||||
{
|
||||
return sprintf($this->user->lang['LDAP_NO_IDENTITY'], $this->user->data['username']);
|
||||
}
|
||||
|
||||
if (!empty($this->config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($this->config['ldap_email'])]))
|
||||
{
|
||||
return $this->user->lang['LDAP_NO_EMAIL'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function login($username, $password)
|
||||
{
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'NO_PASSWORD_SUPPLIED',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$username)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_LDAP_EXTENSION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
$this->config['ldap_port'] = (int) $this->config['ldap_port'];
|
||||
if ($this->config['ldap_port'])
|
||||
{
|
||||
$ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ldap = @ldap_connect($this->config['ldap_server']);
|
||||
}
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_SERVER_CONNECTION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
if ($this->config['ldap_user'] || $this->config['ldap_password'])
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password'])))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
'error_msg' => 'LDAP_NO_SERVER_CONNECTION',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$search = @ldap_search(
|
||||
$ldap,
|
||||
htmlspecialchars_decode($this->config['ldap_base_dn']),
|
||||
$this->ldap_user_filter($username),
|
||||
(empty($this->config['ldap_email'])) ?
|
||||
array(htmlspecialchars_decode($this->config['ldap_uid'])) :
|
||||
array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])),
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
$ldap_result = @ldap_get_entries($ldap, $search);
|
||||
|
||||
if (is_array($ldap_result) && sizeof($ldap_result) > 1)
|
||||
{
|
||||
if (@ldap_bind($ldap, $ldap_result[0]['dn'], htmlspecialchars_decode($password)))
|
||||
{
|
||||
@ldap_close($ldap);
|
||||
|
||||
$sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
unset($ldap_result);
|
||||
|
||||
// User inactive...
|
||||
if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ACTIVE,
|
||||
'error_msg' => 'ACTIVE_ERROR',
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
// Successful login... set user_login_attempts to zero...
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "'
|
||||
AND group_type = " . GROUP_SPECIAL;
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_GROUP');
|
||||
}
|
||||
|
||||
// generate user account data
|
||||
$ldap_user_row = array(
|
||||
'username' => $username,
|
||||
'user_password' => phpbb_hash($password),
|
||||
'user_email' => (!empty($this->config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($this->config['ldap_email'])][0]) : '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => USER_NORMAL,
|
||||
'user_ip' => $this->user->ip,
|
||||
'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0,
|
||||
);
|
||||
|
||||
unset($ldap_result);
|
||||
|
||||
// this is the user's first login so create an empty profile
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE,
|
||||
'error_msg' => false,
|
||||
'user_row' => $ldap_user_row,
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($ldap_result);
|
||||
@ldap_close($ldap);
|
||||
|
||||
// Give status about wrong password...
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_PASSWORD,
|
||||
'error_msg' => 'LOGIN_ERROR_PASSWORD',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_USERNAME,
|
||||
'error_msg' => 'LOGIN_ERROR_USERNAME',
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
$tpl = '
|
||||
|
||||
<dl>
|
||||
<dt><label for="ldap_server">' . $this->user->lang['LDAP_SERVER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_SERVER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="' . $new['ldap_server'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_port">' . $this->user->lang['LDAP_PORT'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_PORT_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="' . $new['ldap_port'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_dn">' . $this->user->lang['LDAP_DN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_DN_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="' . $new['ldap_base_dn'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_uid">' . $this->user->lang['LDAP_UID'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_UID_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="' . $new['ldap_uid'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user_filter">' . $this->user->lang['LDAP_USER_FILTER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_USER_FILTER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="' . $new['ldap_user_filter'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_email">' . $this->user->lang['LDAP_EMAIL'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_EMAIL_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="email" id="ldap_email" size="40" name="config[ldap_email]" value="' . $new['ldap_email'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user">' . $this->user->lang['LDAP_USER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_USER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="' . $new['ldap_user'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_password">' . $this->user->lang['LDAP_PASSWORD'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_PASSWORD_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="' . $new['ldap_password'] . '" autocomplete="off" /></dd>
|
||||
</dl>
|
||||
';
|
||||
|
||||
// These are fields required in the config table
|
||||
return array(
|
||||
'tpl' => $tpl,
|
||||
'config' => array('ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a filter string for ldap_search to find a user
|
||||
*
|
||||
* @param $username string Username identifying the searched user
|
||||
*
|
||||
* @return string A filter string for ldap_search
|
||||
*/
|
||||
private function ldap_user_filter($username)
|
||||
{
|
||||
$filter = '(' . $this->config['ldap_uid'] . '=' . $this->ldap_escape(htmlspecialchars_decode($username)) . ')';
|
||||
if ($this->config['ldap_user_filter'])
|
||||
{
|
||||
$_filter = ($this->config['ldap_user_filter'][0] == '(' && substr($this->config['ldap_user_filter'], -1) == ')') ? $this->config['ldap_user_filter'] : "({$this->config['ldap_user_filter']})";
|
||||
$filter = "(&{$filter}{$_filter})";
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes an LDAP AttributeValue
|
||||
*
|
||||
* @param string $string The string to be escaped
|
||||
* @return string The escaped string
|
||||
*/
|
||||
private function ldap_escape($string)
|
||||
{
|
||||
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -156,6 +156,7 @@ define('PHYSICAL_LINK', 2);
|
|||
define('CONFIRM_REG', 1);
|
||||
define('CONFIRM_LOGIN', 2);
|
||||
define('CONFIRM_POST', 3);
|
||||
define('CONFIRM_REPORT', 4);
|
||||
|
||||
// Categories - Attachments
|
||||
define('ATTACHMENT_CATEGORY_NONE', 0);
|
||||
|
|
|
@ -253,7 +253,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver_mssql_base
|
|||
* Fetch current row
|
||||
* @note number of bytes returned depends on odbc.defaultlrl php.ini setting. If it is limited to 4K for example only 4K of data is returned max.
|
||||
*/
|
||||
function sql_fetchrow($query_id = false, $debug = false)
|
||||
function sql_fetchrow($query_id = false)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -394,7 +394,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
|
|||
*/
|
||||
function sql_affectedrows()
|
||||
{
|
||||
return (!empty($this->query_result)) ? @sqlsrv_rows_affected($this->query_result) : false;
|
||||
return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->query_result) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,7 +409,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -474,9 +474,9 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
|
|||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
if (isset($this->open_queries[$query_id]))
|
||||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[$query_id]);
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @sqlsrv_free_stmt($query_id);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -2345,9 +2345,8 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
|
|||
$tpl_prefix . 'BASE_URL' => $base_url,
|
||||
'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
|
||||
$tpl_prefix . 'PER_PAGE' => $per_page,
|
||||
$tpl_prefix . 'PREVIOUS_PAGE' => $previous_page,
|
||||
$tpl_prefix . 'PREV_PAGE' => $previous_page,
|
||||
$tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '',
|
||||
'U_' . $tpl_prefix . 'PREVIOUS_PAGE' => $previous_page,
|
||||
'U_' . $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '',
|
||||
$tpl_prefix . 'TOTAL_PAGES' => $total_pages,
|
||||
$tpl_prefix . 'CURRENT_PAGE' => $on_page,
|
||||
);
|
||||
|
|
|
@ -46,7 +46,7 @@ function send_avatar_to_browser($file, $browser)
|
|||
$image_data = @getimagesize($file_path);
|
||||
header('Content-Type: ' . image_type_to_mime_type($image_data[2]));
|
||||
|
||||
if (strpos(strtolower($browser), 'msie') !== false && strpos(strtolower($browser), 'msie 8.0') === false)
|
||||
if ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($browser, 7))
|
||||
{
|
||||
header('Content-Disposition: attachment; ' . header_filename($file));
|
||||
|
||||
|
@ -174,10 +174,9 @@ function send_file_to_browser($attachment, $upload_dir, $category)
|
|||
header('Pragma: public');
|
||||
|
||||
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
|
||||
$is_ie8 = (strpos(strtolower($user->browser), 'msie 8.0') !== false);
|
||||
header('Content-Type: ' . $attachment['mimetype']);
|
||||
|
||||
if ($is_ie8)
|
||||
if (phpbb_is_greater_ie_version($user->browser, 7))
|
||||
{
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
}
|
||||
|
@ -189,7 +188,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (empty($user->browser) || (!$is_ie8 && (strpos(strtolower($user->browser), 'msie') !== false)))
|
||||
if (empty($user->browser) || ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7)))
|
||||
{
|
||||
header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
|
||||
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false))
|
||||
|
@ -200,7 +199,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
|
|||
else
|
||||
{
|
||||
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
|
||||
if ($is_ie8 && (strpos($attachment['mimetype'], 'image') !== 0))
|
||||
if (phpbb_is_greater_ie_version($user->browser, 7) && (strpos($attachment['mimetype'], 'image') !== 0))
|
||||
{
|
||||
header('X-Download-Options: noopen');
|
||||
}
|
||||
|
@ -410,7 +409,8 @@ function set_modified_headers($stamp, $browser)
|
|||
|
||||
// let's see if we have to send the file at all
|
||||
$last_load = $request->header('Modified-Since') ? strtotime(trim($request->header('Modified-Since'))) : false;
|
||||
if ((strpos(strtolower($browser), 'msie 6.0') === false) && (strpos(strtolower($browser), 'msie 8.0') === false))
|
||||
|
||||
if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie_version($browser, 7))
|
||||
{
|
||||
if ($last_load !== false && $last_load >= $stamp)
|
||||
{
|
||||
|
@ -721,3 +721,24 @@ function phpbb_download_clean_filename($filename)
|
|||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the browser is internet explorer version 7+
|
||||
*
|
||||
* @param string $user_agent User agent HTTP header
|
||||
* @param int $version IE version to check against
|
||||
*
|
||||
* @return bool true if internet explorer version is greater than $version
|
||||
*/
|
||||
function phpbb_is_greater_ie_version($user_agent, $version)
|
||||
{
|
||||
if (preg_match('/msie (\d+)/', strtolower($user_agent), $matches))
|
||||
{
|
||||
$ie_version = (int) $matches[1];
|
||||
return ($ie_version > $version);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1653,7 +1653,7 @@ function validate_username($username, $allowed_username = false)
|
|||
*/
|
||||
function validate_password($password)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
global $config;
|
||||
|
||||
if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY')
|
||||
{
|
||||
|
|
|
@ -611,7 +611,7 @@ class phpbb_search_fulltext_sphinx
|
|||
|
||||
$result_count = $result['total_found'];
|
||||
|
||||
if ($start >= $result_count)
|
||||
if ($result_count && $start >= $result_count)
|
||||
{
|
||||
$start = floor(($result_count - 1) / $per_page) * $per_page;
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ class phpbb_session
|
|||
function session_begin($update_session_page = true)
|
||||
{
|
||||
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
// Give us some basic information
|
||||
$this->time_now = time();
|
||||
|
@ -402,15 +402,12 @@ class phpbb_session
|
|||
|
||||
// Check whether the session is still valid if we have one
|
||||
$method = basename(trim($config['auth_method']));
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'validate_session_' . $method;
|
||||
if (function_exists($method))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$ret = $provider->validate_session($this->data);
|
||||
if ($ret !== null && !$ret)
|
||||
{
|
||||
if (!$method($this->data))
|
||||
{
|
||||
$session_expired = true;
|
||||
}
|
||||
$session_expired = true;
|
||||
}
|
||||
|
||||
if (!$session_expired)
|
||||
|
@ -504,7 +501,7 @@ class phpbb_session
|
|||
*/
|
||||
function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
|
||||
{
|
||||
global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx;
|
||||
global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$this->data = array();
|
||||
|
||||
|
@ -568,18 +565,14 @@ class phpbb_session
|
|||
}
|
||||
|
||||
$method = basename(trim($config['auth_method']));
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'autologin_' . $method;
|
||||
if (function_exists($method))
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$this->data = $provider->autologin();
|
||||
|
||||
if (sizeof($this->data))
|
||||
{
|
||||
$this->data = $method();
|
||||
|
||||
if (sizeof($this->data))
|
||||
{
|
||||
$this->cookie_data['k'] = '';
|
||||
$this->cookie_data['u'] = $this->data['user_id'];
|
||||
}
|
||||
$this->cookie_data['k'] = '';
|
||||
$this->cookie_data['u'] = $this->data['user_id'];
|
||||
}
|
||||
|
||||
// If we're presented with an autologin key we'll join against it.
|
||||
|
@ -884,7 +877,7 @@ class phpbb_session
|
|||
*/
|
||||
function session_kill($new_session = true)
|
||||
{
|
||||
global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx;
|
||||
global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
|
||||
WHERE session_id = '" . $db->sql_escape($this->session_id) . "'
|
||||
|
@ -893,13 +886,9 @@ class phpbb_session
|
|||
|
||||
// Allow connecting logout with external auth method logout
|
||||
$method = basename(trim($config['auth_method']));
|
||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
||||
|
||||
$method = 'logout_' . $method;
|
||||
if (function_exists($method))
|
||||
{
|
||||
$method($this->data, $new_session);
|
||||
}
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
$provider->logout($this->data, $new_session);
|
||||
|
||||
if ($this->data['user_id'] != ANONYMOUS)
|
||||
{
|
||||
|
|
|
@ -475,6 +475,7 @@ class phpbb_template_filter extends php_user_filter
|
|||
*/
|
||||
private function compile_var_tags(&$text_blocks)
|
||||
{
|
||||
$is_expr = null;
|
||||
$text_blocks = $this->get_varref($text_blocks, $is_expr);
|
||||
$lang_replaced = $this->compile_language_tags($text_blocks);
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ class ucp_groups
|
|||
}
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
if (isset($phpbb_avatar_manager) && !$update)
|
||||
{
|
||||
// Merge any avatars errors into the primary error array
|
||||
$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
|
||||
|
|
|
@ -53,7 +53,7 @@ class install_install extends module
|
|||
function main($mode, $sub)
|
||||
{
|
||||
global $lang, $template, $language, $phpbb_root_path, $phpEx;
|
||||
global $phpbb_container, $cache, $phpbb_log;
|
||||
global $phpbb_container, $cache, $phpbb_log, $request;
|
||||
|
||||
switch ($sub)
|
||||
{
|
||||
|
@ -102,6 +102,9 @@ class install_install extends module
|
|||
break;
|
||||
|
||||
case 'final':
|
||||
// Enable super globals to prevent issues with the new phpbb_request object
|
||||
$request->enable_super_globals();
|
||||
|
||||
// Create a normal container now
|
||||
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||
|
||||
|
|
188
phpBB/report.php
188
phpBB/report.php
|
@ -144,9 +144,25 @@ else
|
|||
$reported_post_enable_magic_url = $report_data['reported_post_enable_magic_url'];
|
||||
}
|
||||
|
||||
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
|
||||
{
|
||||
include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
|
||||
$captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_REPORT);
|
||||
}
|
||||
|
||||
$error = array();
|
||||
$s_hidden_fields = '';
|
||||
|
||||
// Submit report?
|
||||
if ($submit && $reason_id)
|
||||
{
|
||||
$visual_confirmation_response = $captcha->validate();
|
||||
if ($visual_confirmation_response)
|
||||
{
|
||||
$error[] = $visual_confirmation_response;
|
||||
}
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . REPORTS_REASONS_TABLE . "
|
||||
WHERE reason_id = $reason_id";
|
||||
|
@ -156,96 +172,108 @@ if ($submit && $reason_id)
|
|||
|
||||
if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
|
||||
{
|
||||
trigger_error('EMPTY_REPORT');
|
||||
$error[] = $user->lang('EMPTY_REPORT');
|
||||
}
|
||||
|
||||
$sql_ary = array(
|
||||
'reason_id' => (int) $reason_id,
|
||||
'post_id' => $post_id,
|
||||
'pm_id' => $pm_id,
|
||||
'user_id' => (int) $user->data['user_id'],
|
||||
'user_notify' => (int) $user_notify,
|
||||
'report_closed' => 0,
|
||||
'report_time' => (int) time(),
|
||||
'report_text' => (string) $report_text,
|
||||
'reported_post_text' => $reported_post_text,
|
||||
'reported_post_uid' => $reported_post_uid,
|
||||
'reported_post_bitfield' => $reported_post_bitfield,
|
||||
'reported_post_enable_bbcode' => $reported_post_enable_bbcode,
|
||||
'reported_post_enable_smilies' => $reported_post_enable_smilies,
|
||||
'reported_post_enable_magic_url' => $reported_post_enable_magic_url,
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
$report_id = $db->sql_nextid();
|
||||
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
if ($post_id)
|
||||
if (!sizeof($error))
|
||||
{
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET post_reported = 1
|
||||
WHERE post_id = ' . $post_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (!$report_data['topic_reported'])
|
||||
if (isset($captcha))
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_reported = 1
|
||||
WHERE topic_id = ' . $report_data['topic_id'] . '
|
||||
OR topic_moved_id = ' . $report_data['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
$captcha->reset();
|
||||
}
|
||||
|
||||
$lang_return = $user->lang['RETURN_TOPIC'];
|
||||
$lang_success = $user->lang['POST_REPORTED_SUCCESS'];
|
||||
|
||||
$phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data, array(
|
||||
'report_text' => $report_text,
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
|
||||
SET message_reported = 1
|
||||
WHERE msg_id = ' . $pm_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql_ary = array(
|
||||
'msg_id' => $pm_id,
|
||||
'user_id' => ANONYMOUS,
|
||||
'author_id' => (int) $report_data['author_id'],
|
||||
'pm_deleted' => 0,
|
||||
'pm_new' => 0,
|
||||
'pm_unread' => 0,
|
||||
'pm_replied' => 0,
|
||||
'pm_marked' => 0,
|
||||
'pm_forwarded' => 0,
|
||||
'folder_id' => PRIVMSGS_INBOX,
|
||||
'reason_id' => (int) $reason_id,
|
||||
'post_id' => $post_id,
|
||||
'pm_id' => $pm_id,
|
||||
'user_id' => (int) $user->data['user_id'],
|
||||
'user_notify' => (int) $user_notify,
|
||||
'report_closed' => 0,
|
||||
'report_time' => (int) time(),
|
||||
'report_text' => (string) $report_text,
|
||||
'reported_post_text' => $reported_post_text,
|
||||
'reported_post_uid' => $reported_post_uid,
|
||||
'reported_post_bitfield' => $reported_post_bitfield,
|
||||
'reported_post_enable_bbcode' => $reported_post_enable_bbcode,
|
||||
'reported_post_enable_smilies' => $reported_post_enable_smilies,
|
||||
'reported_post_enable_magic_url' => $reported_post_enable_magic_url,
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
$report_id = $db->sql_nextid();
|
||||
|
||||
$lang_return = $user->lang['RETURN_PM'];
|
||||
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array(
|
||||
'report_text' => $report_text,
|
||||
'from_user_id' => $report_data['author_id'],
|
||||
'report_id' => $report_id,
|
||||
)));
|
||||
if ($post_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET post_reported = 1
|
||||
WHERE post_id = ' . $post_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (!$report_data['topic_reported'])
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_reported = 1
|
||||
WHERE topic_id = ' . $report_data['topic_id'] . '
|
||||
OR topic_moved_id = ' . $report_data['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$lang_return = $user->lang['RETURN_TOPIC'];
|
||||
$lang_success = $user->lang['POST_REPORTED_SUCCESS'];
|
||||
|
||||
$phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data, array(
|
||||
'report_text' => $report_text,
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
|
||||
SET message_reported = 1
|
||||
WHERE msg_id = ' . $pm_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql_ary = array(
|
||||
'msg_id' => $pm_id,
|
||||
'user_id' => ANONYMOUS,
|
||||
'author_id' => (int) $report_data['author_id'],
|
||||
'pm_deleted' => 0,
|
||||
'pm_new' => 0,
|
||||
'pm_unread' => 0,
|
||||
'pm_replied' => 0,
|
||||
'pm_marked' => 0,
|
||||
'pm_forwarded' => 0,
|
||||
'folder_id' => PRIVMSGS_INBOX,
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$lang_return = $user->lang['RETURN_PM'];
|
||||
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
|
||||
|
||||
$phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array(
|
||||
'report_text' => $report_text,
|
||||
'from_user_id' => $report_data['author_id'],
|
||||
'report_id' => $report_id,
|
||||
)));
|
||||
}
|
||||
|
||||
meta_refresh(3, $redirect_url);
|
||||
|
||||
$message = $lang_success . '<br /><br />' . sprintf($lang_return, '<a href="' . $redirect_url . '">', '</a>');
|
||||
if ($return_forum_url)
|
||||
{
|
||||
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $return_forum_url . '">', '</a>');
|
||||
}
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
meta_refresh(3, $redirect_url);
|
||||
|
||||
$message = $lang_success . '<br /><br />' . sprintf($lang_return, '<a href="' . $redirect_url . '">', '</a>');
|
||||
if ($return_forum_url)
|
||||
else if (isset($captcha) && $captcha->is_solved() !== false)
|
||||
{
|
||||
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $return_forum_url . '">', '</a>');
|
||||
$s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields());
|
||||
}
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
// Generate the reasons
|
||||
|
@ -253,10 +281,20 @@ display_reasons($reason_id);
|
|||
|
||||
$page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST'];
|
||||
|
||||
if (isset($captcha) && $captcha->is_solved() === false)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_CONFIRM_CODE' => true,
|
||||
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
||||
));
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
||||
'S_REPORT_POST' => ($pm_id) ? false : true,
|
||||
'REPORT_TEXT' => $report_text,
|
||||
'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id),
|
||||
'S_HIDDEN_FIELDS' => (sizeof($s_hidden_fields)) ? $s_hidden_fields : null,
|
||||
|
||||
'S_NOTIFY' => $user_notify,
|
||||
'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
|
||||
|
|
|
@ -85,8 +85,8 @@
|
|||
<!-- ENDIF -->
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY_TOPICS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label>
|
||||
<label>{S_SELECT_SORT_DIR} <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
|
||||
<!-- IF .log -->
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY_POSTS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label>
|
||||
<label>{S_SELECT_SORT_DIR}</label>
|
||||
|
|
|
@ -95,8 +95,8 @@
|
|||
<hr />
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY_LOG}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label><label>{S_SELECT_SORT_DIR}</label>
|
||||
<input type="submit" name="sort" value="{L_GO}" class="button2" />
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
</ul>
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY_POSTS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label><label>{S_SELECT_SORT_DIR}</label>
|
||||
<!-- IF TOPIC_ID --><label><input type="checkbox" class="radio" name="t" value="{TOPIC_ID}" checked="checked" /> <strong>{L_ONLY_TOPIC}</strong></label><!-- ENDIF -->
|
||||
|
|
|
@ -72,8 +72,8 @@
|
|||
</ul>
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY_POSTS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label><label>{S_SELECT_SORT_DIR}</label>
|
||||
<!-- IF TOPIC_ID --><label><input type="checkbox" class="radio" name="t" value="{TOPIC_ID}" checked="checked" /> <strong>{L_ONLY_TOPIC}</strong></label><!-- ENDIF -->
|
||||
|
|
|
@ -140,8 +140,8 @@
|
|||
|
||||
<!-- IF S_IN_SEARCH_POPUP and not S_SEARCH_USER -->
|
||||
<fieldset class="display-options">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<label for="sk">{L_SELECT_SORT_METHOD}{L_COLON} <select name="sk" id="sk">{S_MODE_SELECT}</select></label>
|
||||
<label for="sd">{L_ORDER} <select name="sd" id="sd">{S_ORDER_SELECT}</select> <input type="submit" name="sort" value="{L_SUBMIT}" class="button2" /></label>
|
||||
</fieldset>
|
||||
|
|
|
@ -74,6 +74,10 @@ function insert_single(user)
|
|||
<dt><label for="msn">{L_MSNM}{L_COLON}</label></dt>
|
||||
<dd><input type="text" name="msn" id="msn" value="{MSNM}" class="inputbox" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="jabber">{L_JABBER}:</label></dt>
|
||||
<dd><input type="text" name="jabber" id="jabber" value="{JABBER}" class="inputbox" /></dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fields1 column2">
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<p><!-- IF S_REPORT_POST -->{L_REPORT_POST_EXPLAIN}<!-- ELSE -->{L_REPORT_MESSAGE_EXPLAIN}<!-- ENDIF --></p>
|
||||
|
||||
<fieldset>
|
||||
<!-- IF ERROR --><dl><dd class="error">{ERROR}</dd></dl><!-- ENDIF -->
|
||||
<dl class="fields2">
|
||||
<dt><label for="reason_id">{L_REASON}{L_COLON}</label></dt>
|
||||
<dd><select name="reason_id" id="reason_id" class="full"><!-- BEGIN reason --><option value="{reason.ID}"<!-- IF reason.S_SELECTED --> selected="selected"<!-- ENDIF -->>{reason.DESCRIPTION}</option><!-- END reason --></select></dd>
|
||||
|
@ -27,6 +28,9 @@
|
|||
<dt><label for="report_text">{L_MORE_INFO}{L_COLON}</label><br /><span>{L_CAN_LEAVE_BLANK}</span></dt>
|
||||
<dd><textarea name="report_text" id="report_text" rows="10" cols="76" class="inputbox">{REPORT_TEXT}</textarea></dd>
|
||||
</dl>
|
||||
<!-- IF CAPTCHA_TEMPLATE -->
|
||||
<!-- INCLUDE {CAPTCHA_TEMPLATE} -->
|
||||
<!-- ENDIF -->
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -154,8 +154,8 @@
|
|||
<form method="post" action="{S_SEARCH_ACTION}">
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF S_SELECT_SORT_DAYS or S_SELECT_SORT_KEY -->
|
||||
<label><!-- IF S_SHOW_TOPICS -->{L_DISPLAY_POSTS}<!-- ELSE -->{L_SORT_BY}</label><label><!-- ENDIF --> {S_SELECT_SORT_DAYS}<!-- IF S_SELECT_SORT_KEY --></label> <label>{S_SELECT_SORT_KEY}</label>
|
||||
<label>{S_SELECT_SORT_DIR}<!-- ENDIF --> <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
</ul>
|
||||
|
||||
<fieldset class="display-options">
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<label for="sk">{L_SORT_BY}{L_COLON} <select name="sk" id="sk">{S_SORT_OPTIONS}</select></label>
|
||||
<label><select name="sd" id="sd">{S_ORDER_SELECT}</select></label>
|
||||
<input class="button2" type="submit" name="sort" value="{L_SORT}" />
|
||||
|
|
|
@ -122,8 +122,8 @@
|
|||
|
||||
<!-- IF FOLDER_CUR_MESSAGES neq 0 -->
|
||||
<fieldset class="display-options">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<label>{L_DISPLAY}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label>
|
||||
<label>{S_SELECT_SORT_DIR} <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>
|
||||
|
|
|
@ -192,8 +192,8 @@
|
|||
<!-- IF S_SELECT_SORT_DAYS and not S_DISPLAY_ACTIVE -->
|
||||
<form method="post" action="{S_FORUM_ACTION}">
|
||||
<fieldset class="display-options">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF not S_IS_BOT -->
|
||||
<label>{L_DISPLAY_TOPICS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label>
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IF PREVIOUS_PAGE or NEXT_PAGE -->
|
||||
<!-- IF U_PREVIOUS_PAGE or U_NEXT_PAGE -->
|
||||
<fieldset class="display-options right-box">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ELSE -->{L_PREVIOUS}<!-- ENDIF --> • <!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ELSE -->{L_NEXT}<!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ELSE -->{L_PREVIOUS}<!-- ENDIF --> • <!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ELSE -->{L_NEXT}<!-- ENDIF -->
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
|
||||
|
|
|
@ -245,12 +245,12 @@
|
|||
<!-- IF S_QUICK_REPLY -->
|
||||
<!-- INCLUDE quickreply_editor.html -->
|
||||
<!-- ENDIF -->
|
||||
<!-- IF S_NUM_POSTS > 1 or PREVIOUS_PAGE or NEXT_PAGE -->
|
||||
<!-- IF S_NUM_POSTS > 1 or U_PREVIOUS_PAGE or U_NEXT_PAGE -->
|
||||
<form id="viewtopic" method="post" action="{S_TOPIC_ACTION}">
|
||||
|
||||
<fieldset class="display-options" style="margin-top: 0; ">
|
||||
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF U_PREVIOUS_PAGE --><a href="{U_PREVIOUS_PAGE}" class="left-box arrow-{S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
|
||||
<!-- IF U_NEXT_PAGE --><a href="{U_NEXT_PAGE}" class="right-box arrow-{S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
|
||||
<!-- IF not S_IS_BOT -->
|
||||
<label>{L_DISPLAY_POSTS}{L_COLON} {S_SELECT_SORT_DAYS}</label>
|
||||
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label> <label>{S_SELECT_SORT_DIR} <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>
|
||||
|
|
|
@ -159,7 +159,7 @@ dl.icon dt .list-inner {
|
|||
}
|
||||
|
||||
dl.icon dt, dl.icon dd {
|
||||
min-height: 40px;
|
||||
min-height: 35px;
|
||||
}
|
||||
|
||||
dd.posts, dd.topics, dd.views, dd.extra, dd.mark {
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
<tr>
|
||||
<th colspan="2"><!-- IF S_REPORT_POST -->{L_REPORT_POST}<!-- ELSE -->{L_REPORT_MESSAGE}<!-- ENDIF --></th>
|
||||
</tr>
|
||||
<!-- IF ERROR -->
|
||||
<tr>
|
||||
<td class="row3" colspan="2" align="center"><span class="genmed error">{ERROR}</span></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<tr>
|
||||
<td class="row3" colspan="2"><span class="gensmall"><!-- IF S_REPORT_POST -->{L_REPORT_POST_EXPLAIN}<!-- ELSE -->{L_REPORT_MESSAGE_EXPLAIN}<!-- ENDIF --></span></td>
|
||||
</tr>
|
||||
|
@ -25,6 +30,9 @@
|
|||
<td class="row1" valign="top"><span class="gen"><b>{L_MORE_INFO}{L_COLON}</b></span><br /><span class="gensmall">{L_CAN_LEAVE_BLANK}</span></td>
|
||||
<td class="row2"><textarea class="post" name="report_text" rows="10" cols="50">{REPORT_TEXT}</textarea></td>
|
||||
</tr>
|
||||
<!-- IF CAPTCHA_TEMPLATE -->
|
||||
<!-- INCLUDE {CAPTCHA_TEMPLATE} -->
|
||||
<!-- ENDIF -->
|
||||
<tr>
|
||||
<td class="cat" colspan="2" align="center"><input type="submit" name="submit" class="btnmain" value="{L_SUBMIT}" /> <input type="submit" name="cancel" class="btnlite" value="{L_CANCEL}" /></td>
|
||||
</tr>
|
||||
|
|
|
@ -50,9 +50,11 @@ Database Tests
|
|||
By default all tests requiring a database connection will use sqlite. If you
|
||||
do not have sqlite installed the tests will be skipped. If you wish to run the
|
||||
tests on a different database you have to create a test_config.php file within
|
||||
your tests directory following the same format as phpBB's config.php. An
|
||||
example for mysqli can be found below. More information on configuration
|
||||
options can be found on the wiki (see below).
|
||||
your tests directory following the same format as phpBB's config.php. Testing
|
||||
makes use of a seperate database defined in this config file and before running
|
||||
the tests each time this database is deleted. An example for mysqli can be
|
||||
found below. More information on configuration options can be found on the
|
||||
wiki (see below).
|
||||
|
||||
<?php
|
||||
$dbms = 'phpbb_db_driver_mysqli';
|
||||
|
@ -132,8 +134,36 @@ only want the slow tests, run:
|
|||
|
||||
$ phpBB/vendor/bin/phpunit --group slow
|
||||
|
||||
Functional tests
|
||||
-----------------
|
||||
|
||||
Functional tests test software the way a user would. They simulate a user
|
||||
browsing the website, but they do these steps in an automated way.
|
||||
phpBB allows you to write such tests.
|
||||
|
||||
Running
|
||||
=======
|
||||
|
||||
Running the tests requires your phpBB3 repository to be accessible through a
|
||||
local web server. You will need to supply the URL to the webserver in
|
||||
the 'tests/test_config.php' file. This is as simple as defining the
|
||||
'$phpbb_functional_url' variable, which contains the URL for the directory containing
|
||||
the board. Make sure you include the trailing slash. Note that without extensive
|
||||
changes to the test framework, you cannot use a board outside of the repository
|
||||
on which to run tests.
|
||||
|
||||
$phpbb_functional_url = 'http://localhost/phpBB3/';
|
||||
|
||||
To then run the tests, you run PHPUnit, but use the phpunit.xml.functional
|
||||
config file instead of the default one. Specify this through the "-c" option:
|
||||
|
||||
$ phpBB/vendor/bin/phpunit -c phpunit.xml.functional
|
||||
|
||||
This will change your board's config.php file, but it makes a backup at
|
||||
config_dev.php, so you can restore it after the test run is complete.
|
||||
|
||||
More Information
|
||||
================
|
||||
|
||||
Further information is available on phpbb wiki:
|
||||
http://wiki.phpbb.com/Unit_Tests
|
||||
http://wiki.phpbb.com/Automated_Tests
|
||||
|
|
33
tests/auth/fixtures/user.xml
Normal file
33
tests/auth/fixtures/user.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_password</column>
|
||||
<column>user_passchg</column>
|
||||
<column>user_pass_convert</column>
|
||||
<column>user_email</column>
|
||||
<column>user_type</column>
|
||||
<column>user_login_attempts</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>foobar</value>
|
||||
<value>foobar</value>
|
||||
<value>$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>example@example.com</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
206
tests/auth/provider_apache_test.php
Normal file
206
tests/auth/provider_apache_test.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_auth_provider_apache_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $provider;
|
||||
protected $user;
|
||||
protected $request;
|
||||
|
||||
protected function setup()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$config = new phpbb_config(array());
|
||||
$this->request = $this->getMock('phpbb_request');
|
||||
$this->user = $this->getMock('phpbb_user');
|
||||
|
||||
$this->provider = new phpbb_auth_provider_apache($db, $config, $this->request, $this->user, $phpbb_root_path, $phpEx);
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see if a user is identified to Apache. Expects false if they are.
|
||||
*/
|
||||
public function test_init()
|
||||
{
|
||||
$this->user->data['username'] = 'foobar';
|
||||
$this->request->expects($this->once())
|
||||
->method('is_set')
|
||||
->with('PHP_AUTH_USER',
|
||||
phpbb_request_interface::SERVER)
|
||||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->once())
|
||||
->method('server')
|
||||
->with('PHP_AUTH_USER')
|
||||
->will($this->returnValue('foobar'));
|
||||
|
||||
$this->assertFalse($this->provider->init());
|
||||
}
|
||||
|
||||
public function test_login()
|
||||
{
|
||||
$username = 'foobar';
|
||||
$password = 'example';
|
||||
|
||||
$this->request->expects($this->once())
|
||||
->method('is_set')
|
||||
->with('PHP_AUTH_USER',
|
||||
phpbb_request_interface::SERVER)
|
||||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->at(1))
|
||||
->method('server')
|
||||
->with('PHP_AUTH_USER')
|
||||
->will($this->returnValue('foobar'));
|
||||
$this->request->expects($this->at(2))
|
||||
->method('server')
|
||||
->with('PHP_AUTH_PW')
|
||||
->will($this->returnValue('example'));
|
||||
|
||||
$expected = array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => array(
|
||||
'user_id' => '1',
|
||||
'username' => 'foobar',
|
||||
'user_password' => '$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/',
|
||||
'user_passchg' => '0',
|
||||
'user_email' => 'example@example.com',
|
||||
'user_type' => '0',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->provider->login($username, $password));
|
||||
}
|
||||
|
||||
public function test_autologin()
|
||||
{
|
||||
$this->request->expects($this->once())
|
||||
->method('is_set')
|
||||
->with('PHP_AUTH_USER',
|
||||
phpbb_request_interface::SERVER)
|
||||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->at(1))
|
||||
->method('server')
|
||||
->with('PHP_AUTH_USER')
|
||||
->will($this->returnValue('foobar'));
|
||||
$this->request->expects($this->at(2))
|
||||
->method('server')
|
||||
->with('PHP_AUTH_PW')
|
||||
->will($this->returnValue('example'));
|
||||
|
||||
$expected = array(
|
||||
'user_id' => '1',
|
||||
'user_type' => '0',
|
||||
'group_id' => '3',
|
||||
'user_permissions' => '',
|
||||
'user_perm_from' => '0',
|
||||
'user_ip' => '',
|
||||
'user_regdate' => '0',
|
||||
'username' => 'foobar',
|
||||
'username_clean' => 'foobar',
|
||||
'user_password' => '$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/',
|
||||
'user_passchg' => '0',
|
||||
'user_pass_convert' => '0',
|
||||
'user_email' => 'example@example.com',
|
||||
'user_email_hash' => '0',
|
||||
'user_birthday' => '',
|
||||
'user_lastvisit' => '0',
|
||||
'user_lastmark' => '0',
|
||||
'user_lastpost_time' => '0',
|
||||
'user_lastpage' => '',
|
||||
'user_last_confirm_key' => '',
|
||||
'user_last_search' => '0',
|
||||
'user_warnings' => '0',
|
||||
'user_last_warning' => '0',
|
||||
'user_login_attempts' => '0',
|
||||
'user_inactive_reason' => '0',
|
||||
'user_inactive_time' => '0',
|
||||
'user_posts' => '0',
|
||||
'user_lang' => '',
|
||||
'user_timezone' => 'UTC',
|
||||
'user_dateformat' => 'd M Y H:i',
|
||||
'user_style' => '0',
|
||||
'user_rank' => '0',
|
||||
'user_colour' => '',
|
||||
'user_new_privmsg' => '0',
|
||||
'user_unread_privmsg' => '0',
|
||||
'user_last_privmsg' => '0',
|
||||
'user_message_rules' => '0',
|
||||
'user_full_folder' => '-3',
|
||||
'user_emailtime' => '0',
|
||||
'user_topic_show_days' => '0',
|
||||
'user_topic_sortby_type' => 't',
|
||||
'user_topic_sortby_dir' => 'd',
|
||||
'user_post_show_days' => '0',
|
||||
'user_post_sortby_type' => 't',
|
||||
'user_post_sortby_dir' => 'a',
|
||||
'user_notify' => '0',
|
||||
'user_notify_pm' => '1',
|
||||
'user_notify_type' => '0',
|
||||
'user_allow_pm' => '1',
|
||||
'user_allow_viewonline' => '1',
|
||||
'user_allow_viewemail' => '1',
|
||||
'user_allow_massemail' => '1',
|
||||
'user_options' => '230271',
|
||||
'user_avatar' => '',
|
||||
'user_avatar_type' => '',
|
||||
'user_avatar_width' => '0',
|
||||
'user_avatar_height' => '0',
|
||||
'user_sig' => '',
|
||||
'user_sig_bbcode_uid' => '',
|
||||
'user_sig_bbcode_bitfield' => '',
|
||||
'user_from' => '',
|
||||
'user_icq' => '',
|
||||
'user_aim' => '',
|
||||
'user_yim' => '',
|
||||
'user_msnm' => '',
|
||||
'user_jabber' => '',
|
||||
'user_website' => '',
|
||||
'user_occ' => '',
|
||||
'user_interests' => '',
|
||||
'user_actkey' => '',
|
||||
'user_newpasswd' => '',
|
||||
'user_form_salt' => '',
|
||||
'user_new' => '1',
|
||||
'user_reminded' => '0',
|
||||
'user_reminded_time' => '0',
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->provider->autologin());
|
||||
}
|
||||
|
||||
public function test_validate_session()
|
||||
{
|
||||
$user = array(
|
||||
'username' => 'foobar',
|
||||
'user_type'
|
||||
);
|
||||
$this->request->expects($this->once())
|
||||
->method('is_set')
|
||||
->with('PHP_AUTH_USER',
|
||||
phpbb_request_interface::SERVER)
|
||||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->once())
|
||||
->method('server')
|
||||
->with('PHP_AUTH_USER')
|
||||
->will($this->returnValue('foobar'));
|
||||
|
||||
$this->assertTrue($this->provider->validate_session($user));
|
||||
}
|
||||
}
|
50
tests/auth/provider_db_test.php
Normal file
50
tests/auth/provider_db_test.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_auth_provider_db_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
|
||||
}
|
||||
|
||||
public function test_login()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$config = new phpbb_config(array(
|
||||
'ip_login_limit_max' => 0,
|
||||
'ip_login_limit_use_forwarded' => 0,
|
||||
'max_login_attempts' => 0,
|
||||
));
|
||||
$request = $this->getMock('phpbb_request');
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx);
|
||||
|
||||
$expected = array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
'error_msg' => false,
|
||||
'user_row' => array(
|
||||
'user_id' => '1',
|
||||
'username' => 'foobar',
|
||||
'user_password' => '$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/',
|
||||
'user_passchg' => '0',
|
||||
'user_pass_convert' => '0',
|
||||
'user_email' => 'example@example.com',
|
||||
'user_type' => '0',
|
||||
'user_login_attempts' => '0',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $provider->login('foobar', 'example'));
|
||||
}
|
||||
}
|
130
tests/download/http_user_agent_test.php
Normal file
130
tests/download/http_user_agent_test.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_download.php';
|
||||
|
||||
class phpbb_download_http_user_agent_test extends phpbb_test_case
|
||||
{
|
||||
public function user_agents_check_greater_ie_version()
|
||||
{
|
||||
return array(
|
||||
// user agent
|
||||
// IE version
|
||||
// expected
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
|
||||
7,
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
|
||||
7,
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)',
|
||||
7,
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/4.0 (compatible; MSIE 6.01; Windows NT 6.0)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (Windows NT 6.2; Win64; x64;) Gecko/20100101 Firefox/20.0',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1464.0 Safari/537.36',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Googlebot-Image/1.0',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Googlebot/2.1 ( http://www.google.com/bot.html)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Lynx/2.8.3dev.9 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Links (0.9x; Linux 2.4.7-10 i686)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Opera/9.60 (Windows NT 5.1; U; de) Presto/2.1.1',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT;)',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0) Opera 6.01 [en]',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.24',
|
||||
7,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
|
||||
8,
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
|
||||
9,
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)',
|
||||
10,
|
||||
false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider user_agents_check_greater_ie_version
|
||||
*/
|
||||
public function test_is_greater_ie_version($user_agent, $version, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, phpbb_is_greater_ie_version($user_agent, $version));
|
||||
}
|
||||
}
|
|
@ -12,34 +12,25 @@
|
|||
*/
|
||||
class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||
{
|
||||
static private $copied_files = array();
|
||||
static private $helper;
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the extensions to the phpBB install
|
||||
*/
|
||||
static protected $fixtures = array(
|
||||
'./',
|
||||
);
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$helper = new phpbb_test_case_helpers(self);
|
||||
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
self::$copied_files = array();
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
if (file_exists($phpbb_root_path . 'ext/'))
|
||||
{
|
||||
// First, move any extensions setup on the board to a temp directory
|
||||
self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
|
||||
|
||||
// Then empty the ext/ directory on the board (for accurate test cases)
|
||||
self::$helper->empty_dir($phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Copy our ext/ files from the test case to the board
|
||||
self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/../extension/ext/', $phpbb_root_path . 'ext/'));
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
@ -84,29 +75,6 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
|||
$this->add_lang('acp/extensions');
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the files copied to the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
// Copy back the board installed extensions from the temp directory
|
||||
self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
|
||||
self::$helper->remove_files(self::$copied_files);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
|
||||
}
|
||||
}
|
||||
|
||||
public function test_list()
|
||||
{
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||
|
|
|
@ -15,65 +15,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
|||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
static private $helper;
|
||||
|
||||
static protected $fixtures = array(
|
||||
'foo/bar/config/routing.yml',
|
||||
'foo/bar/config/services.yml',
|
||||
'foo/bar/controller/controller.php',
|
||||
'foo/bar/styles/prosilver/template/foo_bar_body.html',
|
||||
'foo/bar/config/',
|
||||
'foo/bar/controller/',
|
||||
'foo/bar/styles/prosilver/template/',
|
||||
);
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
*/
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
$directories = array(
|
||||
$phpbb_root_path . 'ext/foo/bar/',
|
||||
$phpbb_root_path . 'ext/foo/bar/config/',
|
||||
$phpbb_root_path . 'ext/foo/bar/controller/',
|
||||
$phpbb_root_path . 'ext/foo/bar/styles/prosilver/template',
|
||||
);
|
||||
|
||||
foreach ($directories as $dir)
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
copy(
|
||||
"tests/functional/fixtures/ext/$fixture",
|
||||
"{$phpbb_root_path}ext/$fixture");
|
||||
}
|
||||
self::$helper = new phpbb_test_case_helpers(self);
|
||||
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
unlink("{$phpbb_root_path}ext/$fixture");
|
||||
}
|
||||
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/config");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/controller");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver/template");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar");
|
||||
rmdir("{$phpbb_root_path}ext/foo");
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
|
|
@ -16,56 +16,26 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php';
|
|||
class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
static private $copied_files = array();
|
||||
|
||||
static private $helper;
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
*/
|
||||
static protected $fixtures = array(
|
||||
'./',
|
||||
);
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$helper = new phpbb_test_case_helpers(self);
|
||||
|
||||
self::$copied_files = array();
|
||||
|
||||
if (file_exists($phpbb_root_path . 'ext/'))
|
||||
{
|
||||
// First, move any extensions setup on the board to a temp directory
|
||||
self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
|
||||
|
||||
// Then empty the ext/ directory on the board (for accurate test cases)
|
||||
self::$helper->empty_dir($phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Copy our ext/ files from the test case to the board
|
||||
self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/', $phpbb_root_path . 'ext/'));
|
||||
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
// Copy back the board installed extensions from the temp directory
|
||||
self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
|
||||
self::$helper->remove_files(self::$copied_files);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
|
||||
}
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
|
|
@ -16,59 +16,23 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
|
|||
|
||||
static private $helper;
|
||||
|
||||
static private $copied_files = array();
|
||||
|
||||
static protected $fixtures = array(
|
||||
'foo/bar/language/en/',
|
||||
);
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
*/
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$helper = new phpbb_test_case_helpers(self);
|
||||
|
||||
self::$copied_files = array();
|
||||
|
||||
if (file_exists($phpbb_root_path . 'ext/'))
|
||||
{
|
||||
// First, move any extensions setup on the board to a temp directory
|
||||
self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
|
||||
|
||||
// Then empty the ext/ directory on the board (for accurate test cases)
|
||||
self::$helper->empty_dir($phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Copy our ext/ files from the test case to the board
|
||||
self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture));
|
||||
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
// Copy back the board installed extensions from the temp directory
|
||||
self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
|
||||
}
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
// Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
|
||||
self::$helper->remove_files(self::$copied_files);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
|
||||
}
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
|
|
@ -16,47 +16,25 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
|||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
static private $helpers;
|
||||
static private $helper;
|
||||
|
||||
static protected $fixtures = array(
|
||||
'foo/bar/',
|
||||
);
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
*/
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$helpers = new phpbb_test_case_helpers(self);
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'ext/foo/bar/'))
|
||||
{
|
||||
self::$helpers->makedirs($phpbb_root_path . 'ext/foo/bar/');
|
||||
}
|
||||
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
self::$helpers->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture);
|
||||
}
|
||||
self::$helper = new phpbb_test_case_helpers(self);
|
||||
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
self::$helpers->empty_dir($phpbb_root_path . 'ext/' . $fixture);
|
||||
}
|
||||
self::$helpers->empty_dir($phpbb_root_path . 'ext/foo/');
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
|
39
tests/functional/paging_test.php
Normal file
39
tests/functional/paging_test.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_paging_test extends phpbb_functional_test_case
|
||||
{
|
||||
|
||||
public function test_pagination()
|
||||
{
|
||||
$this->login();
|
||||
|
||||
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
|
||||
for ($post_id = 1; $post_id < 20; $post_id++)
|
||||
{
|
||||
$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post no' . $post_id . ' posted by the testing framework.');
|
||||
}
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
|
||||
$this->assertContains('post no9', $crawler->text());
|
||||
$this->assertNotContains('post no19', $crawler->text());
|
||||
|
||||
$next_link = $crawler->filter('#viewtopic > fieldset > a.arrow-right')->attr('href');
|
||||
$crawler = self::request('GET', $next_link);
|
||||
$this->assertContains('post no19', $crawler->text());
|
||||
$this->assertNotContains('post no9', $crawler->text());
|
||||
|
||||
$prev_link = $crawler->filter('#viewtopic > fieldset > a.arrow-left')->attr('href');
|
||||
$crawler = self::request('GET', $prev_link);
|
||||
$this->assertContains('post no9', $crawler->text());
|
||||
$this->assertNotContains('post no19', $crawler->text());
|
||||
}
|
||||
}
|
|
@ -32,105 +32,4 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
|||
$crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
|
||||
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a topic
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a post
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for submitting posts
|
||||
*
|
||||
* @param string $posting_url
|
||||
* @param string $posting_contains
|
||||
* @param array $form_data
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
protected function submit_post($posting_url, $posting_contains, $form_data)
|
||||
{
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = self::request('GET', $posting_url);
|
||||
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array(
|
||||
$crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
}),
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
{
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$form_data[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
|
||||
// is not at least 2 seconds before submission, cancel the form
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// I use a request because the form submission method does not allow you to send data that is not
|
||||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = self::request('POST', $posting_url, $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||
|
||||
$matches = $topic_id = $post_id = false;
|
||||
preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
|
||||
|
||||
$topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
|
||||
$post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
|
||||
|
||||
return array(
|
||||
'topic_id' => $topic_id,
|
||||
'post_id' => $post_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
61
tests/functional/report_post_captcha.php
Normal file
61
tests/functional/report_post_captcha.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_case
|
||||
{
|
||||
public function test_user_report_post()
|
||||
{
|
||||
$this->login();
|
||||
$crawler = self::request('GET', 'report.php?f=2&p=1');
|
||||
$this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
|
||||
}
|
||||
|
||||
public function test_guest_report_post()
|
||||
{
|
||||
$crawler = self::request('GET', 'report.php?f=2&p=1');
|
||||
$this->add_lang('mcp');
|
||||
$this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());
|
||||
|
||||
$this->set_reporting_guest(1);
|
||||
$crawler = self::request('GET', 'report.php?f=2&p=1');
|
||||
$this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
|
||||
$this->set_reporting_guest(-1);
|
||||
}
|
||||
|
||||
protected function set_reporting_guest($report_post_allowed)
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid);
|
||||
$form = $crawler->selectButton('Submit')->form();
|
||||
$values = $form->getValues();
|
||||
$values["group_id[0]"] = 1;
|
||||
$form->setValues($values);
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$form = $crawler->selectButton('Submit')->form();
|
||||
$values = $form->getValues();
|
||||
$values["forum_id"] = 2;
|
||||
$form->setValues($values);
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$this->add_lang('acp/permissions');
|
||||
$form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form();
|
||||
$values = $form->getValues();
|
||||
$values["setting[1][2][f_report]"] = $report_post_allowed;
|
||||
$form->setValues($values);
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid);
|
||||
}
|
||||
}
|
23
tests/functions/fixtures/validate_email.xml
Normal file
23
tests/functions/fixtures/validate_email.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<column>user_email_hash</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>admin</value>
|
||||
<value>admin</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value>143317126117</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
38
tests/functions/fixtures/validate_username.xml
Normal file
38
tests/functions/fixtures/validate_username.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_groups">
|
||||
<column>group_name</column>
|
||||
<column>group_desc</column>
|
||||
<row>
|
||||
<value>foobar_group</value>
|
||||
<value>test123</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>admin</value>
|
||||
<value>admin</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>moderator</value>
|
||||
<value>moderator</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
36
tests/functions/validate_data_helper.php
Normal file
36
tests/functions/validate_data_helper.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_functions_validate_data_helper
|
||||
{
|
||||
protected $test_case;
|
||||
|
||||
public function __construct($test_case)
|
||||
{
|
||||
$this->test_case = $test_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test provided input data with supplied checks and compare to expected
|
||||
* results
|
||||
*
|
||||
* @param array $data Array containing one or more subarrays with the
|
||||
* test data. The first element of a subarray is the
|
||||
* expected result, the second one is the input, and the
|
||||
* third is the data that should be passed to the function
|
||||
* validate_data().
|
||||
*/
|
||||
public function assert_valid_data($data)
|
||||
{
|
||||
foreach ($data as $key => $test)
|
||||
{
|
||||
$this->test_case->assertEquals($test[0], validate_data(array($test[1]), array($test[2])));
|
||||
}
|
||||
}
|
||||
}
|
82
tests/functions/validate_date_test.php
Normal file
82
tests/functions/validate_date_test.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_date_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_date()
|
||||
{
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array('INVALID'),
|
||||
'',
|
||||
array('date'),
|
||||
),
|
||||
'empty_opt' => array(
|
||||
array(),
|
||||
'',
|
||||
array('date', true),
|
||||
),
|
||||
'double_single' => array(
|
||||
array(),
|
||||
'17-06-1990',
|
||||
array('date'),
|
||||
),
|
||||
'single_single' => array(
|
||||
array(),
|
||||
'05-05-2009',
|
||||
array('date'),
|
||||
),
|
||||
'double_double' => array(
|
||||
array(),
|
||||
'17-12-1990',
|
||||
array('date'),
|
||||
),
|
||||
'month_high' => array(
|
||||
array('INVALID'),
|
||||
'17-17-1990',
|
||||
array('date'),
|
||||
),
|
||||
'month_low' => array(
|
||||
array('INVALID'),
|
||||
'01-00-1990',
|
||||
array('date'),
|
||||
),
|
||||
'day_high' => array(
|
||||
array('INVALID'),
|
||||
'64-01-1990',
|
||||
array('date'),
|
||||
),
|
||||
'day_low' => array(
|
||||
array('INVALID'),
|
||||
'00-12-1990',
|
||||
array('date'),
|
||||
),
|
||||
// Currently fails
|
||||
/*
|
||||
'zero_year' => array(
|
||||
array(),
|
||||
'01-01-0000',
|
||||
array('date'),
|
||||
),
|
||||
*/
|
||||
));
|
||||
}
|
||||
}
|
108
tests/functions/validate_email_test.php
Normal file
108
tests/functions/validate_email_test.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/../mock/user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_email_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $user;
|
||||
protected $helper;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->user = new phpbb_mock_user;
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get validation prerequesites
|
||||
*
|
||||
* @param bool $check_mx Whether mx records should be checked
|
||||
*/
|
||||
protected function set_validation_prerequisites($check_mx)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
$config['email_check_mx'] = $check_mx;
|
||||
$db = $this->db;
|
||||
$user = $this->user;
|
||||
$user->optionset('banned_users', array('banned@example.com'));
|
||||
}
|
||||
|
||||
public function test_validate_email()
|
||||
{
|
||||
$this->set_validation_prerequisites(false);
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array(),
|
||||
'',
|
||||
array('email'),
|
||||
),
|
||||
'allowed' => array(
|
||||
array(),
|
||||
'foobar@example.com',
|
||||
array('email', 'foobar@example.com'),
|
||||
),
|
||||
'invalid' => array(
|
||||
array('EMAIL_INVALID'),
|
||||
'fööbar@example.com',
|
||||
array('email'),
|
||||
),
|
||||
'valid_complex' => array(
|
||||
array(),
|
||||
"'%$~test@example.com",
|
||||
array('email'),
|
||||
),
|
||||
'taken' => array(
|
||||
array('EMAIL_TAKEN'),
|
||||
'admin@example.com',
|
||||
array('email'),
|
||||
),
|
||||
'banned' => array(
|
||||
array('EMAIL_BANNED'),
|
||||
'banned@example.com',
|
||||
array('email'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group slow
|
||||
*/
|
||||
public function test_validate_email_mx()
|
||||
{
|
||||
$this->set_validation_prerequisites(true);
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'valid' => array(
|
||||
array(),
|
||||
'foobar@phpbb.com',
|
||||
array('email'),
|
||||
),
|
||||
'no_mx' => array(
|
||||
array('DOMAIN_NO_MX_RECORD'),
|
||||
'test@does-not-exist.phpbb.com',
|
||||
array('email'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
79
tests/functions/validate_jabber_test.php
Normal file
79
tests/functions/validate_jabber_test.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_jabber_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_jabber()
|
||||
{
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array(),
|
||||
'',
|
||||
array('jabber'),
|
||||
),
|
||||
'no_seperator' => array(
|
||||
array('WRONG_DATA'),
|
||||
'testjabber.ccc',
|
||||
array('jabber'),
|
||||
),
|
||||
'no_user' => array(
|
||||
array('WRONG_DATA'),
|
||||
'@jabber.ccc',
|
||||
array('jabber'),
|
||||
),
|
||||
'no_realm' => array(
|
||||
array('WRONG_DATA'),
|
||||
'user@',
|
||||
array('jabber'),
|
||||
),
|
||||
'dot_realm' => array(
|
||||
array('WRONG_DATA'),
|
||||
'user@.....',
|
||||
array('jabber'),
|
||||
),
|
||||
'-realm' => array(
|
||||
array('WRONG_DATA'),
|
||||
'user@-jabber.ccc',
|
||||
array('jabber'),
|
||||
),
|
||||
'realm-' => array(
|
||||
array('WRONG_DATA'),
|
||||
'user@jabber.ccc-',
|
||||
array('jabber'),
|
||||
),
|
||||
'correct' => array(
|
||||
array(),
|
||||
'user@jabber.09A-z.org',
|
||||
array('jabber'),
|
||||
),
|
||||
'prohibited' => array(
|
||||
array('WRONG_DATA'),
|
||||
'u@ser@jabber.ccc.org',
|
||||
array('jabber'),
|
||||
),
|
||||
'prohibited_char' => array(
|
||||
array('WRONG_DATA'),
|
||||
'u<s>er@jabber.ccc.org',
|
||||
array('jabber'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
60
tests/functions/validate_lang_iso_test.php
Normal file
60
tests/functions/validate_lang_iso_test.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_lang_iso_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $helper;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/language_select.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_lang_iso()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array('WRONG_DATA'),
|
||||
'',
|
||||
array('language_iso_name'),
|
||||
),
|
||||
'en' => array(
|
||||
array(),
|
||||
'en',
|
||||
array('language_iso_name'),
|
||||
),
|
||||
'cs' => array(
|
||||
array(),
|
||||
'cs',
|
||||
array('language_iso_name'),
|
||||
),
|
||||
'de' => array(
|
||||
array('WRONG_DATA'),
|
||||
'de',
|
||||
array('language_iso_name'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
49
tests/functions/validate_match_test.php
Normal file
49
tests/functions/validate_match_test.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_match_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_match()
|
||||
{
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty_opt' => array(
|
||||
array(),
|
||||
'',
|
||||
array('match', true, '/[a-z]$/'),
|
||||
),
|
||||
'empty_empty_match' => array(
|
||||
array(),
|
||||
'',
|
||||
array('match'),
|
||||
),
|
||||
'foobar' => array(
|
||||
array(),
|
||||
'foobar',
|
||||
array('match', false, '/[a-z]$/'),
|
||||
),
|
||||
'foobar_fail' => array(
|
||||
array('WRONG_DATA'),
|
||||
'foobar123',
|
||||
array('match', false, '/[a-z]$/'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
59
tests/functions/validate_num_test.php
Normal file
59
tests/functions/validate_num_test.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_num_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_num()
|
||||
{
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array(),
|
||||
'',
|
||||
array('num'),
|
||||
),
|
||||
'zero' => array(
|
||||
array(),
|
||||
'0',
|
||||
array('num'),
|
||||
),
|
||||
'five_minmax_correct' => array(
|
||||
array(),
|
||||
'5',
|
||||
array('num', false, 2, 6),
|
||||
),
|
||||
'five_minmax_short' => array(
|
||||
array('TOO_SMALL'),
|
||||
'5',
|
||||
array('num', false, 7, 10),
|
||||
),
|
||||
'five_minmax_long' => array(
|
||||
array('TOO_LARGE'),
|
||||
'5',
|
||||
array('num', false, 2, 3),
|
||||
),
|
||||
'string' => array(
|
||||
array(),
|
||||
'foobar',
|
||||
array('num'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
96
tests/functions/validate_password_test.php
Normal file
96
tests/functions/validate_password_test.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_password_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function validate_password_data()
|
||||
{
|
||||
return array(
|
||||
array('PASS_TYPE_ANY', array(
|
||||
'empty' => array(),
|
||||
'foobar_any' => array(),
|
||||
'foobar_mixed' => array(),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_symbol' => array(),
|
||||
)),
|
||||
array('PASS_TYPE_CASE', array(
|
||||
'empty' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_mixed' => array(),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_symbol' => array(),
|
||||
)),
|
||||
array('PASS_TYPE_ALPHA', array(
|
||||
'empty' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_mixed' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_symbol' => array(),
|
||||
)),
|
||||
array('PASS_TYPE_SYMBOL', array(
|
||||
'empty' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_mixed' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array('INVALID_CHARS'),
|
||||
'foobar_symbol' => array(),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_password_data
|
||||
*/
|
||||
public function test_validate_password($pass_complexity, $expected)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Set complexity to mixed case letters, numbers and symbols
|
||||
$config['pass_complex'] = $pass_complexity;
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
$expected['empty'],
|
||||
'',
|
||||
array('password'),
|
||||
),
|
||||
'foobar_any' => array(
|
||||
$expected['foobar_any'],
|
||||
'foobar',
|
||||
array('password'),
|
||||
),
|
||||
'foobar_mixed' => array(
|
||||
$expected['foobar_mixed'],
|
||||
'FooBar',
|
||||
array('password'),
|
||||
),
|
||||
'foobar_alpha' => array(
|
||||
$expected['foobar_alpha'],
|
||||
'F00bar',
|
||||
array('password'),
|
||||
),
|
||||
'foobar_symbol' => array(
|
||||
$expected['foobar_symbol'],
|
||||
'fooBar123*',
|
||||
array('password'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
70
tests/functions/validate_string_test.php
Normal file
70
tests/functions/validate_string_test.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_string_test extends phpbb_test_case
|
||||
{
|
||||
protected $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function test_validate_string()
|
||||
{
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty_opt' => array(
|
||||
array(),
|
||||
'',
|
||||
array('string', true),
|
||||
),
|
||||
'empty' => array(
|
||||
array(),
|
||||
'',
|
||||
array('string'),
|
||||
),
|
||||
'foo' => array(
|
||||
array(),
|
||||
'foobar',
|
||||
array('string'),
|
||||
),
|
||||
'foo_minmax_correct' => array(
|
||||
array(),
|
||||
'foobar',
|
||||
array('string', false, 2, 6),
|
||||
),
|
||||
'foo_minmax_short' => array(
|
||||
array('TOO_SHORT'),
|
||||
'foobar',
|
||||
array('string', false, 7, 9),
|
||||
),
|
||||
'foo_minmax_long' => array(
|
||||
array('TOO_LONG'),
|
||||
'foobar',
|
||||
array('string', false, 2, 5),
|
||||
),
|
||||
'empty_short' => array(
|
||||
array('TOO_SHORT'),
|
||||
'',
|
||||
array('string', false, 1, 6),
|
||||
),
|
||||
'empty_length_opt' => array(
|
||||
array(),
|
||||
'',
|
||||
array('string', true, 1, 6),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
190
tests/functions/validate_username_test.php
Normal file
190
tests/functions/validate_username_test.php
Normal file
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
require_once dirname(__FILE__) . '/../mock/cache.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_data_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $cache;
|
||||
protected $helper;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_username.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->cache = new phpbb_mock_cache;
|
||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||
}
|
||||
|
||||
public function validate_username_data()
|
||||
{
|
||||
return array(
|
||||
array('USERNAME_CHARS_ANY', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array(),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array(),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array(),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('USERNAME_TAKEN'),
|
||||
)),
|
||||
array('USERNAME_ALPHA_ONLY', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array('INVALID_CHARS'),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array('INVALID_CHARS'),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('INVALID_CHARS'),
|
||||
)),
|
||||
array('USERNAME_ALPHA_SPACERS', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array(),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array('INVALID_CHARS'),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('USERNAME_TAKEN'),
|
||||
)),
|
||||
array('USERNAME_LETTER_NUM', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array('INVALID_CHARS'),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array('INVALID_CHARS'),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('INVALID_CHARS'),
|
||||
)),
|
||||
array('USERNAME_LETTER_NUM_SPACERS', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array('INVALID_CHARS'),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array(),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array(),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('USERNAME_TAKEN'),
|
||||
)),
|
||||
array('USERNAME_ASCII', array(
|
||||
'foobar_allow' => array(),
|
||||
'foobar_ascii' => array(),
|
||||
'foobar_any' => array(),
|
||||
'foobar_alpha' => array(),
|
||||
'foobar_alpha_spacers' => array(),
|
||||
'foobar_letter_num' => array(),
|
||||
'foobar_letter_num_sp' => array('INVALID_CHARS'),
|
||||
'foobar_quot' => array('INVALID_CHARS'),
|
||||
'barfoo_disallow' => array('USERNAME_DISALLOWED'),
|
||||
'admin_taken' => array('USERNAME_TAKEN'),
|
||||
'group_taken' => array('USERNAME_TAKEN'),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_username_data
|
||||
*/
|
||||
public function test_validate_username($allow_name_chars, $expected)
|
||||
{
|
||||
global $cache, $config, $db;
|
||||
|
||||
$db = $this->db;
|
||||
$cache = $this->cache;
|
||||
$cache->put('_disallowed_usernames', array('barfoo'));
|
||||
|
||||
$config['allow_name_chars'] = $allow_name_chars;
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'foobar_allow' => array(
|
||||
$expected['foobar_allow'],
|
||||
'foobar',
|
||||
array('username', 'foobar'),
|
||||
),
|
||||
'foobar_ascii' => array(
|
||||
$expected['foobar_ascii'],
|
||||
'foobar',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_any' => array(
|
||||
$expected['foobar_any'],
|
||||
'f*~*^=oo_bar1',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_alpha' => array(
|
||||
$expected['foobar_alpha'],
|
||||
'fo0Bar',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_alpha_spacers' => array(
|
||||
$expected['foobar_alpha_spacers'],
|
||||
'Fo0-[B]_a+ R',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_letter_num' => array(
|
||||
$expected['foobar_letter_num'],
|
||||
'fo0Bar0',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_letter_num_sp' => array(
|
||||
$expected['foobar_letter_num_sp'],
|
||||
'Fö0-[B]_a+ R',
|
||||
array('username'),
|
||||
),
|
||||
'foobar_quot' => array(
|
||||
$expected['foobar_quot'],
|
||||
'"foobar"',
|
||||
array('username'),
|
||||
),
|
||||
'barfoo_disallow' => array(
|
||||
$expected['barfoo_disallow'],
|
||||
'barfoo',
|
||||
array('username'),
|
||||
),
|
||||
'admin_taken' => array(
|
||||
$expected['admin_taken'],
|
||||
'admin',
|
||||
array('username'),
|
||||
),
|
||||
'group_taken' => array(
|
||||
$expected['group_taken'],
|
||||
'foobar_group',
|
||||
array('username'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -53,6 +53,21 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain disallowed usernames. Input data via standard put method.
|
||||
*/
|
||||
public function obtain_disallowed_usernames()
|
||||
{
|
||||
if (($usernames = $this->get('_disallowed_usernames')) !== false)
|
||||
{
|
||||
return $usernames;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
|
||||
{
|
||||
$test->assertTrue(isset($this->data[$var_name]));
|
||||
|
|
|
@ -33,4 +33,17 @@ class phpbb_mock_user
|
|||
{
|
||||
$this->options[$item] = $value;
|
||||
}
|
||||
|
||||
public function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
|
||||
{
|
||||
$banned_users = $this->optionget('banned_users');
|
||||
foreach ($banned_users as $banned)
|
||||
{
|
||||
if ($banned == $user_id || $banned == $user_ips || $banned == $user_email)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_bookmarks">
|
||||
</table>
|
||||
<table name="phpbb_notifications">
|
||||
</table>
|
||||
<table name="phpbb_notification_types">
|
||||
</table>
|
||||
<table name="phpbb_topics_watch">
|
||||
</table>
|
||||
<table name="phpbb_user_notifications">
|
||||
</table>
|
||||
</dataset>
|
||||
|
|
|
@ -53,7 +53,20 @@ class phpbb_session_continue_test extends phpbb_database_test_case
|
|||
*/
|
||||
public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $ip, $expected_sessions, $expected_cookies, $message)
|
||||
{
|
||||
global $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$config = new phpbb_config(array());
|
||||
$request = $this->getMock('phpbb_request');
|
||||
$user = $this->getMock('phpbb_user');
|
||||
|
||||
$auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx);
|
||||
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$phpbb_container->expects($this->any())
|
||||
->method('get')
|
||||
->with('auth.provider.db')
|
||||
->will($this->returnValue($auth_provider));
|
||||
|
||||
$session_factory = new phpbb_session_testable_factory;
|
||||
$session_factory->set_cookies(array(
|
||||
'_sid' => $session_id,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
require_once dirname(__FILE__) . '/testable_factory.php';
|
||||
|
||||
class phpbb_session_init_test extends phpbb_database_test_case
|
||||
class phpbb_session_creation_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
|
@ -20,7 +20,20 @@ class phpbb_session_init_test extends phpbb_database_test_case
|
|||
|
||||
public function test_login_session_create()
|
||||
{
|
||||
global $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$config = new phpbb_config(array());
|
||||
$request = $this->getMock('phpbb_request');
|
||||
$user = $this->getMock('phpbb_user');
|
||||
|
||||
$auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx);
|
||||
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$phpbb_container->expects($this->any())
|
||||
->method('get')
|
||||
->with('auth.provider.db')
|
||||
->will($this->returnValue($auth_provider));
|
||||
|
||||
$session_factory = new phpbb_session_testable_factory;
|
||||
|
||||
$session = $session_factory->get_session($db);
|
||||
|
@ -34,10 +47,11 @@ class phpbb_session_init_test extends phpbb_database_test_case
|
|||
$this->assertSqlResultEquals(
|
||||
array(array('session_user_id' => 3)),
|
||||
$sql,
|
||||
'Check if exacly one session for user id 3 was created'
|
||||
'Check if exactly one session for user id 3 was created'
|
||||
);
|
||||
|
||||
$cookie_expire = $session->time_now + 31536000; // default is one year
|
||||
$one_year_in_seconds = 365 * 24 * 60 * 60;
|
||||
$cookie_expire = $session->time_now + $one_year_in_seconds;
|
||||
|
||||
$session->check_cookies($this, array(
|
||||
'u' => array(null, $cookie_expire),
|
|
@ -83,9 +83,14 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
$this->markTestSkipped("Template cache directory ({$template_cache_dir}) is not writable.");
|
||||
}
|
||||
|
||||
foreach (glob($this->template->cachepath . '*') as $file)
|
||||
$file_array = scandir($template_cache_dir);
|
||||
$file_prefix = basename($this->template->cachepath);
|
||||
foreach ($file_array as $file)
|
||||
{
|
||||
unlink($file);
|
||||
if (strpos($file, $file_prefix) === 0)
|
||||
{
|
||||
unlink($template_cache_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setup_engine();
|
||||
|
@ -95,9 +100,15 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
{
|
||||
if (is_object($this->template))
|
||||
{
|
||||
foreach (glob($this->template->cachepath . '*') as $file)
|
||||
$template_cache_dir = dirname($this->template->cachepath);
|
||||
$file_array = scandir($template_cache_dir);
|
||||
$file_prefix = basename($this->template->cachepath);
|
||||
foreach ($file_array as $file)
|
||||
{
|
||||
unlink($file);
|
||||
if (strpos($file, $file_prefix) === 0)
|
||||
{
|
||||
unlink($template_cache_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,21 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs synchronisations for a given table/column set on the database
|
||||
*
|
||||
* @param array $table_column_map Information about the tables/columns to synchronise
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function database_synchronisation($table_column_map)
|
||||
{
|
||||
$config = $this->get_database_config();
|
||||
$manager = $this->create_connection_manager($config);
|
||||
$manager->connect();
|
||||
$manager->database_synchronisation($table_column_map);
|
||||
}
|
||||
|
||||
public function createXMLDataSet($path)
|
||||
{
|
||||
$db_config = $this->get_database_config();
|
||||
|
|
|
@ -479,12 +479,33 @@ class phpbb_database_test_connection_manager
|
|||
* @return null
|
||||
*/
|
||||
public function post_setup_synchronisation($xml_data_set)
|
||||
{
|
||||
$table_names = $xml_data_set->getTableNames();
|
||||
|
||||
$tables = array();
|
||||
foreach ($table_names as $table)
|
||||
{
|
||||
$tables[$table] = $xml_data_set->getTableMetaData($table)->getColumns();
|
||||
}
|
||||
|
||||
$this->database_synchronisation($tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs synchronisations on the database after a fixture has been loaded
|
||||
*
|
||||
* @param array $table_column_map Array of tables/columns to synchronise
|
||||
* array(table1 => array(column1, column2))
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function database_synchronisation($table_column_map)
|
||||
{
|
||||
$this->ensure_connected(__METHOD__);
|
||||
$queries = array();
|
||||
|
||||
// Get escaped versions of the table names used in the fixture
|
||||
$table_names = array_map(array($this->pdo, 'PDO::quote'), $xml_data_set->getTableNames());
|
||||
// Get escaped versions of the table names to synchronise
|
||||
$table_names = array_map(array($this->pdo, 'PDO::quote'), array_keys($table_column_map));
|
||||
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
|
@ -541,7 +562,7 @@ class phpbb_database_test_connection_manager
|
|||
while ($row = $result->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
// Get the columns used in the fixture for this table
|
||||
$column_names = $xml_data_set->getTableMetaData($row['table_name'])->getColumns();
|
||||
$column_names = $table_column_map[$row['table_name']];
|
||||
|
||||
// Skip sequences that weren't specified in the fixture
|
||||
if (!in_array($row['column_name'], $column_names))
|
||||
|
|
|
@ -219,15 +219,19 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
|
||||
self::recreate_database(self::$config);
|
||||
|
||||
if (file_exists($phpbb_root_path . "config.$phpEx"))
|
||||
$config_file = $phpbb_root_path . "config.$phpEx";
|
||||
$config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
|
||||
$config_file_test = $phpbb_root_path . "config_test.$phpEx";
|
||||
|
||||
if (file_exists($config_file))
|
||||
{
|
||||
if (!file_exists($phpbb_root_path . "config_dev.$phpEx"))
|
||||
if (!file_exists($config_file_dev))
|
||||
{
|
||||
rename($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_dev.$phpEx");
|
||||
rename($config_file, $config_file_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($phpbb_root_path . "config.$phpEx");
|
||||
unlink($config_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,10 +255,12 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
self::assertContains('Welcome to Installation', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
|
||||
// install/index.php?mode=install&sub=requirements
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('Installation compatibility', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
|
||||
// install/index.php?mode=install&sub=database
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('Database configuration', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form(array(
|
||||
|
@ -268,10 +274,12 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'table_prefix' => self::$config['table_prefix'],
|
||||
));
|
||||
|
||||
// install/index.php?mode=install&sub=database
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('Successful connection', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
|
||||
// install/index.php?mode=install&sub=administrator
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('Administrator configuration', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form(array(
|
||||
|
@ -282,16 +290,38 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'board_email' => 'nobody@example.com',
|
||||
));
|
||||
|
||||
// install/index.php?mode=install&sub=administrator
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('Tests passed', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('The configuration file has been written.', $crawler->filter('#main')->text());
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, true));
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
// We have to skip install/index.php?mode=install&sub=config_file
|
||||
// because that step will create a config.php file if phpBB has the
|
||||
// permission to do so. We have to create the config file on our own
|
||||
// in order to get the DEBUG constants defined.
|
||||
$config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, true);
|
||||
$config_created = file_put_contents($config_file, $config_php_data) !== false;
|
||||
if (!$config_created)
|
||||
{
|
||||
self::markTestSkipped("Could not write $config_file file.");
|
||||
}
|
||||
|
||||
$crawler = self::submit($form);
|
||||
// We also have to create a install lock that is normally created by
|
||||
// the installer. The file will be removed by the final step of the
|
||||
// installer.
|
||||
$install_lock_file = $phpbb_root_path . 'cache/install_lock';
|
||||
$lock_created = file_put_contents($install_lock_file, '') !== false;
|
||||
if (!$lock_created)
|
||||
{
|
||||
self::markTestSkipped("Could not create $lock_created file.");
|
||||
}
|
||||
@chmod($install_lock_file, 0666);
|
||||
|
||||
// install/index.php?mode=install&sub=advanced
|
||||
$form_data = $form->getValues();
|
||||
unset($form_data['submit']);
|
||||
|
||||
$crawler = self::request('POST', 'install/index.php?mode=install&sub=advanced', $form_data);
|
||||
self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form(array(
|
||||
'email_enable' => true,
|
||||
|
@ -308,14 +338,17 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'script_path' => $parseURL['path'],
|
||||
));
|
||||
|
||||
// install/index.php?mode=install&sub=create_table
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text());
|
||||
self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text());
|
||||
$form = $crawler->selectButton('submit')->form();
|
||||
|
||||
// install/index.php?mode=install&sub=final
|
||||
$crawler = self::submit($form);
|
||||
self::assertContains('You have successfully installed', $crawler->text());
|
||||
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
||||
|
||||
copy($config_file, $config_file_test);
|
||||
}
|
||||
|
||||
static private function recreate_database($config)
|
||||
|
@ -703,4 +736,105 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a topic
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a post
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for submitting posts
|
||||
*
|
||||
* @param string $posting_url
|
||||
* @param string $posting_contains
|
||||
* @param array $form_data
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
protected function submit_post($posting_url, $posting_contains, $form_data)
|
||||
{
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = self::request('GET', $posting_url);
|
||||
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array(
|
||||
$crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
}),
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
{
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$form_data[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
|
||||
// is not at least 2 seconds before submission, cancel the form
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// I use a request because the form submission method does not allow you to send data that is not
|
||||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = self::request('POST', $posting_url, $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||
|
||||
$matches = $topic_id = $post_id = false;
|
||||
preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
|
||||
|
||||
$topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
|
||||
$post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
|
||||
|
||||
return array(
|
||||
'topic_id' => $topic_id,
|
||||
'post_id' => $post_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,56 @@ class phpbb_test_case_helpers
|
|||
$this->test_case = $test_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
*/
|
||||
public function copy_ext_fixtures($fixtures_dir, $fixtures)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
if (file_exists($phpbb_root_path . 'ext/'))
|
||||
{
|
||||
// First, move any extensions setup on the board to a temp directory
|
||||
$this->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
|
||||
|
||||
// Then empty the ext/ directory on the board (for accurate test cases)
|
||||
$this->empty_dir($phpbb_root_path . 'ext/');
|
||||
}
|
||||
|
||||
// Copy our ext/ files from the test case to the board
|
||||
foreach ($fixtures as $fixture)
|
||||
{
|
||||
$this->copy_dir($fixtures_dir . $fixture, $phpbb_root_path . 'ext/' . $fixture);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
public function restore_original_ext_dir()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
// Remove all of the files we copied from test ext -> board ext
|
||||
$this->empty_dir($phpbb_root_path . 'ext/');
|
||||
|
||||
// Copy back the board installed extensions from the temp directory
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
$this->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
|
||||
|
||||
// Remove all of the files we copied from board ext -> temp_ext
|
||||
$this->empty_dir($phpbb_root_path . 'store/temp_ext/');
|
||||
}
|
||||
|
||||
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
|
||||
{
|
||||
$this->empty_dir($phpbb_root_path . 'store/temp_ext/');
|
||||
}
|
||||
}
|
||||
|
||||
public function setExpectedTriggerError($errno, $message = '')
|
||||
{
|
||||
$exceptionName = '';
|
||||
|
@ -202,27 +252,6 @@ class phpbb_test_case_helpers
|
|||
return $copied_files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove files/directories that are listed in an array
|
||||
* Designed for use with $this->copy_dir()
|
||||
*
|
||||
* @param array $file_list
|
||||
*/
|
||||
public function remove_files($file_list)
|
||||
{
|
||||
foreach ($file_list as $file)
|
||||
{
|
||||
if (is_dir($file))
|
||||
{
|
||||
rmdir($file);
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty directory (remove any subdirectories/files below)
|
||||
*
|
||||
|
|
|
@ -59,27 +59,52 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
|
|||
$this->set = new phpbb_tree_nestedset_forum($this->db, $this->lock, 'phpbb_forums');
|
||||
|
||||
$this->set_up_forums();
|
||||
|
||||
$sql = "UPDATE phpbb_forums
|
||||
SET forum_parents = 'a:0:{}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
protected function set_up_forums()
|
||||
{
|
||||
$this->create_forum('Parent with two flat children');
|
||||
$this->create_forum('Flat child #1', 1);
|
||||
$this->create_forum('Flat child #2', 1);
|
||||
static $forums;
|
||||
|
||||
$this->create_forum('Parent with two nested children');
|
||||
$this->create_forum('Nested child #1', 4);
|
||||
$this->create_forum('Nested child #2', 5);
|
||||
if (empty($forums))
|
||||
{
|
||||
$this->create_forum('Parent with two flat children');
|
||||
$this->create_forum('Flat child #1', 1);
|
||||
$this->create_forum('Flat child #2', 1);
|
||||
|
||||
$this->create_forum('Parent with flat and nested children');
|
||||
$this->create_forum('Mixed child #1', 7);
|
||||
$this->create_forum('Mixed child #2', 7);
|
||||
$this->create_forum('Nested child #1 of Mixed child #2', 9);
|
||||
$this->create_forum('Mixed child #3', 7);
|
||||
$this->create_forum('Parent with two nested children');
|
||||
$this->create_forum('Nested child #1', 4);
|
||||
$this->create_forum('Nested child #2', 5);
|
||||
|
||||
$this->create_forum('Parent with flat and nested children');
|
||||
$this->create_forum('Mixed child #1', 7);
|
||||
$this->create_forum('Mixed child #2', 7);
|
||||
$this->create_forum('Nested child #1 of Mixed child #2', 9);
|
||||
$this->create_forum('Mixed child #3', 7);
|
||||
|
||||
// Updating forum_parents column here so it's not empty
|
||||
// This is required, so we can see whether the methods
|
||||
// correctly clear the values.
|
||||
$sql = "UPDATE phpbb_forums
|
||||
SET forum_parents = 'a:0:{}'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
// Copy the forums into a static array, so we can reuse the list later
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_forums';
|
||||
$result = $this->db->sql_query($sql);
|
||||
$forums = $this->db->sql_fetchrowset($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$buffer = new phpbb_db_sql_insert_buffer($this->db, 'phpbb_forums');
|
||||
$buffer->insert_all($forums);
|
||||
$buffer->flush();
|
||||
|
||||
$this->database_synchronisation(array(
|
||||
'phpbb_forums' => array('forum_id'),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
protected function create_forum($name, $parent_id = 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue