1
Hi guys
andrey3761 from Russian support made a fine URL rewrite hack for user profile pages.
If you want to implement this on your website, please follow 3 simple steps:
1. Add this
RewriteRule ^user/([a-zA-Z0-9 %_-]+) modules/profile/userinfo.php?uname=$1 [L,NC,QSA]
in your .htaccess file and save.
2. Replace
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
include_once $GLOBALS['xoops']->path('modules/system/constants.php');
$uid = intval($_GET['uid']);
with
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
include_once $GLOBALS['xoops']->path('modules/system/constants.php');
$uid = isset( $_GET['uid'] ) ? intval( $_GET['uid'] ) : 0;
//
$uname = ( isset( $_GET['uname'] ) ) ? $GLOBALS['xoopsDB']->quoteString( $_GET['uname'] ) : '';
if (!empty($uname)){
$sql = "SELECT uid FROM " . $GLOBALS['xoopsDB']->prefix('users') . " WHERE uname = $uname";
$result = $GLOBALS['xoopsDB']->query($sql);
list( $uid ) = $GLOBALS['xoopsDB']->fetchRow($result);
}
//
in modules/profile/userinfo.php
3. Replace
function eventCoreUserinfoStart($args)
{
header("location: ./modules/profile/userinfo.php" . (empty($_SERVER['QUERY_STRING']) ? "" : "?" . $_SERVER['QUERY_STRING']) );
exit();
}
with
function eventCoreUserinfoStart($args)
{
$uid = isset( $_GET['uid'] ) ? intval( $_GET['uid'] ) : 0;
$sql = "SELECT uname FROM " . $GLOBALS['xoopsDB']->prefix('users') . " WHERE uid = $uid";
$result = $GLOBALS['xoopsDB']->query($sql);
$uname = '';
list( $uname ) = $GLOBALS['xoopsDB']->fetchRow($result);
header("location: ./user/" . $uname );
exit();
}
in modules/profile/preloads/core.php
and you're gonna be done with the hack.
***
The only problem is that it doesn't redirect profile/userinfo.php to the new page. If somebody can make it, It'd be great.
Yevgeny