get_current_user() & symlinked PHP script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

get_current_user() & symlinked PHP script

Post by tomfra »

I need to get the name of the user executing a PHP script. Normally, get_current_user() does just that. However, the files that are being executed are in fact symlinked files which reside in another account and get_current_user() returns its name instead.

To illustrate:

(WRONG_USERNAME is the username of the account where the symlinked file physically resides).


The PHP script is being executed at:

/home/RIGHT_USERNAME/public_html/


get_current_user() returns:

WRONG_USERNAME


__FILE__ returns:

/home/WRONG_USERNAME/public_html/file.php


But $_SERVER['DOCUMENT_ROOT'] returns:

/home/RIGHT_USERNAME/public_html


Is there a way to get just the RIGHT_USERNAME in my scenario? Of course, I could use the string returned by $_SERVER['DOCUMENT_ROOT'] and get rid of the "/home/" & "/public_html" parts but unfortunately, it's not the same on all servers.

Any ideas are welcome.

Thanks!

Tomas
Post Reply