mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
- Document the *AUTH* vars in the predefined appendix, use $_SERVER and
$_REQUEST in the http auth example, closes #14804. # Wth has there been used !strcmp() to match strigns?! Removed. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@85331 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
9c9839d15e
commit
9bac3b96f6
3 changed files with 71 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
|
||||
<!-- Note: Please do not link or translate this file yet.
|
||||
This is only an initial update, quite a few more commits will
|
||||
|
@ -356,6 +356,36 @@ follow for this appendix. -->
|
|||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_USER</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authentication this
|
||||
variable is set to the username prodived by the user.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_PW</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authentication this
|
||||
variable is set to the password prodived by the user.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_TYPE</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authenticated this
|
||||
variable is set to the authentication type.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.21 $ -->
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
|
||||
<appendix id="reserved">
|
||||
<title>List of Reserved Words</title>
|
||||
|
@ -555,6 +555,36 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_USER</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authentication this
|
||||
variable is set to the username prodived by the user.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_PW</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authentication this
|
||||
variable is set to the password prodived by the user.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>'<varname>PHP_AUTH_TYPE</varname>'</term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
When running under Apache as module doing HTTP authenticated this
|
||||
variable is set to the authentication type.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.22 $ -->
|
||||
<!-- $Revision: 1.23 $ -->
|
||||
<chapter id="features.http-auth">
|
||||
<title>HTTP authentication with PHP</title>
|
||||
|
||||
|
@ -25,14 +25,14 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
if (!isset($PHP_AUTH_USER)) {
|
||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
header("WWW-Authenticate: Basic realm=\"My Realm\"");
|
||||
header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Text to send if user hits Cancel button\n";
|
||||
exit;
|
||||
} else {
|
||||
echo "<p>Hello $PHP_AUTH_USER.</p>";
|
||||
echo "<p>You entered $PHP_AUTH_PW as your password.</p>";
|
||||
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
|
||||
echo "<p>You entered {$_SERVER['$PHP_AUTH_PW']} as your password.</p>";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
@ -104,15 +104,15 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
if (!isset($PHP_AUTH_USER) || ($SeenBefore == 1 && !strcmp($OldAuth, $PHP_AUTH_USER))) {
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || ($SeenBefore == 1 && $OldAuth == $_SERVER['$PHP_AUTH_USER']))) {
|
||||
authenticate();
|
||||
}
|
||||
else {
|
||||
echo "<p>Welcome: $PHP_AUTH_USER<br>";
|
||||
echo "Old: $OldAuth";
|
||||
echo "<form action='$PHP_SELF' METHOD='POST'>\n";
|
||||
echo "<p>Welcome: {$_SERVER['$PHP_AUTH_USER']}<br>";
|
||||
echo "Old: {$_REQUEST['$OldAuth']}";
|
||||
echo "<form action='{$_SERVER['$PHP_SELF']}' METHOD='POST'>\n";
|
||||
echo "<input type='hidden' name='SeenBefore' value='1'>\n";
|
||||
echo "<input type='hidden' name='OldAuth' value='$PHP_AUTH_USER'>\n";
|
||||
echo "<input type='hidden' name='OldAuth' value='{$_SERVER['$PHP_AUTH_USER']}'>\n";
|
||||
echo "<input type='submit' value='Re Authenticate'>\n";
|
||||
echo "</form></p>\n";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue