hidd3n Posted March 20, 2008 Share Posted March 20, 2008 Hi everyone, i am a php newbie, but i was wondering if its any way possible to make a fake referrer on a link without using meta refresh. i read somewhere something about curl, but i have no idea what that even is. for example I put a link on site A which goes THROUGH my website (Site B) and comes out to Site C. I'd like site C to see My site (Site B) as the referer. i think i tried everything under the sun, javascripts, http meta refreshes.. is anything possible? even with some crazy server side things? im willing to pay if this needs some crazy coding. thanks a lot! Quote Link to comment Share on other sites More sharing options...
Perad Posted March 20, 2008 Share Posted March 20, 2008 Bear in mind that no outputted code should be above this line. This includes html, spaces etc. The line below automatically forwards a user to the next site. <?php header('Location: http://mysite.com'); ?> Quote Link to comment Share on other sites More sharing options...
laffin Posted March 20, 2008 Share Posted March 20, 2008 and u may check $_SERVER['HTTP_REFERRER'] to see from which site a user is coming from, or use a $_GET parameter on the redirection Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 perad, this is what im currently using, but it forwards the referer to the last site. Quote Link to comment Share on other sites More sharing options...
lordfrikk Posted March 20, 2008 Share Posted March 20, 2008 If the link goes through your site (B) then C would automatically see B. What's the problem? Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 well the link is on site A. when someone clicks it, it goes to my site's (B's) php file that has that "header...etc" code and redirects to site C. site C sees site A as the referrer instead of my site, even though it just went through my site. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 i think i misunderstood the problem. the user is linked from site A to your site B, then forwarded to site C, however site C shows the referrer as site A instead of your site. but you want site C to see the referrer as your site B. is that correct? Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 yes thats exactly what i would need.. so this is absolutely not possible at all with anything? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 physically setting the referrer of a browser is not possible. the browser must visit the url and then set referrer on it's own. to the best of my knowledge, there is no (at least easy) way to do this using PHP. Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 so there are no server side things that would set this on the persons browser? Quote Link to comment Share on other sites More sharing options...
laffin Posted March 20, 2008 Share Posted March 20, 2008 nope, use a get parameter. but if u have pathinfo enabled, than ya can do all sorts of neat things Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 very easy to do Link to "Site C" goes to your site "Site B" <a href="siteB.php?page=http://www.siteC.com"> page on your site "Site B" SiteB.php <?php if(is_file($_GET['page'])){$page = $_GET['page'];} else{$page = "DEFAULT.php";} header("Location: ".$page); ?> SiteC will think it came from Site B Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 Hi, thanks, i am trying it out, but it goes to default.php Here is a test link http://www.ggstfu.com/test.php?page=http://www.my-i-p.com it goe through www.ggstfu.com/test.php inside which i copied your code and should go out to www.my-i-p.com because my-i-p shows referer data. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 I was trying to think of a fast way to verify the document requested is a valid doc try [code <?php $filename = "$_GET['page']; if(fopen($filename, "r")){ $page = $_GET['page']; } else{$page = "DEFAULT.php";} header("Location: ".$page); ?> Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 does it have to verify the doc? ok i updated, now theres an error on line 2, u can click the link to see Quote Link to comment Share on other sites More sharing options...
laffin Posted March 20, 2008 Share Posted March 20, 2008 wud be nice if u had a page verification system. but i wud set it within yer script as an array of valid pages instead of fetching the page from the site. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 wud be nice if u had a page verification system. but i wud set it within yer script as an array of valid pages instead of fetching the page from the site. That is the better idea, and then u can pass integers vs full text i.e The link siteB.php?page=1 SiteB.php <?php $pages = array("http://www.yahoo.com","http://www.google.com","http://www.phpfreaks.com"); if(intval($_GET['page']) < count($pages) && $pages >= 0){ $page = $pages[$_GET['pages']]; } else{ $page = $pages[0]; #Default to 0 case } header("location: ".$page); ?> Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 20, 2008 Author Share Posted March 20, 2008 thanks for the code, but now it doesent go anywhere ??? http://www.ggstfu.com/test.php?page=1 inside the test.php i pasted your code exactly. Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 21, 2008 Author Share Posted March 21, 2008 any help? thanks! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 it should work or its error somewhere and u are suppressing errors try this though <?php $pages = array("http://www.yahoo.com","http://www.google.com","http://www.phpfreaks.com"); if(intval($_GET['page']) < count($pages) && $pages >= 0){ $page = $pages[$_GET['pages']]; } else{ $page = $pages[0]; #Default to 0 case } die(header("location: ".$page)); ?> Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 21, 2008 Author Share Posted March 21, 2008 still blank page try it with the link, i just paste your code right into that php file. http://www.ggstfu.com/test.php?page=1 Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 my logic was flawed tihs works <?php $pages = array("http://www.yahoo.com","http://www.google.com","http://www.phpfreaks.com"); $page = $pages[$_GET['page']]; if(empty($page)){ $page = $pages[0]; } die(header("location: $page")); ?> Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 21, 2008 Author Share Posted March 21, 2008 yep works, so what happens to the header then? it shows this forum as the referer. thanks for all your help Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 I'm trying to play around with it, the issue is that the refer only comes when a "link" is clicked so somehow you gotta fake that. I tried <?php session_start(); if(empty($_SESSION['refresh'])){ $_SESSION['refresh'] = 1; echo "<html><head><meta http-equiv=\"refresh\" content=\"5\" /></head><body><h1>1 second...</h1></body></html>"; } else{ $pages = array("http://my-i-p.com/","http://www.google.com","http://www.phpfreaks.com"); $page = $pages[$_GET['page']]; if(empty($page)){ $page = $pages[0]; } $_SESSION['refresh'] = ""; header("location: $page"); } ?> so the page actually "hits" and then reloads, but no good the header comes in unknown or the followed link Quote Link to comment Share on other sites More sharing options...
hidd3n Posted March 21, 2008 Author Share Posted March 21, 2008 unknown is good too as long as it removes the referer of the original page Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.