Skip to content

Instantly share code, notes, and snippets.

@koconder
Created October 3, 2013 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koconder/6811140 to your computer and use it in GitHub Desktop.
Save koconder/6811140 to your computer and use it in GitHub Desktop.
Update all Timthumb Files across Cpanel Users
#! /bin/bash
# Detects and updates timthumb.php to latest version for all cPanel users.
# dropdeaddick.com
latest=`lynx -source http://timthumb.googlecode.com/svn/trunk/timthumb.php |grep "define ('VERSION'" $file |cut -f4 -d"'"`
if [ -z "$latest" ]; then
echo "could not get latest timthumb release, aborting!"
exit 1
fi
for user in `awk -F':' '{ if ($3 > 499) print $0 }' /etc/passwd | grep home | cut -d':' -f1`; do
for file in `find /home*/$user/public_html/ -type f \( -name 'thumb.php' -o -name 'timthumb.php' \) 2>/dev/null | tr ' ' '%'`; do
file=`echo $file | tr '%' ' '`
check=`grep -c "code.google.com/p/timthumb" "$file"`
if [ -z "$check" ]; then
break
fi
if [ "$check" -gt "0" ]; then
version=`grep "define ('VERSION'" "$file" |cut -f4 -d"'"`
if [ "$version" != "$latest" ]; then
echo -e "\e[1;31mWARNING version $version\e[0m updating $file!"
# rm -f $file #delete current file before replacing.
wget -nv -t3 -T3 http://timthumb.googlecode.com/svn/trunk/timthumb.php -O "$file"
chown $user: "$file"
else
echo -e "\e[1;32mOK version $version\e[0m skipping $file"
fi
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment