Referer base withOUT ?something=something&somerthing....

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
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Referer base withOUT ?something=something&somerthing....

Post by JAB Creations »

I need to have just the base file name of the referer without any trailing stuff from ?something=something and so on. However using PHP's base function does not remove anything after the file extension. I need to remove all URI commands/queries/properties/values whatever they are referred to as but keep the refering file name intact.

So if the referer was index.php?audio=1&connection=2 I want to strip the referer down to index.php. How do I do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Well it looks like something I could use, if only there were examples for people who haven't been working with PHP for the past five years straight. :?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

??
"Example 2493. A parse_url() example" is straight forward. What do you not understand?
You pass an url to parse_url and it returns an array containing the different parts or fth url.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Ok I'm not sure the answer to my original question but somehow I answered a question to a more advanced version of this with AJAX.

Using AJAX to include an XHTML file (after the page loads in order to reduce initial page load size) I wanted to have a form on the AJAX includes file. However if I echoed the page's self location it would spit out the AJAX file name instead of the page (say index.php). I have learned a little bit about return...


index.php

Code: Select all

ajaxpage('templates/ajax-prompt-theme.php?return=<?php echo $_SERVER['PHP_SELF'];?>', 'themes');
AJAX includes...

Code: Select all

<?php echo basename($_GET['return']); ?>
The AJAX code I use can be found at...
http://www.dynamicdrive.com/dynamicinde ... ontent.htm

I can understand out-of-the-box stuff, I just am not sure about dynamically creating this stuff, mostly because no one is posting any examples!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your echo should probably be passed through rawurlencode() prior to echoing. Also, be very careful using PHP_SELF anywhere; it contains user input and can open you to insertion attacks.
Post Reply