homepage Welcome to WebmasterWorld Guest from 54.234.141.47
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
tracking HTTP_REFERER with personal firewalls
brett manages to, why can't i?
jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 11:53 am on Mar 26, 2003 (gmt 0)

i use norton personal firewall which disguises my referer. this is a standard setting and as such is used by people all over the web with personal firewalls.

when i pass the HTTP_REFERER (either in php or cgi) to a script (such as a 'tell a friend' script) the HTTP_REFERER is always blank, unless i manually deactivate my firewall.

however....
if i click on the 'email a friend' link at the bottom of this very page, the referrer is shown on the next page, even when my firewall is active!

how does brett do it?

 

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 11:55 am on Mar 26, 2003 (gmt 0)

The thread you want to send is coded into the query string. No referrer is used.

[webmasterworld.com...]

Andreas

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 12:05 pm on Mar 26, 2003 (gmt 0)

aaah

thanks andreas. with our static site this would not be possible (unless i manually copy in the link to 100s of pages ;-)

thanks for explaining

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 12:27 pm on Mar 26, 2003 (gmt 0)

hi andreas,

i have been trying to work around this, so that if no referer is given, then my std url is displayed and sent to the next page:

$fullurl = "{$HTTP_REFERER}";
$stdurl = "http://www.mydomain.com";

if(isset($fullurl))
{
echo "Recommended page: $fullurl<br> " ;
echo"<input type=hidden name=link value=$fullurl>";
}
else
{
echo "Recommended page: $stdurl<br> " ;
echo"<input type=hidden name=link value=$stdurl>";
}

this doesn't work though :-(

any tips for a beginner?

many thanks

<added>

don't worry i've done it. i just check to see if http_referer contains something

if(eregi("http", $HTTP_REFERER))

instead of using isset

cheers

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 12:40 pm on Mar 26, 2003 (gmt 0)

This should work:


$url = $_SERVER['HTTP_REFERER'] == ''
? 'http://www.ac.com/'
: $_SERVER['HTTP_REFERER'];
echo "Recommended page: $url<br>
<input type=hidden name=link value=$url>";

It tests whether the referrer string is empty or not. If it is it assigns the standard URL to $url. Otherwise it uses the referrer string.

Andreas

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 1:09 pm on Mar 26, 2003 (gmt 0)

a slightly more elegant solution than mine ;-)

thanks

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 2:20 pm on Mar 26, 2003 (gmt 0)


>>with our static site this would not be possible (unless i
>>manually copy in the link to 100s of pages ;-)

This will all depend on the right tools. The modified tagrep script [webmasterworld.com] would enable you to do that very easily.

Andreas

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 3:18 pm on Mar 26, 2003 (gmt 0)

andreas,

thanks for input,

but i don't understand how i can use this tool to code in the link for each page?

each page would need its own unique link something like mydomain.com/tellfriend.php?myreferringpage.htm. and the php tell a friend script would then use that code to identify the exact page to send.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 3:47 pm on Mar 26, 2003 (gmt 0)


>>each page would need its own unique link

Thatīs just what the script will do. If you had a website structure like this


/index.html
/ac/index.html
/ac/cds.html
/ac/pix.html
/jmc/index.html
/jmc/pix.html

the script would generate a link in each file that would look like this:


friends.cgi?file=http://www.site.com/index.html
friends.cgi?file=http://www.site.com/ac/index.html
friends.cgi?file=http://www.site.com/ac/cds.html
friends.cgi?file=http://www.site.com/ac/pix.html
friends.cgi?file=http://www.site.com/jmc/index.html
friends.cgi?file=http://www.site.com/jmc/pix.html

if you called it like that:


./tagrep __DOCUMENT_ROOT__/ '^friends.cgi$' \
'sub{(my $n = $File::Find::name) =~ \
s!^__DOCUMENT_ROOT__!http://www.site.com!; \
return "friends.cgi?file=$n";}' href

You would need to replace __DOCUMENT_ROOT__ with your DocumentRoot [httpd.apache.org].

Andreas

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 653 posted 4:22 pm on Mar 26, 2003 (gmt 0)

wow andreas, thank you very much!

looks like it will be a late night tonight trying all this out ;-)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved