Problema (Header?)

Stato
Discussione chiusa ad ulteriori risposte.

imported_D4nt3

Utente Silver
6 Gennaio 2008
0
0
0
57
Salve a tutti. Stavo cercando di fare un programmino che si collegasse ad una pagina php.. Per collegarsi sembra collegarsi, ma la pagina restituisce questo problema:

Codice:
<b>Warning:</b> your browser doesn't send the HTTP_REFERER header to the website.<br>This can be caused due to your browser, using a proxy server or your firewall.<br>Please change browser or turn off the use of a proxy<br>or turn off the 'Deny servers to trace web browsing' in your firewall<br>and you shouldn't have problems when sending a POST on this website.

A cosa può essere dovuto? Pezzo di codice:

Codice:
my $Cookies = new HTTP::Cookies;
my $UserAgent = new LWP::UserAgent(
			agent => 'Mozilla/5.0',
			max_redirect => 0,
			cookie_jar => $Cookies,
		) or die $!;

my $Post = $UserAgent->post($HostName,[
				score		=> '1',
		]) || die $!;

Dante
 
Ciao d3nt3 guarda non so come aiutarti anche se credo che sia dovuto ai header applicativi che mette un browser quando si connette oppure puo' essere dovuto ai cookies,

comunque mi dispiace non poterti aiutare :(
 
La pagina fa un controllo sul referer, e se non setti manualmente il referer accettato dalla pagina ti darà errore.
 
Codice:
my $Cookies = new HTTP::Cookies;
my $UserAgent = new LWP::UserAgent(
            agent => 'Mozilla/5.0',
            max_redirect => 0,
            cookie_jar => $Cookies,
        ) or die $!;
$UserAgent->default_header('Referer' => "http://www.quellochevuoi.com/");
my $Post = $UserAgent->post($HostName,[
                score        => '1',
        ]) || die $!;
http://www.google.com/search?q=LWP%3A%3AUserAgent+referer&ie=utf-8&oe=utf-8&aq=t&rls=org.gentoo:en-US:unofficial&client=firefox-a
 
Codice:
my $Method = HTTP::Request->new(POST => $HostName.'modules.php?name=News');
my $Cookies = new HTTP::Cookies;
my $UserAgent = new LWP::UserAgent(
			agent => 'Mozilla/5.0',
			max_redirect => 0,
			cookie_jar => $Cookies,
			default_headers => HTTP::Headers->new,
		) or die $!;

$Method->header('Referer', 'http://127.0.0.1/');
my $Referrer = $Method->header('Referer', 'http://127.0.0.1/');

my $h = HTTP::Headers->new;
my $h1 = HTTP::Headers->new;
$h->header('Referer' => 'http://127.0.0.1/'); # set
$h1->referer('http://127.0.0.1/'); # set
my $ct = $h->header('Referer'); # get
my $ct2 = $h1->header('Referer'); # get

3 volte. In 3 modi diversi. E anche contemporaneamente. E ancora nn va. Nn è possibile, troppo strano.. Cm'è possibile?? Dante
 
Codice:
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTTP::Cookies;
my $cookies = new HTTP::Cookies;
my $client = LWP::UserAgent->new();
$client->agent ("Culo");
$client->cookie_jar ($cookies);
my $request = HTTP::Request->new(POST => "http://tuourl.com");
$request->content_type("application/x-www-form-urlencoded");
$request->content("tuaopzione=tuaopzione&altraopzione=opzione&ecc=ecc");
$request->referer("http://sito.com"); # Devi mettere un referer che il sito possa riconoscere come VALIDO
my $response = $client->request ($request);

if ($response->is_error()) {
  printf("%s\n", $response->status_line);
}
else {
  print $response->content();
}
Il codice è stato preso da varie ricerche su Google, quindi non è mio.
 
Robertof sicuro che sia così? Non sono molto ferrato in perl ma credo debba essere più qualcosa somigliante a

$request->header(Referer => 'http://www.puppamelotanto.com/');

Aspettiamo qualcuno di più ferrato in materia comunque, non ho nemmeno modo di testare ora ^^

Dante, certo devi sapere quali referer il sito accetta (sicuramente nel tuo caso, l'applicazione su cui stai lavorando farà un controllo al momento dell'accesso a qualche cp, vedendo se il referer è il sito stesso).
 
Eh sì, lo eredita da HTTP::Message il metodo, ci sono rimasto male. Come non detto.

D4nt3 ha detto:
Il sito ha un controllo del Referer in ogni pagina. Ce l'ho in locale e ho testato cn Live HTTP Headers, accetta anche 127.0.0.1. Dante

Credo proprio che accetti il 127.0.0.1 PROPRIO perché è installato in locale. Se lo installi in remoto magari pone il controllo sul referer al dominio stesso.
Comunque, è strana come cosa eh, e non ne capisco il senso
 
Il referer è l'host alla fine. Cmq è troppo strano.. Ed è anche tanto brutto, perché questa roba la voglio fare in perl, nn in php o altri linguaggi. Dante
 
Ho scaricato l'ultima versione di Active Perl :) si vede che in quella vecchia c'era qualche bug oppure nn c'erano neancora le funzioni :D ora il problema che ho è nel settare i cookie. Ho fatto un altro topic :) Dante
 
Stato
Discussione chiusa ad ulteriori risposte.