47 lines
1.4 KiB
PHP
Executable File
47 lines
1.4 KiB
PHP
Executable File
#!/usr/bin/php -q
|
|
<?php
|
|
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/"));
|
|
if( isset($wp_api['offers'][0]['current']) ) {
|
|
$wp_current = $wp_api['offers'][0]['current'];
|
|
verbose("Current Wordpress version: $wp_current", 1);
|
|
} else {
|
|
die("Unable to determine current Wordpress version, exiting\n");
|
|
}
|
|
|
|
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) {
|
|
verbose("WARNING: Outdated Wordpress $version at $hostidentifier$location", 0);
|
|
notifyScript("Wordpress", $wp_current, $version, "$hostidentifier$location");
|
|
} else {
|
|
verbose("Recent Wordpress $version at $hostidentifier$location", 2);
|
|
}
|
|
}
|
|
unset($results);
|
|
|
|
}
|
|
|
|
?>
|