-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[ticket/17656] Add shorter guest session length and new AI bots #6960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marc1706
wants to merge
11
commits into
phpbb:3.3.x
Choose a base branch
from
marc1706:ticket/17656
base: 3.3.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f121e7b
[ticket/17656] Add shorter guest sessions and gc
marc1706 8b4972b
[ticket/17656] Add default settings to schema and settings to ACP
marc1706 81b583b
[ticket/17656] Make AI crawlers appear as bots
marc1706 4463581
[ticket/17656] Remove extra blank line
marc1706 cbebc54
[ticket/17656] Add missing entry to schema_data
marc1706 6833c52
[ticket/17656] Improve migration
marc1706 07baf1d
[ticket/17656] Improve wording
marc1706 b4004e3
[ticket/17656] Limit input values to max. 1 day for sessions
marc1706 9794514
[ticket/17656] Add separate group for AI crawlers to allow special ha…
marc1706 9a6992b
[ticket/17656] Fix phing sniff issues
marc1706 de773e3
[ticket/17656] Fix ai crawlers migration and extend guest session length
marc1706 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| { | ||
| return ((int) $this->config['session_guest_last_gc'] + (int) $this->config['session_guest_gc']) <= time(); | ||
| } | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
phpBB/phpbb/db/migration/data/v33x/add_ai_crawlers_group.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.'); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.