|
From: <var...@us...> - 2021-08-13 14:26:00
|
Revision: 10507
http://sourceforge.net/p/phpwiki/code/10507
Author: vargenau
Date: 2021-08-13 14:25:58 +0000 (Fri, 13 Aug 2021)
Log Message:
-----------
Move functions _ncsa_time and _zone_offset from class Request_AccessLogEntry to stdlib
Modified Paths:
--------------
trunk/lib/Request.php
trunk/lib/WikiDB/backend/ADODB_oci8po.php
trunk/lib/WikiDB/backend/PearDB_oci8.php
trunk/lib/WikiUser.php
trunk/lib/stdlib.php
Modified: trunk/lib/Request.php
===================================================================
--- trunk/lib/Request.php 2021-08-13 13:33:55 UTC (rev 10506)
+++ trunk/lib/Request.php 2021-08-13 14:25:58 UTC (rev 10507)
@@ -1067,41 +1067,6 @@
$this->duration = strtr(sprintf("%f", $seconds), ",", ".");
}
- /**
- * Get time zone offset.
- *
- * @param int $time Unix timestamp (defaults to current time).
- * @return string Zone offset, e.g. "-0800" for PST.
- */
- static function _zone_offset($time = 0)
- {
- if (!$time)
- $time = time();
- $offset = date("Z", $time);
- $negoffset = "";
- if ($offset < 0) {
- $negoffset = "-";
- $offset = -$offset;
- }
- $offhours = floor($offset / 3600);
- $offmins = $offset / 60 - $offhours * 60;
- return sprintf("%s%02d%02d", $negoffset, $offhours, $offmins);
- }
-
- /**
- * Format time in NCSA format.
- *
- * @param int $time Unix timestamp (defaults to current time).
- * @return string Formatted date & time.
- */
- function _ncsa_time($time = 0)
- {
- if (!$time)
- $time = time();
- return date("d/M/Y:H:i:s", $time) .
- " " . $this->_zone_offset();
- }
-
function write()
{
if ($this->_accesslog->logfile) $this->write_file();
@@ -1115,7 +1080,7 @@
{
$entry = sprintf('%s %s %s [%s] "%s" %d %d "%s" "%s"',
$this->host, $this->ident, $this->user,
- $this->_ncsa_time($this->time),
+ _ncsa_time($this->time),
$this->request, $this->status, $this->size,
$this->referer, $this->user_agent);
if (!empty($this->_accesslog->reader)) {
Modified: trunk/lib/WikiDB/backend/ADODB_oci8po.php
===================================================================
--- trunk/lib/WikiDB/backend/ADODB_oci8po.php 2021-08-13 13:33:55 UTC (rev 10506)
+++ trunk/lib/WikiDB/backend/ADODB_oci8po.php 2021-08-13 14:25:58 UTC (rev 10507)
@@ -162,7 +162,7 @@
$entry->request,
$entry->request_uri,
$entry->request_args,
- $entry->_ncsa_time($entry->time),
+ _ncsa_time($entry->time),
$entry->status,
$entry->size,
$entry->referer,
Modified: trunk/lib/WikiDB/backend/PearDB_oci8.php
===================================================================
--- trunk/lib/WikiDB/backend/PearDB_oci8.php 2021-08-13 13:33:55 UTC (rev 10506)
+++ trunk/lib/WikiDB/backend/PearDB_oci8.php 2021-08-13 14:25:58 UTC (rev 10507)
@@ -115,7 +115,7 @@
$entry->request,
$entry->request_uri,
$entry->request_args,
- $entry->_ncsa_time($entry->time),
+ _ncsa_time($entry->time),
$entry->status,
$entry->size,
$entry->referer,
Modified: trunk/lib/WikiUser.php
===================================================================
--- trunk/lib/WikiUser.php 2021-08-13 13:33:55 UTC (rev 10506)
+++ trunk/lib/WikiUser.php 2021-08-13 14:25:58 UTC (rev 10507)
@@ -598,7 +598,7 @@
if ($logout) { // Log out
if (LOGIN_LOG and is_writeable(LOGIN_LOG)) {
- $zone_offset = Request_AccessLogEntry::_zone_offset();
+ $zone_offset = _zone_offset();
$ncsa_time = date("d/M/Y:H:i:s", time());
$entry = sprintf('%s - %s - [%s %s] "%s" %s - "%s" "%s"',
(string)$request->get('REMOTE_HOST'),
@@ -634,7 +634,7 @@
$authlevel = $this->checkPass($passwd === false ? '' : $passwd);
if (LOGIN_LOG and is_writeable(LOGIN_LOG)) {
- $zone_offset = Request_AccessLogEntry::_zone_offset();
+ $zone_offset = _zone_offset();
$ncsa_time = date("d/M/Y:H:i:s", time());
$manglepasswd = $passwd;
for ($i = 0; $i < strlen($manglepasswd); $i++) {
Modified: trunk/lib/stdlib.php
===================================================================
--- trunk/lib/stdlib.php 2021-08-13 13:33:55 UTC (rev 10506)
+++ trunk/lib/stdlib.php 2021-08-13 14:25:58 UTC (rev 10507)
@@ -1074,6 +1074,40 @@
}
/**
+ * Get time zone offset.
+ *
+ * @param int $time Unix timestamp (defaults to current time).
+ * @return string Zone offset, e.g. "-0800" for PST.
+ */
+function _zone_offset($time = 0)
+{
+ if (!$time)
+ $time = time();
+ $offset = date("Z", $time);
+ $negoffset = "";
+ if ($offset < 0) {
+ $negoffset = "-";
+ $offset = -$offset;
+ }
+ $offhours = floor($offset / 3600);
+ $offmins = $offset / 60 - $offhours * 60;
+ return sprintf("%s%02d%02d", $negoffset, $offhours, $offmins);
+}
+
+/**
+ * Format time in NCSA format.
+ *
+ * @param int $time Unix timestamp (defaults to current time).
+ * @return string Formatted date & time.
+ */
+function _ncsa_time($time = 0)
+{
+ if (!$time)
+ $time = time();
+ return date("d/M/Y:H:i:s", $time) . " " . _zone_offset();
+}
+
+/**
* Get time offset for local time zone.
*
* @param int $time Get offset for this time. Default: now.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|