modified code so that local machine is checked. CHECK_HOSTS can now be empty (only local check)

This commit is contained in:
florian
2013-10-05 15:05:23 +00:00
parent 76d0a48898
commit 556fe14b86
3 changed files with 23 additions and 8 deletions

View File

@@ -14,14 +14,29 @@ if( getenv('CHK_HOSTS') == null ) {
$wp_api = unserialize(file_get_contents("http://api.wordpress.org/core/version-check/1.6/"));
$wp_current = $wp_api['offers'][0]['current'];
foreach($hosts as $host) {
$cmd = "ssh $host \"locate wp-includes/version.php | xargs grep -H 'wp_version ='\"";
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);
$version = substr($parts[1], 15, 5);
if($version < $wp_current) echo "WARNING: Outdated Wordpress $version at $host:$location\n";
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);