MyBB Community Forums

Full Version: Fatal Error: Enhanced Account Switcher Upgrade
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
LOCATION: /admin/index.php?module=user-accountswitcher

ERROR: 
Quote:Fatal error: Call to undefined function my_validate_url() in /home/***/public_html/inc/plugins/accountswitcher/as_admincp.php on line 926
*** = blocked out the sites name. If needed, please PM me.

FILE LINE 926:
if (my_validate_url($mybb->settings['useravatar'])) {
$account['avatar'] = str_replace(
'{theme}',
'images',
$mybb->settings['useravatar']
);

MYBB VERSION: 1.8.7

PLUGIN VERSION: 2.1.6
IIRC, my_validate_url function was added in MyBB 1.8.8

you can try adding following code segment to functions.php file
function my_validate_url($url, $relative_path=false)
{
	if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
	{
		return true;
	}

	return false;
}

Note: php files should be saved with utf-8 encoding without Byte Order Mark.
in general, we use editor like Notepad++ or file editor at web host panel
Does it matter where I add this code into the functions.php file?
^ can be added at the bottom of functions.php file (assuming that it doesn't have php code end tag i.e. ?>)
Worked like a charm! Thanks a bunch!