Buonasera a tutti,
premetto che non so scrivere i codici ed avrei bisogno del vostro aiuto.
Ho la necessita' di rendere una pagina irraggiungibile tramite link diretto.
L'unica soluzione che ho trovato online e' un piccolo script php che contiene due file
linkObfuscator.php
e il file test.php
ho caricato la cartella con i file nella root del sito.
La domanda e' questa, che codice devo aggiungere nella head della pagina che voglio offuscare per far si che lo script funzioni ?
Come ho detto non conosco il linguaggio php quindi gentilmente se mi potete indicare step by step cosa devo fare.
Ringrazio molto per il vostro aiuto.
K.
premetto che non so scrivere i codici ed avrei bisogno del vostro aiuto.
Ho la necessita' di rendere una pagina irraggiungibile tramite link diretto.
L'unica soluzione che ho trovato online e' un piccolo script php che contiene due file
linkObfuscator.php
PHP:
<?php
/**
*
* @author Cerion Morgauin
* @version $Id$
* @copyright Enrico Marongiu (cerion [email protected]_ 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.
**/
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;
}
}
?>
e il file test.php
PHP:
<?php
/**
*
*@author Cerion Morgauin
* @version $Id$
* @copyright Enrico Marongiu (cerion [email protected]_ 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;
$newLink= preg_replace('/(&|\?)go=(\w)+/','',$_SERVER['REQUEST_URI']);
$newLinkObscured=$lO->obfuscate($newLink);
?>
<a href="<?=$newLinkObscured?>">Obscured</a>
</body>
ho caricato la cartella con i file nella root del sito.
La domanda e' questa, che codice devo aggiungere nella head della pagina che voglio offuscare per far si che lo script funzioni ?
Come ho detto non conosco il linguaggio php quindi gentilmente se mi potete indicare step by step cosa devo fare.
Ringrazio molto per il vostro aiuto.
K.