Login for search.php (phpBB 3.3.8 - 3.3.9)

Custom coding for various phpBB versions as well as other useful scripts.
Post Reply
User avatar
Dimetrodon
Not A Dinosaur!
Not A Dinosaur!
Posts: 197
Joined: Mon Sep 12, 2022 9:30 am
Verification: ✅ Elon Musk Style

Login for search.php (phpBB 3.3.8 - 3.3.9)

Post by Dimetrodon »

Note: If you decide to make these changes to your own board, please make sure you backup search.php and language/en/common.php before proceeding; Works on phpBB 3.3.8. Please proceed with caution and due diligence.

In a default phpBB installation, if a guest is not allowed to search the board (with a permission setting that does not give them such access) and they attempt to use search.php, they are told that they cannot use the search system as opposed to being given a login screen. This is different from when guests cannot view the memberlist/profiles for some reason, but can be changed in search.php by replacing:

Code: Select all

// Is user able to search? Has search been disabled?
if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search'])
{
	$template->assign_var('S_NO_SEARCH', true);
	trigger_error('NO_SEARCH');
}
With:

Code: Select all

// Is user able to search? Has search been disabled?
if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search'])
{
	// Is the user logged in but unable to search? If so, they will get an error message.	 
	if ($user->data['user_id'] != ANONYMOUS)
	{			
	$template->assign_var('S_NO_SEARCH', true);
	 trigger_error('NO_SEARCH');
	}

// If the user is a guest and cannot search, they will recieve a login page.                      
login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_SEARCH']));
}
And in language/en/common.php

Finding:

Code: Select all

'LOGIN_EXPLAIN_VIEWONLINE'			=> 'In order to view the online list you have to be registered and logged in.',


And adding the following after it:

Code: Select all

'LOGIN_EXPLAIN_SEARCH'			=> 'In order to search the board you have to be registered and logged in.',

It is better than saying "Sorry but you are not permitted to use the search system." to unregistered users imho.

[Edited: Code edited a bit to make it a bit more organized and hopefully human readable. What it does is unchanged and I have tested it with the edit.]
Last edited by Dimetrodon on Sun Dec 18, 2022 6:57 am, edited 2 times in total.

User avatar
Dimetrodon
Not A Dinosaur!
Not A Dinosaur!
Posts: 197
Joined: Mon Sep 12, 2022 9:30 am
Verification: ✅ Elon Musk Style

Re: Login for search.php (phpBB 3.3.8)

Post by Dimetrodon »

Cleaned up further to make it more organized.

Post Reply