xoops forums

wishcraft

Module Developer
Posted on: 2008/4/20 6:23
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3711
Since: 2007/5/18
#21

Re: username as uid ?

Hi krew,

it is pretty straight forward to introduce features like that but you have to be an intermediate PHP programmer I would say.

What you need to do..

ie: to edit a file such as userinfo.php so you have, http://www.yoursite.com/Username for there profile.

is introduce a new $_GET['username'] into the script with some SQL to find the UID of $_GET['username']

ie. select uid from _prefix_users where uname = $_GET['username'];

if you have a uid then you can call the rest of the script make the following change to the .htaccess file in your root.

Quote:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9\ \'\_]+)$ userinfo.php?username=$1 [L,NC,QSA]
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/SimonXaies
github.com/Chronolabs-Cooperative
facebook.com/SimonSXaies

sarahmx

Quite a regular
Posted on: 2008/4/20 10:40
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 381
Since: 2007/10/28
#22

Re: username as uid ?

Quote:

Trabis wrote:
http://www.xuups.com/modules/wfdownlo ... inglefile.php?cid=6&lid=1

i'm using the default XOOPS profile
i've tested this in localhost(xampp)

using this url http://localhost/xoops/users/admin/
i received the object not found message..

while this one is working
http://localhost/xoops/users/index.php?uname=admin

will test this in real server later

Quote:

wishcraft wrote:
e: to edit a file such as userinfo.php so you have, http://www.yoursite.com/Username for there profile.

is introduce a new $_GET['username'] into the script with some SQL to find the UID of $_GET['username']



wishcraft,

can you explain..step by step ? it will be great if you provide a download package like trabis

wishcraft

Module Developer
Posted on: 2008/4/20 10:56
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3711
Since: 2007/5/18
#23

Re: username as uid ?

Quote:


wishcraft,

can you explain..step by step ? it will be great if you provide a download package like trabis



Well if you have the .htaccess in the /XOOPS_ROOT_PATH/.htaccess

And the .htaccess for that is

Quote:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^users/([a-zA-Z0-9\ \'\_]+)/$ users/index.php?uname=$1 [L,NC,QSA]
RewriteRule ^users/([a-zA-Z0-9\ \'\_]+)$ users/index.php?uname=$1 [L,NC,QSA]
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/SimonXaies
github.com/Chronolabs-Cooperative
facebook.com/SimonSXaies

trabis

Core Developer
Posted on: 2008/4/20 13:29
trabis
trabis (Show more)
Core Developer
Posts: 2269
Since: 2006/9/1 1
#24

Re: username as uid ?

Quote:

using this url http://localhost/xoops/users/admin/
i received the object not found message..


http://localhost/xoops/users/admin should work, I did not count with the last traling slash, that way it will be looking for uname = 'admin/'.

sarahmx

Quite a regular
Posted on: 2008/4/21 7:56
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 381
Since: 2007/10/28
#25

Re: username as uid ?

i did not understand this part..i'm not a programmer

Quote:
is introduce a new $_GET['username'] into the script with some SQL to find the UID of $_GET['username']

ie. select uid from _prefix_users where uname = $_GET['username'];

if you have a uid then you can call the rest of the script make the following change to the .htaccess file in your root.




http://localhost/xoops/users/admin/ or
http://localhost/xoops/users/admin does not work

but this one is working

http://localhost/xoops/users/index.php?uname=admin

sarahmx

Quite a regular
Posted on: 2008/4/21 7:56
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 381
Since: 2007/10/28
#26

Re: username as uid ?

have anyone else tried ? does it work for you guys ?

trabis

Core Developer
Posted on: 2008/4/21 12:38
trabis
trabis (Show more)
Core Developer
Posts: 2269
Since: 2006/9/1 1
#27

Re: username as uid ?

Quote:

sarahmx wrote:
have anyone else tried ? does it work for you guys ?


Probably you do not have mod_rewrite enable. :(

ericktot

Just popping in
Posted on: 2008/5/17 1:08
ericktot
ericktot (Show more)
Just popping in
Posts: 6
Since: 2003/2/21
#28

Re: username as uid ? (Yogurt Social Network)

I found the code, sarahmx try...


create username.php in XOOPS root

Quote:

<?php

require_once "mainfile.php";

unset($uname);
if (isset($_GET['uname'])) $uname = $_GET['uname'];

if (isset($uname)) {
$member_handler =& xoops_gethandler('member');
$criteria = new Criteria("uname", $uname);
if ($member_handler->getUserCount($criteria) == 1) {
$user_list =& $member_handler->getUsers($criteria);
list($user) = $user_list;
header('Location: '.XOOPS_URL.'/modules/yogurt/index.php?uid=' . $user->uid()); exit ();
} else {
header('Location: '.XOOPS_URL.'/user.php'); exit ();
}

}

?>



In .htaccess in XOOPS root

Quote:

RewriteEngine On
RewriteRule ^([A-Za-z_0-9-]+)((/)|())?$ http://yourdomain.com/username.php?uname=$1


working for me =)

sarahmx

Quite a regular
Posted on: 2008/7/27 8:55
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 381
Since: 2007/10/28
#29

Re: username as uid ?

will try again this later

antifmradio

Just can't stay away
Posted on: 2008/7/27 19:48
antifmradio
antifmradio (Show more)
Just can't stay away
Posts: 457
Since: 2007/8/15
#30

Re: username as uid ?

sory to say but you guys are getting this all wrong

the code above that some of you are having trouble with is called a
REWRITE RULE

this will take a URL that you goto and REWRITE it on the browser to something else

if that something ELSE doesnt exist in your domain, then it wont work


most of you are actually trying to use

REDIRECT Rule

i posted this in another thread for everyone to use
Look for REDIRECT RULE