Simple FREE solution to support any chars in names

This method supports ALL characters, including UTF8, spaces, etc, and does not require modifying htaccess.

I don't know why people are selling mods on this, it's barely any effort to change.  However, just to sanity-check with feedback here, the way I've done it is editing /inc/profiles.inc.php and changing the following code:


From:

function getProfileLink( $iID, $sLinkAdd = '' ) {
$aProfInfo = getProfileInfo( $iID );
$iID = ($aProfInfo['Couple'] > 0 && $aProfInfo['ID'] > $aProfInfo['Couple']) ? $aProfInfo['Couple'] : $iID;

return (getParam('enable_modrewrite') == 'on') ? BX_DOL_URL_ROOT . getNickName($iID) . ( $sLinkAdd ? "?{$sLinkAdd}" : '' ) : BX_DOL_URL_ROOT . 'profile.php?ID='.$iID . ( $sLinkAdd ? "&{$sLinkAdd}" : '' );
}

To:

function getProfileLink( $iID, $sLinkAdd = '' ) {
$aProfInfo = getProfileInfo( $iID );
$iID = ($aProfInfo['Couple'] > 0 && $aProfInfo['ID'] > $aProfInfo['Couple']) ? $aProfInfo['Couple'] : $iID;
return (getParam('enable_modrewrite') == 'on') ? BX_DOL_URL_ROOT . escapeNickNameForURL(getNickName($iID)) . ( $sLinkAdd ? "?{$sLinkAdd}" : '' ) : BX_DOL_URL_ROOT . 'profile.php?ID='.$iID . ( $sLinkAdd ? "&{$sLinkAdd}" : '' );
}
function escapeNickNameForURL( $NickName ) {
return str_replace("%2520", "+", urlencode(urlencode(utf8_encode($NickName))));
}


And of course editing the regular expression constraints in the admin section:


From:

return ( preg_match( '/^[a-zA-Z0-9_-]+$/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) );

To:

return ( preg_match( '/\S+/', $arg0 ) and !file_exists( $dir['root'] . $arg0 ) );

No need for contorting the htaccess file at all, no spaces are passed, they are URL-encoded to "+".  It also addresses a long-standing Apache bug which unescapes URI-escaped characters by double-encoding and also avoids the "+" being improperly encoded back to "+" when it was originally %2b (actually intended as an excaped "+" rather than symbolic of a space character.

IMPORTANT: Once those changes are made, all template cache & public cache should be cleared.  I don't know if this is also dependent on a cron for clean-up since I did run into errors when initially clearing the template cache (blank pages) but it sort of fixed itself.  I haven't checked into this yet but does clearing the cache from the admin area get done via a cron or is it done immediately?

I don't think I missed anything on this, there's only one function which generates links to for member profiles and all other escaping in HTML output is handled by the existing code.  Seriously, this is the most braindead simple "mod" imaginable...

Quote · 31 Jan 2010
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.