cvs: pearweb /include pear-auth.php
| From: | Stig Bakken | Date: | Thu, 25 Apr 2002 01:38:06 +0000 |
| Subject: | cvs: pearweb /include pear-auth.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3533@lists.php.net to get a copy of this message | ||
ssb Wed Apr 24 21:38:06 2002 EDT
Modified files:
/pearweb/include pear-auth.php
Log:
* use http authentication for xmlrpc requests, and cookies for html
Index: pearweb/include/pear-auth.php
diff -u pearweb/include/pear-auth.php:1.20 pearweb/include/pear-auth.php:1.21
--- pearweb/include/pear-auth.php:1.20 Wed Apr 24 21:17:30 2002
+++ pearweb/include/pear-auth.php Wed Apr 24 21:38:06 2002
@@ -2,51 +2,52 @@
function auth_reject($realm = null, $message = null, $refresh = false)
{
+ global $format;
if ($realm === null) {
$realm = PEAR_AUTH_REALM;
}
if ($message === null) {
$message = "Please enter your username and password:";
}
-/*
- Header("HTTP/1.0 401 Unauthorized");
- Header("WWW-authenticate: basic realm=\"$realm\"");
- if ($refresh) {
- Header("Refresh: 3; url=/");
- }
-*/
- $GLOBALS['ONLOAD'] = "document.login.PEAR_USER.focus();";
+
response_header($message);
- report_error($message);
- print "<form name=\"login\" action=\"/login.php\"
method=\"POST\">\n";
- print "<table>\n";
- print " <tr>\n";
- print " <td>Username:</td>\n";
- print " <td><input size=\"20\"
name=\"PEAR_USER\"></td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <td>Password:</td>\n";
- print " <td><input size=\"20\" name=\"PEAR_PW\"
type=\"password\"></td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <td> </td>\n";
- print " <td><input type=\"checkbox\" name=\"PEAR_PERSIST\"
value=\"on\"> Remember username and password.</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <td> </td>\n";
- print " <td><input type=\"submit\" value=\"Log
in!\"></td>\n";
- print " </tr>\n";
- print "</table>\n";
- print '<input type="hidden" name="PEAR_OLDURL" value="';
- if (basename($_SERVER['PHP_SELF']) == 'login.php') {
- print '/';
- } elseif (isset($_POST['PEAR_OLDURL'])) {
- print htmlspecialchars($_POST['PEAR_OLDURL']);
- } else {
- print htmlspecialchars($_SERVER['REQUEST_URI']);
+ if ($format == 'xmlrpc') {
+ Header("HTTP/1.0 401 Unauthorized");
+ Header("WWW-authenticate: basic realm=\"$realm\"");
+ report_error($message);
+ } elseif ($format == 'html') {
+ $GLOBALS['ONLOAD'] = "document.login.PEAR_USER.focus();";
+ report_error($message);
+ print "<form name=\"login\" action=\"/login.php\"
method=\"POST\">\n";
+ print "<table>\n";
+ print " <tr>\n";
+ print " <td>Username:</td>\n";
+ print " <td><input size=\"20\"
name=\"PEAR_USER\"></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <td>Password:</td>\n";
+ print " <td><input size=\"20\" name=\"PEAR_PW\"
type=\"password\"></td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <td> </td>\n";
+ print " <td><input type=\"checkbox\"
name=\"PEAR_PERSIST\" value=\"on\"> Remember username and
password.</td>\n";
+ print " </tr>\n";
+ print " <tr>\n";
+ print " <td> </td>\n";
+ print " <td><input type=\"submit\" value=\"Log
in!\"></td>\n";
+ print " </tr>\n";
+ print "</table>\n";
+ print '<input type="hidden" name="PEAR_OLDURL"
value="';
+ if (basename($_SERVER['PHP_SELF']) == 'login.php') {
+ print '/';
+ } elseif (isset($_POST['PEAR_OLDURL'])) {
+ print htmlspecialchars($_POST['PEAR_OLDURL']);
+ } else {
+ print htmlspecialchars($_SERVER['REQUEST_URI']);
+ }
+ print "\" />\n";
+ print "</form>\n";
}
- print "\" />\n";
- print "</form>\n";
response_footer();
exit;
}