Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions phpBB/config/default/container/services_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ services:
tags:
- { name: cron.task }

cron.task.core.tidy_guest_sessions:
class: phpbb\cron\task\core\tidy_guest_sessions
arguments:
- '@config'
- '@user'
calls:
- [set_name, [cron.task.core.tidy_guest_sessions]]
tags:
- { name: cron.task }

cron.task.core.tidy_warnings:
class: phpbb\cron\task\core\tidy_warnings
arguments:
Expand Down
16 changes: 14 additions & 2 deletions phpBB/config/installer/container/services_install_data.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
services:
installer.install_data.add_ai_crawlers:
class: phpbb\install\module\install_data\task\add_ai_crawlers
arguments:
- '@installer.helper.config'
- '@installer.helper.iohandler'
- '@installer.helper.container_factory'
- '@language'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: install_data_install, order: 30 }

installer.install_data.add_bots:
class: phpbb\install\module\install_data\task\add_bots
arguments:
Expand Down Expand Up @@ -27,7 +39,7 @@ services:
- '@installer.helper.iohandler'
- '@installer.helper.container_factory'
tags:
- { name: install_data_install, order: 30 }
- { name: install_data_install, order: 40 }

installer.install_data.create_search_index:
class: phpbb\install\module\install_data\task\create_search_index
Expand All @@ -37,7 +49,7 @@ services:
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: install_data_install, order: 40 }
- { name: install_data_install, order: 50 }

