Skip to content

Commit 606d697

Browse files
authored
Merge pull request #230 from iMattPro/updates
Delete all phpbb cookies option
2 parents cd3a811 + 4083ea2 commit 606d697

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

includes/qi.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
class qi
1414
{
15+
/** @var string The prefix name of phpBB board cookies */
16+
const PHPBB_COOKIE_PREFIX = 'phpbb3_';
17+
1518
/**
1619
* Output the standard page header
1720
*/
@@ -535,7 +538,7 @@ public static function delete_cookies($name)
535538
$crumb = trim($crumbs[0]);
536539
if (strpos($crumb, $name) === 0)
537540
{
538-
self::set_cookie($name);
541+
self::set_cookie($crumb);
539542
}
540543
}
541544
}

index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@
9797
$profile = '';
9898
}
9999

100+
// delete all phpbb cookies if requested
101+
if (qi_request_var('delete-cookies', '') === qi::PHPBB_COOKIE_PREFIX)
102+
{
103+
qi::delete_cookies(qi::PHPBB_COOKIE_PREFIX);
104+
}
105+
100106
// load settings profile
101107
$settings->import_profile($profile);
102108

language/en/qi.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
'DEFAULT_LANG' => 'Default language',
129129
'DEFAULT_LANG_EXPLAIN' => 'The default language that will be used for your boards. Language packs need to be in <code>sources/phpBB3/language/</code> to be available in this list.',
130130
'DELETE' => 'Delete',
131+
'DELETE_COOKIES' => 'Delete all phpBB cookies',
132+
'DELETE_COOKIES_CONFIRM' => 'This will log you out of all phpBB boards on this server. Are you sure you want to continue?',
133+
'DELETE_COOKIES_TITLE' => 'Over time and many QI board installs, loads of cookies that may no longer be needed can build up in your server.',
131134
'DELETE_FILES_IF_EXIST' => 'Delete files if they exist',
132135
'DELETE_FILES_IF_EXIST_EXPLAIN' => 'Have &quot;Delete files if they exist&quot; checked by default when creating boards.',
133136
'DELETE_PROFILE' => 'Delete profile',

modules/qi_create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function run()
367367
'server_protocol' => $settings->get_server_protocol(),
368368
'newest_username' => $admin_name,
369369
'avatar_salt' => md5(mt_rand()),
370-
'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5)),
370+
'cookie_name' => qi::PHPBB_COOKIE_PREFIX . strtolower(gen_rand_string(5)),
371371
);
372372

373373
if (defined('PHPBB_31'))

modules/qi_phpinfo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function run()
8181
$template->assign_vars(array(
8282
'S_PHPINFO' => true,
8383
'PHPINFO' => $output,
84+
'U_DELETE_COOKIES' => qi::url('phpinfo') . '&amp;delete-cookies=' . qi::PHPBB_COOKIE_PREFIX,
8485
));
8586

8687
// Output page

style/overall_footer.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

22
</div>
33
<footer class="text-center py-3">
4-
<p class="mb-0"><small>{{ lang('PHPBB_QI_FULLLINK', QI_VERSION) }}</small></p>
5-
<p class="mb-0"><small>{{ lang('POWERED_BY_PHPBB') }}</small></p>
4+
{% if U_DELETE_COOKIES %}<p class="small">[ <a title="{{ lang('DELETE_COOKIES_TITLE') }}" href="{{ U_DELETE_COOKIES }}" data-qi-confirm="{{ lang('DELETE_COOKIES_CONFIRM') }}">{{ lang('DELETE_COOKIES') }}</a> ]</p>{% endif %}
5+
<p class="mb-0 small">{{ lang('PHPBB_QI_FULLLINK', QI_VERSION) }}</p>
6+
<p class="mb-0 small">{{ lang('POWERED_BY_PHPBB') }}</p>
67
{% if TRANSLATION_INFO %}<p class="mb-0">{{ TRANSLATION_INFO }}</p>{% endif %}
78
</footer>
89
</div>

0 commit comments

Comments
 (0)