xoops forums

deka87

Friend of XOOPS
Posted on: 2010/2/8 17:43
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#1

User profile URL rewrite hack

Hi guys

andrey3761 from Russian support made a fine URL rewrite hack for user profile pages.

Resized Image


If you want to implement this on your website, please follow 3 simple steps:

1. Add this

RewriteRule ^user/([a-zA-Z0-%_-]+) modules/profile/userinfo.php?uname=$[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

acegamer

Not too shy to talk
Posted on: 2010/2/8 19:46
acegamer
acegamer (Show more)
Not too shy to talk
Posts: 162
Since: 2005/7/11
#2

Re: User profile URL rewrite hack

cool hack, must definitely be in XOOPS 3.0 standard ;)

belia

Just popping in
Posted on: 2010/2/9 0:17
belia
belia (Show more)
Just popping in
Posts: 83
Since: 2007/12/18
#3

Re: User profile URL rewrite hack

this is cool

Quote:

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.


deka87

take a look at this thread...

https://xoops.org/modules/newbb/viewto ... at&order=ASC&type=&mode=0

maybe it can help

acegamer

Not too shy to talk
Posted on: 2010/2/9 13:45
acegamer
acegamer (Show more)
Not too shy to talk
Posts: 162
Since: 2005/7/11
#4

Re: User profile URL rewrite hack

I self don't know a lot of programming, but if this is fixed.
Can someone please set the full hack here again, our suggest it to the development team of 3.0 ?


Kind Regards

demian

Quite a regular
Posted on: 2010/3/20 15:30
demian
demian (Show more)
Quite a regular
Posts: 225
Since: 2008/4/29
#5

Re: User profile URL rewrite hack

this should be improved and made it to the XOOPS core ..!!!!


Great

sabahan

Quite a regular
Posted on: 2010/5/15 1:09
sabahan
sabahan (Show more)
Quite a regular
Posts: 317
Since: 2006/3/4 5
#6

Re: User profile URL rewrite hack

anyone know how to fix this

Quote:

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.



maybe someone can fix this and made a rmcommon plugin for this...

sabahan

Quite a regular
Posted on: 2010/6/14 11:32
sabahan
sabahan (Show more)
Quite a regular
Posts: 317
Since: 2006/3/4 5
#7

Re: User profile URL rewrite hack

bump

mboyden

Moderator
Posted on: 2010/6/14 15:37
mboyden
mboyden (Show more)
Moderator
Posts: 484
Since: 2005/3/9 1
#8

Re: User profile URL rewrite hack

Do you really want to reveal the usernames? To me this is asking for script kiddiez to come try and break into your site. Among other reasons, this is the reason why our sites use the "Real Name" field (we call it display name) and don't ever reveal the login name to other users. It also means that many modules need some modifications because of it.

Also, how well would this hack work with the xoRewriteModule which also IMHO should belong in the core. I dont' think it will based on other similar module SEO/rewrite code I've played with.

Anyhoos, good luck with it.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development