1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge branch 'develop' of https://github.com/phpbb/phpbb into feature/passwords

Conflicts:
	phpBB/config/services.yml
This commit is contained in:
Marc Alexander
2013-12-29 13:46:42 +01:00
619 changed files with 13392 additions and 5996 deletions

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Permission/Auth class
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Apache authentication provider for phpBB3
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base authentication provider class that all other providers should implement
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database authentication provider for phpBB3
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database authentication provider for phpBB3
*
@@ -106,7 +98,6 @@ class ldap extends \phpbb\auth\provider\base
@ldap_close($ldap);
if (!is_array($result) || sizeof($result) < 2)
{
return sprintf($this->user->lang['LDAP_NO_IDENTITY'], $this->user->data['username']);

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Uri\Uri;
@@ -179,7 +171,7 @@ class oauth extends \phpbb\auth\provider\base
$storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table);
$query = 'mode=login&login=external&oauth_service=' . $service_name_original;
$service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope(), $query);
$service = $this->get_service($service_name_original, $storage, $service_credentials, $query, $this->service_providers[$service_name]->get_auth_scope());
if ($this->request->is_set('code', \phpbb\request\request_interface::GET))
{
@@ -273,13 +265,13 @@ class oauth extends \phpbb\auth\provider\base
* @param string $service_name The name of the service
* @param \phpbb\auth\provider\oauth\token_storage $storage
* @param array $service_credentials {@see \phpbb\auth\provider\oauth\oauth::get_service_credentials}
* @param array $scope The scope of the request against
* the api.
* @param string $query The query string of the
* current_uri used in redirection
* @param array $scope The scope of the request against
* the api.
* @return \OAuth\Common\Service\ServiceInterface
*/
protected function get_service($service_name, \phpbb\auth\provider\oauth\token_storage $storage, array $service_credentials, array $scopes = array(), $query)
protected function get_service($service_name, \phpbb\auth\provider\oauth\token_storage $storage, array $service_credentials, $query, array $scopes = array())
{
$current_uri = $this->get_current_uri($service_name, $query);
@@ -458,7 +450,7 @@ class oauth extends \phpbb\auth\provider\base
// Prepare for an authentication request
$service_credentials = $this->service_providers[$service_name]->get_service_credentials();
$scopes = $this->service_providers[$service_name]->get_auth_scope();
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query);
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $query, $scopes);
$this->service_providers[$service_name]->set_external_service_provider($service);
// The user has already authenticated successfully, request to authenticate again
@@ -491,7 +483,7 @@ class oauth extends \phpbb\auth\provider\base
$query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . strtolower($link_data['oauth_service']);
$service_credentials = $this->service_providers[$service_name]->get_service_credentials();
$scopes = $this->service_providers[$service_name]->get_auth_scope();
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query);
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $query, $scopes);
if ($this->request->is_set('code', \phpbb\request\request_interface::GET))
{

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base OAuth abstract class that all OAuth services should implement
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Bitly OAuth service
*

View File

@@ -7,19 +7,13 @@
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
namespace phpbb\auth\provider\oauth\service;
/**
* OAuth service exception class
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_exception extends RuntimeException
class exception extends \RuntimeException
{
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Facebook OAuth service
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Google OAuth service
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth\service;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* OAuth service interface
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider\oauth;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use OAuth\OAuth1\Token\StdOAuth1Token;
use OAuth\Common\Token\TokenInterface;
@@ -78,7 +70,7 @@ class token_storage implements TokenStorageInterface
{
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken instanceOf TokenInterface)
if ($this->cachedToken instanceof TokenInterface)
{
return $this->cachedToken;
}
@@ -238,7 +230,7 @@ class token_storage implements TokenStorageInterface
{
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken instanceOf TokenInterface) {
if ($this->cachedToken instanceof TokenInterface) {
return $this->cachedToken;
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\auth\provider;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The interface authentication provider classes have to implement.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base class for avatar drivers
* @package phpBB3
@@ -47,6 +39,12 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
*/
protected $php_ext;
/**
* Path Helper
* @var \phpbb\path_helper
*/
protected $path_helper;
/**
* Cache driver
* @var \phpbb\cache\driver\driver_interface
@@ -75,13 +73,15 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
* @param \phpbb\request\request $request Request object
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension
* @param \phpbb_path_helper $path_helper phpBB path helper
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
*/
public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null)
public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->path_helper = $path_helper;
$this->cache = $cache;
}
@@ -109,17 +109,6 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
return true;
}
/**
* @inheritdoc
*/
public function get_template_name()
{
$driver = preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this));
$template = "ucp_avatar_options_$driver.html";
return $template;
}
/**
* @inheritdoc
*/

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Interface for avatar drivers
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted at gravatar.com
* @package phpBB3
@@ -154,6 +146,14 @@ class gravatar extends \phpbb\avatar\driver\driver
);
}
/**
* @inheritdoc
*/
public function get_template_name()
{
return 'ucp_avatar_options_gravatar.html';
}
/**
* Build gravatar URL for output on page
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars selected from the board gallery
* @package phpBB3
@@ -29,7 +21,7 @@ class local extends \phpbb\avatar\driver\driver
public function get_data($row)
{
return array(
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'src' => $this->path_helper->get_web_root_path() . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
@@ -142,6 +134,14 @@ class local extends \phpbb\avatar\driver\driver
);
}
/**
* @inheritdoc
*/
public function get_template_name()
{
return 'ucp_avatar_options_local.html';
}
/**
* Get a list of avatars that are locally available
* Results get cached for 24 hours (86400 seconds)

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted remotely
* @package phpBB3
@@ -125,6 +117,37 @@ class remote extends \phpbb\avatar\driver\driver
$types = \fileupload::image_types();
$extension = strtolower(\filespec::get_extension($url));
// Check if this is actually an image
if ($file_stream = @fopen($url, 'r'))
{
// Timeout after 1 second
stream_set_timeout($file_stream, 1);
$meta = stream_get_meta_data($file_stream);
foreach ($meta['wrapper_data'] as $header)
{
$header = preg_split('/ /', $header, 2);
if (strtr(strtolower(trim($header[0], ':')), '_', '-') === 'content-type')
{
if (strpos($header[1], 'image/') !== 0)
{
$error[] = 'AVATAR_URL_INVALID';
fclose($file_stream);
return false;
}
else
{
fclose($file_stream);
break;
}
}
}
}
else
{
$error[] = 'AVATAR_URL_INVALID';
return false;
}
if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]])))
{
if (!isset($types[$image_data[2]]))
@@ -163,4 +186,12 @@ class remote extends \phpbb\avatar\driver\driver
'avatar_height' => $height,
);
}
/**
* @inheritdoc
*/
public function get_template_name()
{
return 'ucp_avatar_options_remote.html';
}
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars uploaded to the board
* @package phpBB3
@@ -29,7 +21,7 @@ class upload extends \phpbb\avatar\driver\driver
public function get_data($row, $ignore_config = false)
{
return array(
'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'src' => $this->path_helper->get_web_root_path() . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
@@ -175,6 +167,14 @@ class upload extends \phpbb\avatar\driver\driver
return true;
}
/**
* @inheritdoc
*/
public function get_template_name()
{
return 'ucp_avatar_options_upload.html';
}
/**
* Check if user is able to upload an avatar
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\avatar;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package avatar
*/
@@ -41,12 +33,6 @@ class manager
*/
protected $avatar_drivers;
/**
* Service container object
* @var object
*/
protected $container;
/**
* Default avatar data row
* @var array
@@ -63,13 +49,27 @@ class manager
*
* @param \phpbb\config\config $config phpBB configuration
* @param array $avatar_drivers Avatar drivers passed via the service container
* @param object $container Container object
*/
public function __construct(\phpbb\config\config $config, $avatar_drivers, $container)
public function __construct(\phpbb\config\config $config, $avatar_drivers)
{
$this->config = $config;
$this->avatar_drivers = $avatar_drivers;
$this->container = $container;
$this->register_avatar_drivers($avatar_drivers);
}
/**
* Register avatar drivers
*
* @param array $avatar_drivers Service collection of avatar drivers
*/
protected function register_avatar_drivers($avatar_drivers)
{
if (!empty($avatar_drivers))
{
foreach ($avatar_drivers as $driver)
{
$this->avatar_drivers[$driver->get_name()] = $driver;
}
}
}
/**
@@ -112,7 +112,7 @@ class manager
* There is no need to handle invalid avatar types as the following code
* will cause a ServiceNotFoundException if the type does not exist
*/
$driver = $this->container->get($avatar_type);
$driver = $this->avatar_drivers[$avatar_type];
return $driver;
}
@@ -178,14 +178,16 @@ class manager
}
/**
* Strip out user_ and group_ prefixes from keys
* Strip out user_, group_, or other prefixes from array keys
*
* @param array $row User data or group data
* @param array $row User data or group data
* @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore
*
* @return array User data or group data with keys that have been
* stripped from the preceding "user_" or "group_"
* @return array User or group data with keys that have been
* stripped from the preceding "user_" or "group_"
* Also the group id is prefixed with g, when the prefix group is removed.
*/
static public function clean_row($row)
static public function clean_row($row, $prefix = '')
{
// Upon creation of a user/group $row might be empty
if (empty($row))
@@ -193,23 +195,19 @@ class manager
return self::$default_row;
}
$keys = array_keys($row);
$values = array_values($row);
$output = array();
foreach ($row as $key => $value)
{
$key = preg_replace("#^(?:{$prefix}_)#", '', $key);
$output[$key] = $value;
}
$keys = array_map(array('\phpbb\avatar\manager', 'strip_prefix'), $keys);
if ($prefix === 'group' && isset($output['id']))
{
$output['id'] = 'g' . $output['id'];
}
return array_combine($keys, $values);
}
/**
* Strip prepending user_ or group_ prefix from key
*
* @param string Array key
* @return string Key that has been stripped from its prefix
*/
static protected function strip_prefix($key)
{
return preg_replace('#^(?:user_|group_)#', '', $key);
return $output;
}
/**

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for APC
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acm
*/

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* An interface that all cache drivers must implement
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for eAccelerator
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM File Based Caching
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (!defined('PHPBB_ACM_MEMCACHE_PORT'))
{
define('PHPBB_ACM_MEMCACHE_PORT', 11211);

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM Abstract Memory Class
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM Null Caching
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (!defined('PHPBB_ACM_REDIS_PORT'))
{
define('PHPBB_ACM_REDIS_PORT', 6379);

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for WinCache
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* ACM for XCache
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb\cache;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Class for grabbing/handling cached entries
* @package acm

View File

@@ -9,14 +9,6 @@
namespace phpbb;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The class loader resolves class names to file system paths and loads them if
* necessary.
@@ -55,7 +47,7 @@ class class_loader
* @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface.
*/
public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null)
{
{
if ($namespace[0] !== '\\')
{
$namespace = '\\' . $namespace;

View File

@@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Configuration container class
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Configuration container class
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\config;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Manages configuration options with an arbitrary length value stored in a TEXT
* column. In constrast to class \phpbb\config\db, values are never cached and

View File

@@ -0,0 +1,23 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console;
use Symfony\Component\DependencyInjection\TaggedContainerInterface;
class application extends \Symfony\Component\Console\Application
{
function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command')
{
foreach($container->findTaggedServiceIds($tag) as $id => $void)
{
$this->add($container->get($id));
}
}
}

View File

@@ -0,0 +1,14 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command;
abstract class command extends \Symfony\Component\Console\Command\Command
{
}

View File

@@ -0,0 +1,22 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\extension;
abstract class command extends \phpbb\console\command\command
{
/** @var \phpbb\extension\manager */
protected $manager;
function __construct(\phpbb\extension\manager $manager)
{
$this->manager = $manager;
parent::__construct();
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class disable extends command
{
protected function configure()
{
$this
->setName('extension:disable')
->setDescription('Disables the specified extension.')
->addArgument(
'extension-name',
InputArgument::REQUIRED,
'Name of the extension'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('extension-name');
$this->manager->disable($name);
$this->manager->load_extensions();
if ($this->manager->enabled($name))
{
$output->writeln("<error>Could not disable extension $name</error>");
return 1;
}
else
{
$output->writeln("<info>Successfully disabled extension $name</info>");
return 0;
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class enable extends command
{
protected function configure()
{
$this
->setName('extension:enable')
->setDescription('Enables the specified extension.')
->addArgument(
'extension-name',
InputArgument::REQUIRED,
'Name of the extension'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('extension-name');
$this->manager->enable($name);
$this->manager->load_extensions();
if ($this->manager->enabled($name))
{
$output->writeln("<info>Successfully enabled extension $name</info>");
return 0;
}
else
{
$output->writeln("<error>Could not enable extension $name</error>");
return 1;
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class purge extends command
{
protected function configure()
{
$this
->setName('extension:purge')
->setDescription('Purges the specified extension.')
->addArgument(
'extension-name',
InputArgument::REQUIRED,
'Name of the extension'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('extension-name');
$this->manager->purge($name);
$this->manager->load_extensions();
if ($this->manager->enabled($name))
{
$output->writeln("<error>Could not purge extension $name</error>");
return 1;
}
else
{
$output->writeln("<info>Successfully purge extension $name</info>");
return 0;
}
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class show extends command
{
protected function configure()
{
$this
->setName('extension:show')
->setDescription('Lists all extensions in the database and on the filesystem.')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->manager->load_extensions();
$all = array_keys($this->manager->all_available());
if (empty($all))
{
$output->writeln('<comment>No extensions were found.</comment>');
return 3;
}
$enabled = array_keys($this->manager->all_enabled());
$this->print_extension_list($output, 'Enabled', $enabled);
$output->writeln('');
$disabled = array_keys($this->manager->all_disabled());
$this->print_extension_list($output, 'Disabled', $disabled);
$output->writeln('');
$purged = array_diff($all, $enabled, $disabled);
$this->print_extension_list($output, 'Available', $purged);
}
protected function print_extension_list(OutputInterface $output, $type, array $extensions)
{
$output->writeln("<info>$type:</info>");
foreach ($extensions as $extension)
{
$output->writeln(" - $extension");
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\fixup;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class recalculate_email_hash extends \phpbb\console\command\command
{
/** @var \phpbb\db\driver\driver */
protected $db;
function __construct(\phpbb\db\driver\driver $db)
{
$this->db = $db;
parent::__construct();
}
protected function configure()
{
$this
->setName('fixup:recalculate-email-hash')
->setDescription('Recalculates the user_email_hash column of the users table.')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$sql = 'SELECT user_id, user_email, user_email_hash
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . "
AND user_email <> ''";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$user_email_hash = phpbb_email_hash($row['user_email']);
if ($user_email_hash !== $row['user_email_hash'])
{
$sql_ary = array(
'user_email_hash' => $user_email_hash,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $row['user_id'];
$this->db->sql_query($sql);
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG)
{
$output->writeln(sprintf(
'user_id %d, email %s => %s',
$row['user_id'],
$row['user_email'],
$user_email_hash
));
}
}
}
$this->db->sql_freeresult($result);
$output->writeln('<info>Successfully recalculated all email hashes.</info>');
}
}

View File

@@ -9,14 +9,6 @@
namespace phpbb;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* phpbb_visibility
* Handle fetching and setting the visibility for topics and posts
@@ -556,7 +548,7 @@ class content_visibility
*
* @param $data array Contains information from the topics table about given topic
* @param $sql_data array Populated with the SQL changes, may be empty at call time
* @return void
* @return null
*/
public function add_post_to_statistic($data, &$sql_data)
{
@@ -577,7 +569,7 @@ class content_visibility
*
* @param $data array Contains information from the topics table about given topic
* @param $sql_data array Populated with the SQL changes, may be empty at call time
* @return void
* @return null
*/
public function remove_post_from_statistic($data, &$sql_data)
{
@@ -599,7 +591,7 @@ class content_visibility
* @param $forum_id int Forum where the topic is found
* @param $topic_row array Contains information from the topic, may be empty at call time
* @param $sql_data array Populated with the SQL changes, may be empty at call time
* @return void
* @return null
*/
public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data)
{

View File

@@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Controller exception class
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\HttpFoundation\Response;
/**

View File

@@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
@@ -31,17 +23,17 @@ class provider
* YAML file(s) containing route information
* @var array
*/
protected $routing_paths;
protected $routing_files;
/**
* Construct method
*
* @param array() $routing_paths Array of strings containing paths
* @param array() $routing_files Array of strings containing paths
* to YAML files holding route information
*/
public function __construct($routing_paths = array())
public function __construct($routing_files = array())
{
$this->routing_paths = $routing_paths;
$this->routing_files = $routing_files;
}
/**
@@ -54,12 +46,11 @@ class provider
{
// We hardcode the path to the core config directory
// because the finder cannot find it
$this->routing_paths = array_merge(array('config'), array_map('dirname', array_keys($finder
$this->routing_files = array_merge(array('config/routing.yml'), array_keys($finder
->directory('config')
->prefix('routing')
->suffix('yml')
->suffix('routing.yml')
->find()
)));
));
return $this;
}
@@ -73,10 +64,10 @@ class provider
public function find($base_path = '')
{
$routes = new RouteCollection;
foreach ($this->routing_paths as $path)
foreach ($this->routing_files as $file_path)
{
$loader = new YamlFileLoader(new FileLocator($base_path . $path));
$routes->addCollection($loader->load('routing.yml'));
$loader = new YamlFileLoader(new FileLocator($base_path));
$routes->addCollection($loader->load($file_path));
}
return $routes;

View File

@@ -9,14 +9,6 @@
namespace phpbb\controller;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron manager class.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task base class. Provides sensible defaults for cron tasks
* and partially implements cron task interface, making writing cron tasks easier.

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prune all forums cron task.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prune one forum cron task.
*

View File

@@ -7,20 +7,14 @@
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
namespace phpbb\cron\task\core;
/**
* Prune notifications cron task.
*
* @package phpBB3
*/
class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base
class prune_notifications extends \phpbb\cron\task\base
{
protected $config;
protected $notification_manager;
@@ -28,10 +22,10 @@ class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base
/**
* Constructor.
*
* @param phpbb_config $config The config
* @param phpbb_notification_manager $notification_manager Notification manager
* @param \phpbb\config\config $config The config
* @param \phpbb\notification\manager $notification_manager Notification manager
*/
public function __construct(phpbb_config $config, phpbb_notification_manager $notification_manager)
public function __construct(\phpbb\config\config $config, \phpbb\notification\manager $notification_manager)
{
$this->config = $config;
$this->notification_manager = $notification_manager;

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Queue cron task. Sends email and jabber messages queued by other scripts.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy cache cron task.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy database cron task.
*

View File

@@ -0,0 +1,116 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\cron\task\core;
/**
* Cron task for cleaning plupload's temporary upload directory.
*
* @package phpBB3
*/
class tidy_plupload extends \phpbb\cron\task\base
{
/**
* How old a file must be (in seconds) before it is deleted.
* @var int
*/
protected $max_file_age = 86400;
/**
* How often we run the cron (in seconds).
* @var int
*/
protected $cron_frequency = 86400;
/**
* phpBB root path
* @var string
*/
protected $phpbb_root_path;
/**
* Config object
* @var \phpbb\config\config
*/
protected $config;
/**
* Directory where plupload stores temporary files.
* @var string
*/
protected $plupload_upload_path;
/**
* Constructor.
*
* @param string $phpbb_root_path The root path
* @param \phpbb\config\config $config The config
*/
public function __construct($phpbb_root_path, \phpbb\config\config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->config = $config;
$this->plupload_upload_path = $this->phpbb_root_path . $this->config['upload_path'] . '/plupload';
}
/**
* {@inheritDoc}
*/
public function run()
{
// Remove old temporary file (perhaps failed uploads?)
$last_valid_timestamp = time() - $this->max_file_age;
try
{
$iterator = new \DirectoryIterator($this->plupload_upload_path);
foreach ($iterator as $file)
{
if (strpos($file->getBasename(), $this->config['plupload_salt']) !== 0)
{
// Skip over any non-plupload files.
continue;
}
if ($file->getMTime() < $last_valid_timestamp)
{
@unlink($file->getPathname());
}
}
}
catch (\UnexpectedValueException $e)
{
add_log(
'critical',
'LOG_PLUPLOAD_TIDY_FAILED',
$this->plupload_upload_path,
$e->getMessage(),
$e->getTraceAsString()
);
}
$this->config->set('plupload_last_gc', time(), true);
}
/**
* {@inheritDoc}
*/
public function is_runnable()
{
return !empty($this->config['plupload_salt']) && is_dir($this->plupload_upload_path);
}
/**
* {@inheritDoc}
*/
public function should_run()
{
return $this->config['plupload_last_gc'] < time() - $this->cron_frequency;
}
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy search cron task.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy sessions cron task.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task\core;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tidy warnings cron task.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Parametrized cron task interface.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task interface
* @package phpBB3

View File

@@ -9,14 +9,6 @@
namespace phpbb\cron\task;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Cron task wrapper class.
* Enhances cron tasks with convenience methods that work identically for all tasks.

View File

@@ -74,8 +74,8 @@ class datetime extends \DateTime
* finally check that relative dates are supported by the language pack
*/
if ($delta <= 3600 && $delta > -60 &&
($delta >= -5 || (($now_ts / 60) % 60) == (($timestamp / 60) % 60))
&& isset($this->user->lang['datetime']['AGO']))
($delta >= -5 || (($now_ts / 60) % 60) == (($timestamp / 60) % 60))
&& isset($this->user->lang['datetime']['AGO']))
{
return $this->user->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Database Abstraction Layer
* @package dbal
@@ -824,7 +816,7 @@ class driver
*/
function sql_report($mode, $query = '')
{
global $cache, $starttime, $phpbb_root_path, $phpbb_admin_path, $user;
global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper, $user;
global $request;
if (is_object($request) && !$request->variable('explain', false))
@@ -854,7 +846,7 @@ class driver
<head>
<meta charset="utf-8">
<title>SQL Report</title>
<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />
<link href="' . htmlspecialchars($phpbb_path_helper->update_web_root_path($phpbb_root_path) . $phpbb_path_helper->get_adm_relative_path()) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body id="errorpage">
<div id="wrap">

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Firebird/Interbase Database Abstraction Layer
* Minimum Requirement is Firebird 2.1
@@ -398,7 +390,7 @@ class firebird extends \phpbb\db\driver\driver
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MSSQL Database Abstraction Layer
* Minimum Requirement is MSSQL 2000+
@@ -259,7 +251,7 @@ class mssql extends \phpbb\db\driver\driver
{
foreach ($row as $key => $value)
{
$row[$key] = ($value === ' ' || $value === NULL) ? '' : $value;
$row[$key] = ($value === ' ' || $value === null) ? '' : $value;
}
}
@@ -318,14 +310,14 @@ class mssql extends \phpbb\db\driver\driver
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
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 @mssql_free_result($query_id);
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MSSQL Database Base Abstraction Layer
* @package dbal

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Unified ODBC functions
* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere...
@@ -305,7 +297,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View File

@@ -13,189 +13,12 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Prior to version 1.1 the SQL Server Native PHP driver didn't support sqlsrv_num_rows, or cursor based seeking so we recall all rows into an array
* and maintain our own cursor index into that array.
*/
class result_mssqlnative
{
public function result_mssqlnative($queryresult = false)
{
$this->m_cursor = 0;
$this->m_rows = array();
$this->m_num_fields = sqlsrv_num_fields($queryresult);
$this->m_field_meta = sqlsrv_field_metadata($queryresult);
while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC))
{
if ($row !== null)
{
foreach($row as $k => $v)
{
if (is_object($v) && method_exists($v, 'format'))
{
$row[$k] = $v->format("Y-m-d\TH:i:s\Z");
}
}
$this->m_rows[] = $row;//read results into memory, cursors are not supported
}
}
$this->m_row_count = sizeof($this->m_rows);
}
private function array_to_obj($array, &$obj)
{
foreach ($array as $key => $value)
{
if (is_array($value))
{
$obj->$key = new \stdClass();
array_to_obj($value, $obj->$key);
}
else
{
$obj->$key = $value;
}
}
return $obj;
}
public function fetch($mode = SQLSRV_FETCH_BOTH, $object_class = 'stdClass')
{
if ($this->m_cursor >= $this->m_row_count || $this->m_row_count == 0)
{
return false;
}
$ret = false;
$arr_num = array();
if ($mode == SQLSRV_FETCH_NUMERIC || $mode == SQLSRV_FETCH_BOTH)
{
foreach($this->m_rows[$this->m_cursor] as $key => $value)
{
$arr_num[] = $value;
}
}
switch ($mode)
{
case SQLSRV_FETCH_ASSOC:
$ret = $this->m_rows[$this->m_cursor];
break;
case SQLSRV_FETCH_NUMERIC:
$ret = $arr_num;
break;
case 'OBJECT':
$ret = $this->array_to_obj($this->m_rows[$this->m_cursor], $o = new $object_class);
break;
case SQLSRV_FETCH_BOTH:
default:
$ret = $this->m_rows[$this->m_cursor] + $arr_num;
break;
}
$this->m_cursor++;
return $ret;
}
public function get($pos, $fld)
{
return $this->m_rows[$pos][$fld];
}
public function num_rows()
{
return $this->m_row_count;
}
public function seek($iRow)
{
$this->m_cursor = min($iRow, $this->m_row_count);
}
public function num_fields()
{
return $this->m_num_fields;
}
public function field_name($nr)
{
$arr_keys = array_keys($this->m_rows[0]);
return $arr_keys[$nr];
}
public function field_type($nr)
{
$i = 0;
$int_type = -1;
$str_type = '';
foreach ($this->m_field_meta as $meta)
{
if ($nr == $i)
{
$int_type = $meta['Type'];
break;
}
$i++;
}
//http://msdn.microsoft.com/en-us/library/cc296183.aspx contains type table
switch ($int_type)
{
case SQLSRV_SQLTYPE_BIGINT: $str_type = 'bigint'; break;
case SQLSRV_SQLTYPE_BINARY: $str_type = 'binary'; break;
case SQLSRV_SQLTYPE_BIT: $str_type = 'bit'; break;
case SQLSRV_SQLTYPE_CHAR: $str_type = 'char'; break;
case SQLSRV_SQLTYPE_DATETIME: $str_type = 'datetime'; break;
case SQLSRV_SQLTYPE_DECIMAL/*($precision, $scale)*/: $str_type = 'decimal'; break;
case SQLSRV_SQLTYPE_FLOAT: $str_type = 'float'; break;
case SQLSRV_SQLTYPE_IMAGE: $str_type = 'image'; break;
case SQLSRV_SQLTYPE_INT: $str_type = 'int'; break;
case SQLSRV_SQLTYPE_MONEY: $str_type = 'money'; break;
case SQLSRV_SQLTYPE_NCHAR/*($charCount)*/: $str_type = 'nchar'; break;
case SQLSRV_SQLTYPE_NUMERIC/*($precision, $scale)*/: $str_type = 'numeric'; break;
case SQLSRV_SQLTYPE_NVARCHAR/*($charCount)*/: $str_type = 'nvarchar'; break;
case SQLSRV_SQLTYPE_NTEXT: $str_type = 'ntext'; break;
case SQLSRV_SQLTYPE_REAL: $str_type = 'real'; break;
case SQLSRV_SQLTYPE_SMALLDATETIME: $str_type = 'smalldatetime'; break;
case SQLSRV_SQLTYPE_SMALLINT: $str_type = 'smallint'; break;
case SQLSRV_SQLTYPE_SMALLMONEY: $str_type = 'smallmoney'; break;
case SQLSRV_SQLTYPE_TEXT: $str_type = 'text'; break;
case SQLSRV_SQLTYPE_TIMESTAMP: $str_type = 'timestamp'; break;
case SQLSRV_SQLTYPE_TINYINT: $str_type = 'tinyint'; break;
case SQLSRV_SQLTYPE_UNIQUEIDENTIFIER: $str_type = 'uniqueidentifier'; break;
case SQLSRV_SQLTYPE_UDT: $str_type = 'UDT'; break;
case SQLSRV_SQLTYPE_VARBINARY/*($byteCount)*/: $str_type = 'varbinary'; break;
case SQLSRV_SQLTYPE_VARCHAR/*($charCount)*/: $str_type = 'varchar'; break;
case SQLSRV_SQLTYPE_XML: $str_type = 'xml'; break;
default: $str_type = $int_type;
}
return $str_type;
}
public function free()
{
unset($this->m_rows);
return;
}
}
/**
* @package dbal
*/
class mssqlnative extends \phpbb\db\driver\mssql_base
{
var $m_insert_id = NULL;
var $m_insert_id = null;
var $last_query_text = '';
var $query_options = array();
var $connect_error = '';
@@ -427,7 +250,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
{
foreach ($row as $key => $value)
{
$row[$key] = ($value === ' ' || $value === NULL) ? '' : $value;
$row[$key] = ($value === ' ' || $value === null) ? '' : $value;
}
// remove helper values from LIMIT queries
@@ -471,7 +294,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
@@ -481,6 +304,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
unset($this->open_queries[(int) $query_id]);
return @sqlsrv_free_stmt($query_id);
}
return false;
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MySQL4 Database Abstraction Layer
* Compatible with:
@@ -289,7 +281,7 @@ class mysql extends \phpbb\db\driver\mysql_base
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Abstract MySQL Database Base Abstraction Layer
* @package dbal

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* MySQLi Database Abstraction Layer
* mysqli-extension has to be compiled with:
@@ -31,7 +23,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
if (!function_exists('mysqli_connect'))
{
@@ -47,11 +39,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
$this->server = ($this->persistency) ? 'p:' . (($sqlserver) ? $sqlserver : 'localhost') : $sqlserver;
$this->dbname = $database;
$port = (!$port) ? NULL : $port;
$port = (!$port) ? null : $port;
// If port is set and it is not numeric, most likely mysqli socket is set.
// Try to map it to the $socket parameter.
$socket = NULL;
$socket = null;
if ($port)
{
if (is_numeric($port))
@@ -61,7 +53,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
else
{
$socket = $port;
$port = NULL;
$port = null;
}
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Oracle Database Abstraction Layer
* @package dbal
@@ -621,7 +613,7 @@ class oracle extends \phpbb\db\driver\driver
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* PostgreSQL Database Abstraction Layer
* Minimum Requirement is Version 7.3+
@@ -328,7 +320,7 @@ class postgres extends \phpbb\db\driver\driver
return false;
}
$temp_result = @pg_fetch_assoc($temp_q_id, NULL);
$temp_result = @pg_fetch_assoc($temp_q_id, null);
@pg_free_result($query_id);
return ($temp_result) ? $temp_result['last_value'] : false;
@@ -350,7 +342,7 @@ class postgres extends \phpbb\db\driver\driver
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
@@ -456,7 +448,7 @@ class postgres extends \phpbb\db\driver\driver
if ($result = @pg_query($this->db_connect_id, "EXPLAIN $explain_query"))
{
while ($row = @pg_fetch_assoc($result, NULL))
while ($row = @pg_fetch_assoc($result, null))
{
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
}
@@ -476,7 +468,7 @@ class postgres extends \phpbb\db\driver\driver
$endtime = $endtime[0] + $endtime[1];
$result = @pg_query($this->db_connect_id, $query);
while ($void = @pg_fetch_assoc($result, NULL))
while ($void = @pg_fetch_assoc($result, null))
{
// Take the time spent on parsing rows into account
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\driver;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Sqlite Database Abstraction Layer
* Minimum Requirement: 2.8.2+
@@ -261,7 +253,7 @@ class sqlite extends \phpbb\db\driver\driver
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v30x;
class release_3_0_12 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return phpbb_version_compare($this->config['version'], '3.0.12', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<');
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v30x\release_3_0_12_rc3');
}
public function update_data()
{
return array(
array('if', array(
phpbb_version_compare($this->config['version'], '3.0.12', '<'),
array('config.update', array('version', '3.0.12')),
)),
);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v30x;
class release_3_0_12_rc2 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return phpbb_version_compare($this->config['version'], '3.0.12-RC2', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<');
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v30x\release_3_0_12_rc1');
}
public function update_data()
{
return array(
array('if', array(
phpbb_version_compare($this->config['version'], '3.0.12-RC2', '<'),
array('config.update', array('version', '3.0.12-RC2')),
)),
);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v30x;
class release_3_0_12_rc3 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return phpbb_version_compare($this->config['version'], '3.0.12-RC3', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<');
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v30x\release_3_0_12_rc2');
}
public function update_data()
{
return array(
array('if', array(
phpbb_version_compare($this->config['version'], '3.0.12-RC3', '<'),
array('config.update', array('version', '3.0.12-RC3')),
)),
);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class acp_style_components_module extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . MODULES_TABLE . "
WHERE module_class = 'acp'
AND module_langname = 'ACP_STYLE_COMPONENTS'";
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
return $module_id == false;
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()
{
return array(
array('module.remove', array(
'acp',
false,
'ACP_STYLE_COMPONENTS',
)),
);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class allow_cdn extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['allow_cdn']);
}
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v310\jquery_update',
);
}
public function update_data()
{
return array(
array('config.add', array('allow_cdn', (int) $this->config['load_jquery_cdn'])),
array('config.remove', array('load_jquery_cdn')),
);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class alpha1 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v30x\local_url_bbcode',
'\phpbb\db\migration\data\v30x\release_3_0_12',
'\phpbb\db\migration\data\v310\acp_style_components_module',
'\phpbb\db\migration\data\v310\allow_cdn',
'\phpbb\db\migration\data\v310\auth_provider_oauth',
'\phpbb\db\migration\data\v310\avatars',
'\phpbb\db\migration\data\v310\boardindex',
'\phpbb\db\migration\data\v310\config_db_text',
'\phpbb\db\migration\data\v310\forgot_password',
'\phpbb\db\migration\data\v310\mod_rewrite',
'\phpbb\db\migration\data\v310\mysql_fulltext_drop',
'\phpbb\db\migration\data\v310\namespaces',
'\phpbb\db\migration\data\v310\notifications_cron',
'\phpbb\db\migration\data\v310\notification_options_reconvert',
'\phpbb\db\migration\data\v310\plupload',
'\phpbb\db\migration\data\v310\signature_module_auth',
'\phpbb\db\migration\data\v310\softdelete_mcp_modules',
'\phpbb\db\migration\data\v310\teampage',
);
}
public function update_data()
{
return array(
array('config.update', array('version', '3.1.0-a1')),
);
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class alpha2 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v310\alpha1',
'\phpbb\db\migration\data\v310\notifications_cron_p2',
);
}
public function update_data()
{
return array(
array('config.update', array('version', '3.1.0-a2')),
);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class avatar_types extends \phpbb\db\migration\migration
{
/**
* @var avatar type map
*/
protected $avatar_type_map = array(
AVATAR_UPLOAD => 'avatar.driver.upload',
AVATAR_REMOTE => 'avatar.driver.remote',
AVATAR_GALLERY => 'avatar.driver.local',
);
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v310\dev',
'\phpbb\db\migration\data\v310\avatars',
);
}
public function update_data()
{
return array(
array('custom', array(array($this, 'update_user_avatar_type'))),
array('custom', array(array($this, 'update_group_avatar_type'))),
);
}
public function update_user_avatar_type()
{
foreach ($this->avatar_type_map as $old => $new)
{
$sql = 'UPDATE ' . $this->table_prefix . "users
SET user_avatar_type = '$new'
WHERE user_avatar_type = '$old'";
$this->db->sql_query($sql);
}
}
public function update_group_avatar_type()
{
foreach ($this->avatar_type_map as $old => $new)
{
$sql = 'UPDATE ' . $this->table_prefix . "groups
SET group_avatar_type = '$new'
WHERE group_avatar_type = '$old'";
$this->db->sql_query($sql);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class mysql_fulltext_drop extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
// This migration is irrelevant for all non-MySQL DBMSes.
return strpos($this->db->sql_layer, 'mysql') === false;
}
static public function depends_on()
{
return array(
'\phpbb\db\migration\data\v310\dev',
);
}
public function update_schema()
{
/*
* Drop FULLTEXT indexes related to MySQL fulltext search.
* Doing so is equivalent to dropping the search index from the ACP.
* Possibly time-consuming recreation of the search index (i.e.
* FULLTEXT indexes) is left as a task to the admin to not
* unnecessarily stall the upgrade process. The new search index will
* then require about 40% less table space (also see PHPBB3-11621).
*/
return array(
'drop_keys' => array(
$this->table_prefix . 'posts' => array(
'post_subject',
'post_text',
'post_content',
),
),
);
}
}

View File

@@ -23,7 +23,7 @@ class namespaces extends \phpbb\db\migration\migration
return array(
array('if', array(
(preg_match('#^phpbb_search_#', $this->config['search_type'])),
array('config.update', array('search_type', str_replace('phpbb_search_', 'phpbb\\search\\', $this->config['search_type']))),
array('config.update', array('search_type', str_replace('phpbb_search_', '\\phpbb\\search\\', $this->config['search_type']))),
)),
);
}

View File

@@ -34,7 +34,7 @@ class notifications extends \phpbb\db\migration\migration
),
$this->table_prefix . 'notifications' => array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
'notification_id' => array('UINT', null, 'auto_increment'),
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),

View File

@@ -0,0 +1,27 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class notifications_cron_p2 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\notifications_cron');
}
public function update_data()
{
return array(
// Make read_notification_last_gc dynamic.
array('config.remove', array('read_notification_last_gc')),
array('config.add', array('read_notification_last_gc', 0, 1)),
);
}
}

View File

@@ -26,7 +26,7 @@ class notifications_schema_fix extends \phpbb\db\migration\migration
'add_tables' => array(
$this->table_prefix . 'notification_types' => array(
'COLUMNS' => array(
'notification_type_id' => array('USINT', NULL, 'auto_increment'),
'notification_type_id' => array('USINT', null, 'auto_increment'),
'notification_type_name' => array('VCHAR:255', ''),
'notification_type_enabled' => array('BOOL', 1),
),
@@ -37,7 +37,7 @@ class notifications_schema_fix extends \phpbb\db\migration\migration
),
$this->table_prefix . 'notifications' => array(
'COLUMNS' => array(
'notification_id' => array('UINT:10', NULL, 'auto_increment'),
'notification_id' => array('UINT:10', null, 'auto_increment'),
'notification_type_id' => array('USINT', 0),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),
@@ -73,7 +73,7 @@ class notifications_schema_fix extends \phpbb\db\migration\migration
),
$this->table_prefix . 'notifications' => array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
'notification_id' => array('UINT', null, 'auto_increment'),
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),

View File

@@ -0,0 +1,32 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class plupload extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['plupload_last_gc']) &&
isset($this->config['plupload_salt']);
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()
{
return array(
array('config.add', array('plupload_last_gc', 0)),
array('config.add', array('plupload_salt', unique_id())),
);
}
}

View File

@@ -27,7 +27,7 @@ class signature_module_auth extends \phpbb\db\migration\migration
static public function depends_on()
{
return array('\phpbb\db\migration\data\v31x\dev');
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()

View File

@@ -34,7 +34,10 @@ class softdelete_p2 extends \phpbb\db\migration\migration
),
'drop_keys' => array(
$this->table_prefix . 'posts' => array('post_approved'),
$this->table_prefix . 'topics' => array('forum_appr_last'),
$this->table_prefix . 'topics' => array(
'forum_appr_last',
'topic_approved',
),
),
);
}
@@ -63,6 +66,7 @@ class softdelete_p2 extends \phpbb\db\migration\migration
),
$this->table_prefix . 'topics' => array(
'forum_appr_last' => array('forum_id', 'topic_approved', 'topic_last_post_id'),
'topic_approved' => array('topic_approved'),
),
),
);

View File

@@ -24,6 +24,14 @@ class style_update_p2 extends \phpbb\db\migration\migration
public function update_schema()
{
return array(
'drop_keys' => array(
$this->table_prefix . 'styles' => array(
'imageset_id',
'template_id',
'theme_id',
),
),
'drop_columns' => array(
$this->table_prefix . 'styles' => array(
'imageset_id',
@@ -53,10 +61,18 @@ class style_update_p2 extends \phpbb\db\migration\migration
),
),
'add_index' => array(
$this->table_prefix . 'styles' => array(
'imageset_id' => array('imageset_id'),
'template_id' => array('template_id'),
'theme_id' => array('theme_id'),
),
),
'add_tables' => array(
$this->table_prefix . 'styles_imageset' => array(
'COLUMNS' => array(
'imageset_id' => array('UINT', NULL, 'auto_increment'),
'imageset_id' => array('UINT', null, 'auto_increment'),
'imageset_name' => array('VCHAR_UNI:255', ''),
'imageset_copyright' => array('VCHAR_UNI', ''),
'imageset_path' => array('VCHAR:100', ''),
@@ -68,7 +84,7 @@ class style_update_p2 extends \phpbb\db\migration\migration
),
$this->table_prefix . 'styles_imageset_data' => array(
'COLUMNS' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'image_id' => array('UINT', null, 'auto_increment'),
'image_name' => array('VCHAR:200', ''),
'image_filename' => array('VCHAR:200', ''),
'image_lang' => array('VCHAR:30', ''),
@@ -83,7 +99,7 @@ class style_update_p2 extends \phpbb\db\migration\migration
),
$this->table_prefix . 'styles_template' => array(
'COLUMNS' => array(
'template_id' => array('UINT', NULL, 'auto_increment'),
'template_id' => array('UINT', null, 'auto_increment'),
'template_name' => array('VCHAR_UNI:255', ''),
'template_copyright' => array('VCHAR_UNI', ''),
'template_path' => array('VCHAR:100', ''),
@@ -112,7 +128,7 @@ class style_update_p2 extends \phpbb\db\migration\migration
),
$this->table_prefix . 'styles_theme' => array(
'COLUMNS' => array(
'theme_id' => array('UINT', NULL, 'auto_increment'),
'theme_id' => array('UINT', null, 'auto_increment'),
'theme_name' => array('VCHAR_UNI:255', ''),
'theme_copyright' => array('VCHAR_UNI', ''),
'theme_path' => array('VCHAR:100', ''),

View File

@@ -27,7 +27,7 @@ class teampage extends \phpbb\db\migration\migration
'add_tables' => array(
$this->table_prefix . 'teampage' => array(
'COLUMNS' => array(
'teampage_id' => array('UINT', NULL, 'auto_increment'),
'teampage_id' => array('UINT', null, 'auto_increment'),
'group_id' => array('UINT', 0),
'teampage_name' => array('VCHAR_UNI:255', ''),
'teampage_position' => array('UINT', 0),

View File

@@ -0,0 +1,42 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\db\migration\data\v310;
class ucp_popuppm_module extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . MODULES_TABLE . "
WHERE module_class = 'ucp'
AND module_langname = 'UCP_PM_POPUP_TITLE'";
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
return $module_id == false;
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()
{
return array(
array('module.remove', array(
'ucp',
'UCP_PM',
'UCP_PM_POPUP_TITLE',
)),
);
}
}

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\migration;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The migrator is responsible for applying new migrations in the correct order.
*

View File

@@ -9,14 +9,6 @@
namespace phpbb\db\migration;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Abstract base class for database migrations
*

View File

@@ -130,6 +130,10 @@ class config implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
if (sizeof($arguments) == 1)
{
$arguments[] = '';
}
break;
case 'update_if_equals':

Some files were not shown because too many files have changed in this diff Show More