Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.php > #4703

Verwendung von $_SERVER (was: Validator kaputt?)

From Sebastian Suchanek <sebastian.suchanek@gmx.de>
Newsgroups de.comm.software.mozilla.browser, de.comp.lang.php
Subject Verwendung von $_SERVER (was: Validator kaputt?)
Followup-To de.comp.lang.php
Date 2021-05-16 18:07 +0200
Message-ID <s7rg0g$n9v$1@msgid.suchanek.de> (permalink)
References (4 earlier) <609F8ECE.970942F@Berger-Odenthal.De> <igarr8Fjp2cU1@mid.individual.net> <87pmxrw28i.fsf@usenet.ankman.de> <s7qle4$v01$1@msgid.suchanek.de> <87k0nywwvd.fsf@usenet.ankman.de>

Cross-posted to 2 groups.

Followups directed to: de.comp.lang.php

Show all headers | View raw


Am 16.05.2021 um 16:56 schrieb Andreas Kohlbach:
> On Sun, 16 May 2021 10:34:14 +0200, Sebastian Suchanek wrote:
>>
>> Am 16.05.2021 um 09:45 schrieb Andreas Kohlbach:
>>
>>> [Link für W3C-Validator]
>>> Für
>>> <?php
>>>    echo "http://validator.w3.org/check?uri=" . $_SERVER['HTTP_REFERER'];
>>> ?>
>>> habe ich eine oder zwei Minuten gebraucht. Vielleicht nicht "schön",
>>> aber
>>> kostenlos.
>>
>> ...und vor allem fchals.
>>
>> Wenn, dann eher etwas wie:
>>
>> <?php
>>   echo
>>   'http://validator.w3.org/check?uri=http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
>> ?>
>>
>> (Ungetestet!)
> 
> Auf meinem Server (lighttp) geben Deine und meine Zeile Identisches aus.

Ich nehme an, Du hast Deinen Testcase im Browser direkt aufgerufen?

> Wenn meine falsch wäre, hätte der Server sich beschweren sollen. Apache
> oder so habe ich zum Testen nicht zur Verfügung.

RTFM[1]:

| [...]
| 'HTTP_REFERER'
|     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.
| [...]

IOW: Deine Zeile schickt baut nicht die URL von Alex' Seite in den 
Validator-Link ein, sondern den Referer, von dem aus der Bersucher auf 
Alex' Seite gekommen ist. Das kann eine andere Seite von Alex sein, das 
kann Google sein...
Und warum die Verwendung von $_SERVER['HTTP_REFERER'] an sich keine gute 
Idee ist, ist auch angedeutet.


Tschüs,

Sebastian

PS: XP & f'up2 de.comp.lang.php

_____
[1] https://www.php.net/manual/en/reserved.variables.server.php

Back to de.comp.lang.php | Previous | NextNext in thread | Find similar


Thread

Verwendung von $_SERVER (was: Validator kaputt?) Sebastian Suchanek <sebastian.suchanek@gmx.de> - 2021-05-16 18:07 +0200
  Re: Verwendung von $_SERVER Andreas Kohlbach <ank@spamfence.net> - 2021-05-16 15:10 -0400

csiph-web