Last change
on this file since 834 was
181,
checked in by sherbold, 13 years ago
|
initial commit of PHPMonitor, a short script for the usage monitoring of PHP based web applications
|
File size:
1.0 KB
|
Line | |
---|
1 | <?php
|
---|
2 | /*
|
---|
3 | * Usage monitoring script for PHP web applications.
|
---|
4 | * Requires the apache modules mod_usertrack to provide
|
---|
5 | * a cookie for user identification.
|
---|
6 | */
|
---|
7 | $log_dir = dirname( __FILE__)."/";
|
---|
8 | $log_name = "usage.log";
|
---|
9 | $cookie_name = "swe_informatik_uni-goettingen_de";
|
---|
10 |
|
---|
11 | $postkeys = "";
|
---|
12 |
|
---|
13 | while (list($key, $value) = each($_POST)) {
|
---|
14 | $postkeys = $postkeys." ".$key;
|
---|
15 | }
|
---|
16 | if( $_SERVER['HTTP_REFERER']=='' ) {
|
---|
17 | $referer = '-';
|
---|
18 | } else {
|
---|
19 | $referer = $_SERVER['HTTP_REFERER'];
|
---|
20 | }
|
---|
21 |
|
---|
22 | $cookieVal = $_COOKIE[$cookie_name];
|
---|
23 | if($cookieVal==0) {
|
---|
24 | $apacheHeader = apache_response_headers();
|
---|
25 | $explodeResult1 = explode(';',$apacheHeader['Set-Cookie']);
|
---|
26 | $explodeResult2 = explode('=',$explodeResult1[0]);
|
---|
27 | $cookieVal = $explodeResult2[1];
|
---|
28 | }
|
---|
29 |
|
---|
30 | $log_entry = "\"".$cookieVal."\" \"".gmdate('Y-m-d H:i:s')."\" \"".$_SERVER['REQUEST_URI']."\" \"".$referer."\" \"".$_SERVER['HTTP_USER_AGENT']."\" \"".$postkeys."\"\r\n";
|
---|
31 | $fp=fopen( $log_dir . $log_name, 'a' );
|
---|
32 | fputs($fp, $log_entry);
|
---|
33 | fclose($fp);
|
---|
34 | ?>
|
---|
Note: See
TracBrowser
for help on using the repository browser.