#!/bin/sh
#
# SPHPBlog-Security 4.0.5p1
# <http://www.simplerezo.com/FreeBSD/sphpblog/>
#
# Small shell script to secure SPHPBlog installation on Apache 1.3/2.0
# by Clément Moulin <cmoulin@simplerezo.com> for SimpleRezo
# Distributed freely under GPL WITHOUT ANY WARRANTY
#
# Run it from the base directory of your SPHPBlog
# It has been tested under FreeBSD 5, should work under any Unix/Linux ;)
#

USER_RO="root:wheel"
USER_RW="www:www"

PRG_CAT=/bin/cat
PRG_CHMOD=/bin/chmod
PRG_CHOWN=/usr/sbin/chown
PRG_FIND=/usr/bin/find



echo -n "Please wait..."

# Somes .htaccess :)
echo 'Deny From All' > config/.htaccess
echo 'Deny From All' > content/.htaccess
${PRG_CAT} > images/.htaccess <<EOI
Deny From All

<FilesMatch "\.(gif|jpe?g|png|GIF|JPE?G|PNG)$">
  Allow From All
</FilesMatch>
EOI

# Change owners/access
${PRG_CHOWN} -R ${USER_RO} .
${PRG_CHOWN} -R ${USER_RW} config content images
${PRG_CHOWN} ${USER_RO} config/password.php */.htaccess
${PRG_FIND} . -type d -exec ${PRG_CHMOD} 755 {} \;
${PRG_FIND} . -type f -exec ${PRG_CHMOD} 644 {} \;

echo " done!"

