Files
neighborhoodwatch/run.d/wordpress
florian e0da46edca add scripts for CakePHP and PHPMyAdmin, courtesy of WvR.
Also include new logging options (verbosity)
2013-10-05 15:45:31 +00:00

40 lines
1.1 KiB
PHP
Executable File

#!/usr/bin/php -q
<?
require_once("toolkit.php");
// Retrieve current Wordpress version from http://api.wordpress.org/core/version-check/1.6/
//
$wp_api = unserialize(file_get_contents("http://api.wordpress.org/core/version-check/1.6/"));
$wp_current = $wp_api['offers'][0]['current'];
verbose("Current Wordpress version: $wp_current", 1);
checkHost(null, $wp_current);
if( $hosts != null ) {
foreach($hosts as $host) {
checkHost($host, $wp_current);
}
}
function checkHost($host, $wp_current) {
$cmd = "locate wp-includes/version.php | xargs grep -H 'wp_version ='";
$hostidentifier = "localhost:";
if( $host != null ) {
$cmd = "ssh $host \"" . $cmd . "\"";
$hostidentifier = $host . ":";
}
exec($cmd, $results);
foreach($results as $instance) {
$parts = explode(':', $instance);
$location = substr($parts[0], 0, strlen($parts[0])-23);
preg_match("/wp_version = '([0-9]+\.[0-9]+(\.[0-9]+)?)';/", $parts[1], $matches);
$version = $matches[1];
if($version < $wp_current) {
echo "WARNING: Outdated Wordpress $version at $hostidentifier$location\n";
}
}
unset($results);
}
?>