installer.module.data_install_collection:
class: phpbb\di\ordered_service_collection
Expand Down
13 changes: 8 additions & 5 deletions phpBB/includes/acp/acp_board.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,14 @@ function main($id, $mode)
$display_vars = array(
'title' => 'ACP_LOAD_SETTINGS',
'vars' => array(
'legend1' => 'GENERAL_SETTINGS',
'limit_load' => array('lang' => 'LIMIT_LOAD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true),
'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:9999999999', 'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true),
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'legend1' => 'GENERAL_SETTINGS',
'limit_load' => array('lang' => 'LIMIT_LOAD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true),
'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:86400', 'type' => 'number:60:86400', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'session_gc' => array('lang' => 'SESSION_GC', 'validate' => 'int:60:86400', 'type' => 'number:60:86400', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'session_guest_length' => array('lang' => 'SESSION_GUEST_LENGTH', 'validate' => 'int:60:86400', 'type' => 'number:60:86400', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'session_guest_gc' => array('lang' => 'SESSION_GUEST_GC', 'validate' => 'int:60:86400', 'type' => 'number:60:86400', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true),
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'read_notification_expire_days' => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

'legend2' => 'GENERAL_OPTIONS',
Expand Down
4 changes: 4 additions & 0 deletions phpBB/install/schemas/schema_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_protocol', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_length', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_guest_length', '900');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_guest_gc', '900');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CONFIG_SITE_DESC}');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', '');
Expand Down Expand Up @@ -342,6 +344,7 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('repars
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_indexing_state', '', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_guest_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('smtp_password', '', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('smtp_username', '', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1);
Expand Down Expand Up @@ -541,6 +544,7 @@ INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_co
INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('ADMINISTRATORS', 3, 1, 'AA0000', 1, '', '', '', 0);
INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('BOTS', 3, 0, '9E8DA7', 0, '', '', '', 5);
INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5);
INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('AI_CRAWLERS', 3, 0, '7D9EAE', 0, '', '', '', 5);

# -- Teampage
INSERT INTO phpbb_teampage (group_id, teampage_name, teampage_position, teampage_parent) VALUES (5, '', 1, 0);
Expand Down
34 changes: 20 additions & 14 deletions phpBB/language/en/acp/board.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,26 @@
$lang = array_merge($lang, array(
'ACP_COOKIE_SETTINGS_EXPLAIN' => 'These details define the data used to send cookies to your users browsers. In most cases the default values for the cookie settings should be sufficient. If you do need to change any do so with care, incorrect settings can prevent users logging in. If you have problems with users staying logging in to your board, visit the <strong><a href="https://www.phpbb.com/support/go/cookie-settings">phpBB.com Knowledge Base - Fixing incorrect cookie settings</a></strong>.',

'COOKIE_DOMAIN' => 'Cookie domain',
'COOKIE_DOMAIN_EXPLAIN' => 'In most cases the cookie domain is optional. Leave it blank if you are unsure.<br><br> In the case where you have a board integrated with other software or have multiple domains, then to determine the cookie domain you need to do the following. If you have something like <i>example.com</i> and <i>forums.example.com</i>, or perhaps <i>forums.example.com</i> and <i>blog.example.com</i>. Remove the subdomains until you find the common domain, <i>example.com</i>. Now add a dot in front of the common domain and you would enter .example.com (note the dot at the beginning).',
'COOKIE_NAME' => 'Cookie name',
'COOKIE_NAME_EXPLAIN' => 'This can be anything what you want, make it original. Whenever the cookie settings are changed the name of the cookie should be changed.',
'COOKIE_NOTICE' => 'Cookie notice',
'COOKIE_NOTICE_EXPLAIN' => 'If enabled a cookie notice will be displayed to users when visiting your board. This might be required by law depending on the content of your board and enabled extensions.',
'COOKIE_PATH' => 'Cookie path',
'COOKIE_PATH_EXPLAIN' => 'This will usually be the same as your script path or simply a slash to make the cookie accessible across the site domain.',
'COOKIE_SECURE' => 'Cookie secure',
'COOKIE_SECURE_EXPLAIN' => 'If your server is running via SSL set this to enabled else leave as disabled. Having this enabled and not running via SSL will result in server errors during redirects.',
'ONLINE_LENGTH' => 'View online time span',
'ONLINE_LENGTH_EXPLAIN' => 'Number of minutes after which inactive users will not appear in “Who is online” listings. The higher this value the greater is the processing required to generate the listing.',
'SESSION_LENGTH' => 'Session length',
'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.',
'COOKIE_DOMAIN' => 'Cookie domain',
'COOKIE_DOMAIN_EXPLAIN' => 'In most cases the cookie domain is optional. Leave it blank if you are unsure.<br><br> In the case where you have a board integrated with other software or have multiple domains, then to determine the cookie domain you need to do the following. If you have something like <i>example.com</i> and <i>forums.example.com</i>, or perhaps <i>forums.example.com</i> and <i>blog.example.com</i>. Remove the subdomains until you find the common domain, <i>example.com</i>. Now add a dot in front of the common domain and you would enter .example.com (note the dot at the beginning).',
'COOKIE_NAME' => 'Cookie name',
'COOKIE_NAME_EXPLAIN' => 'This can be anything what you want, make it original. Whenever the cookie settings are changed the name of the cookie should be changed.',
'COOKIE_NOTICE' => 'Cookie notice',
'COOKIE_NOTICE_EXPLAIN' => 'If enabled a cookie notice will be displayed to users when visiting your board. This might be required by law depending on the content of your board and enabled extensions.',
'COOKIE_PATH' => 'Cookie path',
'COOKIE_PATH_EXPLAIN' => 'This will usually be the same as your script path or simply a slash to make the cookie accessible across the site domain.',
'COOKIE_SECURE' => 'Cookie secure',
'COOKIE_SECURE_EXPLAIN' => 'If your server is running via SSL set this to enabled else leave as disabled. Having this enabled and not running via SSL will result in server errors during redirects.',
'ONLINE_LENGTH' => 'View online time span',
'ONLINE_LENGTH_EXPLAIN' => 'Number of minutes after which inactive users will not appear in “Who is online” listings. The higher this value the greater is the processing required to generate the listing.',
'SESSION_LENGTH' => 'Session length',
'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.',
'SESSION_GC' => 'Session cleanup interval',
'SESSION_GC_EXPLAIN' => 'Sessions will be cleaned up after this time, in seconds.',
'SESSION_GUEST_LENGTH' => 'Guest session length',
'SESSION_GUEST_LENGTH_EXPLAIN' => 'Guest sessions will expire after this time, in seconds.',
'SESSION_GUEST_GC' => 'Guest session cleanup interval',
'SESSION_GUEST_GC_EXPLAIN' => 'Guest sessions will be cleaned up after this time, in seconds.',
));

// Contact Settings
Expand Down
1 change: 1 addition & 0 deletions phpBB/language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@
2 => '%d guests',
),
'G_ADMINISTRATORS' => 'Administrators',
'G_AI_CRAWLERS' => 'AI Crawlers',
'G_BOTS' => 'Bots',
'G_GUESTS' => 'Guests',
'G_REGISTERED' => 'Registered users',
Expand Down
1 change: 1 addition & 0 deletions phpBB/language/en/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
'TASK_CREATE_TABLES' => 'Creating tables',

// Install data
'TASK_ADD_AI_CRAWLERS' => 'Registering AI crawlers',
'TASK_ADD_BOTS' => 'Registering bots',
'TASK_ADD_LANGUAGES' => 'Installing available languages',
'TASK_ADD_MODULES' => 'Installing modules',
Expand Down
57 changes: 57 additions & 0 deletions phpBB/phpbb/cron/task/core/tidy_guest_sessions.php
Original file line number Diff line number Diff line change
@@ -0,0 +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.
*
*/

namespace phpbb\cron\task\core;

use phpbb\config\config;
use phpbb\cron\task\base;
use phpbb\user;

/**
* Tidy guest (anonymous) sessions cron task.
*
* Runs independently of tidy_sessions on a tighter schedule.
*/
class tidy_guest_sessions extends base
{
protected $config;
protected $user;

/**
* Constructor.
*
* @param config $config The config
* @param user $user The user
*/
public function __construct(config $config, user $user)
{
$this->config = $config;
$this->user = $user;
}

/**
* {@inheritdoc}
*/
public function run()
{
$this->user->session_guest_gc();
}

/**
* {@inheritdoc}
*/
public function should_run(): bool
Comment thread
marc1706 marked this conversation as resolved.
{
return ((int) $this->config['session_guest_last_gc'] + (int) $this->config['session_guest_gc']) <= time();
}
}
73 changes: 73 additions & 0 deletions phpBB/phpbb/db/migration/data/v33x/add_ai_crawlers_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?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\v33x;

use phpbb\db\migration\exception;
use phpbb\db\migration\migration;

class add_ai_crawlers_group extends migration
{
public static function depends_on(): array
{
return [
'\phpbb\db\migration\data\v33x\bot_update_v2',
'\phpbb\db\migration\data\v33x\guest_session_config',
];
}

public function update_data(): array
{
return [
['custom', [[$this, 'add_crawlers_group']]],
];
}

/**
* @throws exception
*/
public function add_crawlers_group(): void
{
$sql = 'SELECT group_id
FROM ' . $this->table_prefix . 'groups
WHERE ' . $this->db->sql_build_array('SELECT', ['group_name' => 'AI_CRAWLERS']);
$result = $this->db->sql_query($sql);
$group_exists = (bool) $this->db->sql_fetchfield('group_id');
$this->db->sql_freeresult($result);

if ($group_exists)
{
return;
}

if (!function_exists('group_create'))
{
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}

$group_id = 0;
$group_attributes = [
'group_colour' => '7D9EAE',
'group_legend' => 0,
'group_max_recipients' => 5,
'group_founder_manage' => 0,
];

$error = group_create($group_id, GROUP_SPECIAL, 'AI_CRAWLERS', '', $group_attributes);

if ($error)
{
throw new exception('Failed to create AI_CRAWLERS group.');
}
}
}
Loading
Loading