Guest User

Untitled

a guest
Jan 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. $mydomain = 'yourdomain.com';
  3. $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
  4.  
  5. $url = $_GET['url'];
  6. if ($host==$mydomain || isset($_GET['step']) && $_GET['step']==2) {//if using site directly, or already 2nd step
  7. $redirectUrl = $url;//referer is OK, go to real url
  8. }
  9. else {//1st step. redirect to 2nd step to change referer
  10. $redirectUrl = "?".http_build_query(array('step'=>2) + $_GET);
  11. }
  12. ?>
  13. <html>
  14. <head>
  15. <!-- HTTP redirect in 3 seconds, in case javascript does not work -->
  16. <meta http-equiv="refresh" content="3;url=<?=$redirectUrl?>" />
  17. </head>
  18. <script type="text/javascript">
  19. function openUrl(url)
  20. {
  21. var fakeLink = document.createElement('a');
  22.  
  23. // Firefox & other browsers
  24. if (typeof(fakeLink.click) == 'undefined')
  25. {
  26. location.href = url;
  27. }
  28. // Internet Explorer
  29. else
  30. {
  31. fakeLink.href = url;
  32. document.body.appendChild(fakeLink);
  33. fakeLink.click();
  34. }
  35.  
  36. return true;
  37. }
  38. //javascript redirect in 100 ms.
  39. setTimeout(function(){openUrl("<?=$redirectUrl?>");}, 100);
  40. </script>
  41. <body>
  42. <center>
  43. Redirecting...
  44. </center>
  45. </body>
  46. </html>
Add Comment
Please, Sign In to add comment