Tentative de régler le bordel
This commit is contained in:
@@ -13,34 +13,55 @@
|
||||
|
||||
namespace phpbb\auth\provider;
|
||||
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\request\type_cast_helper;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
* Apache authentication provider for phpBB3
|
||||
*/
|
||||
class apache extends \phpbb\auth\provider\base
|
||||
class apache extends base
|
||||
{
|
||||
/**
|
||||
* phpBB passwords manager
|
||||
*
|
||||
* @var \phpbb\passwords\manager
|
||||
*/
|
||||
protected $passwords_manager;
|
||||
/** @var config phpBB config */
|
||||
protected $config;
|
||||
|
||||
/** @var driver_interface Database object */
|
||||
protected $db;
|
||||
|
||||
/** @var language Language object */
|
||||
protected $language;
|
||||
|
||||
/** @var request_interface Request object */
|
||||
protected $request;
|
||||
|
||||
/** @var user User object */
|
||||
protected $user;
|
||||
|
||||
/** @var string Relative path to phpBB root */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var string PHP file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Apache Authentication Constructor
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db Database object
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\passwords\manager $passwords_manager Passwords Manager object
|
||||
* @param \phpbb\request\request $request Request object
|
||||
* @param \phpbb\user $user User object
|
||||
* @param config $config Config object
|
||||
* @param driver_interface $db Database object
|
||||
* @param language $language Language object
|
||||
* @param request_interface $request Request object
|
||||
* @param user $user User object
|
||||
* @param string $phpbb_root_path Relative path to phpBB root
|
||||
* @param string $php_ext PHP file extension
|
||||
*/
|
||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, $phpbb_root_path, $php_ext)
|
||||
public function __construct(config $config, driver_interface $db, language $language, request_interface $request, user $user, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->passwords_manager = $passwords_manager;
|
||||
$this->db = $db;
|
||||
$this->language = $language;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
@@ -52,9 +73,9 @@ class apache extends \phpbb\auth\provider\base
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')))
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')))
|
||||
{
|
||||
return $this->user->lang['APACHE_SETUP_BEFORE_USE'];
|
||||
return $this->language->lang('APACHE_SETUP_BEFORE_USE');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -83,7 +104,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER))
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER))
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_EXTERNAL_AUTH,
|
||||
@@ -137,7 +158,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
return array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE,
|
||||
'error_msg' => false,
|
||||
'user_row' => $this->user_row($php_auth_user, $php_auth_pw),
|
||||
'user_row' => $this->user_row($php_auth_user),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -154,7 +175,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER))
|
||||
if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -164,8 +185,8 @@ class apache extends \phpbb\auth\provider\base
|
||||
|
||||
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);
|
||||
$type_cast_helper = new type_cast_helper();
|
||||
$type_cast_helper->set_var($php_auth_user, $php_auth_user, 'string', true);
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
@@ -185,7 +206,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
}
|
||||
|
||||
// create the user if he does not exist yet
|
||||
user_add($this->user_row($php_auth_user, $php_auth_pw));
|
||||
user_add($this->user_row($php_auth_user));
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
@@ -208,11 +229,11 @@ class apache extends \phpbb\auth\provider\base
|
||||
* 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)
|
||||
private function user_row($username)
|
||||
{
|
||||
// first retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
@@ -231,7 +252,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
// generate user account data
|
||||
return array(
|
||||
'username' => $username,
|
||||
'user_password' => $this->passwords_manager->hash($password),
|
||||
'user_password' => '',
|
||||
'user_email' => '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => USER_NORMAL,
|
||||
@@ -246,7 +267,7 @@ class apache extends \phpbb\auth\provider\base
|
||||
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\request_interface::SERVER))
|
||||
if ($this->request->is_set('PHP_AUTH_USER', request_interface::SERVER))
|
||||
{
|
||||
$php_auth_user = $this->request->server('PHP_AUTH_USER');
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace phpbb\auth\provider;
|
||||
/**
|
||||
* Base authentication provider class that all other providers should implement
|
||||
*/
|
||||
abstract class base implements \phpbb\auth\provider\provider_interface
|
||||
abstract class base implements provider_interface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -13,48 +13,69 @@
|
||||
|
||||
namespace phpbb\auth\provider;
|
||||
|
||||
use phpbb\captcha\factory;
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\passwords\manager;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
* Database authentication provider for phpBB3
|
||||
* This is for authentication via the integrated user table
|
||||
*/
|
||||
class db extends \phpbb\auth\provider\base
|
||||
class db extends base
|
||||
{
|
||||
/** @var factory CAPTCHA factory */
|
||||
protected $captcha_factory;
|
||||
|
||||
/** @var config phpBB config */
|
||||
protected $config;
|
||||
|
||||
/** @var driver_interface DBAL driver instance */
|
||||
protected $db;
|
||||
|
||||
/** @var request_interface Request object */
|
||||
protected $request;
|
||||
|
||||
/** @var user User object */
|
||||
protected $user;
|
||||
|
||||
/** @var string phpBB root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var string PHP file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* phpBB passwords manager
|
||||
*
|
||||
* @var \phpbb\passwords\manager
|
||||
* @var manager
|
||||
*/
|
||||
protected $passwords_manager;
|
||||
|
||||
/**
|
||||
* DI container
|
||||
*
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected $phpbb_container;
|
||||
|
||||
/**
|
||||
* Database Authentication Constructor
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\passwords\manager $passwords_manager
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\user $user
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container
|
||||
* @param factory $captcha_factory
|
||||
* @param config $config
|
||||
* @param driver_interface $db
|
||||
* @param manager $passwords_manager
|
||||
* @param request_interface $request
|
||||
* @param user $user
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext)
|
||||
public function __construct(factory $captcha_factory, config $config, driver_interface $db, manager $passwords_manager, request_interface $request, user $user, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->captcha_factory = $captcha_factory;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->passwords_manager = $passwords_manager;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->phpbb_container = $phpbb_container;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,9 +176,7 @@ class db extends \phpbb\auth\provider\base
|
||||
// Every auth module is able to define what to do by itself...
|
||||
if ($show_captcha)
|
||||
{
|
||||
/* @var $captcha_factory \phpbb\captcha\factory */
|
||||
$captcha_factory = $this->phpbb_container->get('captcha.factory');
|
||||
$captcha = $captcha_factory->get_instance($this->config['captcha_plugin']);
|
||||
$captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_LOGIN);
|
||||
$vc_response = $captcha->validate($row);
|
||||
if ($vc_response)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
@@ -13,32 +14,42 @@
|
||||
|
||||
namespace phpbb\auth\provider;
|
||||
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
* Database authentication provider for phpBB3
|
||||
* This is for authentication via the integrated user table
|
||||
*/
|
||||
class ldap extends \phpbb\auth\provider\base
|
||||
class ldap extends base
|
||||
{
|
||||
/**
|
||||
* phpBB passwords manager
|
||||
*
|
||||
* @var \phpbb\passwords\manager
|
||||
*/
|
||||
protected $passwords_manager;
|
||||
/** @var config phpBB config */
|
||||
protected $config;
|
||||
|
||||
/** @var driver_interface DBAL driver interface */
|
||||
protected $db;
|
||||
|
||||
/** @var language phpBB language class */
|
||||
protected $language;
|
||||
|
||||
/** @var user phpBB user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* LDAP Authentication Constructor
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db Database object
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\passwords\manager $passwords_manager Passwords manager object
|
||||
* @param \phpbb\user $user User object
|
||||
* @param config $config Config object
|
||||
* @param driver_interface $db DBAL driver interface
|
||||
* @param language $language Language object
|
||||
* @param user $user User object
|
||||
*/
|
||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\user $user)
|
||||
public function __construct(config $config, driver_interface $db, language $language, user $user)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->passwords_manager = $passwords_manager;
|
||||
$this->db = $db;
|
||||
$this->language = $language;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
@@ -49,7 +60,7 @@ class ldap extends \phpbb\auth\provider\base
|
||||
{
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return $this->user->lang['LDAP_NO_LDAP_EXTENSION'];
|
||||
return $this->language->lang('LDAP_NO_LDAP_EXTENSION');
|
||||
}
|
||||
|
||||
$this->config['ldap_port'] = (int) $this->config['ldap_port'];
|
||||
@@ -64,7 +75,7 @@ class ldap extends \phpbb\auth\provider\base
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return $this->user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
return $this->language->lang('LDAP_NO_SERVER_CONNECTION');
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@@ -74,7 +85,7 @@ class ldap extends \phpbb\auth\provider\base
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password'])))
|
||||
{
|
||||
return $this->user->lang['LDAP_INCORRECT_USER_PASSWORD'];
|
||||
return $this->language->lang('LDAP_INCORRECT_USER_PASSWORD');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +103,7 @@ class ldap extends \phpbb\auth\provider\base
|
||||
|
||||
if ($search === false)
|
||||
{
|
||||
return $this->user->lang['LDAP_SEARCH_FAILED'];
|
||||
return $this->language->lang('LDAP_SEARCH_FAILED');
|
||||
}
|
||||
|
||||
$result = @ldap_get_entries($ldap, $search);
|
||||
@@ -101,12 +112,12 @@ class ldap extends \phpbb\auth\provider\base
|
||||
|
||||
if (!is_array($result) || count($result) < 2)
|
||||
{
|
||||
return sprintf($this->user->lang['LDAP_NO_IDENTITY'], $this->user->data['username']);
|
||||
return $this->language->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 $this->language->lang('LDAP_NO_EMAIL');
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -245,7 +256,7 @@ class ldap extends \phpbb\auth\provider\base
|
||||
// generate user account data
|
||||
$ldap_user_row = array(
|
||||
'username' => $username,
|
||||
'user_password' => $this->passwords_manager->hash($password),
|
||||
'user_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,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,49 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* Base OAuth abstract class that all OAuth services should implement
|
||||
*/
|
||||
abstract class base implements \phpbb\auth\provider\oauth\service\service_interface
|
||||
* Base OAuth abstract class that all OAuth services should implement
|
||||
*/
|
||||
abstract class base implements service_interface
|
||||
{
|
||||
/**
|
||||
* External OAuth service provider
|
||||
*
|
||||
* @var \OAuth\Common\Service\ServiceInterface
|
||||
*/
|
||||
* External OAuth service provider
|
||||
*
|
||||
* @var \OAuth\Common\Service\ServiceInterface
|
||||
*/
|
||||
protected $service_provider;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_auth_scope()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_external_service_class()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_external_service_provider()
|
||||
{
|
||||
return $this->service_provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_auth_scope()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider)
|
||||
{
|
||||
$this->service_provider = $service_provider;
|
||||
|
||||
@@ -1,94 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* Bitly OAuth service
|
||||
*/
|
||||
class bitly extends \phpbb\auth\provider\oauth\service\base
|
||||
* Bitly OAuth service
|
||||
*/
|
||||
class bitly extends base
|
||||
{
|
||||
/**
|
||||
* phpBB config
|
||||
*
|
||||
* @var \phpbb\config\config
|
||||
*/
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* phpBB request
|
||||
*
|
||||
* @var \phpbb\request\request_interface
|
||||
*/
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\request\request_interface $request
|
||||
*/
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\request\request_interface $request Request object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_service_credentials()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'key' => $this->config['auth_oauth_bitly_key'],
|
||||
'secret' => $this->config['auth_oauth_bitly_secret'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_auth_login()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly))
|
||||
{
|
||||
throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// This was a callback request from bitly, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
try
|
||||
{
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
}
|
||||
catch (\OAuth\Common\Http\Exception\TokenResponseException $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('user/info'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('user/info'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier returned from bitly
|
||||
return $result['data']['login'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly))
|
||||
{
|
||||
throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('user/info'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('user/info'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier returned from bitly
|
||||
// Return the unique identifier
|
||||
return $result['data']['login'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* Facebook OAuth service
|
||||
*/
|
||||
* Facebook OAuth service
|
||||
*/
|
||||
class facebook extends base
|
||||
{
|
||||
/**
|
||||
* phpBB config
|
||||
*
|
||||
* @var \phpbb\config\config
|
||||
*/
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* phpBB request
|
||||
*
|
||||
* @var \phpbb\request\request_interface
|
||||
*/
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\request\request_interface $request
|
||||
*/
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\request\request_interface $request Request object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_service_credentials()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'key' => $this->config['auth_oauth_facebook_key'],
|
||||
'secret' => $this->config['auth_oauth_facebook_secret'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_auth_login()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook))
|
||||
@@ -65,19 +57,33 @@ class facebook extends base
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
try
|
||||
{
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
}
|
||||
catch (\OAuth\Common\Http\Exception\TokenResponseException $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('/me'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('/me'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook))
|
||||
@@ -85,8 +91,15 @@ class facebook extends base
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('/me'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('/me'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
|
||||
@@ -1,74 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* Google OAuth service
|
||||
*/
|
||||
* Google OAuth service
|
||||
*/
|
||||
class google extends base
|
||||
{
|
||||
/**
|
||||
* phpBB config
|
||||
*
|
||||
* @var \phpbb\config\config
|
||||
*/
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* phpBB request
|
||||
*
|
||||
* @var \phpbb\request\request_interface
|
||||
*/
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\request\request_interface $request
|
||||
*/
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\request\request_interface $request Request object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_auth_scope()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'userinfo_email',
|
||||
'userinfo_profile',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_service_credentials()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'key' => $this->config['auth_oauth_google_key'],
|
||||
'secret' => $this->config['auth_oauth_google_secret'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_auth_login()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google))
|
||||
@@ -76,19 +68,33 @@ class google extends base
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
try
|
||||
{
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken($this->request->variable('code', ''));
|
||||
}
|
||||
catch (\OAuth\Common\Http\Exception\TokenResponseException $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google))
|
||||
@@ -96,8 +102,15 @@ class google extends base
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
|
||||
try
|
||||
{
|
||||
// Send a request with it
|
||||
$result = (array) json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
|
||||
}
|
||||
catch (\OAuth\Common\Exception\Exception $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
|
||||
@@ -1,73 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* OAuth service interface
|
||||
*/
|
||||
* OAuth service interface
|
||||
*/
|
||||
interface service_interface
|
||||
{
|
||||
/**
|
||||
* Returns an array of the scopes necessary for auth
|
||||
*
|
||||
* @return array An array of the required scopes
|
||||
*/
|
||||
* Returns an array of the scopes necessary for auth
|
||||
*
|
||||
* @return array An array of the required scopes
|
||||
*/
|
||||
public function get_auth_scope();
|
||||
|
||||
/**
|
||||
* Returns the external library service provider once it has been set
|
||||
*
|
||||
* @param \OAuth\Common\Service\ServiceInterface|null
|
||||
*/
|
||||
public function get_external_service_provider();
|
||||
|
||||
/**
|
||||
* Returns an array containing the service credentials belonging to requested
|
||||
* service.
|
||||
*
|
||||
* @return array An array containing the 'key' and the 'secret' of the
|
||||
* service in the form:
|
||||
* array(
|
||||
* 'key' => string
|
||||
* 'secret' => string
|
||||
* )
|
||||
*/
|
||||
* Returns an array containing the service credentials belonging to requested
|
||||
* service.
|
||||
*
|
||||
* @return array An array containing the 'key' and the 'secret' of the
|
||||
* service in the form:
|
||||
* array(
|
||||
* 'key' => string
|
||||
* 'secret' => string
|
||||
* )
|
||||
*/
|
||||
public function get_service_credentials();
|
||||
|
||||
/**
|
||||
* Returns the results of the authentication in json format
|
||||
*
|
||||
* @throws \phpbb\auth\provider\oauth\service\exception
|
||||
* @return string The unique identifier returned by the service provider
|
||||
* that is used to authenticate the user with phpBB.
|
||||
*/
|
||||
* Returns the results of the authentication in json format
|
||||
*
|
||||
* @throws \phpbb\auth\provider\oauth\service\exception
|
||||
* @return string The unique identifier returned by the service provider
|
||||
* that is used to authenticate the user with phpBB.
|
||||
*/
|
||||
public function perform_auth_login();
|
||||
|
||||
/**
|
||||
* Returns the results of the authentication in json format
|
||||
* Use this function when the user already has an access token
|
||||
*
|
||||
* @throws \phpbb\auth\provider\oauth\service\exception
|
||||
* @return string The unique identifier returned by the service provider
|
||||
* that is used to authenticate the user with phpBB.
|
||||
*/
|
||||
* Returns the results of the authentication in json format
|
||||
* Use this function when the user already has an access token
|
||||
*
|
||||
* @throws \phpbb\auth\provider\oauth\service\exception
|
||||
* @return string The unique identifier returned by the service provider
|
||||
* that is used to authenticate the user with phpBB.
|
||||
*/
|
||||
public function perform_token_auth();
|
||||
|
||||
/**
|
||||
* Sets the external library service provider
|
||||
*
|
||||
* @param \OAuth\Common\Service\ServiceInterface $service_provider
|
||||
*/
|
||||
* Returns the class of external library service provider that has to be used.
|
||||
*
|
||||
* @return string If the string is a class, it will register the provided string as a class,
|
||||
* which later will be generated as the OAuth external service provider.
|
||||
* If the string is not a class, it will use this string,
|
||||
* trying to generate a service for the version 2 and 1 respectively:
|
||||
* \OAuth\OAuth2\Service\<string>
|
||||
* If the string is empty, it will default to OAuth's standard service classes,
|
||||
* trying to generate a service for the version 2 and 1 respectively:
|
||||
* \OAuth\OAuth2\Service\Facebook
|
||||
*/
|
||||
public function get_external_service_class();
|
||||
|
||||
/**
|
||||
* Returns the external library service provider once it has been set
|
||||
*/
|
||||
public function get_external_service_provider();
|
||||
|
||||
/**
|
||||
* Sets the external library service provider
|
||||
*
|
||||
* @param \OAuth\Common\Service\ServiceInterface $service_provider
|
||||
*/
|
||||
public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider);
|
||||
}
|
||||
|
||||
@@ -1,102 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth\service;
|
||||
|
||||
/**
|
||||
* Twitter OAuth service
|
||||
*/
|
||||
class twitter extends \phpbb\auth\provider\oauth\service\base
|
||||
* Twitter OAuth service
|
||||
*/
|
||||
class twitter extends base
|
||||
{
|
||||
/**
|
||||
* phpBB config
|
||||
*
|
||||
* @var \phpbb\config\config
|
||||
*/
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* phpBB request
|
||||
*
|
||||
* @var \phpbb\request\request_interface
|
||||
*/
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\request\request_interface $request
|
||||
*/
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\config\config $config Config object
|
||||
* @param \phpbb\request\request_interface $request Request object
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_service_credentials()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'key' => $this->config['auth_oauth_twitter_key'],
|
||||
'secret' => $this->config['auth_oauth_twitter_secret'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_auth_login()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter))
|
||||
{
|
||||
throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
$storage = $this->service_provider->getStorage();
|
||||
$token = $storage->retrieveAccessToken('Twitter');
|
||||
$tokensecret = $token->getRequestTokenSecret();
|
||||
|
||||
// This was a callback request from twitter, get the token
|
||||
$this->service_provider->requestAccessToken(
|
||||
$this->request->variable('oauth_token', ''),
|
||||
$this->request->variable('oauth_verifier', ''),
|
||||
$tokensecret
|
||||
);
|
||||
try
|
||||
{
|
||||
/** @var \OAuth\OAuth1\Token\TokenInterface $token */
|
||||
$token = $storage->retrieveAccessToken('Twitter');
|
||||
}
|
||||
catch (\OAuth\Common\Storage\Exception\TokenNotFoundException $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
$secret = $token->getRequestTokenSecret();
|
||||
|
||||
try
|
||||
{
|
||||
// This was a callback request, get the token
|
||||
$this->service_provider->requestAccessToken(
|
||||
$this->request->variable('oauth_token', ''),
|
||||
$this->request->variable('oauth_verifier', ''),
|
||||
$secret
|
||||
);
|
||||
}
|
||||
catch (\OAuth\Common\Http\Exception\TokenResponseException $e)
|
||||
{
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('account/verify_credentials.json'), true);
|
||||
$result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true);
|
||||
|
||||
// Return the unique identifier returned from twitter
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter))
|
||||
{
|
||||
throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode($this->service_provider->request('account/verify_credentials.json'), true);
|
||||
$result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true);
|
||||
|
||||
// Return the unique identifier returned from twitter
|
||||
// Return the unique identifier
|
||||
return $result['id'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\auth\provider\oauth;
|
||||
|
||||
@@ -20,67 +20,48 @@ use OAuth\Common\Storage\Exception\TokenNotFoundException;
|
||||
use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException;
|
||||
|
||||
/**
|
||||
* OAuth storage wrapper for phpbb's cache
|
||||
*/
|
||||
* OAuth storage wrapper for phpBB's cache
|
||||
*/
|
||||
class token_storage implements TokenStorageInterface
|
||||
{
|
||||
/**
|
||||
* Cache driver.
|
||||
*
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* phpBB user
|
||||
*
|
||||
* @var \phpbb\user
|
||||
*/
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* OAuth token table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string OAuth table: token storage */
|
||||
protected $oauth_token_table;
|
||||
|
||||
/**
|
||||
* OAuth state table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string OAuth table: state */
|
||||
protected $oauth_state_table;
|
||||
|
||||
/**
|
||||
* @var object|TokenInterface
|
||||
*/
|
||||
/** @var TokenInterface OAuth token */
|
||||
protected $cachedToken;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string OAuth state */
|
||||
protected $cachedState;
|
||||
|
||||
/**
|
||||
* Creates token storage for phpBB.
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\user $user
|
||||
* @param string $oauth_token_table
|
||||
* @param string $oauth_state_table
|
||||
*/
|
||||
* Constructor.
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db Database object
|
||||
* @param \phpbb\user $user User object
|
||||
* @param string $oauth_token_table OAuth table: token storage
|
||||
* @param string $oauth_state_table OAuth table: state
|
||||
*/
|
||||
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $oauth_token_table, $oauth_state_table)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->user = $user;
|
||||
|
||||
$this->oauth_token_table = $oauth_token_table;
|
||||
$this->oauth_state_table = $oauth_state_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function retrieveAccessToken($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -90,10 +71,10 @@ class token_storage implements TokenStorageInterface
|
||||
return $this->cachedToken;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
{
|
||||
@@ -104,33 +85,38 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function storeAccessToken($service, TokenInterface $token)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
|
||||
$this->cachedToken = $token;
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'oauth_token' => $this->json_encode_token($token),
|
||||
);
|
||||
];
|
||||
|
||||
$sql = 'UPDATE ' . $this->oauth_token_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
|
||||
WHERE user_id = ' . (int) $this->user->data['user_id'] . '
|
||||
' . ((int) $this->user->data['user_id'] === ANONYMOUS ? "AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'" : '') . "
|
||||
AND provider = '" . $this->db->sql_escape($service) . "'";
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
|
||||
WHERE user_id = ' . (int) $this->user->data['user_id'] . "
|
||||
AND provider = '" . $this->db->sql_escape($service) . "'";
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
{
|
||||
$sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'";
|
||||
}
|
||||
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if (!$this->db->sql_affectedrows())
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
'oauth_token' => $this->json_encode_token($token),
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
);
|
||||
];
|
||||
|
||||
$sql = 'INSERT INTO ' . $this->oauth_token_table . $this->db->sql_build_array('INSERT', $data);
|
||||
|
||||
@@ -141,8 +127,8 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasAccessToken($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -152,22 +138,22 @@ class token_storage implements TokenStorageInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
{
|
||||
$data['session_id'] = $this->user->data['session_id'];
|
||||
}
|
||||
|
||||
return $this->_has_acess_token($data);
|
||||
return $this->has_access_token($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clearToken($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -189,13 +175,13 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clearAllTokens()
|
||||
{
|
||||
$this->cachedToken = null;
|
||||
|
||||
$sql = 'DELETE FROM ' . $this->oauth_token_table . '
|
||||
$sql = 'DELETE FROM ' . $this->oauth_token_table . '
|
||||
WHERE user_id = ' . (int) $this->user->data['user_id'];
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
@@ -209,31 +195,30 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function storeAuthorizationState($service, $state)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
|
||||
$this->cachedState = $state;
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
'oauth_state' => $state,
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
);
|
||||
];
|
||||
|
||||
$sql = 'INSERT INTO ' . $this->oauth_state_table . '
|
||||
' . $this->db->sql_build_array('INSERT', $data);
|
||||
$sql = 'INSERT INTO ' . $this->oauth_state_table . ' ' . $this->db->sql_build_array('INSERT', $data);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasAuthorizationState($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -243,10 +228,10 @@ class token_storage implements TokenStorageInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
{
|
||||
@@ -257,8 +242,8 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function retrieveAuthorizationState($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -268,10 +253,10 @@ class token_storage implements TokenStorageInterface
|
||||
return $this->cachedState;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'user_id' => (int) $this->user->data['user_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
if ((int) $this->user->data['user_id'] === ANONYMOUS)
|
||||
{
|
||||
@@ -282,8 +267,8 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clearAuthorizationState($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -305,8 +290,8 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clearAllAuthorizationStates()
|
||||
{
|
||||
$this->cachedState = null;
|
||||
@@ -325,10 +310,11 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the user_id field in the database assosciated with the token
|
||||
*
|
||||
* @param int $user_id
|
||||
*/
|
||||
* Updates the user_id field in the database associated with the token.
|
||||
*
|
||||
* @param int $user_id The user identifier
|
||||
* @return void
|
||||
*/
|
||||
public function set_user_id($user_id)
|
||||
{
|
||||
if (!$this->cachedToken)
|
||||
@@ -336,21 +322,24 @@ class token_storage implements TokenStorageInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => (int) $user_id,
|
||||
];
|
||||
|
||||
$sql = 'UPDATE ' . $this->oauth_token_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', array(
|
||||
'user_id' => (int) $user_id
|
||||
)) . '
|
||||
WHERE user_id = ' . (int) $this->user->data['user_id'] . "
|
||||
AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'";
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
|
||||
WHERE user_id = ' . (int) $this->user->data['user_id'] . "
|
||||
AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an access token exists solely by the session_id of the user
|
||||
*
|
||||
* @param string $service The name of the OAuth service
|
||||
* @return bool true if they have token, false if they don't
|
||||
*/
|
||||
* Checks to see if an access token exists solely by the session_id of the user.
|
||||
*
|
||||
* @param string $service The OAuth service name
|
||||
* @return bool true if the user's access token exists,
|
||||
* false if the user's access token does not exist
|
||||
*/
|
||||
public function has_access_token_by_session($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -360,20 +349,21 @@ class token_storage implements TokenStorageInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
return $this->_has_acess_token($data);
|
||||
return $this->has_access_token($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a state exists solely by the session_id of the user
|
||||
*
|
||||
* @param string $service The name of the OAuth service
|
||||
* @return bool true if they have state, false if they don't
|
||||
*/
|
||||
* Checks to see if a state exists solely by the session_id of the user.
|
||||
*
|
||||
* @param string $service The OAuth service name
|
||||
* @return bool true if the user's state exists,
|
||||
* false if the user's state does not exist
|
||||
*/
|
||||
public function has_state_by_session($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -383,25 +373,34 @@ class token_storage implements TokenStorageInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
];
|
||||
|
||||
return (bool) $this->get_state_row($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for has access token functions
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
protected function _has_acess_token($data)
|
||||
* A helper function that performs the query for has access token functions.
|
||||
*
|
||||
* @param array $data The SQL WHERE data
|
||||
* @return bool true if the user's access token exists,
|
||||
* false if the user's access token does not exist
|
||||
*/
|
||||
protected function has_access_token($data)
|
||||
{
|
||||
return (bool) $this->get_access_token_row($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieving access token functions by session.
|
||||
* Also checks if the token is a valid token.
|
||||
*
|
||||
* @param string $service The OAuth service provider name
|
||||
* @return TokenInterface
|
||||
* @throws TokenNotFoundException
|
||||
*/
|
||||
public function retrieve_access_token_by_session($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -411,14 +410,21 @@ class token_storage implements TokenStorageInterface
|
||||
return $this->cachedToken;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
'provider' => $service,
|
||||
];
|
||||
|
||||
return $this->_retrieve_access_token($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieving state functions by session.
|
||||
*
|
||||
* @param string $service The OAuth service provider name
|
||||
* @return string The OAuth state
|
||||
* @throws AuthorizationStateNotFoundException
|
||||
*/
|
||||
public function retrieve_state_by_session($service)
|
||||
{
|
||||
$service = $this->get_service_name_for_db($service);
|
||||
@@ -428,22 +434,22 @@ class token_storage implements TokenStorageInterface
|
||||
return $this->cachedState;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'session_id' => $this->user->data['session_id'],
|
||||
'provider' => $service,
|
||||
);
|
||||
'provider' => $service,
|
||||
];
|
||||
|
||||
return $this->_retrieve_state($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieve access token functions
|
||||
* Also checks if the token is a valid token
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @throws \OAuth\Common\Storage\Exception\TokenNotFoundException
|
||||
*/
|
||||
* A helper function that performs the query for retrieve access token functions.
|
||||
* Also checks if the token is a valid token.
|
||||
*
|
||||
* @param array $data The SQL WHERE data
|
||||
* @return TokenInterface
|
||||
* @throws TokenNotFoundException
|
||||
*/
|
||||
protected function _retrieve_access_token($data)
|
||||
{
|
||||
$row = $this->get_access_token_row($data);
|
||||
@@ -459,19 +465,21 @@ class token_storage implements TokenStorageInterface
|
||||
if (!($token instanceof TokenInterface))
|
||||
{
|
||||
$this->clearToken($data['provider']);
|
||||
|
||||
throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED');
|
||||
}
|
||||
|
||||
$this->cachedToken = $token;
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieve state functions
|
||||
* A helper function that performs the query for retrieve state functions.
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @throws \OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException
|
||||
* @param array $data The SQL WHERE data
|
||||
* @return string The OAuth state
|
||||
* @throws AuthorizationStateNotFoundException
|
||||
*/
|
||||
protected function _retrieve_state($data)
|
||||
{
|
||||
@@ -483,18 +491,21 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
$this->cachedState = $row['oauth_state'];
|
||||
|
||||
return $this->cachedState;
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieving an access token
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
* A helper function that performs the query for retrieving an access token.
|
||||
*
|
||||
* @param array $data The SQL WHERE data
|
||||
* @return array|false array with the OAuth token row,
|
||||
* false if the token does not exist
|
||||
*/
|
||||
protected function get_access_token_row($data)
|
||||
{
|
||||
$sql = 'SELECT oauth_token FROM ' . $this->oauth_token_table . '
|
||||
$sql = 'SELECT oauth_token
|
||||
FROM ' . $this->oauth_token_table . '
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', $data);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
@@ -504,14 +515,16 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that performs the query for retrieving a state
|
||||
* A helper function that performs the query for retrieving a state.
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @param array $data The SQL WHERE data
|
||||
* @return array|false array with the OAuth state row,
|
||||
* false if the state does not exist
|
||||
*/
|
||||
protected function get_state_row($data)
|
||||
{
|
||||
$sql = 'SELECT oauth_state FROM ' . $this->oauth_state_table . '
|
||||
$sql = 'SELECT oauth_state
|
||||
FROM ' . $this->oauth_state_table . '
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', $data);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
@@ -520,16 +533,22 @@ class token_storage implements TokenStorageInterface
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that JSON encodes a TokenInterface's data.
|
||||
*
|
||||
* @param TokenInterface $token
|
||||
* @return string The json encoded TokenInterface's data
|
||||
*/
|
||||
public function json_encode_token(TokenInterface $token)
|
||||
{
|
||||
$members = array(
|
||||
$members = [
|
||||
'accessToken' => $token->getAccessToken(),
|
||||
'endOfLife' => $token->getEndOfLife(),
|
||||
'extraParams' => $token->getExtraParams(),
|
||||
'refreshToken' => $token->getRefreshToken(),
|
||||
|
||||
'token_class' => get_class($token),
|
||||
);
|
||||
];
|
||||
|
||||
// Handle additional data needed for OAuth1 tokens
|
||||
if ($token instanceof StdOAuth1Token)
|
||||
@@ -542,6 +561,13 @@ class token_storage implements TokenStorageInterface
|
||||
return json_encode($members);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function that JSON decodes a data string and creates a TokenInterface.
|
||||
*
|
||||
* @param string $json The json encoded TokenInterface's data
|
||||
* @return TokenInterface
|
||||
* @throws TokenNotFoundException
|
||||
*/
|
||||
public function json_decode_token($json)
|
||||
{
|
||||
$token_data = json_decode($json, true);
|
||||
@@ -557,7 +583,10 @@ class token_storage implements TokenStorageInterface
|
||||
$endOfLife = $token_data['endOfLife'];
|
||||
$extra_params = $token_data['extraParams'];
|
||||
|
||||
// Create the token
|
||||
/**
|
||||
* Create the token
|
||||
* @var TokenInterface $token
|
||||
*/
|
||||
$token = new $token_class($access_token, $refresh_token, TokenInterface::EOL_NEVER_EXPIRES, $extra_params);
|
||||
$token->setEndOfLife($endOfLife);
|
||||
|
||||
@@ -573,20 +602,19 @@ class token_storage implements TokenStorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the service as it must be stored in the database.
|
||||
*
|
||||
* @param string $service The name of the OAuth service
|
||||
* @return string The name of the OAuth service as it needs to be stored
|
||||
* in the database.
|
||||
*/
|
||||
protected function get_service_name_for_db($service)
|
||||
* Returns the service name as it must be stored in the database.
|
||||
*
|
||||
* @param string $provider The OAuth provider name
|
||||
* @return string The OAuth service name
|
||||
*/
|
||||
protected function get_service_name_for_db($provider)
|
||||
{
|
||||
// Enforce the naming convention for oauth services
|
||||
if (strpos($service, 'auth.provider.oauth.service.') !== 0)
|
||||
if (strpos($provider, 'auth.provider.oauth.service.') !== 0)
|
||||
{
|
||||
$service = 'auth.provider.oauth.service.' . strtolower($service);
|
||||
$provider = 'auth.provider.oauth.service.' . strtolower($provider);
|
||||
}
|
||||
|
||||
return $service;
|
||||
return $provider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ interface provider_interface
|
||||
* Autologin function
|
||||
*
|
||||
* @return array|null containing the user row, empty if no auto login
|
||||
* should take place, or null if not impletmented.
|
||||
* should take place, or null if not implemented.
|
||||
*/
|
||||
public function autologin();
|
||||
|
||||
@@ -68,12 +68,13 @@ interface provider_interface
|
||||
|
||||
/**
|
||||
* This function updates the template with variables related to the acp
|
||||
* options with whatever configuraton values are passed to it as an array.
|
||||
* options with whatever configuration values are passed to it as an array.
|
||||
* It then returns the name of the acp file related to this authentication
|
||||
* provider.
|
||||
* @param array $new_config Contains the new configuration values that
|
||||
* have been set in acp_board.
|
||||
* @return array|null Returns null if not implemented or an array with
|
||||
*
|
||||
* @param \phpbb\config\config $new_config Contains the new configuration values
|
||||
* that have been set in acp_board.
|
||||
* @return array|null Returns null if not implemented or an array with
|
||||
* the template file name and an array of the vars
|
||||
* that the template needs that must conform to the
|
||||
* following example:
|
||||
|
||||
@@ -49,6 +49,8 @@ class remote extends \phpbb\avatar\driver\driver
|
||||
*/
|
||||
public function process_form($request, $template, $user, $row, &$error)
|
||||
{
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
$url = $request->variable('avatar_remote_url', '');
|
||||
$width = $request->variable('avatar_remote_width', 0);
|
||||
$height = $request->variable('avatar_remote_height', 0);
|
||||
@@ -84,6 +86,24 @@ class remote extends \phpbb\avatar\driver\driver
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to make custom validation of avatar upload
|
||||
*
|
||||
* @event core.ucp_profile_avatar_upload_validation
|
||||
* @var string url Image url
|
||||
* @var string width Image width
|
||||
* @var string height Image height
|
||||
* @var array error Error message array
|
||||
* @since 3.2.9-RC1
|
||||
*/
|
||||
$vars = array('url', 'width', 'height', 'error');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_upload_validation', compact($vars)));
|
||||
|
||||
if (!empty($error))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if this url looks alright
|
||||
// Do not allow specifying the port (see RFC 3986) or IP addresses
|
||||
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) ||
|
||||
|
||||
@@ -84,6 +84,7 @@ class upload extends \phpbb\avatar\driver\driver
|
||||
$template->assign_vars(array(
|
||||
'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false,
|
||||
'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'],
|
||||
'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)),
|
||||
));
|
||||
|
||||
return true;
|
||||
|
||||
22
phpbb/cache/driver/memcached.php
vendored
22
phpbb/cache/driver/memcached.php
vendored
@@ -50,12 +50,16 @@ class memcached extends \phpbb\cache\driver\memory
|
||||
|
||||
/**
|
||||
* Memcached constructor
|
||||
*
|
||||
* @param string $memcached_servers Memcached servers string (optional)
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($memcached_servers = '')
|
||||
{
|
||||
// Call the parent constructor
|
||||
parent::__construct();
|
||||
|
||||
$memcached_servers = $memcached_servers ?: PHPBB_ACM_MEMCACHED;
|
||||
|
||||
$this->memcached = new \Memcached();
|
||||
$this->memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
|
||||
// Memcached defaults to using compression, disable if we don't want
|
||||
@@ -65,10 +69,20 @@ class memcached extends \phpbb\cache\driver\memory
|
||||
$this->memcached->setOption(\Memcached::OPT_COMPRESSION, false);
|
||||
}
|
||||
|
||||
foreach (explode(',', PHPBB_ACM_MEMCACHED) as $u)
|
||||
$server_list = [];
|
||||
foreach (explode(',', $memcached_servers) as $u)
|
||||
{
|
||||
preg_match('#(.*)/(\d+)#', $u, $parts);
|
||||
$this->memcached->addServer(trim($parts[1]), (int) trim($parts[2]));
|
||||
if (preg_match('#(.*)/(\d+)#', $u, $parts))
|
||||
{
|
||||
$server_list[] = [trim($parts[1]), (int) trim($parts[2])];
|
||||
}
|
||||
}
|
||||
|
||||
$this->memcached->addServers($server_list);
|
||||
|
||||
if (empty($server_list) || empty($this->memcached->getStats()))
|
||||
{
|
||||
trigger_error('Could not connect to memcached server(s).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
phpbb/cache/driver/memory.php
vendored
2
phpbb/cache/driver/memory.php
vendored
@@ -25,7 +25,7 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $phpbb_root_path, $dbname, $table_prefix, $phpbb_container;
|
||||
global $dbname, $table_prefix, $phpbb_container;
|
||||
|
||||
$this->cache_dir = $phpbb_container->getParameter('core.cache_dir');
|
||||
$this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_';
|
||||
|
||||
@@ -78,7 +78,7 @@ class non_gd
|
||||
|
||||
for ($j = 0; $j < $code_len; $j++)
|
||||
{
|
||||
$image .= $this->randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]);
|
||||
$image .= $this->randomise(substr($hold_chars[$code[$j]][$i - $offset_y - 1], 1), $char_widths[$j]);
|
||||
}
|
||||
|
||||
for ($j = $offset_x + $img_width; $j < $this->width; $j++)
|
||||
@@ -117,7 +117,7 @@ class non_gd
|
||||
$end = strlen($scanline) - ceil($width/2);
|
||||
for ($i = (int) floor($width / 2); $i < $end; $i++)
|
||||
{
|
||||
$pixel = ord($scanline{$i});
|
||||
$pixel = ord($scanline[$i]);
|
||||
|
||||
if ($pixel < 190)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ class non_gd
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_line .= $scanline{$i};
|
||||
$new_line .= $scanline[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class qa
|
||||
{
|
||||
var $confirm_id;
|
||||
var $answer;
|
||||
var $question_ids;
|
||||
var $question_ids = [];
|
||||
var $question_text;
|
||||
var $question_lang;
|
||||
var $question_strict;
|
||||
|
||||
@@ -64,7 +64,7 @@ class class_loader
|
||||
|
||||
/**
|
||||
* Provide the class loader with a cache to store paths. If set to null, the
|
||||
* the class loader will resolve paths by checking for the existance of every
|
||||
* the class loader will resolve paths by checking for the existence of every
|
||||
* directory in the class name every time.
|
||||
*
|
||||
* @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface.
|
||||
|
||||
@@ -147,6 +147,25 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks configuration option's value only if the new_value matches the
|
||||
* current configuration value and the configuration value does exist.Called
|
||||
* only after set_atomic has been called.
|
||||
*
|
||||
* @param string $key The configuration option's name
|
||||
* @param string $new_value New configuration value
|
||||
* @throws \phpbb\exception\http_exception when config value is set and not equal to new_value.
|
||||
* @return bool True if the value was changed, false otherwise.
|
||||
*/
|
||||
public function ensure_lock($key, $new_value)
|
||||
{
|
||||
if (isset($this->config[$key]) && $this->config[$key] == $new_value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments an integer configuration value.
|
||||
*
|
||||
|
||||
@@ -155,6 +155,12 @@ class config_php_file
|
||||
return $dbms;
|
||||
}
|
||||
|
||||
// Force use of mysqli when specifying mysql
|
||||
if (preg_match('/(phpbb\\\db\\\driver\\\)?mysql$/i', $dbms))
|
||||
{
|
||||
return 'phpbb\db\driver\mysqli';
|
||||
}
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class run extends \phpbb\console\command\command
|
||||
* @param InputInterface $input The input stream used to get the argument and verboe option.
|
||||
* @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
|
||||
*
|
||||
* @return int 0 if all is ok, 1 if a lock error occured and 2 if no task matching the argument was found.
|
||||
* @return int 0 if all is ok, 1 if a lock error occurred and 2 if no task matching the argument was found.
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
@@ -145,9 +145,11 @@ class run extends \phpbb\console\command\command
|
||||
* and returns with status 2.
|
||||
*
|
||||
* @see execute
|
||||
* @param string $task_name The name of the task that should be run.
|
||||
*
|
||||
* @param InputInterface $input The input stream used to get the argument and verbose option.
|
||||
* @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
|
||||
* @param string $task_name The name of the task that should be run.
|
||||
*
|
||||
* @return int 0 if all is well, 2 if no task matches $task_name.
|
||||
*/
|
||||
protected function run_one(InputInterface $input, OutputInterface $output, $task_name)
|
||||
|
||||
@@ -46,9 +46,11 @@ class enable extends command
|
||||
|
||||
$extension = $this->manager->get_extension($name);
|
||||
|
||||
if (!$extension->is_enableable())
|
||||
if (($enableable = $extension->is_enableable()) !== true)
|
||||
{
|
||||
$io->error($this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name));
|
||||
$message = !empty($enableable) ? $enableable : $this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name);
|
||||
$message = is_array($message) ? implode(PHP_EOL, $message) : $message;
|
||||
$io->error($message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class check extends \phpbb\console\command\command
|
||||
*
|
||||
* @param InputInterface $input Input stream, used to get the options.
|
||||
* @param OutputInterface $output Output stream, used to print messages.
|
||||
* @return int 0 if the board is up to date, 1 if it is not and 2 if an error occured.
|
||||
* @return int 0 if the board is up to date, 1 if it is not and 2 if an error occurred.
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
@@ -223,6 +223,7 @@ class check extends \phpbb\console\command\command
|
||||
* Check if all the available extensions are up to date
|
||||
*
|
||||
* @param SymfonyStyle $io IO handler, for formatted and unified IO
|
||||
* @param string $stability Stability specifier string
|
||||
* @param bool $recheck Disallow the use of the cache
|
||||
* @return int
|
||||
*/
|
||||
|
||||
@@ -239,7 +239,7 @@ class add extends command
|
||||
array('string', false, $this->config['min_name_chars'], $this->config['max_name_chars']),
|
||||
array('username', '')),
|
||||
'new_password' => array(
|
||||
array('string', false, $this->config['min_pass_chars'], $this->config['max_pass_chars']),
|
||||
array('string', false, $this->config['min_pass_chars'], 0),
|
||||
array('password')),
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
|
||||
@@ -144,7 +144,14 @@ class content_visibility
|
||||
*/
|
||||
public function is_visible($mode, $forum_id, $data)
|
||||
{
|
||||
$is_visible = $this->auth->acl_get('m_approve', $forum_id) || $data[$mode . '_visibility'] == ITEM_APPROVED;
|
||||
$visibility = $data[$mode . '_visibility'];
|
||||
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
|
||||
$is_visible = ($visibility == ITEM_APPROVED) ||
|
||||
($this->config['display_unapproved_posts'] &&
|
||||
($this->user->data['user_id'] != ANONYMOUS) &&
|
||||
($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) &&
|
||||
($this->user->data['user_id'] == $data[$poster_key])) ||
|
||||
$this->auth->acl_get('m_approve', $forum_id);
|
||||
|
||||
/**
|
||||
* Allow changing the result of calling is_visible
|
||||
@@ -216,9 +223,16 @@ class content_visibility
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql .= $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
|
||||
}
|
||||
$visibility_query = $table_alias . $mode . '_visibility = ';
|
||||
|
||||
$where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')';
|
||||
if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] != ANONYMOUS))
|
||||
{
|
||||
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
|
||||
$where_sql .= ' OR ((' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE .')';
|
||||
$where_sql .= ' AND ' . $table_alias . $poster_key . ' = ' . ((int) $this->user->data['user_id']) . ')';
|
||||
}
|
||||
}
|
||||
return '(' . $where_sql . ')';
|
||||
}
|
||||
|
||||
@@ -684,7 +698,7 @@ class content_visibility
|
||||
* @param $time int Timestamp when the action is performed
|
||||
* @param $reason string Reason why the visibilty was changed.
|
||||
* @param $force_update_all bool Force to update all posts within the topic
|
||||
* @return array Changed topic data, empty array if an error occured.
|
||||
* @return array Changed topic data, empty array if an error occurred.
|
||||
*/
|
||||
public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false)
|
||||
{
|
||||
|
||||
@@ -121,7 +121,7 @@ class helper
|
||||
* @param int $code The error code (e.g. 404, 500, 503, etc.)
|
||||
* @return Response A Response instance
|
||||
*
|
||||
* @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead.
|
||||
* @deprecated 3.1.3 (To be removed: 4.0.0) Use exceptions instead.
|
||||
*/
|
||||
public function error($message, $code = 500)
|
||||
{
|
||||
|
||||
40
phpbb/cron/controller/cron.php
Normal file
40
phpbb/cron/controller/cron.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\cron\controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Controller for running cron jobs
|
||||
*/
|
||||
class cron
|
||||
{
|
||||
/**
|
||||
* Handles CRON requests
|
||||
*
|
||||
* @param string $cron_type
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function handle($cron_type)
|
||||
{
|
||||
$response = new Response();
|
||||
$response->headers->set('Cache-Control', 'no-cache');
|
||||
$response->headers->set('Content-type', 'image/gif');
|
||||
$response->headers->set('Content-length', '43');
|
||||
$response->setContent(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='));
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
103
phpbb/cron/event/cron_runner_listener.php
Normal file
103
phpbb/cron/event/cron_runner_listener.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\cron\event;
|
||||
|
||||
use phpbb\cron\manager;
|
||||
use phpbb\lock\db;
|
||||
use phpbb\request\request_interface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
|
||||
/**
|
||||
* Event listener that executes cron tasks, after the response was served
|
||||
*/
|
||||
class cron_runner_listener implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\lock\db
|
||||
*/
|
||||
private $cron_lock;
|
||||
|
||||
/**
|
||||
* @var \phpbb\cron\manager
|
||||
*/
|
||||
private $cron_manager;
|
||||
|
||||
/**
|
||||
* @var \phpbb\request\request_interface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param db $lock
|
||||
* @param manager $manager
|
||||
* @param request_interface $request
|
||||
*/
|
||||
public function __construct(db $lock, manager $manager, request_interface $request)
|
||||
{
|
||||
$this->cron_lock = $lock;
|
||||
$this->cron_manager = $manager;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the cron job after the response was sent
|
||||
*
|
||||
* @param PostResponseEvent $event The event
|
||||
*/
|
||||
public function on_kernel_terminate(PostResponseEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$controller_name = $request->get('_route');
|
||||
|
||||
if ($controller_name !== 'phpbb_cron_run')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$cron_type = $request->get('cron_type');
|
||||
|
||||
if ($this->cron_lock->acquire())
|
||||
{
|
||||
$task = $this->cron_manager->find_task($cron_type);
|
||||
if ($task)
|
||||
{
|
||||
if ($task->is_parametrized())
|
||||
{
|
||||
$task->parse_parameters($this->request);
|
||||
}
|
||||
|
||||
if ($task->is_ready())
|
||||
{
|
||||
$task->run();
|
||||
}
|
||||
|
||||
$this->cron_lock->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::TERMINATE => 'on_kernel_terminate',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
namespace phpbb\cron;
|
||||
|
||||
use phpbb\cron\task\wrapper;
|
||||
use phpbb\routing\helper;
|
||||
|
||||
/**
|
||||
* Cron manager class.
|
||||
*
|
||||
@@ -20,6 +23,11 @@ namespace phpbb\cron;
|
||||
*/
|
||||
class manager
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $routing_helper;
|
||||
|
||||
/**
|
||||
* Set of \phpbb\cron\task\wrapper objects.
|
||||
* Array holding all tasks that have been found.
|
||||
@@ -28,18 +36,27 @@ class manager
|
||||
*/
|
||||
protected $tasks = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor. Loads all available tasks.
|
||||
*
|
||||
* @param array|\Traversable $tasks Provides an iterable set of task names
|
||||
* @param helper $routing_helper Routing helper
|
||||
* @param string $phpbb_root_path Relative path to phpBB root
|
||||
* @param string $php_ext PHP file extension
|
||||
*/
|
||||
public function __construct($tasks, $phpbb_root_path, $php_ext)
|
||||
public function __construct($tasks, helper $routing_helper, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->routing_helper = $routing_helper;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
@@ -142,6 +159,6 @@ class manager
|
||||
*/
|
||||
public function wrap_task(\phpbb\cron\task\task $task)
|
||||
{
|
||||
return new \phpbb\cron\task\wrapper($task, $this->phpbb_root_path, $this->php_ext);
|
||||
return new wrapper($task, $this->routing_helper, $this->phpbb_root_path, $this->php_ext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class update_hashes extends \phpbb\cron\task\base
|
||||
|
||||
foreach ($defaults as $type)
|
||||
{
|
||||
if ($hashing_algorithms[$type]->is_supported())
|
||||
if ($hashing_algorithms[$type]->is_supported() && !$hashing_algorithms[$type] instanceof \phpbb\passwords\driver\base_native)
|
||||
{
|
||||
$this->default_type = $type;
|
||||
break;
|
||||
|
||||
@@ -13,14 +13,32 @@
|
||||
|
||||
namespace phpbb\cron\task;
|
||||
|
||||
use phpbb\routing\helper;
|
||||
|
||||
/**
|
||||
* Cron task wrapper class.
|
||||
* Enhances cron tasks with convenience methods that work identically for all tasks.
|
||||
*/
|
||||
class wrapper
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $routing_helper;
|
||||
|
||||
/**
|
||||
* @var task
|
||||
*/
|
||||
protected $task;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
@@ -28,13 +46,15 @@ class wrapper
|
||||
*
|
||||
* Wraps a task $task, which must implement cron_task interface.
|
||||
*
|
||||
* @param \phpbb\cron\task\task $task The cron task to wrap.
|
||||
* @param string $phpbb_root_path Relative path to phpBB root
|
||||
* @param string $php_ext PHP file extension
|
||||
* @param task $task The cron task to wrap.
|
||||
* @param helper $routing_helper Routing helper for route generation
|
||||
* @param string $phpbb_root_path Relative path to phpBB root
|
||||
* @param string $php_ext PHP file extension
|
||||
*/
|
||||
public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext)
|
||||
public function __construct(task $task, helper $routing_helper, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->task = $task;
|
||||
$this->routing_helper = $routing_helper;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
@@ -49,7 +69,7 @@ class wrapper
|
||||
*/
|
||||
public function is_parametrized()
|
||||
{
|
||||
return $this->task instanceof \phpbb\cron\task\parametrized;
|
||||
return $this->task instanceof parametrized;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,22 +96,13 @@ class wrapper
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
$name = $this->get_name();
|
||||
$params['cron_type'] = $this->get_name();
|
||||
if ($this->is_parametrized())
|
||||
{
|
||||
$params = $this->task->get_parameters();
|
||||
$extra = '';
|
||||
foreach ($params as $key => $value)
|
||||
{
|
||||
$extra .= '&' . $key . '=' . urlencode($value);
|
||||
}
|
||||
$params = array_merge($params, $this->task->get_parameters());
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra = '';
|
||||
}
|
||||
$url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra);
|
||||
return $url;
|
||||
|
||||
return $this->routing_helper->route('phpbb_cron_run', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,16 @@ abstract class driver implements driver_interface
|
||||
const SUBQUERY_SELECT_TYPE = 4;
|
||||
const SUBQUERY_BUILD = 5;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $debug_load_time = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $debug_sql_explain = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -95,6 +105,22 @@ abstract class driver implements driver_interface
|
||||
$this->one_char = chr(0) . '_';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_load_time($value)
|
||||
{
|
||||
$this->debug_load_time = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_sql_explain($value)
|
||||
{
|
||||
$this->debug_sql_explain = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -955,7 +981,7 @@ abstract class driver implements driver_interface
|
||||
// Show complete SQL error and path to administrators only
|
||||
// Additionally show complete error on installation or if extended debug mode is enabled
|
||||
// The DEBUG constant is for development only!
|
||||
if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG'))
|
||||
if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || $this->debug_sql_explain)
|
||||
{
|
||||
$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';
|
||||
}
|
||||
|
||||
@@ -15,6 +15,20 @@ namespace phpbb\db\driver;
|
||||
|
||||
interface driver_interface
|
||||
{
|
||||
/**
|
||||
* Set value for load_time debug parameter
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function set_debug_load_time($value);
|
||||
|
||||
/**
|
||||
* Set value for sql_explain debug parameter
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function set_debug_sql_explain($value);
|
||||
|
||||
/**
|
||||
* Gets the name of the sql layer.
|
||||
*
|
||||
|
||||
@@ -65,6 +65,22 @@ class factory implements driver_interface
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_load_time($value)
|
||||
{
|
||||
$this->get_driver()->set_debug_load_time($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_sql_explain($value)
|
||||
{
|
||||
$this->get_driver()->set_debug_sql_explain($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -151,12 +151,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -172,11 +171,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
||||
$this->sql_error($query);
|
||||
}
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -196,7 +195,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
|
||||
@@ -123,12 +123,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -146,11 +145,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
||||
// reset options for next query
|
||||
$this->query_options = array();
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -170,7 +169,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
// Disable loading local files on client side
|
||||
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
|
||||
|
||||
@mysqli_query($this->db_connect_id, "SET NAMES 'utf8'");
|
||||
|
||||
// enforce strict mode on databases that support it
|
||||
@@ -173,12 +176,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -193,11 +195,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
$this->sql_error($query);
|
||||
}
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -212,7 +214,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
@@ -373,7 +375,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
{
|
||||
static $test_prof;
|
||||
|
||||
// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
|
||||
// current detection method, might just switch to see the existence of INFORMATION_SCHEMA.PROFILING
|
||||
if ($test_prof === null)
|
||||
{
|
||||
$test_prof = false;
|
||||
|
||||
@@ -246,12 +246,11 @@ class oracle extends \phpbb\db\driver\driver
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -428,11 +427,11 @@ class oracle extends \phpbb\db\driver\driver
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -452,7 +451,7 @@ class oracle extends \phpbb\db\driver\driver
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
|
||||
@@ -173,12 +173,11 @@ class postgres extends \phpbb\db\driver\driver
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -194,11 +193,11 @@ class postgres extends \phpbb\db\driver\driver
|
||||
$this->sql_error($query);
|
||||
}
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -218,7 +217,7 @@ class postgres extends \phpbb\db\driver\driver
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
|
||||
@@ -118,12 +118,11 @@ class sqlite3 extends \phpbb\db\driver\driver
|
||||
{
|
||||
global $cache;
|
||||
|
||||
// EXPLAIN only in extra debug mode
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('start', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->curtime = microtime(true);
|
||||
}
|
||||
@@ -156,11 +155,11 @@ class sqlite3 extends \phpbb\db\driver\driver
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('DEBUG'))
|
||||
if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
|
||||
else if ($this->debug_load_time)
|
||||
{
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
@@ -175,7 +174,7 @@ class sqlite3 extends \phpbb\db\driver\driver
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
else if ($this->debug_sql_explain)
|
||||
{
|
||||
$this->sql_report('fromcache', $query);
|
||||
}
|
||||
|
||||
@@ -79,14 +79,7 @@ class mysql_extractor extends base_extractor
|
||||
throw new extractor_not_initialized_exception();
|
||||
}
|
||||
|
||||
if ($this->db->get_sql_layer() === 'mysqli')
|
||||
{
|
||||
$this->write_data_mysqli($table_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->write_data_mysql($table_name);
|
||||
}
|
||||
$this->write_data_mysqli($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,101 +172,6 @@ class mysql_extractor extends base_extractor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts data from database table (for MySQL driver)
|
||||
*
|
||||
* @param string $table_name name of the database table
|
||||
* @return null
|
||||
* @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor()
|
||||
*/
|
||||
protected function write_data_mysql($table_name)
|
||||
{
|
||||
if (!$this->is_initialized)
|
||||
{
|
||||
throw new extractor_not_initialized_exception();
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM $table_name";
|
||||
$result = mysql_unbuffered_query($sql, $this->db->get_db_connect_id());
|
||||
|
||||
if ($result != false)
|
||||
{
|
||||
$fields_cnt = mysql_num_fields($result);
|
||||
|
||||
// Get field information
|
||||
$field = array();
|
||||
for ($i = 0; $i < $fields_cnt; $i++)
|
||||
{
|
||||
$field[] = mysql_fetch_field($result, $i);
|
||||
}
|
||||
$field_set = array();
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++)
|
||||
{
|
||||
$field_set[] = $field[$j]->name;
|
||||
}
|
||||
|
||||
$search = array("\\", "'", "\x00", "\x0a", "\x0d", "\x1a", '"');
|
||||
$replace = array("\\\\", "\\'", '\0', '\n', '\r', '\Z', '\\"');
|
||||
$fields = implode(', ', $field_set);
|
||||
$sql_data = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES ';
|
||||
$first_set = true;
|
||||
$query_len = 0;
|
||||
$max_len = get_usable_memory();
|
||||
|
||||
while ($row = mysql_fetch_row($result))
|
||||
{
|
||||
$values = array();
|
||||
if ($first_set)
|
||||
{
|
||||
$query = $sql_data . '(';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .= ',(';
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++)
|
||||
{
|
||||
if (!isset($row[$j]) || is_null($row[$j]))
|
||||
{
|
||||
$values[$j] = 'NULL';
|
||||
}
|
||||
else if ($field[$j]->numeric && ($field[$j]->type !== 'timestamp'))
|
||||
{
|
||||
$values[$j] = $row[$j];
|
||||
}
|
||||
else
|
||||
{
|
||||
$values[$j] = "'" . str_replace($search, $replace, $row[$j]) . "'";
|
||||
}
|
||||
}
|
||||
$query .= implode(', ', $values) . ')';
|
||||
|
||||
$query_len += strlen($query);
|
||||
if ($query_len > $max_len)
|
||||
{
|
||||
$this->flush($query . ";\n\n");
|
||||
$query = '';
|
||||
$query_len = 0;
|
||||
$first_set = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$first_set = false;
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
|
||||
// check to make sure we have nothing left to flush
|
||||
if (!$first_set && $query)
|
||||
{
|
||||
$this->flush($query . ";\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts database table structure (for MySQLi or MySQL 3.23.20+)
|
||||
*
|
||||
@@ -300,7 +198,7 @@ class mysql_extractor extends base_extractor
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts database table structure (for MySQL verisons older than 3.23.20)
|
||||
* Extracts database table structure (for MySQL versions older than 3.23.20)
|
||||
*
|
||||
* @param string $table_name name of the database table
|
||||
* @return null
|
||||
|
||||
@@ -117,7 +117,7 @@ class release_3_0_4_rc1 extends \phpbb\db\migration\migration
|
||||
}
|
||||
else
|
||||
{
|
||||
// equivelant to "none", which is the "Display in user control panel" option
|
||||
// equivalent to "none", which is the "Display in user control panel" option
|
||||
$sql_ary['field_show_profile'] = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class softdelete_p1 extends \phpbb\db\migration\migration
|
||||
/*
|
||||
* Using sql_case here to avoid "BIGINT UNSIGNED value is out of range" errors.
|
||||
* As we update all topics in 2 queries, one broken topic would stop the conversion
|
||||
* for all topics and the surpressed error will cause the admin to not even notice it.
|
||||
* for all topics and the suppressed error will cause the admin to not even notice it.
|
||||
*/
|
||||
$sql = 'UPDATE ' . $this->table_prefix . 'topics
|
||||
SET topic_posts_approved = topic_replies + 1,
|
||||
|
||||
29
phpbb/db/migration/data/v32x/timezone_p3.php
Normal file
29
phpbb/db/migration/data/v32x/timezone_p3.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class timezone_p3 extends \phpbb\db\migration\migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('\phpbb\db\migration\data\v310\timezone');
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.remove', array('board_dst')),
|
||||
);
|
||||
}
|
||||
}
|
||||
44
phpbb/db/migration/data/v32x/user_emoji_permission.php
Normal file
44
phpbb/db/migration/data/v32x/user_emoji_permission.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class user_emoji_permission extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
$sql = 'SELECT auth_option_id
|
||||
FROM ' . ACL_OPTIONS_TABLE . "
|
||||
WHERE auth_option = 'u_emoji'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$auth_option_id = $this->db->sql_fetchfield('auth_option_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $auth_option_id !== false;
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v32x\v329rc1',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['permission.add', ['u_emoji']],
|
||||
['permission.permission_set', ['REGISTERED', 'u_emoji', 'group']],
|
||||
];
|
||||
}
|
||||
}
|
||||
36
phpbb/db/migration/data/v32x/v328.php
Normal file
36
phpbb/db/migration/data/v32x/v328.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class v328 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return phpbb_version_compare($this->config['version'], '3.2.8', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\v328rc1',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.2.8')),
|
||||
);
|
||||
}
|
||||
}
|
||||
37
phpbb/db/migration/data/v32x/v328rc1.php
Normal file
37
phpbb/db/migration/data/v32x/v328rc1.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class v328rc1 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return phpbb_version_compare($this->config['version'], '3.2.8-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\timezone_p3',
|
||||
'\phpbb\db\migration\data\v32x\v327',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.2.8-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
37
phpbb/db/migration/data/v32x/v329.php
Normal file
37
phpbb/db/migration/data/v32x/v329.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class v329 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return phpbb_version_compare($this->config['version'], '3.2.9', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\v329rc1',
|
||||
'\phpbb\db\migration\data\v32x\user_emoji_permission',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.2.9')),
|
||||
);
|
||||
}
|
||||
}
|
||||
36
phpbb/db/migration/data/v32x/v329rc1.php
Normal file
36
phpbb/db/migration/data/v32x/v329rc1.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v32x;
|
||||
|
||||
class v329rc1 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return phpbb_version_compare($this->config['version'], '3.2.9-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\v328',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.2.9-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class add_display_unapproved_posts_config extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->config->offsetExists('display_unapproved_posts');
|
||||
}
|
||||
|
||||
public static function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v330\dev',];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.add', ['display_unapproved_posts', 1]],
|
||||
];
|
||||
}
|
||||
}
|
||||
36
phpbb/db/migration/data/v330/dev.php
Normal file
36
phpbb/db/migration/data/v330/dev.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class dev extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.0-dev', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\v327',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.3.0-dev')),
|
||||
);
|
||||
}
|
||||
}
|
||||
49
phpbb/db/migration/data/v330/forums_legend_limit.php
Normal file
49
phpbb/db/migration/data/v330/forums_legend_limit.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class forums_legend_limit extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'display_subforum_limit');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v330\v330b1'];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'display_subforum_limit' => ['BOOL', 0, 'after' => 'display_subforum_list'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'display_subforum_limit',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
37
phpbb/db/migration/data/v330/jquery_update.php
Normal file
37
phpbb/db/migration/data/v330/jquery_update.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class jquery_update extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->config['load_jquery_url'] === '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js';
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v330\dev',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
89
phpbb/db/migration/data/v330/remove_attachment_flash.php
Normal file
89
phpbb/db/migration/data/v330/remove_attachment_flash.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class remove_attachment_flash extends \phpbb\db\migration\migration
|
||||
{
|
||||
// Following constants were deprecated in 3.3
|
||||
// and moved from constants.php to compatibility_globals.php,
|
||||
// thus define them as class constants
|
||||
const ATTACHMENT_CATEGORY_FLASH = 5;
|
||||
|
||||
protected $cat_id = array(
|
||||
self::ATTACHMENT_CATEGORY_FLASH,
|
||||
);
|
||||
|
||||
public static function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v330\dev',];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'remove_flash_group'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function remove_flash_group()
|
||||
{
|
||||
// select group ids of outdated media
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id);
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$group_ids = array();
|
||||
while ($group_id = (int) $this->db->sql_fetchfield('group_id'))
|
||||
{
|
||||
$group_ids[] = $group_id;
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// nothing to do, admin has removed all the outdated media extension groups
|
||||
if (empty($group_ids))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the group id of downloadable files
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_name = 'DOWNLOADABLE_FILES'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$download_id = (int) $this->db->sql_fetchfield('group_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (empty($download_id))
|
||||
{
|
||||
$sql = 'UPDATE ' . EXTENSIONS_TABLE . '
|
||||
SET group_id = 0
|
||||
WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move outdated media extensions to downloadable files
|
||||
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
|
||||
SET group_id = $download_id" . '
|
||||
WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
|
||||
}
|
||||
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
// delete the now empty, outdated media extension groups
|
||||
$sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
62
phpbb/db/migration/data/v330/remove_email_hash.php
Normal file
62
phpbb/db/migration/data/v330/remove_email_hash.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class remove_email_hash extends \phpbb\db\migration\migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v30x\release_3_0_0'];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return [
|
||||
'add_index' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_email' => ['user_email'],
|
||||
],
|
||||
],
|
||||
'drop_keys' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_email_hash',
|
||||
],
|
||||
],
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'users' => ['user_email_hash'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_email_hash' => ['BINT', 0],
|
||||
],
|
||||
],
|
||||
'add_index' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_email_hash',
|
||||
],
|
||||
],
|
||||
'drop_keys' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_email' => ['user_email'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
43
phpbb/db/migration/data/v330/remove_max_pass_chars.php
Normal file
43
phpbb/db/migration/data/v330/remove_max_pass_chars.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class remove_max_pass_chars extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return !$this->config->offsetExists('max_pass_chars');
|
||||
}
|
||||
|
||||
public static function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v330\dev',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.remove', ['max_pass_chars']],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_data()
|
||||
{
|
||||
return [
|
||||
['config.add', ['max_pass_chars', 100]],
|
||||
];
|
||||
}
|
||||
}
|
||||
48
phpbb/db/migration/data/v330/reset_password.php
Normal file
48
phpbb/db/migration/data/v330/reset_password.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class reset_password extends \phpbb\db\migration\migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v330\dev',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'reset_token' => ['VCHAR:64', '', 'after' => 'user_actkey'],
|
||||
'reset_token_expiration' => ['TIMESTAMP', 0, 'after' => 'reset_token'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'reset_token',
|
||||
'reset_token_expiration',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
37
phpbb/db/migration/data/v330/v330.php
Normal file
37
phpbb/db/migration/data/v330/v330.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class v330 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.0', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v32x\v329',
|
||||
'\phpbb\db\migration\data\v330\v330rc1',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.3.0')),
|
||||
);
|
||||
}
|
||||
}
|
||||
41
phpbb/db/migration/data/v330/v330b1.php
Normal file
41
phpbb/db/migration/data/v330/v330b1.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class v330b1 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.0-b1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v330\jquery_update',
|
||||
'\phpbb\db\migration\data\v330\reset_password',
|
||||
'\phpbb\db\migration\data\v330\remove_attachment_flash',
|
||||
'\phpbb\db\migration\data\v330\remove_max_pass_chars',
|
||||
'\phpbb\db\migration\data\v32x\v328',
|
||||
'\phpbb\db\migration\data\v330\dev',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.3.0-b1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
39
phpbb/db/migration/data/v330/v330b2.php
Normal file
39
phpbb/db/migration/data/v330/v330b2.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class v330b2 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.0-b2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v330\add_display_unapproved_posts_config',
|
||||
'\phpbb\db\migration\data\v330\forums_legend_limit',
|
||||
'\phpbb\db\migration\data\v330\remove_email_hash',
|
||||
'\phpbb\db\migration\data\v330\v330b1',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.3.0-b2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
36
phpbb/db/migration/data/v330/v330rc1.php
Normal file
36
phpbb/db/migration/data/v330/v330rc1.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class v330rc1 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.0-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v330\v330b2',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.3.0-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -509,7 +509,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||
* Get parent module id
|
||||
*
|
||||
* @param string|int $parent_id The parent module_id|module_langname
|
||||
* @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding
|
||||
* @param int|string|array $data The module_id, module_langname for existence checking or module data array for adding
|
||||
* @param bool $throw_exception The flag indicating if exception should be thrown on error
|
||||
* @return mixed The int parent module_id, an array of int parent module_id values or false
|
||||
* @throws \phpbb\db\migration\exception
|
||||
|
||||
@@ -784,7 +784,7 @@ class migrator
|
||||
{
|
||||
return array(
|
||||
$parameters[0],
|
||||
array($last_result),
|
||||
isset($parameters[1]) ? array_merge($parameters[1], array($last_result)) : array($last_result),
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -194,7 +194,7 @@ class mssql extends tools
|
||||
$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];
|
||||
}
|
||||
|
||||
// create sequence DDL based off of the existance of auto incrementing columns
|
||||
// create sequence DDL based off of the existence of auto incrementing columns
|
||||
if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])
|
||||
{
|
||||
$create_sequence = $column_name;
|
||||
|
||||
@@ -141,7 +141,7 @@ class postgres extends tools
|
||||
$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];
|
||||
}
|
||||
|
||||
// create sequence DDL based off of the existance of auto incrementing columns
|
||||
// create sequence DDL based off of the existence of auto incrementing columns
|
||||
if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])
|
||||
{
|
||||
$create_sequence = $column_name;
|
||||
|
||||
@@ -74,37 +74,6 @@ class tools implements tools_interface
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
|
||||
'mysql_40' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'ULINT' => 'INT(10) UNSIGNED',
|
||||
'UINT' => 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'smallint(4) UNSIGNED',
|
||||
'BOOL' => 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varbinary(255)',
|
||||
'VCHAR:' => 'varbinary(%d)',
|
||||
'CHAR:' => 'binary(%d)',
|
||||
'XSTEXT' => 'blob',
|
||||
'XSTEXT_UNI'=> 'blob',
|
||||
'STEXT' => 'blob',
|
||||
'STEXT_UNI' => 'blob',
|
||||
'TEXT' => 'blob',
|
||||
'TEXT_UNI' => 'blob',
|
||||
'MTEXT' => 'mediumblob',
|
||||
'MTEXT_UNI' => 'mediumblob',
|
||||
'TIMESTAMP' => 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'blob',
|
||||
'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')),
|
||||
'VCHAR_CI' => 'blob',
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
|
||||
'oracle' => array(
|
||||
'INT:' => 'number(%d)',
|
||||
'BINT' => 'number(20)',
|
||||
@@ -197,21 +166,6 @@ class tools implements tools_interface
|
||||
// Determine mapping database type
|
||||
switch ($this->db->get_sql_layer())
|
||||
{
|
||||
case 'mysql':
|
||||
$this->sql_layer = 'mysql_40';
|
||||
break;
|
||||
|
||||
case 'mysql4':
|
||||
if (version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
|
||||
{
|
||||
$this->sql_layer = 'mysql_41';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sql_layer = 'mysql_40';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'mysqli':
|
||||
$this->sql_layer = 'mysql_41';
|
||||
break;
|
||||
@@ -240,8 +194,6 @@ class tools implements tools_interface
|
||||
{
|
||||
switch ($this->db->get_sql_layer())
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
case 'mysqli':
|
||||
$sql = 'SHOW TABLES';
|
||||
break;
|
||||
@@ -335,7 +287,7 @@ class tools implements tools_interface
|
||||
$primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set'];
|
||||
}
|
||||
|
||||
// create sequence DDL based off of the existance of auto incrementing columns
|
||||
// create sequence DDL based off of the existence of auto incrementing columns
|
||||
if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'])
|
||||
{
|
||||
$create_sequence = $column_name;
|
||||
@@ -359,7 +311,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
case 'sqlite3':
|
||||
$table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')';
|
||||
@@ -381,7 +332,6 @@ class tools implements tools_interface
|
||||
$statements[] = $table_sql;
|
||||
break;
|
||||
|
||||
case 'mysql_40':
|
||||
case 'sqlite3':
|
||||
$table_sql .= "\n);";
|
||||
$statements[] = $table_sql;
|
||||
@@ -576,7 +526,7 @@ class tools implements tools_interface
|
||||
{
|
||||
foreach ($indexes as $index_name)
|
||||
{
|
||||
if (!$this->sql_index_exists($table, $index_name))
|
||||
if (!$this->sql_index_exists($table, $index_name) && !$this->sql_unique_index_exists($table, $index_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -834,7 +784,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql = "SHOW COLUMNS FROM $table_name";
|
||||
break;
|
||||
@@ -911,7 +860,6 @@ class tools implements tools_interface
|
||||
{
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql = 'SHOW KEYS
|
||||
FROM ' . $table_name;
|
||||
@@ -936,7 +884,7 @@ class tools implements tools_interface
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique'])
|
||||
if ($this->sql_layer == 'mysql_41' && !$row['Non_unique'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -971,7 +919,6 @@ class tools implements tools_interface
|
||||
{
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql = 'SHOW KEYS
|
||||
FROM ' . $table_name;
|
||||
@@ -996,7 +943,7 @@ class tools implements tools_interface
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && ($row['Non_unique'] || $row[$col] == 'PRIMARY'))
|
||||
if ($this->sql_layer == 'mysql_41' && ($row['Non_unique'] || $row[$col] == 'PRIMARY'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1094,7 +1041,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql .= " {$column_type} ";
|
||||
|
||||
@@ -1248,7 +1194,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$after = (!empty($column_data['after'])) ? ' AFTER ' . $column_data['after'] : '';
|
||||
$statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql'] . $after;
|
||||
@@ -1281,7 +1226,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$statements[] = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`';
|
||||
break;
|
||||
@@ -1360,7 +1304,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$index_name = $this->check_index_name_length($table_name, $index_name, false);
|
||||
$statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name;
|
||||
@@ -1422,7 +1365,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')';
|
||||
break;
|
||||
@@ -1500,7 +1442,6 @@ class tools implements tools_interface
|
||||
$statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||
break;
|
||||
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$index_name = $this->check_index_name_length($table_name, $index_name);
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')';
|
||||
@@ -1517,11 +1458,7 @@ class tools implements tools_interface
|
||||
{
|
||||
$statements = array();
|
||||
|
||||
// remove index length unless MySQL4
|
||||
if ('mysql_40' != $this->sql_layer)
|
||||
{
|
||||
$column = preg_replace('#:.*$#', '', $column);
|
||||
}
|
||||
$column = preg_replace('#:.*$#', '', $column);
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
@@ -1531,17 +1468,6 @@ class tools implements tools_interface
|
||||
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||
break;
|
||||
|
||||
case 'mysql_40':
|
||||
// add index size to definition as required by MySQL4
|
||||
foreach ($column as $i => $col)
|
||||
{
|
||||
if (false !== strpos($col, ':'))
|
||||
{
|
||||
list($col, $index_size) = explode(':', $col);
|
||||
$column[$i] = "$col($index_size)";
|
||||
}
|
||||
}
|
||||
// no break
|
||||
case 'mysql_41':
|
||||
$index_name = $this->check_index_name_length($table_name, $index_name);
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')';
|
||||
@@ -1609,7 +1535,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql = 'SHOW KEYS
|
||||
FROM ' . $table_name;
|
||||
@@ -1634,7 +1559,7 @@ class tools implements tools_interface
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique'])
|
||||
if ($this->sql_layer == 'mysql_41' && !$row['Non_unique'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1677,7 +1602,6 @@ class tools implements tools_interface
|
||||
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$statements[] = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql'];
|
||||
break;
|
||||
@@ -1826,7 +1750,6 @@ class tools implements tools_interface
|
||||
{
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
case 'sqlite3':
|
||||
// Not supported
|
||||
|
||||
@@ -158,13 +158,18 @@ class container_builder
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->container_extensions = array(new extension\core($this->get_config_path()));
|
||||
$this->container_extensions = [
|
||||
new extension\core($this->get_config_path()),
|
||||
];
|
||||
|
||||
if ($this->use_extensions)
|
||||
{
|
||||
$this->load_extensions();
|
||||
}
|
||||
|
||||
// Add tables extension after all extensions
|
||||
$this->container_extensions[] = new extension\tables();
|
||||
|
||||
// Inject the config
|
||||
if ($this->config_php_file)
|
||||
{
|
||||
@@ -481,7 +486,7 @@ class container_builder
|
||||
|
||||
$cached_container_dump = $dumper->dump(array(
|
||||
'class' => 'phpbb_cache_container',
|
||||
'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
|
||||
'base_class' => 'Symfony\\Component\\DependencyInjection\\Container',
|
||||
));
|
||||
|
||||
$cache->write($cached_container_dump, $this->container->getResources());
|
||||
|
||||
@@ -31,10 +31,15 @@ class container_configuration implements ConfigurationInterface
|
||||
$rootNode
|
||||
->children()
|
||||
->booleanNode('require_dev_dependencies')->defaultValue(false)->end()
|
||||
->booleanNode('allow_install_dir')->defaultValue(false)->end()
|
||||
->arrayNode('debug')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('exceptions')->defaultValue(false)->end()
|
||||
->booleanNode('load_time')->defaultValue(false)->end()
|
||||
->booleanNode('sql_explain')->defaultValue(false)->end()
|
||||
->booleanNode('memory')->defaultValue(false)->end()
|
||||
->booleanNode('show_errors')->defaultValue(false)->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('twig')
|
||||
@@ -45,6 +50,12 @@ class container_configuration implements ConfigurationInterface
|
||||
->booleanNode('enable_debug_extension')->defaultValue(false)->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('session')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('log_errors')->defaultValue(false)->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
return $treeBuilder;
|
||||
|
||||
@@ -71,6 +71,8 @@ class core extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
$container->setParameter('allow_install_dir', $config['allow_install_dir']);
|
||||
|
||||
// Set the Twig options if defined in the environment
|
||||
$definition = $container->getDefinition('template.twig.environment');
|
||||
$twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION);
|
||||
@@ -97,6 +99,12 @@ class core extends Extension
|
||||
{
|
||||
$container->setParameter('debug.' . $name, $value);
|
||||
}
|
||||
|
||||
// Set the log options
|
||||
foreach ($config['session'] as $name => $value)
|
||||
{
|
||||
$container->setParameter('session.' . $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
59
phpbb/di/extension/tables.php
Normal file
59
phpbb/di/extension/tables.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\di\extension;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* Container tables extension
|
||||
*/
|
||||
class tables extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// Tables is a reserved parameter and will be overwritten at all times
|
||||
$tables = [];
|
||||
|
||||
// Add access via 'tables' parameter to acquire array with all tables
|
||||
$parameterBag = $container->getParameterBag();
|
||||
$parameters = $parameterBag->all();
|
||||
foreach ($parameters as $parameter_name => $parameter_value)
|
||||
{
|
||||
if (!preg_match('/tables\.(.+)/', $parameter_name, $matches))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$tables[$matches[1]] = $parameter_value;
|
||||
}
|
||||
|
||||
$container->setParameter('tables', $tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recommended alias to use in XML.
|
||||
*
|
||||
* This alias is also the mandatory prefix to use when using YAML.
|
||||
*
|
||||
* @return string The alias
|
||||
*/
|
||||
public function getAlias()
|
||||
{
|
||||
return 'tables';
|
||||
}
|
||||
}
|
||||
@@ -49,21 +49,6 @@ class service_collection extends \ArrayObject
|
||||
return new service_collection_iterator($this);
|
||||
}
|
||||
|
||||
// Because of a PHP issue we have to redefine offsetExists
|
||||
// (even with a call to the parent):
|
||||
// https://bugs.php.net/bug.php?id=66834
|
||||
// https://bugs.php.net/bug.php?id=67067
|
||||
// But it triggers a sniffer issue that we have to skip
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetExists($index)
|
||||
{
|
||||
return parent::offsetExists($index);
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -76,11 +61,11 @@ class service_collection extends \ArrayObject
|
||||
* Add a service to the collection
|
||||
*
|
||||
* @param string $name The service name
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
public function add($name)
|
||||
{
|
||||
$this->offsetSet($name, null);
|
||||
$this->offsetSet($name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,4 +88,35 @@ class service_collection extends \ArrayObject
|
||||
{
|
||||
return $this->service_classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the service associated to a class
|
||||
*
|
||||
* @return mixed
|
||||
* @throw \RuntimeException if the
|
||||
*/
|
||||
public function get_by_class($class)
|
||||
{
|
||||
$service_id = null;
|
||||
|
||||
foreach ($this->service_classes as $id => $service_class)
|
||||
{
|
||||
if ($service_class === $class)
|
||||
{
|
||||
if ($service_id !== null)
|
||||
{
|
||||
throw new \RuntimeException('More than one service definitions found for class "'.$class.'" in collection.');
|
||||
}
|
||||
|
||||
$service_id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($service_id === null)
|
||||
{
|
||||
throw new \RuntimeException('No service found for class "'.$class.'" in collection.');
|
||||
}
|
||||
|
||||
return $this->offsetGet($service_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,9 +389,16 @@ class md_exporter
|
||||
$files = explode("\n + ", $file_details);
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (!preg_match('#^([^ ]+)( \([0-9]+\))?$#', $file))
|
||||
{
|
||||
throw new \LogicException("Invalid event instances for file '{$file}' found for event '{$this->current_event}'", 1);
|
||||
}
|
||||
|
||||
list($file) = explode(" ", $file);
|
||||
|
||||
if (!file_exists($this->path . $file) || substr($file, -5) !== '.html')
|
||||
{
|
||||
throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1);
|
||||
throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
|
||||
}
|
||||
|
||||
if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)
|
||||
@@ -404,7 +411,7 @@ class md_exporter
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
|
||||
throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 3);
|
||||
}
|
||||
|
||||
$this->events_by_file[$file][] = $this->current_event;
|
||||
@@ -424,7 +431,7 @@ class md_exporter
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2);
|
||||
throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 1);
|
||||
}
|
||||
|
||||
return $files_list;
|
||||
|
||||
@@ -22,7 +22,8 @@ interface extension_interface
|
||||
/**
|
||||
* Indicate whether or not the extension can be enabled.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool|array True if extension is enableable, array of reasons
|
||||
* if not, false for generic reason.
|
||||
*/
|
||||
public function is_enableable();
|
||||
|
||||
|
||||
@@ -160,6 +160,47 @@ class manager
|
||||
return $this->extensions[$name]['metadata'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the database entry for an extension
|
||||
*
|
||||
* @param string $name Extension name to update
|
||||
* @param array $data Data to update in the database
|
||||
* @param string $action Action to perform, by default 'update', may be also 'insert' or 'delete'
|
||||
*/
|
||||
protected function update_state($name, $data, $action = 'update')
|
||||
{
|
||||
switch ($action)
|
||||
{
|
||||
case 'insert':
|
||||
$this->extensions[$name] = $data;
|
||||
$this->extensions[$name]['ext_path'] = $this->get_extension_path($name);
|
||||
ksort($this->extensions);
|
||||
$sql = 'INSERT INTO ' . $this->extension_table . ' ' . $this->db->sql_build_array('INSERT', $data);
|
||||
$this->db->sql_query($sql);
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$this->extensions[$name] = array_merge($this->extensions[$name], $data);
|
||||
$sql = 'UPDATE ' . $this->extension_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $data) . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
unset($this->extensions[$name]);
|
||||
$sql = 'DELETE FROM ' . $this->extension_table . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a step of the extension enabling process.
|
||||
*
|
||||
@@ -197,35 +238,7 @@ class manager
|
||||
'ext_state' => serialize($state),
|
||||
);
|
||||
|
||||
$this->extensions[$name] = $extension_data;
|
||||
$this->extensions[$name]['ext_path'] = $this->get_extension_path($extension_data['ext_name']);
|
||||
ksort($this->extensions);
|
||||
|
||||
$sql = 'SELECT COUNT(ext_name) as row_count
|
||||
FROM ' . $this->extension_table . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$count = $this->db->sql_fetchfield('row_count');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($count)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->extension_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $this->extension_table . '
|
||||
' . $this->db->sql_build_array('INSERT', $extension_data);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
$this->update_state($name, $extension_data, $this->is_configured($name) ? 'update' : 'insert');
|
||||
|
||||
if ($active)
|
||||
{
|
||||
@@ -272,46 +285,15 @@ class manager
|
||||
|
||||
$extension = $this->get_extension($name);
|
||||
$state = $extension->disable_step($old_state);
|
||||
|
||||
// continue until the state is false
|
||||
if ($state !== false)
|
||||
{
|
||||
$extension_data = array(
|
||||
'ext_state' => serialize($state),
|
||||
);
|
||||
$this->extensions[$name]['ext_state'] = serialize($state);
|
||||
|
||||
$sql = 'UPDATE ' . $this->extension_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
$active = ($state !== false);
|
||||
|
||||
$extension_data = array(
|
||||
'ext_active' => false,
|
||||
'ext_state' => serialize(false),
|
||||
'ext_active' => $active,
|
||||
'ext_state' => serialize($state),
|
||||
);
|
||||
$this->extensions[$name]['ext_active'] = false;
|
||||
$this->extensions[$name]['ext_state'] = serialize(false);
|
||||
$this->update_state($name, $extension_data);
|
||||
|
||||
$sql = 'UPDATE ' . $this->extension_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
|
||||
return false;
|
||||
return $active;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,40 +339,16 @@ class manager
|
||||
|
||||
$extension = $this->get_extension($name);
|
||||
$state = $extension->purge_step($old_state);
|
||||
$purged = ($state === false);
|
||||
|
||||
$extension_data = array(
|
||||
'ext_state' => serialize($state),
|
||||
);
|
||||
|
||||
$this->update_state($name, $extension_data, $purged ? 'delete' : 'update');
|
||||
|
||||
// continue until the state is false
|
||||
if ($state !== false)
|
||||
{
|
||||
$extension_data = array(
|
||||
'ext_state' => serialize($state),
|
||||
);
|
||||
$this->extensions[$name]['ext_state'] = serialize($state);
|
||||
|
||||
$sql = 'UPDATE ' . $this->extension_table . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unset($this->extensions[$name]);
|
||||
|
||||
$sql = 'DELETE FROM ' . $this->extension_table . "
|
||||
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($this->cache)
|
||||
{
|
||||
$this->cache->purge();
|
||||
}
|
||||
|
||||
return false;
|
||||
return !$purged;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -308,14 +308,13 @@ class feed
|
||||
* Event to modify the feed row
|
||||
*
|
||||
* @event core.feed_modify_feed_row
|
||||
* @var int forum_id Forum ID
|
||||
* @var string mode Feeds mode (forums|topics|topics_new|topics_active|news)
|
||||
* @var feed_interface feed Feed instance
|
||||
* @var array row Array with feed data
|
||||
* @var int topic_id Topic ID
|
||||
*
|
||||
* @since 3.1.10-RC1
|
||||
* @changed 3.3.0 Replace forum_id, mode, topic_id with feed instance
|
||||
*/
|
||||
$vars = array('forum_id', 'mode', 'row', 'topic_id');
|
||||
$vars = array('feed', 'row');
|
||||
extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars)));
|
||||
|
||||
// BBCode options to correctly disable urls, smilies, bbcode...
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace phpbb\feed;
|
||||
* Active Topics feed
|
||||
*
|
||||
* This will give you the last {$this->num_items} topics
|
||||
* with replies made withing the last {$this->sort_days} days
|
||||
* with replies made within the last {$this->sort_days} days
|
||||
* including the last post.
|
||||
*/
|
||||
class topics_active extends topic_base
|
||||
|
||||
@@ -420,7 +420,7 @@ class filespec
|
||||
return false;
|
||||
}
|
||||
|
||||
$upload_mode = ($this->php_ini->getBool('open_basedir') || $this->php_ini->getBool('safe_mode')) ? 'move' : 'copy';
|
||||
$upload_mode = ($this->php_ini->getBool('open_basedir')) ? 'move' : 'copy';
|
||||
$upload_mode = ($this->local) ? 'local' : $upload_mode;
|
||||
$this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace phpbb;
|
||||
|
||||
/**
|
||||
* @deprecated 3.2.0-dev (To be removed 3.3.0) use \phpbb\filesystem\filesystem instead
|
||||
* @deprecated 3.2.0-dev (To be removed 4.0.0) use \phpbb\filesystem\filesystem instead
|
||||
*/
|
||||
class filesystem extends \phpbb\filesystem\filesystem
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ class filesystem implements filesystem_interface
|
||||
$error = trim($e->getMessage());
|
||||
$file = substr($error, strrpos($error, ' '));
|
||||
|
||||
throw new filesystem_exception('CANNOT_CHANGE_FILE_GROUP', $file, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_GROUP', $file, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,14 +124,14 @@ class filesystem implements filesystem_interface
|
||||
{
|
||||
if (true !== @chmod($file, $dir_perm))
|
||||
{
|
||||
throw new filesystem_exception('CANNOT_CHANGE_FILE_PERMISSIONS', $file, array());
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_PERMISSIONS', $file, array());
|
||||
}
|
||||
}
|
||||
else if (is_file($file))
|
||||
{
|
||||
if (true !== @chmod($file, $file_perm))
|
||||
{
|
||||
throw new filesystem_exception('CANNOT_CHANGE_FILE_PERMISSIONS', $file, array());
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_PERMISSIONS', $file, array());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ class filesystem implements filesystem_interface
|
||||
$error = trim($e->getMessage());
|
||||
$file = substr($error, strrpos($error, ' '));
|
||||
|
||||
throw new filesystem_exception('CANNOT_CHANGE_FILE_GROUP', $file, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_GROUP', $file, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ class filesystem implements filesystem_interface
|
||||
}
|
||||
catch (\Symfony\Component\Filesystem\Exception\IOException $e)
|
||||
{
|
||||
throw new filesystem_exception('CANNOT_COPY_FILES', '', array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_COPY_FILES', '', array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class filesystem implements filesystem_interface
|
||||
}
|
||||
catch (\Symfony\Component\Filesystem\Exception\IOException $e)
|
||||
{
|
||||
throw new filesystem_exception('CANNOT_DUMP_FILE', $filename, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_DUMP_FILE', $filename, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ class filesystem implements filesystem_interface
|
||||
$msg = $e->getMessage();
|
||||
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
|
||||
|
||||
throw new filesystem_exception('CANNOT_MIRROR_DIRECTORY', $filename, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_MIRROR_DIRECTORY', $filename, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ class filesystem implements filesystem_interface
|
||||
$msg = $e->getMessage();
|
||||
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
|
||||
|
||||
throw new filesystem_exception('CANNOT_CREATE_DIRECTORY', $filename, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CREATE_DIRECTORY', $filename, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ class filesystem implements filesystem_interface
|
||||
$error = trim($e->getMessage());
|
||||
$file = substr($error, strrpos($error, ' '));
|
||||
|
||||
throw new filesystem_exception('CANNOT_DELETE_FILES', $file, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_DELETE_FILES', $file, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ class filesystem implements filesystem_interface
|
||||
$msg = $e->getMessage();
|
||||
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
|
||||
|
||||
throw new filesystem_exception('CANNOT_RENAME_FILE', $filename, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_RENAME_FILE', $filename, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,7 +558,7 @@ class filesystem implements filesystem_interface
|
||||
}
|
||||
catch (\Symfony\Component\Filesystem\Exception\IOException $e)
|
||||
{
|
||||
throw new filesystem_exception('CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ class filesystem implements filesystem_interface
|
||||
$error = trim($e->getMessage());
|
||||
$file = substr($error, strrpos($error, ' '));
|
||||
|
||||
throw new filesystem_exception('CANNOT_TOUCH_FILES', $file, array(), $e);
|
||||
throw new filesystem_exception('FILESYSTEM_CANNOT_TOUCH_FILES', $file, array(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ class filesystem implements filesystem_interface
|
||||
$current_path = $resolved_path . '/' . $path_part;
|
||||
|
||||
// Resolve symlinks
|
||||
if (is_link($current_path))
|
||||
if (@is_link($current_path))
|
||||
{
|
||||
if (!function_exists('readlink'))
|
||||
{
|
||||
@@ -872,12 +872,12 @@ class filesystem implements filesystem_interface
|
||||
|
||||
$resolved_path = false;
|
||||
}
|
||||
else if (is_dir($current_path . '/'))
|
||||
else if (@is_dir($current_path . '/'))
|
||||
{
|
||||
$resolved[] = $path_part;
|
||||
$resolved_path = $current_path;
|
||||
}
|
||||
else if (is_file($current_path))
|
||||
else if (@is_file($current_path))
|
||||
{
|
||||
$resolved[] = $path_part;
|
||||
$resolved_path = $current_path;
|
||||
|
||||
@@ -204,7 +204,7 @@ interface filesystem_interface
|
||||
* This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions.
|
||||
* The function determines owner and group from common.php file and sets the same to the provided file.
|
||||
* The function uses bit fields to build the permissions.
|
||||
* The function sets the appropiate execute bit on directories.
|
||||
* The function sets the appropriate execute bit on directories.
|
||||
*
|
||||
* Supported constants representing bit fields are:
|
||||
*
|
||||
|
||||
@@ -80,7 +80,7 @@ class finder
|
||||
/**
|
||||
* Set the array of extensions
|
||||
*
|
||||
* @param array $extensions A list of extensions that should be searched aswell
|
||||
* @param array $extensions A list of extensions that should be searched as well
|
||||
* @param bool $replace_list Should the list be emptied before adding the extensions
|
||||
* @return \phpbb\finder This object for chaining calls
|
||||
*/
|
||||
@@ -237,7 +237,7 @@ class finder
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes occurances of /./ and makes sure path ends without trailing slash
|
||||
* Removes occurrences of /./ and makes sure path ends without trailing slash
|
||||
*
|
||||
* @param string $directory A directory pattern
|
||||
* @return string A cleaned up directory pattern
|
||||
|
||||
@@ -13,19 +13,74 @@
|
||||
|
||||
namespace phpbb\group;
|
||||
|
||||
use phpbb\auth\auth;
|
||||
use phpbb\cache\service as cache;
|
||||
use phpbb\config\config;
|
||||
use phpbb\language\language;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\path_helper;
|
||||
use phpbb\user;
|
||||
|
||||
class helper
|
||||
{
|
||||
/** @var \phpbb\language\language */
|
||||
/** @var auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var cache */
|
||||
protected $cache;
|
||||
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
/** @var language */
|
||||
protected $language;
|
||||
|
||||
/** @var dispatcher_interface */
|
||||
protected $dispatcher;
|
||||
|
||||
/** @var path_helper */
|
||||
protected $path_helper;
|
||||
|
||||
/** @var user */
|
||||
protected $user;
|
||||
|
||||
/** @var string phpBB root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var array Return templates for a group name string */
|
||||
protected $name_strings;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\language\language $language Language object
|
||||
* @param auth $auth Authentication object
|
||||
* @param cache $cache Cache service object
|
||||
* @param config $config Configuration object
|
||||
* @param language $language Language object
|
||||
* @param dispatcher_interface $dispatcher Event dispatcher object
|
||||
* @param path_helper $path_helper Path helper object
|
||||
* @param user $user User object
|
||||
*/
|
||||
public function __construct(\phpbb\language\language $language)
|
||||
public function __construct(auth $auth, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->cache = $cache;
|
||||
$this->config = $config;
|
||||
$this->language = $language;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->path_helper = $path_helper;
|
||||
$this->user = $user;
|
||||
|
||||
$this->phpbb_root_path = $path_helper->get_phpbb_root_path();
|
||||
|
||||
/** @html Group name spans and links for usage in the template */
|
||||
$this->name_strings = array(
|
||||
'base_url' => "{$path_helper->get_phpbb_root_path()}memberlist.{$path_helper->get_php_ext()}?mode=group&g={GROUP_ID}",
|
||||
'tpl_noprofile' => '<span class="username">{GROUP_NAME}</span>',
|
||||
'tpl_noprofile_colour' => '<span class="username-coloured" style="color: {GROUP_COLOUR};">{GROUP_NAME}</span>',
|
||||
'tpl_profile' => '<a class="username" href="{PROFILE_URL}">{GROUP_NAME}</a>',
|
||||
'tpl_profile_colour' => '<a class="username-coloured" href="{PROFILE_URL}" style="color: {GROUP_COLOUR};">{GROUP_NAME}</a>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,4 +92,203 @@ class helper
|
||||
{
|
||||
return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group name details for placing into templates.
|
||||
*
|
||||
* @html Group name spans and links
|
||||
*
|
||||
* @param string $mode Profile (for getting an url to the profile),
|
||||
* group_name (for obtaining the group name),
|
||||
* colour (for obtaining the group colour),
|
||||
* full (for obtaining a coloured group name link to the group's profile),
|
||||
* no_profile (the same as full but forcing no profile link)
|
||||
* @param int $group_id The group id
|
||||
* @param string $group_name The group name
|
||||
* @param string $group_colour The group colour
|
||||
* @param mixed $custom_profile_url optional parameter to specify a profile url. The group id gets appended to this url as &g={group_id}
|
||||
*
|
||||
* @return string A string consisting of what is wanted based on $mode.
|
||||
*/
|
||||
public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false)
|
||||
{
|
||||
$s_is_bots = ($group_name === 'BOTS');
|
||||
|
||||
// This switch makes sure we only run code required for the mode
|
||||
switch ($mode)
|
||||
{
|
||||
case 'full':
|
||||
case 'no_profile':
|
||||
case 'colour':
|
||||
|
||||
// Build correct group colour
|
||||
$group_colour = $group_colour ? '#' . $group_colour : '';
|
||||
|
||||
// Return colour
|
||||
if ($mode === 'colour')
|
||||
{
|
||||
$group_name_string = $group_colour;
|
||||
break;
|
||||
}
|
||||
|
||||
// no break;
|
||||
|
||||
case 'group_name':
|
||||
|
||||
// Build correct group name
|
||||
$group_name = $this->get_name($group_name);
|
||||
|
||||
// Return group name
|
||||
if ($mode === 'group_name')
|
||||
{
|
||||
$group_name_string = $group_name;
|
||||
break;
|
||||
}
|
||||
|
||||
// no break;
|
||||
|
||||
case 'profile':
|
||||
|
||||
// Build correct profile url - only show if not anonymous and permission to view profile if registered user
|
||||
// For anonymous the link leads to a login page.
|
||||
if ($group_id && !$s_is_bots && ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_get('u_viewprofile')))
|
||||
{
|
||||
$profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&g=' . (int) $group_id : str_replace(array('={GROUP_ID}', '=%7BGROUP_ID%7D'), '=' . (int) $group_id, append_sid($this->name_strings['base_url']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_url = '';
|
||||
}
|
||||
|
||||
// Return profile
|
||||
if ($mode === 'profile')
|
||||
{
|
||||
$group_name_string = $profile_url;
|
||||
break;
|
||||
}
|
||||
|
||||
// no break;
|
||||
}
|
||||
|
||||
if (!isset($group_name_string))
|
||||
{
|
||||
if (($mode === 'full' && empty($profile_url)) || $mode === 'no_profile' || $s_is_bots)
|
||||
{
|
||||
$group_name_string = str_replace(array('{GROUP_COLOUR}', '{GROUP_NAME}'), array($group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_noprofile'] : $this->name_strings['tpl_noprofile_colour']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_name_string = str_replace(array('{PROFILE_URL}', '{GROUP_COLOUR}', '{GROUP_NAME}'), array($profile_url, $group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_profile'] : $this->name_strings['tpl_profile_colour']);
|
||||
}
|
||||
}
|
||||
|
||||
$name_strings = $this->name_strings;
|
||||
|
||||
/**
|
||||
* Use this event to change the output of the group name
|
||||
*
|
||||
* @event core.modify_group_name_string
|
||||
* @var string mode profile|group_name|colour|full|no_profile
|
||||
* @var int group_id The group identifier
|
||||
* @var string group_name The group name
|
||||
* @var string group_colour The group colour
|
||||
* @var string custom_profile_url Optional parameter to specify a profile url.
|
||||
* @var string group_name_string The string that has been generated
|
||||
* @var array name_strings Array of original return templates
|
||||
* @since 3.2.8-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'mode',
|
||||
'group_id',
|
||||
'group_name',
|
||||
'group_colour',
|
||||
'custom_profile_url',
|
||||
'group_name_string',
|
||||
'name_strings',
|
||||
);
|
||||
extract($this->dispatcher->trigger_event('core.modify_group_name_string', compact($vars)));
|
||||
|
||||
return $group_name_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group rank title and image
|
||||
*
|
||||
* @html Group rank image element
|
||||
*
|
||||
* @param array $group_data The current stored group data
|
||||
*
|
||||
* @return array An associative array containing the rank title (title),
|
||||
* the rank image as full img tag (img) and the rank image source (img_src)
|
||||
*/
|
||||
public function get_rank($group_data)
|
||||
{
|
||||
$group_rank_data = array(
|
||||
'title' => null,
|
||||
'img' => null,
|
||||
'img_src' => null,
|
||||
);
|
||||
|
||||
/**
|
||||
* Preparing a group's rank before displaying
|
||||
*
|
||||
* @event core.get_group_rank_before
|
||||
* @var array group_data Array with group's data
|
||||
* @since 3.2.8-RC1
|
||||
*/
|
||||
|
||||
$vars = array('group_data');
|
||||
extract($this->dispatcher->trigger_event('core.get_group_rank_before', compact($vars)));
|
||||
|
||||
if (!empty($group_data['group_rank']))
|
||||
{
|
||||
// Only obtain ranks if group rank is set
|
||||
$ranks = $this->cache->obtain_ranks();
|
||||
|
||||
if (isset($ranks['special'][$group_data['group_rank']]))
|
||||
{
|
||||
$rank = $ranks['special'][$group_data['group_rank']];
|
||||
|
||||
$group_rank_data['title'] = $rank['rank_title'];
|
||||
|
||||
$group_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $this->path_helper->update_web_root_path($this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image']) : '';
|
||||
|
||||
/** @html Group rank image element for usage in the template */
|
||||
$group_rank_data['img'] = (!empty($rank['rank_image'])) ? '<img src="' . $group_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a group's rank before displaying
|
||||
*
|
||||
* @event core.get_group_rank_after
|
||||
* @var array group_data Array with group's data
|
||||
* @var array group_rank_data Group rank data
|
||||
* @since 3.2.8-RC1
|
||||
*/
|
||||
|
||||
$vars = array(
|
||||
'group_data',
|
||||
'group_rank_data',
|
||||
);
|
||||
extract($this->dispatcher->trigger_event('core.get_group_rank_after', compact($vars)));
|
||||
|
||||
return $group_rank_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group avatar.
|
||||
* Wrapper function for phpbb_get_group_avatar()
|
||||
*
|
||||
* @param array $group_row Row from the groups table
|
||||
* @param string $alt Optional language string for alt tag within image, can be a language key or text
|
||||
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
|
||||
* @param bool $lazy If true, will be lazy loaded (requires JS)
|
||||
*
|
||||
* @return string Avatar html
|
||||
*/
|
||||
function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
|
||||
{
|
||||
return phpbb_get_group_avatar($group_row, $alt, $ignore_config, $lazy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ class bbcode extends controller
|
||||
{
|
||||
$this->language->add_lang('help/bbcode');
|
||||
|
||||
$this->template->assign_block_vars('navlinks', array(
|
||||
'BREADCRUMB_NAME' => $this->language->lang('BBCODE_GUIDE'),
|
||||
'U_BREADCRUMB' => $this->helper->route('phpbb_help_bbcode_controller'),
|
||||
));
|
||||
|
||||
$this->manager->add_block(
|
||||
'HELP_BBCODE_BLOCK_INTRO',
|
||||
false,
|
||||
|
||||
@@ -25,6 +25,11 @@ class faq extends controller
|
||||
{
|
||||
$this->language->add_lang('help/faq');
|
||||
|
||||
$this->template->assign_block_vars('navlinks', array(
|
||||
'BREADCRUMB_NAME' => $this->language->lang('FAQ_EXPLAIN'),
|
||||
'U_BREADCRUMB' => $this->helper->route('phpbb_help_faq_controller'),
|
||||
));
|
||||
|
||||
$this->manager->add_block(
|
||||
'HELP_FAQ_BLOCK_LOGIN',
|
||||
false,
|
||||
|
||||
@@ -267,7 +267,7 @@ class helper
|
||||
'L_SKIP' => $this->language->lang('SKIP'),
|
||||
'PAGE_TITLE' => $this->language->lang($page_title),
|
||||
'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images',
|
||||
'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js',
|
||||
'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery-3.4.1.min.js',
|
||||
'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style',
|
||||
'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets',
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class container_factory
|
||||
$this->request->disable_super_globals();
|
||||
}
|
||||
|
||||
// Get compatibilty globals and constants
|
||||
// Get compatibility globals and constants
|
||||
$this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext);
|
||||
|
||||
register_compatibility_globals();
|
||||
|
||||
@@ -45,15 +45,6 @@ class database
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
'mysql' => array(
|
||||
'LABEL' => 'MySQL',
|
||||
'SCHEMA' => 'mysql',
|
||||
'MODULE' => 'mysql',
|
||||
'DELIM' => ';',
|
||||
'DRIVER' => 'phpbb\db\driver\mysql',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
'mssql_odbc'=> array(
|
||||
'LABEL' => 'MS SQL Server [ ODBC ]',
|
||||
'SCHEMA' => 'mssql',
|
||||
@@ -256,7 +247,6 @@ class database
|
||||
$dbms_info = $this->get_available_dbms($dbms);
|
||||
switch ($dbms_info[$dbms]['SCHEMA'])
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql_41':
|
||||
$prefix_length = 36;
|
||||
break;
|
||||
@@ -382,14 +372,6 @@ class database
|
||||
// Check if database version is supported
|
||||
switch ($dbms)
|
||||
{
|
||||
case 'mysqli':
|
||||
if (version_compare($db->sql_server_info(true), '4.1.3', '<'))
|
||||
{
|
||||
$errors[] = array(
|
||||
'title' => 'INST_ERR_DB_NO_MYSQLI',
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'sqlite3':
|
||||
if (version_compare($db->sql_server_info(true), '3.6.15', '<'))
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ interface iohandler_interface
|
||||
* @param string $name Name of the input variable to obtain
|
||||
* @param mixed $default A default value that is returned if the variable was not set.
|
||||
* This function will always return a value of the same type as the default.
|
||||
* @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
|
||||
* @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters
|
||||
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
|
||||
*
|
||||
* @return mixed Value of the input variable
|
||||
|
||||
@@ -48,9 +48,9 @@ class installer_configuration implements ConfigurationInterface
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->scalarNode('description')
|
||||
->defaultValue('My amazing new phpBB board')
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->defaultValue('My amazing new phpBB board')
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('database')
|
||||
@@ -128,12 +128,11 @@ class installer_configuration implements ConfigurationInterface
|
||||
->integerNode('server_port')
|
||||
->defaultValue(80)
|
||||
->min(1)
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->scalarNode('script_path')
|
||||
->defaultValue('/')
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('extensions')
|
||||
|
||||
@@ -245,7 +245,6 @@ class add_config_settings extends \phpbb\install\task_base
|
||||
user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "',
|
||||
user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "',
|
||||
user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "',
|
||||
user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ",
|
||||
username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "'
|
||||
WHERE username = 'Admin'",
|
||||
|
||||
|
||||
@@ -129,14 +129,7 @@ class create_schema extends \phpbb\install\task_base
|
||||
|
||||
if ($dbms === 'mysql')
|
||||
{
|
||||
if (version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
|
||||
{
|
||||
$schema_name .= '_41';
|
||||
}
|
||||
else
|
||||
{
|
||||
$schema_name .= '_40';
|
||||
}
|
||||
$schema_name .= '_41';
|
||||
}
|
||||
|
||||
$db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
|
||||
|
||||
@@ -102,14 +102,7 @@ class set_up_database extends \phpbb\install\task_base
|
||||
|
||||
if ($dbms === 'mysql')
|
||||
{
|
||||
if (version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
|
||||
{
|
||||
$schema_name .= '_41';
|
||||
}
|
||||
else
|
||||
{
|
||||
$schema_name .= '_40';
|
||||
}
|
||||
$schema_name .= '_41';
|
||||
}
|
||||
|
||||
$this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
|
||||
|
||||
@@ -165,7 +165,7 @@ class create_config_file extends \phpbb\install\task_base
|
||||
protected function get_config_data($debug = false, $debug_container = false, $environment = null)
|
||||
{
|
||||
$config_content = "<?php\n";
|
||||
$config_content .= "// phpBB 3.2.x auto-generated configuration file\n// Do not change anything in this file!\n";
|
||||
$config_content .= "// phpBB 3.3.x auto-generated configuration file\n// Do not change anything in this file!\n";
|
||||
|
||||
$dbms = $this->install_config->get('dbms');
|
||||
$db_driver = $this->db_helper->get_available_dbms($dbms);
|
||||
@@ -191,7 +191,6 @@ class create_config_file extends \phpbb\install\task_base
|
||||
}
|
||||
|
||||
$config_content .= "\n@define('PHPBB_INSTALLED', true);\n";
|
||||
$config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n";
|
||||
|
||||
if ($environment)
|
||||
{
|
||||
|
||||
@@ -96,9 +96,7 @@ class check_server_environment extends \phpbb\install\task_base
|
||||
*/
|
||||
protected function check_php_version()
|
||||
{
|
||||
$php_version = PHP_VERSION;
|
||||
|
||||
if (version_compare($php_version, '5.4') < 0)
|
||||
if (version_compare(PHP_VERSION, '7.1.3', '<'))
|
||||
{
|
||||
$this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN');
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ abstract class module_base implements module_interface
|
||||
$name,
|
||||
));
|
||||
|
||||
$this->install_config->increment_current_task_progress($this->task_step_count[$name]);
|
||||
$this->install_config->increment_current_task_progress($this->task_step_count[$name] ?? false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -151,6 +151,7 @@ class language_file_loader
|
||||
*
|
||||
* @param string $path Path to language directory
|
||||
* @param string $filename Filename to load language strings from
|
||||
* @param array $locales Array containing language fallback options
|
||||
*
|
||||
* @return string Relative path to language file
|
||||
*
|
||||
|
||||
@@ -110,6 +110,13 @@ class db
|
||||
// process we failed to acquire the lock.
|
||||
$this->locked = $this->config->set_atomic($this->config_name, $lock_value, $this->unique_id, false);
|
||||
|
||||
if ($this->locked == true)
|
||||
{
|
||||
if ($this->config->ensure_lock($this->config_name, $this->unique_id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return $this->locked;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,10 @@ class flock
|
||||
|
||||
if ($this->lock_fp)
|
||||
{
|
||||
@flock($this->lock_fp, LOCK_EX);
|
||||
if (!@flock($this->lock_fp, LOCK_EX))
|
||||
{
|
||||
throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.');
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $this->lock_fp;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user