Unterstütze uns! Spende jetzt!

Tools/Wordpress-Plugin-Status

Aus PiratenWiki
Zur Navigation springen Zur Suche springen

Dieses Skript dient zum "Ausspähen" der installierten Wordpress- und Plugin-Versionen aller Blogs des LVBB.


WTFPL logo.svg

Diese Datei wird unter der Do What the Fuck You Want to Public License" zur Verfügung gestellt.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.


#!/bin/bash
#
# alle Wordpress- und Plugin-Versionen aus /var/www auslesen
#

set -e

IFS_BAK="$IFS";
IFS=$'\n';

ABSENDER="Der nette Admin <root by piratenbrandenburg.de>"
SENDTO="root-admins by piratenbrandenburg.de"

DATUM=$(date +%Y%m%d)

SUBJECT='wordpress status'

# tmp directory is fixed, tmp-file is determined randomly.
wp_tmpfile="$(mktemp -q /tmp/wp.XXXXXXXXXXXXXXXXXXXXXXXX)" || exit 1

echo -e "Beginn Check Wordpress- und Plugin-Versionen\n" > "$wp_tmpfile"

for page in $(find /var/www -type d -name 'wp-content') ; do

    echo -e "\n### $page ###########\n" >> "$wp_tmpfile"

    if [ -d "$page" ]; then

        cd "$page"

        if [ -f ../wp-includes/version.php ]; then

            grep '^$wp_version' ../wp-includes/version.php >> "$wp_tmpfile"
            echo "" >> "$wp_tmpfile"

        fi

    fi

    plugindir="$page/plugins"

    if [ -d "$plugindir" ]; then

        phpfiles=$(find "$plugindir" -name '*.php')

        for plugin in $phpfiles ; do

            if pname=$(grep -E '^\s*.?\s*Plugin Name:' "$plugin") ; then

                echo "$pname" >> "$wp_tmpfile"
                grep -E '^\s*.?\s*Version:' "$plugin" >> "$wp_tmpfile"

            fi

        done

    fi

done

echo -e "\n\nEnde Check Wordpress- und Plugin-Versionen" >> "$wp_tmpfile"

IFS="$IFS_BAK"

if [ -f "$wp_tmpfile" ]; then
    mail -a "From: $ABSENDER" -s "[$(hostname)] $SUBJECT $DATUM" "$SENDTO" < "$wp_tmpfile"
    rm -f "$wp_tmpfile" > /dev/null 2>&1
fi

exit 0

# eof