45 lines
1.3 KiB
PHP
Executable File
45 lines
1.3 KiB
PHP
Executable File
#!/usr/bin/php -q
|
|
<?php
|
|
require_once("toolkit.php");
|
|
|
|
$pma_api = json_decode(file_get_contents("http://www.phpmyadmin.net/home_page/version.json"));
|
|
if(is_object($pma_api) && strlen($pma_api->version)>0) {
|
|
$pma_current = $pma_api->version;
|
|
verbose("Current PHPMyAdmin version: $pma_current", 1);
|
|
} else {
|
|
die("Unable to determine current PHPMyAdmin version, exiting\n");
|
|
}
|
|
|
|
checkHost(null, $pma_current);
|
|
if($hosts != null) {
|
|
foreach($hosts as $host) {
|
|
checkHost($host, $pma_current);
|
|
}
|
|
}
|
|
|
|
function checkHost($host, $pma_current) {
|
|
$cmd = "locate libraries/Config.class.php | xargs grep -H \"'PMA_VERSION'\" | grep set";
|
|
$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])-26);
|
|
if(preg_match("/->set\('PMA_VERSION', '([0-9\.a-z]+)'\);/", $parts[1], $matches)) {
|
|
$version = $matches[1];
|
|
if($version < $pma_current) {
|
|
verbose("WARNING: Outdated PHPMyAdmin $version at $hostidentifier$location", 0);
|
|
notifyScript("PHPMyAdmin", $pma_current, $version, "$hostidentifier$location");
|
|
} else {
|
|
verbose("Recent PHPMyAdmin $version at $hostidentifier$location", 2);
|
|
}
|
|
}
|
|
}
|
|
unset($results);
|
|
}
|
|
|
|
?>
|