Shoutbox

php helpage - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: php helpage (/showthread.php?tid=59638)

php helpage by lordy on 05-22-2006 at 11:56 AM

I've seen one some sites and i swear i've read how to do it somewhere but i dont remember where, but you can access a page by going www.example.com/file.php/directory/blah

Can someone point me to the right place in the PHP man or some other site that explains how to do this? I can't find it anywhere xD


RE: php helpage by Eljay on 05-22-2006 at 12:01 PM

$_SERVER['PATH_INFO'] = the /directory/blah thing, do with it what you will :P


RE: php helpage by Ezra on 05-22-2006 at 03:11 PM

I think you mean you want it like directory's instead of ? and &, I think you need mod_rewrite then


RE: php helpage by J-Thread on 05-22-2006 at 09:25 PM

Yes, that's probably the best option, because $_SERVER['PATH_INFO'] isn't reliable (however, it will work on most servers).

Take a look at this page for more info about the URL rewrite engine.


RE: php helpage by lordy on 05-22-2006 at 09:39 PM

can you explain to me why $_SERVER['PATH_INFO'] isn't reliable?

The mod_rewrite thing looks a bit complex for me I think :P


RE: php helpage by J-Thread on 05-23-2006 at 10:10 AM

http://www.php.net/manual/en/reserved.variables.p...d.variables.server


RE: php helpage by Adeptus on 05-23-2006 at 02:40 PM

It looks like you are making a script that takes the path of the desired content from the URL, then sends that content to the client.  While there are valid uses for that and it can be done safely, be careful or you will get in trouble.

The problem with such scripts is that, without additional code to validate the path, they can be easily manipulated to read anything on the server -- overriding the server's built-in security restrictions, things like .htaccess and so forth.

This is just a mandatory security note: it doesn't mean you shouldn't do it, just make sure you do it right.  :p


RE: php helpage by ipab on 05-23-2006 at 04:01 PM

I looked into this over the weekend for my site, coudn't do it properly, so I got dt to help :D. You can try asking him, perhaps he will assist you.


RE: php helpage by TheSteve on 05-23-2006 at 11:15 PM

You can use the 'REQUEST_URI' server variable.

For example in the URL
http://www.somewhere.com/index.php/bob/red.png

$_SERVER['REQUEST_URI'] would be /index.php/bob/red.png

And this code should get just the /bob/red.png at the end.

code:
<?php
$filename = "index.php";
$request = strstr($_SERVER['REQUEST_URI'],$filename);
$request = strstr($request,"/");
?>

See this implementation
http://www.baxteronline.com/uriviewer.php/this/is/a/test
RE: php helpage by lordy on 05-24-2006 at 12:48 AM

quote:
Originally posted by ipab
I looked into this over the weekend for my site, coudn't do it properly, so I got dt to help :D. You can try asking him, perhaps he will assist you.
I understand how to do it now, I just needed the info :P

I understand what Adeptus is saying too, and I don't reall wan to risk that, so it looks like I should go with what I was going to do and try and make that section of my site database driven instead :P

I've not done much with databases, so it will be a learning experience for me :P