1
deka87
User profile URL rewrite hack
  • 2010/2/8 17:43

  • deka87

  • Friend of XOOPS

  • Posts: 1124

  • Since: 2007/10/5


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

2
acegamer
Re: User profile URL rewrite hack
  • 2010/2/8 19:46

  • acegamer

  • Not too shy to talk

  • Posts: 162

  • Since: 2005/7/11


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

3
belia
Re: User profile URL rewrite hack
  • 2010/2/9 0:17

  • belia

  • Just popping in

  • Posts: 83

  • Since: 2007/12/18


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

4
acegamer
Re: User profile URL rewrite hack
  • 2010/2/9 13:45

  • acegamer

  • Not too shy to talk

  • Posts: 162

  • Since: 2005/7/11


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

5
demian
Re: User profile URL rewrite hack
  • 2010/3/20 15:30

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


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


Great

6
sabahan
Re: User profile URL rewrite hack
  • 2010/5/15 1:09

  • sabahan

  • Quite a regular

  • Posts: 317

  • Since: 2006/3/4 5


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...

7
sabahan
Re: User profile URL rewrite hack
  • 2010/6/14 11:32

  • sabahan

  • Quite a regular

  • Posts: 317

  • Since: 2006/3/4 5


bump

8
mboyden
Re: User profile URL rewrite hack
  • 2010/6/14 15:37

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


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

Login

Who's Online

76 user(s) are online (42 user(s) are browsing Support Forums)


Members: 0


Guests: 76


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits