コミットメタ情報

リビジョン341077ba76e1c318e0eb3884d3d4a6985b5c4669 (tree)
日時2017-08-23 05:51:19
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/571 Write out editing history

変更サマリ

差分

--- a/lib/file.php
+++ b/lib/file.php
@@ -319,14 +319,16 @@ function file_write($dir, $page, $str, $notimestamp = FALSE, $is_delete = FALSE)
319319 } else if ($dir == DIFF_DIR && $notify) {
320320 if ($notify_diff_only) $str = preg_replace('/^[^-+].*\n/m', '', $str);
321321 $footer['ACTION'] = 'Page update';
322- $footer['PAGE'] = & $page;
322+ $footer['PAGE'] = $page;
323323 $footer['URI'] = get_script_uri() . '?' . pagename_urlencode($page);
324324 $footer['USER_AGENT'] = TRUE;
325325 $footer['REMOTE_ADDR'] = TRUE;
326326 pkwk_mail_notify($notify_subject, $str, $footer) or
327327 die('pkwk_mail_notify(): Failed');
328328 }
329-
329+ if ($dir === DIFF_DIR) {
330+ pkwk_access_log_updates($page, $str);
331+ }
330332 is_page($page, TRUE); // Clear is_page() cache
331333 }
332334
--- a/lib/func.php
+++ b/lib/func.php
@@ -27,6 +27,38 @@ function pkwk_log($message)
2727 }
2828
2929 /**
30+ * Write access_log to update contents.
31+ *
32+ * @param $page page name
33+ * @param $diff_content diff expression
34+ */
35+function pkwk_access_log_updates($page, $diff_content) {
36+ global $user_agent;
37+ $log_dir = 'accesslog';
38+ $json_filename = $log_dir . '/accesslog.' . gmdate('Ymd') . '.json';
39+ $log_filename = $log_dir . '/accesslog.' . gmdate('Ymd') . '.log';
40+ $d = array(
41+ 'time' => gmdate('Y-m-d H:i:s'),
42+ 'uri' => $_SERVER['REQUEST_URI'],
43+ 'method' => $_SERVER['REQUEST_METHOD'],
44+ 'remote_addr' => $_SERVER['REMOTE_ADDR'],
45+ 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
46+ 'page' => $page,
47+ 'diff' => $diff_content
48+ );
49+ if (file_exists($log_dir) && defined('JSON_UNESCAPED_UNICODE')) {
50+ // PHP5.4+
51+ $line = json_encode($d, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\n";
52+ file_put_contents($json_filename, $line, FILE_APPEND | LOCK_EX);
53+ $ltsv = "time:" . $d['time'] . "\turi:" . $d['uri'] .
54+ "\tmethod:" . $d['method'] . "\tremote_addr:" . $d['remote_addr'] .
55+ "\tuser_agent:" . $d['user_agent'] . "\tpage:" .
56+ preg_replace('#[\t\r\n]#', '', $d['page']) . "\n";
57+ file_put_contents($log_filename, $ltsv, FILE_APPEND | LOCK_EX);
58+ }
59+}
60+
61+/**
3062 * ctype_digit that supports PHP4+.
3163 *
3264 * PHP official document says PHP4 has ctype_digit() function.
--- a/lib/init.php
+++ b/lib/init.php
@@ -2,7 +2,7 @@
22 // PukiWiki - Yet another WikiWikiWeb clone.
33 // init.php
44 // Copyright
5-// 2002-2016 PukiWiki Development Team
5+// 2002-2017 PukiWiki Development Team
66 // 2001-2002 Originally written by yu-ji
77 // License: GPL v2 or (at your option) any later version
88 //
@@ -152,7 +152,6 @@ $ua = 'HTTP_USER_AGENT';
152152 $user_agent = $matches = array();
153153
154154 $user_agent['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
155-unset(${$ua}, $_SERVER[$ua], $HTTP_SERVER_VARS[$ua], $ua); // safety
156155
157156 foreach ($agents as $agent) {
158157 if (preg_match($agent['pattern'], $user_agent['agent'], $matches)) {
@@ -453,3 +452,4 @@ $line_rules = array_merge(array(
453452 '&amp;(#[0-9]+|#x[0-9a-f]+|' . get_html_entity_pattern() . ');' => '&$1;',
454453 "\r" => '<br />' . "\n", /* 行末にチルダは改行 */
455454 ), $line_rules);
455+
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -1,8 +1,8 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: mail.php,v 1.7 2005/06/09 15:16:41 henoheno Exp $
4-// Copyright (C)
5-// 2003-2005 PukiWiki Developers Team
3+// mail.php
4+// Copyright
5+// 2003-2017 PukiWiki Development Team
66 // 2003 Originally written by upk
77 // License: GPL v2 or (at your option) any later version
88 //
@@ -51,7 +51,7 @@ function pkwk_mail_notify($subject, $message, $footer = array())
5151 if (isset($footer['PAGE'])) $subject = str_replace('$page', $footer['PAGE'], $subject);
5252
5353 // Footer
54- if (isset($footer['REMOTE_ADDR'])) $footer['REMOTE_ADDR'] = & $_SERVER['REMOTE_ADDR'];
54+ if (isset($footer['REMOTE_ADDR'])) $footer['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
5555 if (isset($footer['USER_AGENT']))
5656 $footer['USER_AGENT'] = '(' . UA_PROFILE . ') ' . UA_NAME . '/' . UA_VERS;
5757 if (! empty($footer)) {
@@ -152,4 +152,4 @@ function pop_before_smtp($pop_userid = '', $pop_passwd = '',
152152 return TRUE; // Success
153153 }
154154 }
155-?>
155+
旧リポジトリブラウザで表示