GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Simple way to catch referer using javascript and PHP? (https://gfy.com/showthread.php?t=994211)

Emil 10-25-2010 03:14 AM

Simple way to catch referer using javascript and PHP?
 
Lets say I want people to put a small javascript on their site. This javascript should "send" the referer-URL to one of my PHP-scripts on my server.

How could this be done? All these webcounters use Javascript, can anyone plz explain how I can do this?

redwhiteandblue 10-25-2010 03:39 AM

You could do something simple like

Code:

<script language="Javascript" type="text/javascript">
<!--
var docRef = document.referrer
docRef = encodeURIComponent(docRef) //URI encode the referrer string
dummyPhpImg = new Image
dummyPhpImg.src = '/yourserversidescript.php?REF=' + docRef
//-->
</script>

Basically loads a dummy image object which is actually your php script, don't forget to send a header response as an img file at the of the script, it can be an empty 1x1 pixel image, doesn't matter as you're not going to display it. BTW you can add more parameters to the query string such as screen size, client time, etc.

Emil 10-25-2010 03:45 AM

Thank you!


All times are GMT -7. The time now is 01:11 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123