diff options
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/config/default/container/services_console.yml | 37 | ||||
| -rw-r--r-- | phpBB/docs/CHANGELOG.html | 63 | ||||
| -rw-r--r-- | phpBB/language/en/cli.php | 19 | ||||
| -rw-r--r-- | phpBB/language/en/install.php | 22 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/user/activate.php | 218 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/user/add.php | 32 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/user/delete.php | 170 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/user/reclean.php | 198 | ||||
| -rw-r--r-- | phpBB/phpbb/controller/helper.php | 18 | ||||
| -rw-r--r-- | phpBB/phpbb/db/migration/data/v31x/v319rc1.php | 36 | ||||
| -rw-r--r-- | phpBB/phpbb/di/container_builder.php | 16 | ||||
| -rw-r--r-- | phpBB/phpbb/install/module/requirements/task/check_filesystem.php | 8 | ||||
| -rw-r--r-- | phpBB/phpbb/install/module_base.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/routing/helper.php | 11 | ||||
| -rw-r--r-- | phpBB/posting.php | 3 | ||||
| -rw-r--r-- | phpBB/web.config | 7 | 
16 files changed, 816 insertions, 44 deletions
diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index 0a28c0ed1f..3f27ee666a 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -220,6 +220,21 @@ services:          tags:              - { name: console.command } +    console.command.user.activate: +        class: phpbb\console\command\user\activate +        arguments: +            - '@user' +            - '@dbal.conn' +            - '@config' +            - '@language' +            - '@log' +            - '@notification_manager' +            - '@user_loader' +            - '%core.root_path%' +            - '%core.php_ext%' +        tags: +            - { name: console.command } +      console.command.user.add:          class: phpbb\console\command\user\add          arguments: @@ -232,3 +247,25 @@ services:              - '%core.php_ext%'          tags:              - { name: console.command } + +    console.command.user.delete: +        class: phpbb\console\command\user\delete +        arguments: +            - '@user' +            - '@dbal.conn' +            - '@language' +            - '@log' +            - '@user_loader' +            - '%core.root_path%' +            - '%core.php_ext%' +        tags: +            - { name: console.command } + +    console.command.user.reclean: +        class: phpbb\console\command\user\reclean +        arguments: +            - '@user' +            - '@dbal.conn' +            - '@language' +        tags: +            - { name: console.command } diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 10dc48b801..08c582b896 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -53,6 +53,7 @@  		<li><a href="#v320a2">Changes since 3.2.0-a2</a></li>  		<li><a href="#v320a1">Changes since 3.2.0-a1</a></li>  		<li><a href="#v31x">Changes since 3.1.x</a></li> +		<li><a href="#v318">Changes since 3.1.8</a></li>  		<li><a href="#v317pl1">Changes since 3.1.7-PL1</a></li>  		<li><a href="#v317">Changes since 3.1.7</a></li>  		<li><a href="#v316">Changes since 3.1.6</a></li> @@ -439,6 +440,68 @@  				<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14265">PHPBB3-14265</a>] - Make all tables available in the container</li>  			</ul> +			<a name="v318"></a><h3>Changes since 3.1.8</h3> + +	<h4>Bug</h4> +	<ul> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8058">PHPBB3-8058</a>] - Default style in ACP->Board Settings not observing offset</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13028">PHPBB3-13028</a>] - "View unanswered posts" link should be called instead "View unanswered topics"</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13264">PHPBB3-13264</a>] - Editing an unapproved post as a moderator/admin approves it</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13521">PHPBB3-13521</a>] - Q&A Captcha ACP, required fields error corrupts inputted data</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13630">PHPBB3-13630</a>] - NULL value parsed into $select_single can cause 403 Forbidden on certain restrictive hosting environments for "Find a Member" function within Private Message composition</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13681">PHPBB3-13681</a>] - Email queue shouldn't be cached by opcache</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13683">PHPBB3-13683</a>] - Controller generates urls with absolute path of phpbb's root</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13842">PHPBB3-13842</a>] - Missing rewrite module on IIS7 leads to an error</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13977">PHPBB3-13977</a>] - Fatal error entering UCP if bookmarked topic was deleted</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14132">PHPBB3-14132</a>] - SQL Error when creating a new subject on fresh installation</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14136">PHPBB3-14136</a>] - IE compatibility meta is missing in overall_header.html</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14241">PHPBB3-14241</a>] - Security bug into Spambot control Questions</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14272">PHPBB3-14272</a>] - Use valid html5 input elements in forms</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14290">PHPBB3-14290</a>] - Function set_modified_headers() never sends 304 'Not Modified' header</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14408">PHPBB3-14408</a>] - Remove span corners</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14422">PHPBB3-14422</a>] - Support cmd+enter & ctrl+enter for submitting message</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14437">PHPBB3-14437</a>] - Place Inline Images on Post get scrambled up -- not follow the order you place them in.</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14443">PHPBB3-14443</a>] - jabber notification-template prefix "short" breaks resolution of paths in extensions</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14475">PHPBB3-14475</a>] - Do not log upon automatically removing users form newly registered users group</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14481">PHPBB3-14481</a>] - phpBB does not obey HTTP_X_FORWARDED_PORT header</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14483">PHPBB3-14483</a>] - call to header(arg, arg) function sendHeaders() in Response.php causes Error 500 in app.php generated links</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14496">PHPBB3-14496</a>] - Automatic update relies on cache creating files in cache folder</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14500">PHPBB3-14500</a>] - Duplicate newversion in build.xml</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14514">PHPBB3-14514</a>] - Users get skipped in passwords_convert_p1 migration</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14519">PHPBB3-14519</a>] - Do not query database for unread notifications if all are retrieved</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14532">PHPBB3-14532</a>] - Database column default incorrectly escaped on MSSQL</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14533">PHPBB3-14533</a>] - "U_NOTIFICATION_SETTINGS" doesn't return the correct URL</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14536">PHPBB3-14536</a>] - Force timestamp to be integer in user::format_date()</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14559">PHPBB3-14559</a>] - Attachments' behaviour in quotes</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14562">PHPBB3-14562</a>] - Extension's permissions don't have language fallback</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14570">PHPBB3-14570</a>] - Board versions for 3.2.x can be accidentally downgraded to 3.1.x</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14577">PHPBB3-14577</a>] - Stop using sizeof() inside for() loop</li> +	</ul> +	<h4>Improvement</h4> +	<ul> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10356">PHPBB3-10356</a>] - Username search should find all users for administrators instead of NORMALs and FOUNDERs only</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-12305">PHPBB3-12305</a>] - Add new event core.viewforum_get_topic_id_sql to control forum topic listing</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14134">PHPBB3-14134</a>] - Send warning notification PM in user's language.</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14316">PHPBB3-14316</a>] - Add memberlist_view.html template events before/after the custom fields and zebra links</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14365">PHPBB3-14365</a>] - Add core event to the function topic_review() </li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14366">PHPBB3-14366</a>] - Add core events to the function decode_message()</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14395">PHPBB3-14395</a>] - Add event core.viewtopic_add_quickmod_option_after</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14471">PHPBB3-14471</a>] - Add filedata var to the core.avatar_driver_upload_move_file_before event</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14486">PHPBB3-14486</a>] - Add an event and fix an event in login_box()</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14508">PHPBB3-14508</a>] - Change language notice on account activation</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14540">PHPBB3-14540</a>] - Adjust class recursive_dot_prefix_filter_iterator to increase performance</li> +	</ul> +	<h4>New Feature</h4> +	<ul> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-12684">PHPBB3-12684</a>] - Add a command to add a user from the CLI</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14189">PHPBB3-14189</a>] - [PHP] - core.gen_sort_selects_after</li> +	</ul> +	<h4>Task</h4> +	<ul> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14538">PHPBB3-14538</a>] - Update composer dependencies</li> +		<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14565">PHPBB3-14565</a>] - Updates composer to 1.0.0-b2</li> +	</ul> +  	<a name="v317pl1"></a><h3>Changes since 3.1.7-PL1</h3>  	<h4>Bug</h4> diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php index 6cb516ebfd..db4b5f9ec6 100644 --- a/phpBB/language/en/cli.php +++ b/phpBB/language/en/cli.php @@ -82,11 +82,20 @@ $lang = array_merge($lang, array(  	'CLI_DESCRIPTION_THUMBNAIL_GENERATE'	=> 'Generate all missing thumbnails.',  	'CLI_DESCRIPTION_THUMBNAIL_RECREATE'	=> 'Recreate all thumbnails.', +	'CLI_DESCRIPTION_USER_ACTIVATE'				=> 'Activate (or deactivate) a user account.', +	'CLI_DESCRIPTION_USER_ACTIVATE_USERNAME'	=> 'Username of the account to activate.', +	'CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE'	=> 'Deactivate the user’s account', +	'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'		=> 'The user is already active.', +	'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'	=> 'The user is already inactive.',  	'CLI_DESCRIPTION_USER_ADD'					=> 'Add a new user.',  	'CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME'	=> 'Username of the new user',  	'CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD'	=> 'Password of the new user',  	'CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL'		=> 'E-mail address of the new user',  	'CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY'	=> 'Send account activation email to the new user (not sent by default)', +	'CLI_DESCRIPTION_USER_DELETE'				=> 'Delete a user account.', +	'CLI_DESCRIPTION_USER_DELETE_USERNAME'		=> 'Username of the user to delete', +	'CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS'	=> 'Delete all posts by the user. Without this option, the user’s posts will be retained.', +	'CLI_DESCRIPTION_USER_RECLEAN'				=> 'Re-clean usernames.',  	'CLI_EXTENSION_DISABLE_FAILURE'		=> 'Could not disable extension %s',  	'CLI_EXTENSION_DISABLE_SUCCESS'		=> 'Successfully disabled extension %s', @@ -126,12 +135,22 @@ $lang = array_merge($lang, array(  	'CLI_THUMBNAIL_NOTHING_TO_DELETE'	=> 'No thumbnails to delete.',  	'CLI_USER_ADD_SUCCESS'		=> 'Successfully added user %s.', +	'CLI_USER_DELETE_CONFIRM'	=> 'Are you sure you want to delete ‘%s’? [y/N]', +	'CLI_USER_RECLEAN_START'	=> 'Re-cleaning usernames', +	'CLI_USER_RECLEAN_DONE'		=> [ +		0	=> 'Re-cleaning complete. No usernames needed to be cleaned.', +		1	=> 'Re-cleaning complete. %d username was cleaned.', +		2	=> 'Re-cleaning complete. %d usernames were cleaned.', +	],  ));  // Additional help for commands.  $lang = array_merge($lang, array(  	'CLI_HELP_CRON_RUN'			=> $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.', +	'CLI_HELP_USER_ACTIVATE'	=> 'Activate a user account, or deactivate an account using the <info>--deactivate</info> option. +To optionally send an activation email to the user, use the <info>--send-email</info> option.',  	'CLI_HELP_USER_ADD'			=> 'The <info>%command.name%</info> command adds a new user:  If this command is run without options, you will be prompted to enter them.  To optionally send an email to the new user, use the <info>--send-email</info> option.', +	'CLI_HELP_USER_RECLEAN'		=> 'Re-clean usernames will check all stored usernames and ensure clean versions are also stored. Cleaned usernames are a case insensitive form, NFC normalized and transformed to ASCII.',  )); diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 9a727be649..88cbaf1533 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -90,15 +90,19 @@ $lang = array_merge($lang, array(  // Requirements translation  $lang = array_merge($lang, array(  	// Filesystem requirements -	'FILE_NOT_EXISTS'			=> 'File not exists', -	'FILE_NOT_EXISTS_EXPLAIN'	=> 'To be able to install phpBB the %1$s file needs to exist.', -	'FILE_NOT_WRITABLE'			=> 'File not writable', -	'FILE_NOT_WRITABLE_EXPLAIN'	=> 'To be able to install phpBB the %1$s file needs to be writable.', - -	'DIRECTORY_NOT_EXISTS'				=> 'Directory not exists', -	'DIRECTORY_NOT_EXISTS_EXPLAIN'		=> 'To be able to install phpBB the %1$s directory needs to exist.', -	'DIRECTORY_NOT_WRITABLE'			=> 'Directory not writable', -	'DIRECTORY_NOT_WRITABLE_EXPLAIN'	=> 'To be able to install phpBB the %1$s directory needs to be writable.', +	'FILE_NOT_EXISTS'						=> 'File does not exist', +	'FILE_NOT_EXISTS_EXPLAIN'				=> 'To be able to install phpBB the %1$s file needs to exist.', +	'FILE_NOT_EXISTS_EXPLAIN_OPTIONAL'		=> 'It is recommended that the %1$s file exist for a better forum user experience.', +	'FILE_NOT_WRITABLE'						=> 'File is not writable', +	'FILE_NOT_WRITABLE_EXPLAIN'				=> 'To be able to install phpBB the %1$s file needs to be writable.', +	'FILE_NOT_WRITABLE_EXPLAIN_OPTIONAL'	=> 'It is recommended that the %1$s file be writable for a better forum user experience.', + +	'DIRECTORY_NOT_EXISTS'						=> 'Directory does not exist', +	'DIRECTORY_NOT_EXISTS_EXPLAIN'				=> 'To be able to install phpBB the %1$s directory needs to exist.', +	'DIRECTORY_NOT_EXISTS_EXPLAIN_OPTIONAL'		=> 'It is recommended that the %1$s directory exist for a better forum user experience.', +	'DIRECTORY_NOT_WRITABLE'					=> 'Directory is not writable', +	'DIRECTORY_NOT_WRITABLE_EXPLAIN'			=> 'To be able to install phpBB the %1$s directory needs to be writable.', +	'DIRECTORY_NOT_WRITABLE_EXPLAIN_OPTIONAL'	=> 'It is recommended that the %1$s directory be writable for a better forum user experience.',  	// Server requirements  	'PHP_VERSION_REQD'					=> 'PHP version', diff --git a/phpBB/phpbb/console/command/user/activate.php b/phpBB/phpbb/console/command/user/activate.php new file mode 100644 index 0000000000..9c85718b4c --- /dev/null +++ b/phpBB/phpbb/console/command/user/activate.php @@ -0,0 +1,218 @@ +<?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\console\command\user; + +use phpbb\config\config; +use phpbb\console\command\command; +use phpbb\db\driver\driver_interface; +use phpbb\language\language; +use phpbb\log\log_interface; +use phpbb\notification\manager; +use phpbb\user; +use phpbb\user_loader; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +class activate extends command +{ +	/** @var driver_interface */ +	protected $db; + +	/** @var config */ +	protected $config; + +	/** @var language */ +	protected $language; + +	/** @var log_interface */ +	protected $log; + +	/** @var manager */ +	protected $notifications; + +	/** @var user_loader */ +	protected $user_loader; + +	/** +	 * phpBB root path +	 * +	 * @var string +	 */ +	protected $phpbb_root_path; + +	/** +	 * PHP extension. +	 * +	 * @var string +	 */ +	protected $php_ext; + +	/** +	 * Construct method +	 * +	 * @param user             $user +	 * @param driver_interface $db +	 * @param config           $config +	 * @param language         $language +	 * @param log_interface    $log +	 * @param manager          $notifications +	 * @param user_loader      $user_loader +	 * @param string           $phpbb_root_path +	 * @param string           $php_ext +	 */ +	public function __construct(user $user, driver_interface $db, config $config, language $language, log_interface $log, manager $notifications, user_loader $user_loader, $phpbb_root_path, $php_ext) +	{ +		$this->db = $db; +		$this->config = $config; +		$this->language = $language; +		$this->log = $log; +		$this->notifications = $notifications; +		$this->user_loader = $user_loader; +		$this->phpbb_root_path = $phpbb_root_path; +		$this->php_ext = $php_ext; + +		$this->language->add_lang('acp/users'); +		parent::__construct($user); +	} + +	/** +	 * Sets the command name and description +	 * +	 * @return null +	 */ +	protected function configure() +	{ +		$this +			->setName('user:activate') +			->setDescription($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE')) +			->setHelp($this->language->lang('CLI_HELP_USER_ACTIVATE')) +			->addArgument( +				'username', +				InputArgument::REQUIRED, +				$this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_USERNAME') +			) +			->addOption( +				'deactivate', +				'd', +				InputOption::VALUE_NONE, +				$this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE') +			) +			->addOption( +				'send-email', +				null, +				InputOption::VALUE_NONE, +				$this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY') +			) +		; +	} + +	/** +	 * Executes the command user:activate +	 * +	 * Activate (or deactivate) a user account +	 * +	 * @param InputInterface  $input  The input stream used to get the options +	 * @param OutputInterface $output The output stream, used to print messages +	 * +	 * @return int 0 if all is well, 1 if any errors occurred +	 */ +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		$io = new SymfonyStyle($input, $output); + +		$name = $input->getArgument('username'); +		$mode = ($input->getOption('deactivate')) ? 'deactivate' : 'activate'; + +		$user_id  = $this->user_loader->load_user_by_username($name); +		$user_row = $this->user_loader->get_user($user_id); + +		if ($user_row['user_id'] == ANONYMOUS) +		{ +			$io->error($this->language->lang('NO_USER')); +			return 1; +		} + +		// Check if the user is already active (or inactive) +		if ($mode == 'activate' && $user_row['user_type'] != USER_INACTIVE) +		{ +			$io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE')); +			return 1; +		} +		else if ($mode == 'deactivate' && $user_row['user_type'] == USER_INACTIVE) +		{ +			$io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE')); +			return 1; +		} + +		// Activate the user account +		if (!function_exists('user_active_flip')) +		{ +			require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); +		} + +		user_active_flip($mode, $user_row['user_id']); + +		// Notify the user upon activation +		if ($mode == 'activate' && $this->config['require_activation'] == USER_ACTIVATION_ADMIN) +		{ +			$this->send_notification($user_row, $input); +		} + +		// Log and display the result +		$msg = ($mode == 'activate') ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; +		$log = ($mode == 'activate') ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; + +		$this->log->add('admin', ANONYMOUS, '', $log, false, array($user_row['username'])); +		$this->log->add('user', ANONYMOUS, '', $log . '_USER', false, array( +			'reportee_id' => $user_row['user_id'] +		)); + +		$io->success($this->language->lang($msg)); + +		return 0; +	} + +	/** +	 * Send account activation notification to user +	 * +	 * @param array           $user_row The user data array +	 * @param InputInterface  $input    The input stream used to get the options +	 * @return null +	 */ +	protected function send_notification($user_row, InputInterface $input) +	{ +		$this->notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); + +		if ($input->getOption('send-email')) +		{ +			if (!class_exists('messenger')) +			{ +				require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); +			} + +			$messenger = new \messenger(false); +			$messenger->template('admin_welcome_activated', $user_row['user_lang']); +			$messenger->set_addresses($user_row); +			$messenger->anti_abuse_headers($this->config, $this->user); +			$messenger->assign_vars(array( +					'USERNAME'	=> htmlspecialchars_decode($user_row['username'])) +			); + +			$messenger->send(NOTIFY_EMAIL); +		} +	} +} diff --git a/phpBB/phpbb/console/command/user/add.php b/phpBB/phpbb/console/command/user/add.php index df1f4aa54a..c60a059251 100644 --- a/phpBB/phpbb/console/command/user/add.php +++ b/phpBB/phpbb/console/command/user/add.php @@ -13,28 +13,34 @@  namespace phpbb\console\command\user; +use phpbb\config\config; +use phpbb\console\command\command; +use phpbb\db\driver\driver_interface;  use phpbb\exception\runtime_exception; +use phpbb\language\language; +use phpbb\passwords\manager; +use phpbb\user;  use Symfony\Component\Console\Input\InputInterface;  use Symfony\Component\Console\Input\InputOption;  use Symfony\Component\Console\Output\OutputInterface;  use Symfony\Component\Console\Question\Question;  use Symfony\Component\Console\Style\SymfonyStyle; -class add extends \phpbb\console\command\command +class add extends command  {  	/** @var array Array of interactively acquired options */  	protected $data; -	/** @var \phpbb\db\driver\driver_interface */ +	/** @var driver_interface */  	protected $db; -	/** @var \phpbb\config\config */ +	/** @var config */  	protected $config; -	/** @var \phpbb\language\language */ +	/** @var language */  	protected $language; -	/** @var \phpbb\passwords\manager */ +	/** @var manager */  	protected $password_manager;  	/** @@ -54,15 +60,15 @@ class add extends \phpbb\console\command\command  	/**  	 * Construct method  	 * -	 * @param \phpbb\user                       $user -	 * @param \phpbb\db\driver\driver_interface $db -	 * @param \phpbb\config\config              $config -	 * @param \phpbb\language\language          $language -	 * @param \phpbb\passwords\manager          $password_manager -	 * @param string                            $phpbb_root_path -	 * @param string                            $php_ext +	 * @param user             $user +	 * @param driver_interface $db +	 * @param config           $config +	 * @param language         $language +	 * @param manager          $password_manager +	 * @param string           $phpbb_root_path +	 * @param string           $php_ext  	 */ -	public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\language\language $language, \phpbb\passwords\manager $password_manager, $phpbb_root_path, $php_ext) +	public function __construct(user $user, driver_interface $db, config $config, language $language, manager $password_manager, $phpbb_root_path, $php_ext)  	{  		$this->db = $db;  		$this->config = $config; diff --git a/phpBB/phpbb/console/command/user/delete.php b/phpBB/phpbb/console/command/user/delete.php new file mode 100644 index 0000000000..8593541c1a --- /dev/null +++ b/phpBB/phpbb/console/command/user/delete.php @@ -0,0 +1,170 @@ +<?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\console\command\user; + +use phpbb\console\command\command; +use phpbb\db\driver\driver_interface; +use phpbb\language\language; +use phpbb\log\log_interface; +use phpbb\user; +use phpbb\user_loader; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Style\SymfonyStyle; + +class delete extends command +{ +	/** @var driver_interface */ +	protected $db; + +	/** @var language */ +	protected $language; + +	/** @var log_interface */ +	protected $log; + +	/** @var user_loader */ +	protected $user_loader; + +	/** +	 * phpBB root path +	 * +	 * @var string +	 */ +	protected $phpbb_root_path; + +	/** +	 * PHP extension. +	 * +	 * @var string +	 */ +	protected $php_ext; + +	/** +	 * Construct method +	 * +	 * @param user             $user +	 * @param driver_interface $db +	 * @param language         $language +	 * @param log_interface    $log +	 * @param user_loader      $user_loader +	 * @param string           $phpbb_root_path +	 * @param string           $php_ext +	 */ +	public function __construct(user $user, driver_interface $db, language $language, log_interface $log, user_loader $user_loader, $phpbb_root_path, $php_ext) +	{ +		$this->db = $db; +		$this->language = $language; +		$this->log = $log; +		$this->user_loader = $user_loader; +		$this->phpbb_root_path = $phpbb_root_path; +		$this->php_ext = $php_ext; + +		$this->language->add_lang('acp/users'); +		parent::__construct($user); +	} + +	/** +	 * Sets the command name and description +	 * +	 * @return null +	 */ +	protected function configure() +	{ +		$this +			->setName('user:delete') +			->setDescription($this->language->lang('CLI_DESCRIPTION_USER_DELETE')) +			->addArgument( +				'username', +				InputArgument::REQUIRED, +				$this->language->lang('CLI_DESCRIPTION_USER_DELETE_USERNAME') +			) +			->addOption( +				'delete-posts', +				null, +				InputOption::VALUE_NONE, +				$this->language->lang('CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS') +			) +		; +	} + +	/** +	 * Executes the command user:delete +	 * +	 * Deletes a user from the database. An option to delete the user's posts +	 * is available, by default posts will be retained. +	 * +	 * @param InputInterface  $input  The input stream used to get the options +	 * @param OutputInterface $output The output stream, used to print messages +	 * +	 * @return int 0 if all is well, 1 if any errors occurred +	 */ +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		$name = $input->getArgument('username'); +		$mode = ($input->getOption('delete-posts')) ? 'remove' : 'retain'; + +		if ($name) +		{ +			$io = new SymfonyStyle($input, $output); + +			$user_id  = $this->user_loader->load_user_by_username($name); +			$user_row = $this->user_loader->get_user($user_id); + +			if ($user_row['user_id'] == ANONYMOUS) +			{ +				$io->error($this->language->lang('NO_USER')); +				return 1; +			} + +			if (!function_exists('user_delete')) +			{ +				require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); +			} + +			user_delete($mode, $user_row['user_id'], $user_row['username']); + +			$this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username'])); + +			$io->success($this->language->lang('USER_DELETED')); +		} + +		return 0; +	} + +	/** +	 * Interacts with the user. +	 * Confirm they really want to delete the account...last chance! +	 * +	 * @param InputInterface  $input  An InputInterface instance +	 * @param OutputInterface $output An OutputInterface instance +	 */ +	protected function interact(InputInterface $input, OutputInterface $output) +	{ +		$helper = $this->getHelper('question'); + +		$question = new ConfirmationQuestion( +			$this->language->lang('CLI_USER_DELETE_CONFIRM', $input->getArgument('username')), +			false +		); + +		if (!$helper->ask($input, $output, $question)) +		{ +			$input->setArgument('username', false); +		} +	} +} diff --git a/phpBB/phpbb/console/command/user/reclean.php b/phpBB/phpbb/console/command/user/reclean.php new file mode 100644 index 0000000000..e298c285be --- /dev/null +++ b/phpBB/phpbb/console/command/user/reclean.php @@ -0,0 +1,198 @@ +<?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\console\command\user; + +use phpbb\console\command\command; +use phpbb\db\driver\driver_interface; +use phpbb\language\language; +use phpbb\user; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +class reclean extends command +{ +	/** @var driver_interface */ +	protected $db; + +	/** @var language */ +	protected $language; + +	/** @var int A count of the number of re-cleaned user names */ +	protected $processed; + +	/** @var ProgressBar */ +	protected $progress; + +	/** +	 * Construct method +	 * +	 * @param user             $user +	 * @param driver_interface $db +	 * @param language         $language +	 */ +	public function __construct(user $user, driver_interface $db, language $language) +	{ +		$this->db = $db; +		$this->language = $language; + +		parent::__construct($user); +	} + +	/** +	 * Sets the command name and description +	 * +	 * @return null +	 */ +	protected function configure() +	{ +		$this +			->setName('user:reclean') +			->setDescription($this->language->lang('CLI_DESCRIPTION_USER_RECLEAN')) +			->setHelp($this->language->lang('CLI_HELP_USER_RECLEAN')) +		; +	} + +	/** +	 * Executes the command user:reclean +	 * +	 * Cleans user names that are unclean. +	 * +	 * @param InputInterface  $input  The input stream used to get the options +	 * @param OutputInterface $output The output stream, used to print messages +	 * +	 * @return int 0 if all is well, 1 if any errors occurred +	 */ +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		$io = new SymfonyStyle($input, $output); + +		$io->section($this->language->lang('CLI_USER_RECLEAN_START')); + +		$this->processed = 0; + +		$this->progress = $this->create_progress_bar($this->get_count(), $io, $output); +		$this->progress->setMessage($this->language->lang('CLI_USER_RECLEAN_START')); +		$this->progress->start(); + +		$stage = 0; +		while ($stage !== true) +		{ +			$stage = $this->reclean_usernames($stage); +		} + +		$this->progress->finish(); + +		$io->newLine(2); +		$io->success($this->language->lang('CLI_USER_RECLEAN_DONE', $this->processed)); + +		return 0; +	} + +	/** +	 * Re-clean user names +	 * Only user names that are unclean will be re-cleaned +	 * +	 * @param int $start An offset index +	 * @return bool|int Return the next offset index or true if all records have been processed. +	 */ +	protected function reclean_usernames($start = 0) +	{ +		$limit = 500; +		$i = 0; + +		$this->db->sql_transaction('begin'); + +		$sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE; +		$result = $this->db->sql_query_limit($sql, $limit, $start); +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$i++; +			$username_clean = $this->db->sql_escape(utf8_clean_string($row['username'])); + +			if ($username_clean != $row['username_clean']) +			{ +				$sql = 'UPDATE ' . USERS_TABLE . " +					SET username_clean = '$username_clean' +					WHERE user_id = {$row['user_id']}"; +				$this->db->sql_query($sql); + +				$this->processed++; +			} + +			$this->progress->advance(); +		} +		$this->db->sql_freeresult($result); + +		$this->db->sql_transaction('commit'); + +		return ($i < $limit) ? true : $start + $i; +	} + +	/** +	 * Create a styled progress bar +	 * +	 * @param integer         $max    Max value for the progress bar +	 * @param SymfonyStyle    $io +	 * @param OutputInterface $output The output stream, used to print messages +	 * @return ProgressBar +	 */ +	protected function create_progress_bar($max, SymfonyStyle $io, OutputInterface $output) +	{ +		$progress = $io->createProgressBar($max); +		if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) +		{ +			$progress->setFormat('<info>[%percent:3s%%]</info> %message%'); +			$progress->setOverwrite(false); +		} +		else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) +		{ +			$progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%'); +			$progress->setOverwrite(false); +		} +		else +		{ +			$io->newLine(2); +			$progress->setFormat( +				"    %current:s%/%max:s% %bar%  %percent:3s%%\n" . +				"                         %elapsed:6s%/%estimated:-6s% %memory:6s%\n"); +			$progress->setBarWidth(60); +		} + +		if (!defined('PHP_WINDOWS_VERSION_BUILD')) +		{ +			$progress->setEmptyBarCharacter('░'); // light shade character \u2591 +			$progress->setProgressCharacter(''); +			$progress->setBarCharacter('▓'); // dark shade character \u2593 +		} + +		return $progress; +	} + +	/** +	 * Get the count of users in the database +	 * +	 * @return int +	 */ +	protected function get_count() +	{ +		$sql = 'SELECT COUNT(user_id) AS count FROM ' . USERS_TABLE; +		$result = $this->db->sql_query($sql); +		$count = (int) $this->db->sql_fetchfield('count'); +		$this->db->sql_freeresult($result); + +		return $count; +	} +} diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 9dbc3737f7..664b4f4e0f 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -52,15 +52,15 @@ class helper  	protected $routing_helper;  	/** -	* Constructor -	* -	* @param \phpbb\template\template $template Template object -	* @param \phpbb\user $user User object -	* @param \phpbb\config\config $config Config object -	* @param \phpbb\symfony_request $symfony_request Symfony Request object -	* @param \phpbb\request\request_interface $request phpBB request object -	* @param \phpbb\routing\helper $routing_helper Helper to generate the routes -	*/ +	 * Constructor +	 * +	 * @param \phpbb\template\template $template Template object +	 * @param \phpbb\user $user User object +	 * @param \phpbb\config\config $config Config object +	 * @param \phpbb\symfony_request $symfony_request Symfony Request object +	 * @param \phpbb\request\request_interface $request phpBB request object +	 * @param \phpbb\routing\helper $routing_helper Helper to generate the routes +	 */  	public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\routing\helper $routing_helper)  	{  		$this->template = $template; diff --git a/phpBB/phpbb/db/migration/data/v31x/v319rc1.php b/phpBB/phpbb/db/migration/data/v31x/v319rc1.php new file mode 100644 index 0000000000..9805b45572 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v319rc1.php @@ -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\v31x; + +class v319rc1 extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return phpbb_version_compare($this->config['version'], '3.1.9-RC1', '>='); +	} + +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v318', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.9-RC1')), +		); +	} +} diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 0462fb60c2..b6854673c2 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -562,7 +562,13 @@ class container_builder  	 */  	protected function get_container_filename()  	{ -		return $this->get_cache_dir() . 'container_' . md5($this->phpbb_root_path) . '.' . $this->php_ext; +		$container_params = [ +			'phpbb_root_path' => $this->phpbb_root_path, +			'use_extensions' => $this->use_extensions, +			'config_path' => $this->config_path, +		]; + +		return $this->get_cache_dir() . 'container_' . md5(implode(',', $container_params)) . '.' . $this->php_ext;  	}  	/** @@ -572,7 +578,13 @@ class container_builder  	 */  	protected function get_autoload_filename()  	{ -		return $this->get_cache_dir() . 'autoload_' . md5($this->phpbb_root_path) . '.' . $this->php_ext; +		$container_params = [ +			'phpbb_root_path' => $this->phpbb_root_path, +			'use_extensions' => $this->use_extensions, +			'config_path' => $this->config_path, +		]; + +		return $this->get_cache_dir() . 'autoload_' . md5(implode(',', $container_params)) . '.' . $this->php_ext;  	}  	/** diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php index 2aec3915e0..868af39433 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php +++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php @@ -177,7 +177,9 @@ class check_filesystem extends \phpbb\install\task_base  		if (!($exists && $writable))  		{  			$title = ($exists) ? 'FILE_NOT_WRITABLE' : 'FILE_NOT_EXISTS'; -			$description = array($title . '_EXPLAIN', $file); +			$lang_suffix = '_EXPLAIN'; +			$lang_suffix .= ($failable) ? '_OPTIONAL' : ''; +			$description = array($title . $lang_suffix, $file);  			if ($failable)  			{ @@ -244,7 +246,9 @@ class check_filesystem extends \phpbb\install\task_base  		if (!($exists && $writable))  		{  			$title = ($exists) ? 'DIRECTORY_NOT_WRITABLE' : 'DIRECTORY_NOT_EXISTS'; -			$description = array($title . '_EXPLAIN', $dir); +			$lang_suffix = '_EXPLAIN'; +			$lang_suffix .= ($failable) ? '_OPTIONAL' : ''; +			$description = array($title . $lang_suffix, $dir);  			if ($failable)  			{ diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 527447b4a1..93c10bd656 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -172,7 +172,7 @@ abstract class module_base implements module_interface  			$this->iohandler->send_response();  			// Stop execution if resource limit is reached -			if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) +			if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0))  			{  				throw new resource_limit_reached_exception();  			} diff --git a/phpBB/phpbb/routing/helper.php b/phpBB/phpbb/routing/helper.php index f56974a354..c15608dce5 100644 --- a/phpBB/phpbb/routing/helper.php +++ b/phpBB/phpbb/routing/helper.php @@ -104,6 +104,15 @@ class helper  		$context = new RequestContext();  		$context->fromRequest($this->symfony_request); +		if ($this->config['force_server_vars']) +		{ +			$context->setHost($this->config['server_name']); +			$context->setScheme(substr($this->config['server_protocol'], 0, -3)); +			$context->setHttpPort($this->config['server_port']); +			$context->setHttpsPort($this->config['server_port']); +			$context->setBaseUrl(rtrim($this->config['script_path'], '/')); +		} +  		$script_name = $this->symfony_request->getScriptName();  		$page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); @@ -119,7 +128,7 @@ class helper  		$base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);  		// We need to update the base url to move to the directory of the app.php file if the current script is not app.php -		if ($page_name !== 'app.php') +		if ($page_name !== 'app.php' && !$this->config['force_server_vars'])  		{  			if (empty($this->config['enable_mod_rewrite']))  			{ diff --git a/phpBB/posting.php b/phpBB/posting.php index 9bd4acf99b..4986909148 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1593,6 +1593,9 @@ $message_parser->decode_message($post_data['bbcode_uid']);  if ($generate_quote)  { +	// Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any +	$message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message); +  	if ($config['allow_bbcode'])  	{  		$message_parser->message = $phpbb_container->get('text_formatter.utils')->generate_quote( diff --git a/phpBB/web.config b/phpBB/web.config index c7a1240453..99a1fe6023 100644 --- a/phpBB/web.config +++ b/phpBB/web.config @@ -1,12 +1,5 @@  <?xml version="1.0" encoding="UTF-8"?>  <configuration> -	<configSections> -		<sectionGroup name="system.webServer" > -			<sectionGroup name="rewrite"> -				<section name="rules" overrideModeDefault="Allow" /> -			</sectionGroup> -		</sectionGroup> -	</configSections>  	<system.webServer>  		<rewrite>  			<rules>  | 
