riguardo HTTP_REFERER il manuale di php dice:

"The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted."

e infatti non mi restituisce nulla.

alla fine ho creato una classe le cui istanze contengono tutte le informazioni relative alla richiesta di un utente. ecco qua:


Codice PHP:
class request
{
    public 
$protocol;        
    public 
$domain;
    public 
$path;
    public 
$resource;
    public 
$query;

    public 
$real_req;        // richiesta realmente effettuata dalla barra indirizzi
    
public $explicit_req;    // richiesta riscritta con script esplicitato

    
public $get;
    public 
$post;
    public 
$files;

    public function 
__construct()
    {    
        
$xprt explode'/'$_SERVER['SERVER_PROTOCOL'] );
        
$xpuq parse_url$_SERVER['REQUEST_URI'], PHP_URL_QUERY );
        
$xscr explode'/'$_SERVER['SCRIPT_NAME'] );

        
$this->protocol        strtolower$xprt[0] );
        
$this->domain        $_SERVER['SERVER_NAME'];
        
$this->query        = ( $xpuq !== NULL )? $xpuq '';
        
$this->resource        array_pop$xscr );
        
$this->path            implode'/'$xscr ).'/';

        
$this->real_req        $this->protocol.'://'.$this->domain.$_SERVER['REQUEST_URI'];
        
$this->explicit_req    $this->protocol.'://'.$this->domain.$this->path.$this->resource.( ( $this->query === '' )? '' '?'.$this->query );

        
$this->get             &= $_GET;
        
$this->post         &= $_POST;
        
$this->files        &= $_FILES;
    }

ovviamente basta una sola istanza per ogni esecuzione del programma, percui si puo' utilizzare il pattern singleton