Wednesday, 25 August 2010

encode url as a php parameter and display it in url bar

<?php //file1.php

$url = 'http://www.google.com';

echo '<a href=./goto.php?goto=' . bin2hex($url) . '>click to go</a>';

?>







<?php //goto.php

//http://www.w3schools.com/TAGS/ref_urlencode.asp

//frame wrapper for redirect to php

$goto = @$_GET['goto'] ;

//echo $goto;

echo '<frameset rows="100%" >

<frame src="./redirect.php?goto=' . $goto . '" noresize="noresize" />

</frameset>';

?>







<?php //redirect.php

function hex2bin($h)

{

if (!is_string($h)) return null;

$r='';

for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); }

return $r;

}

$goto = @$_GET['goto'];

if ($goto != '')

{

Header( "HTTP/1.1 301 Moved Permanently" );

Header( "Location: " . hex2bin($goto) );

}

?>

No comments:

Labels

Search This Blog