From 1fbbc8c3b2d719581991b9c031929e50b6a78dfc Mon Sep 17 00:00:00 2001 From: Patrick Neumann Date: Fri, 16 Nov 2018 10:16:09 +0100 Subject: [PATCH] first try --- etc-cron.daily-anonymize-pafal | 17 ++++++ index.php | 95 ++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100755 etc-cron.daily-anonymize-pafal create mode 100644 index.php diff --git a/etc-cron.daily-anonymize-pafal b/etc-cron.daily-anonymize-pafal new file mode 100755 index 0000000..181c3aa --- /dev/null +++ b/etc-cron.daily-anonymize-pafal @@ -0,0 +1,17 @@ +#!/bin/sh + +# simple cronjob to anonymize IPv4 and IPv6 addresses +# in pafakedaccesslog logfile entries +# on a Debian GNU/Linux default Apache2 and PHP installation +# placed in /etc/cron.daily/ . + +# config +readonly LOG="/var/www/html/pafal/faccess.log" + +# ipv4 +/bin/sed -i -E 's/^([[:digit:]]{1,3}\.)([[:digit:]]{1,3}\.)([^ ]*)(.*)/\1\20.0\4/' "${LOG}" + +# ipv6 +/bin/sed -i -E 's/^([[:xdigit:]]{1,4}:)([[:xdigit:]]{1,4}:)([[:xdigit:]]{1,4}:)([^ ]*)(.*)/\1\2\3:0\5/' "${LOG}" + +exit 0 \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..973e64e --- /dev/null +++ b/index.php @@ -0,0 +1,95 @@ + + + + + + PA | FakedAccessLog + + + + + +

P (olizei) A (kademie) | F (aked) A (ccess) L (og)

+
+
+    
+

+ No access permissions to a "real" access.log are required. + - Logrotation with a maximum of 100 entries. + +

+ + +"; +$emsg .= "How to fix it:
"; +$emsg .= "~# touch $file
"; +$emsg .= "~# chown $user $file
"; +$emsg .= "~# chmod 644 $file"; + +// delete oldest log line if max is reached +if( $log = file( $file ) ) { + if( count( $log ) >= $max ) $log = array_slice( $log, 1 ); +} else { + die( $emsg ); +} + +// append log line to file +$log[] = $line; +if( $add = fopen( $file, 'w' ) ) { + fwrite( $add, implode( '', $log ) ); + fclose( $add ); +} else { + die( $emsg ); +} + +?> \ No newline at end of file