Jump to content


Photo

getting addres bar vars


  • Please log in to reply
3 replies to this topic

#1 WhiteHawk

WhiteHawk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 April 2006 - 07:52 PM

Basically I'm building a php MMORPG or online game, now I have hit a small snag...

in order ot stop players cheating I have produced a large number of logs. n.p.

however one of the things I want to include is the address of the page that its currently on.

No problem you say...

[blockquote]$address = $_SERVER['PHP_SELF'];[/blockquote]

or

[blockquote]$address = __FILE__;[/blockquote]

unfortunately this doesn't store all I need it to. lets say for instance we're on train.php if we use any of the above methods it will work fine.

but if we're on train.php?step=pie then it will drop the vars and I'll just end up with train.php in the $address.

The idea is if someone was trying to cheat, e.g. train.php?step=pie&money=-1000 or something then it would be able to get the whole address so that when its inserted into the log I can see how people are modding any get vars that are used.

any help would be appreciated.

WhiteHawk.

#2 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 April 2006 - 08:02 PM

Tehehe actually ran into this today trying to work that same problem backwards

Try

$var1 = $_SERVER['PHP_SELF'];
$var2 = $_SERVER['SCRIPT_NAME'];
$var3 = $_SERVER['REQUEST_URI'];

Errr one of those three should do it, URI I believe


Side note
$var3 = $_SERVER['REQUEST_URI'];

Should be what you are looking for

Then if you need to strip off the extra what I used was ereg() though I am not sure if that is the best solution


#3 WhiteHawk

WhiteHawk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 April 2006 - 09:25 PM

I looked through that but guess I didn't twig to it lol, nvm

cheers, that should solve my problem.

#4 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 07 April 2006 - 04:21 PM

you can use the parse_str function to separate all you're vars if I think that's what you want to do


print_r(parse_str($_SERVER['REQUEST_URI']));

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users