how to obfuscate links while working with mysql?
Posted: Fri Sep 02, 2005 8:54 pm
I am very new on this and have been desperately trying to find a way to obfuscate links (what would appear on the address bar). The following works for static pages, but not when working with databases. would there be a creative way to modify this or am I approaching it incorrectly?
feyd | Please use
Code: Select all
class linkObfuscator
{
var $seed=0;
var $referralSeed=0;
function linkObfuscator($referralSeed=false)
{
// new seed, to obfuscate new pages
srand();
$this->seed= rand();
// old seed, to check access
if($referralSeed===false or !is_numeric($referralSeed)) {
$this->referralSeed=$referralSeed;
} else if(is_numeric($_SESSION['referralSeed'])) {
$this->referralSeed=$_SESSION['referralSeed'];
$_SESSION['referralSeed']=$this->seed;
}
}
function _obfuscate($aLink,$aSeed)
{
$sep=(strpos('?',$aLink)===false)?'?':'&';
return $aLink. $sep ."go=".md5($aSeed .$aLink);
}
function obfuscate($aLink)
{
return $this->_obfuscate($aLink,$this->seed);
}
function check($anObfuscatedLink)
{
$theLink=preg_replace('/(&|\?)go=(\w)+/','',$anObfuscatedLink);
if($this->_obfuscate($theLink,$this->referralSeed)==$anObfuscatedLink)
return true;
return false;
}
}feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]