Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of eikron morgauin  >  Link Obfuscator  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: A simple test file
Class: Link Obfuscator
Obfuscate HTML links to prevent direct page access
Author: By
Last change:
Date: 2004-08-17 08:21
Size: 1,134 bytes
 

Contents

Class file image Download
<?php

/**
 * 
 *@author Cerion Morgauin
 * @version $Id$
 * @copyright Enrico Marongiu (cerion _@_ tiscali _._ it) - 2004
*  linkObfuscator manages a simple way of validating links: starting from a session, an user can browse exclusively those links that are performed by this page. to do this, a random seed is generated and a special code (named go) is attached to each link.
* each page that has to be obfuscated needs this class and a $linkObfuscator::check() to validate the user.
 **/

require_once('linkObfuscator.class.php');

session_start();


$lO=new linkObfuscator($_SESSION['referralSeed']);
print 
"actual referral Seed:"$_SESSION['referralSeed'] ."<br />\n";
?>
<html><body>
<?
if ($lO->referralSeed) {
    if(
$lO->check($_SERVER['REQUEST_URI'])){
        print 
"checked link: ${_SERVER['REQUEST_URI']}<br />\n";
    }else{
        print 
"link invalid: ${_SERVER['REQUEST_URI']} \n";

    }
}
$_SESSION['referralSeed']=$lO->seed;
$newLinkpreg_replace('/(&|\?)go=(\w)+/','',$_SERVER['REQUEST_URI']);
$newLinkObscured=$lO->obfuscate($newLink);

?>
<a href="<?=$newLinkObscured?>">Obscured</a>
</body>