#!/bin/bash # Hotfix script for TYPO3 to mask IP address for data privacy protection reasons. # The IP address xxx.xxx.xxx.xxx will be masked with xxx.xxx.xxx.0 # # Work with Typo3 4.2.x and 4.3.x # # This script will search for affected files within MYPATH (can be changed # below) and fixes every file automatically, keeping a backup copy with # suffix "." in the same directory. Permissions and ownership # of the files will be preserved. # # Author: Nathan von Alemann - Logisdat GmbH - info at logisdat.de - 16.04.2010 # adapted from fix_10364.sh from Michael Stucki # # Usage: # 1) Make this script executable - maybe you like rename it to .sh # 2) Run this script # # chmod a+x ./typo3_ipmask.sh # ./typo3_ipmask.sh # # How to check if the fix was successful: # Search the whole system for files named "class.tslib_fe.php" that # contain the string "// Log part 2: Fake the remote logname" # Start path: Search for affected files within this directory. Leave # default if unsure. MYPATH=/ # Do not change these values! FILE2FIX="class.tslib_fe.php" SEARCH="\/\/ Log part 2: Fake the remote logname" COMMENT="\/\/ Mask remote address for data privacy protection reasons." MASK="\$LogLine = substr(\$LogLine, 0, strrpos(\$LogLine, '.')).'.0';" echo "Typo3 fix - mask IP" echo "Searching for file $FILE2FIX in $MYPATH" echo -e "\tThis might tak a while...\n" for FILE in $(find $MYPATH -name $FILE2FIX); do echo "Fixing file $FILE..." if [ $(grep -c "$MASK" $FILE) -eq 0 ] then sed -i.$(date +%s) "s/$SEARCH/$COMMENT\n\t\t\t\t\t\t$MASK\n\t\t\t\t\t\t\t$SEARCH/" $FILE else echo -e "\tFile already fixed!" fi done