#!/bin/bash

# Fix hebrew with an extremely dirty hack. Any .html file that
# isn't under source/ and has been modified during the last 60 minutes is
# mangled. Any line in these files that doesn't look like UTF-8 is translated
# into UTF-8 from windows-1255.
										
WWWPATH=/var/www/html
find $WWWPATH -iname \*.html -a -type f -a -mmin -60 \
     -a -not -path $WWWPATH/source/\* | \
  while read fixfile ; do
    ./fix-utf8.pl "$fixfile" > "$fixfile.utf8-tmp"
    mv -f "$fixfile.utf8-tmp" "$fixfile"
  done;

# Extra cleanup, just to be sure
rm -f `find $WWWPATH -name \*.utf8-tmp`

