Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv7439/lib
Modified Files:
config.php main.php stdlib.php userauth.php
Added Files:
logger.php
Log Message:
Added support for creating our own NCSA style access_log's.
***** Error reading new file: [Errno 2] No such file or directory: 'logger.php'
Index: config.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** config.php 2001/02/15 05:57:18 1.33
--- config.php 2001/02/16 04:43:07 1.34
***************
*** 27,31 ****
// Set up localization
//
-
if (empty($LANG))
$LANG = "C";
--- 27,30 ----
***************
*** 232,235 ****
--- 231,243 ----
}
+ // Access log
+ if (!defined('ACCESS_LOG'))
+ define('ACCESS_LOG', '');
+
+ // Get remote host name, if apache hasn't done it for us
+ if (empty($REMOTE_HOST) && ENABLE_REVERSE_DNS)
+ $REMOTE_HOST = gethostbyaddr($REMOTE_ADDR);
+
+
// For emacs users
// Local Variables:
Index: main.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/main.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** main.php 2001/02/15 19:32:34 1.4
--- main.php 2001/02/16 04:43:08 1.5
***************
*** 5,10 ****
--- 5,20 ----
include "lib/userauth.php";
+ if (ACCESS_LOG)
+ {
+ include "lib/logger.php";
+ $LogEntry = new AccessLogEntry;
+
+ function _write_log () { $GLOBALS['LogEntry']->write(ACCESS_LOG); }
+ register_shutdown_function('_write_log');
+ }
+
if (USE_PATH_INFO && !isset($PATH_INFO))
{
+ $LogEntry->status = 302; // "302 Found"
header("Location: " . SERVER_URL . $REQUEST_URI);
exit;
***************
*** 73,77 ****
--- 83,92 ----
}
+
$user = new WikiUser(get_auth_mode($action));
+ if (ACCESS_LOG and $user->is_authenticated())
+ $LogEntry->user = $user->id;
+
+
// All requests require the database
Index: stdlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** stdlib.php 2001/02/15 21:35:03 1.33
--- stdlib.php 2001/02/16 04:43:08 1.34
***************
*** 4,8 ****
/*
Standard functions for Wiki functionality
- ExitWiki($errormsg)
WikiURL($pagename, $args, $abs)
--- 4,7 ----
***************
*** 29,45 ****
return $text;
}
-
-
- function get_remote_host () {
- // Apache won't show REMOTE_HOST unless the admin configured it
- // properly. We'll be nice and see if it's there.
- if (getenv('REMOTE_HOST'))
- return getenv('REMOTE_HOST');
- $host = getenv('REMOTE_ADDR');
- if (ENABLE_REVERSE_DNS)
- return gethostbyaddr($host);
- return $host;
- }
-
function arrays_equal ($a, $b)
--- 28,31 ----
Index: userauth.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/userauth.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** userauth.php 2001/02/13 05:54:38 1.3
--- userauth.php 2001/02/16 04:43:08 1.4
***************
*** 19,23 ****
function WikiUser ($auth_mode = '') {
// Restore from cookie.
! global $WIKI_AUTH;
if (empty($WIKI_AUTH))
{
--- 19,23 ----
function WikiUser ($auth_mode = '') {
// Restore from cookie.
! global $WIKI_AUTH, $REMOTE_HOST, $REMOTE_ADDR;
if (empty($WIKI_AUTH))
{
***************
*** 50,54 ****
$this->realm++;
$this->state = 'loggedout';
! $this->userid = get_remote_host(); // Anonymous user id is hostname.
}
else
--- 50,54 ----
$this->realm++;
$this->state = 'loggedout';
! $this->userid = empty($REMOTE_HOST) ? $REMOTE_ADDR : $REMOTE_HOST;
}
else
***************
*** 154,157 ****
--- 154,159 ----
header('WWW-Authenticate: Basic realm="' . $this->realm . '"');
header("HTTP/1.0 401 Unauthorized");
+ if (ACCESS_LOG)
+ $LogEntry->status = 401;
echo gettext ("You entered an invalid login or password.");
ExitWiki();
|