Gentoo Archives: gentoo-commits

From: "Tom Knight (tomk)" <tomk@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-projects commit in forums/htdocs/includes: functions.php page_header.php page_tail.php
Date: Wed, 08 Sep 2010 10:42:11
Message-Id: 20100908104203.D8E6720051@flycatcher.gentoo.org
1 tomk 10/09/08 10:42:03
2
3 Modified: functions.php page_header.php page_tail.php
4 Log:
5 log requests to syslog
6
7 Revision Changes Path
8 1.28 forums/htdocs/includes/functions.php
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/functions.php?rev=1.28&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/functions.php?rev=1.28&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/functions.php?r1=1.27&r2=1.28
13
14 Index: functions.php
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-projects/forums/htdocs/includes/functions.php,v
17 retrieving revision 1.27
18 retrieving revision 1.28
19 diff -u -r1.27 -r1.28
20 --- functions.php 19 Aug 2009 17:41:37 -0000 1.27
21 +++ functions.php 8 Sep 2010 10:42:03 -0000 1.28
22 @@ -7,7 +7,7 @@
23 * copyright : (C) 2001 The phpBB Group
24 * email : support@×××××.com
25 *
26 - * $Id: functions.php,v 1.27 2009/08/19 17:41:37 robbat2 Exp $
27 + * $Id: functions.php,v 1.28 2010/09/08 10:42:03 tomk Exp $
28 *
29 *
30 ***************************************************************************/
31 @@ -1138,6 +1138,54 @@
32 fclose($handle);
33 }
34
35 +// 2010-09-08 tomk
36 +// log message to syslog
37 +function phpbb_syslog($message, $priority=LOG_INFO) {
38 + if (openlog("phpbb", LOG_ODELAY | LOG_PID, LOG_USER)) {
39 + syslog($priority, $message);
40 + } else {
41 + // failed to open syslog - move along nothing to see here
42 + }
43 +
44 + closelog();
45 +}
46 +
47 +// 2010-09-08 tomk
48 +// log requests to syslog to be able to track potential OOM requests
49 +// use similar format to combined apache log without things that are only known after request is complete
50 +// "%{identifier} %h %{DomainName} %u %t \"%r\" %{MemoryUsage} \"%{Referer}i\" \"%{User-agent}i\""
51 +// optionally include memory usage (really only usefully at end of script)
52 +function phpbb_syslog_request($identifier, $mem_usage=false) {
53 + // identifier
54 + $message = $identifier . " ";
55 +
56 + // remote IP
57 + $message .= $_SERVER['REMOTE_ADDR'] . " ";
58 +
59 + // domain name
60 + $message .= $_SERVER['SERVER_NAME'] . " ";
61 +
62 + // auth user
63 + $message .= (empty($_SERVER['PHP_AUTH_USER']) ? "-" : $_SERVER['PHP_AUTH_USER']) . " ";
64 +
65 + // timestamp - [day/month/year:hour:minute:second zone]
66 + $message .= date("[d/M/Y:G:i:s O]") . " ";
67 +
68 + // request
69 + $message .= "\"" . $_SERVER['REQUEST_METHOD'] . " " . $_SERVER['REQUEST_URI'] . " " . $_SERVER['SERVER_PROTOCOL'] . "\" ";
70 +
71 + // optional memory usage
72 + $message .= ($mem_usage ? memory_get_usage() : "-") . " ";
73 +
74 + // referrer
75 + $message .= "\"" . (empty($_SERVER['HTTP_REFERER']) ? "-" : $_SERVER['HTTP_REFERER']) . "\" ";
76 +
77 + // user agent
78 + $message .= "\"" . (empty($_SERVER['HTTP_USER_AGENT']) ? "-" : $_SERVER['HTTP_USER_AGENT']) . "\"";
79 +
80 + phpbb_syslog($message);
81 +}
82 +
83 // 2005-04-18 tomk
84 // Check users post distribution
85 /*
86
87
88
89 1.15 forums/htdocs/includes/page_header.php
90
91 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_header.php?rev=1.15&view=markup
92 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_header.php?rev=1.15&content-type=text/plain
93 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_header.php?r1=1.14&r2=1.15
94
95 Index: page_header.php
96 ===================================================================
97 RCS file: /var/cvsroot/gentoo-projects/forums/htdocs/includes/page_header.php,v
98 retrieving revision 1.14
99 retrieving revision 1.15
100 diff -u -r1.14 -r1.15
101 --- page_header.php 30 Jul 2009 11:41:55 -0000 1.14
102 +++ page_header.php 8 Sep 2010 10:42:03 -0000 1.15
103 @@ -6,7 +6,7 @@
104 * copyright : (C) 2001 The phpBB Group
105 * email : support@×××××.com
106 *
107 - * $Id: page_header.php,v 1.14 2009/07/30 11:41:55 desultory Exp $
108 + * $Id: page_header.php,v 1.15 2010/09/08 10:42:03 tomk Exp $
109 *
110 *
111 ***************************************************************************/
112 @@ -27,6 +27,9 @@
113
114 define('HEADER_INC', TRUE);
115
116 +// 2010-09-08 tomk - log request to syslog
117 +phpbb_syslog_request("S");
118 +
119 //
120 // gzip_compression
121 //
122
123
124
125 1.8 forums/htdocs/includes/page_tail.php
126
127 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_tail.php?rev=1.8&view=markup
128 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_tail.php?rev=1.8&content-type=text/plain
129 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/forums/htdocs/includes/page_tail.php?r1=1.7&r2=1.8
130
131 Index: page_tail.php
132 ===================================================================
133 RCS file: /var/cvsroot/gentoo-projects/forums/htdocs/includes/page_tail.php,v
134 retrieving revision 1.7
135 retrieving revision 1.8
136 diff -u -r1.7 -r1.8
137 --- page_tail.php 18 May 2010 19:05:53 -0000 1.7
138 +++ page_tail.php 8 Sep 2010 10:42:03 -0000 1.8
139 @@ -6,7 +6,7 @@
140 * copyright : (C) 2001 The phpBB Group
141 * email : support@×××××.com
142 *
143 - * $Id: page_tail.php,v 1.7 2010/05/18 19:05:53 tomk Exp $
144 + * $Id: page_tail.php,v 1.8 2010/09/08 10:42:03 tomk Exp $
145 *
146 *
147 ***************************************************************************/
148 @@ -76,6 +76,9 @@
149 echo pack('V', $gzip_size);
150 }
151
152 +// 2010-09-08 tomk - log request to syslog with mem usage
153 +phpbb_syslog_request("E", true);
154 +
155 exit;
156
157 ?>