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SfX45jSbPs
Mh9mJmjBvP3bXU4za3XrCxcK/aELxNvczp/UlmL5KDYMalA7arHhaIahLgN2sYNGh
2tzJywxNGVdWcRQJoFNRCbqRMcroP6ro/VAO4gELfq1RE7C3ZJqjcfwAno6XABi3I
PuR+LzADuh9yM+1xdYrpAmYfrMEYgBzyx05vn33GDRsaryHYtvkjNRrjBAujnYY0n
Obus4i/hVah6yUgURhprwARav1gPn4IaZbjV0C93CpIWvodwruNW1eTEMoPOw3Fl6
x4N1r5Q1uQpHkfJoOnEOSzUxVLa6kMYamF6fE9ckM55RkzJCX+ff4tUPzDGXhS6/x
w==
</ViaThinkSoftSignature> */ ?>
<?php
/*
* VNag - Nagios Framework for PHP
* Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
* Licensed under the terms of the Apache 2.0 license
*
* Revision 2022-09-12
*/
declare(ticks=1);
class PhpMyAdminVersionCheck extends VNag {
protected $argSystemDir = null;
public function __construct() {
parent::__construct();
$this->registerExpectedStandardArguments('Vht');
$this->getHelpManager()->setPluginName('check_phpmyadmin_version');
$this->getHelpManager()->setVersion('1.0');
$this->getHelpManager()->setShortDescription('This plugin checks if a local phpMyAdmin system has the latest version installed.');
$this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.');
$this->getHelpManager()->setSyntax('$SCRIPTNAME$ [-d <directory>]');
$this->getHelpManager()->setFootNotes('If you encounter bugs, please contact ViaThinkSoft at www.viathinksoft.com');
// Individual (non-standard) arguments:
$this->addExpectedArgument($this->argSystemDir = new VNagArgument('d', 'directory', VNagArgument::VALUE_REQUIRED, 'phpmyadminPath', 'The local directory where your phpMyAdmin installation is located.'));
}
protected function get_phpmyadmin_version($path) {
if (file_exists($file = "$path/libraries/classes/Version.php")) { // Variant 3 (5.1.0+)
$regex = '@VERSION = \'(.*)\'@ismU';
} else if (file_exists($file = "$path/libraries/classes/Config.php")) { // Variant 2 (5.0.x)
$regex = '@\$this->set\(\'PMA_VERSION\', \'(.*)\'\);@ismU';
} else if (file_exists($file = "$path/libraries/Config.class.php")) { // Variant 1 (very old)
$regex = '@\$this->set\(\'PMA_VERSION\', \'(.*)\'\);@ismU';
} else {
throw new Exception("Cannot find the phpMyAdmin version information at $path");
}
throw new Exception("Cannot parse the phpMyAdmin version information at $path");
}
return $m[1];
}
protected function cbRun
($optional_args=array()) {
$system_dir = $this->argSystemDir->getValue();
if (empty($system_dir)) {
throw new Exception("Please specify the directory of the phpMyAdmin installation.");
}
$system_dir = realpath($system_dir) === false ?
$system_dir : realpath($system_dir);
throw new Exception('Directory "'.$system_dir.'" not found.');
}
$version = $this->get_phpmyadmin_version($system_dir);
$cont = @file_get_contents('https://www.phpmyadmin.net/home_page/version.json'); // alternatively version.php
if (!$cont) {
throw new Exception('Cannot parse version from phpMyAdmin website. The plugin probably needs to be updated.');
}
$latest_version = $json['version'];
$this->setStatus(VNag::STATUS_OK);
if ($version == $latest_version) {
$this->setHeadline("Version $version (Latest version) at $system_dir", true);
} else {
$this->setHeadline("Version $version (Latest version $latest_version) at $system_dir", true);
}
} else {
$this->setStatus(VNag::STATUS_WARNING);
$this->setHeadline("Version $version is outdated (Latest version is $latest_version) at $system_dir", true);
}
}
}