The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 10:35:08 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: JS Beacon redirect  (Read 1898 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« on: October 28, 2008, 07:46:09 PM »

I thought I would share my snazzy little beacon/redirector/spidergobyebye function

Code:
testspider('http://cia.gov');

function testspider($url)
{
if ($_GET['code'] != '')
{
if ($_GET['code'] == $_COOKIE['code'])
{
echo 'window.location = "'.$url.'";'; //could obviously do a serverside redirect, but I prefered to keep it JS for doublecheck.
}
die();
}
else
{
$buf = '';
                //this code is what is passed via cookie AND getstring to verify realtime browsing.
$code = mt_rand(0,99999999);
setcookie("code", $code, time()+10);
//have to double wrap it like it is below, because of the returned JS code. dont forget that!
$buf .= '<script language="JavaScript"><!--';
$buf .= "\n";                                                                                           
$buf .= 'document.write("<sc"+"ript lang"+"uage=\"JavaS"+"cript\" src=\"'.$_SERVER['PHP_SELF'].'?code='.$code.'\"></scr"+"ipt>");';
$buf .= "\n";
$buf .= '//--></script>';
$buf .= "\n";
echo $buf;
}
}

just call the testspider('someurl');
from your PHP page, in the middle of your HTML output, whereever you think you want it. this fits my specific needs, but adjust to your fit Smiley
« Last Edit: October 28, 2008, 07:54:24 PM by nutballs » Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: October 28, 2008, 09:18:32 PM »

Nicely done NBs. SpiderGoByeBye, heh. Nice.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!