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WP
o1tvBqQoNxuM8FwtJEaDLLJYGI8SM7pRj1bNtekOoNrC2EWmATpXpawSEhVD/4FGh
tsfXhp3uGM/7mtnQgBS6N2rBN1zJ0qTcT1RxTmU9CcY2odrmAcI7cRIoBphdkaE8N
v5IA5ODOpT9F/ZMmo38FPrKLSNGbcVWIjhBht3tq8EVK3+sO0CjUgnBX46vVkQtzZ
3coIm9KhY6VPW8//Wugby2nG3hOFqMEPYVfCfUNj+7Fsw0gWTnhvpZITKjW+hjccC
64d8LOmGGCYpRSn89mItof6I0EDvXR99Sd6eMEuQGLyijFcBbWQePuiwda1sDNf9U
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 FourImagesVersionCheck extends VNag {
protected $argSystemDir = null;
public function __construct() {
parent::__construct();
$this->registerExpectedStandardArguments('Vht');
$this->getHelpManager()->setPluginName('check_4images_version');
$this->getHelpManager()->setVersion('1.0');
$this->getHelpManager()->setShortDescription('This plugin checks if a local 4images 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, '4imagesPath', 'The local directory where your 4images installation is located.'));
}
protected function get_4images_version($path) {
if (!preg_match("@define\('SCRIPT_VERSION', '(.*)'\);@ismU", $cont, $m)) {
throw new Exception("Cannot find version information at $path");
}
return $m[1];
}
protected function get_latest_version() {
if (!$cont) {
throw new Exception("Cannot access website with latest version");
}
if (!preg_match('@<h2>Download 4images (.+)</h2>@ismU', $cont, $m)) {
if (!preg_match('@>Current Version: (.+)</a>@ismU', $cont, $m)) {
throw new Exception("Cannot find version information on the website");
}
}
}
protected function cbRun
($optional_args=array()) {
$system_dir = $this->argSystemDir->getValue();
if (empty($system_dir)) {
throw new Exception("Please specify the directory of the 4images installation.");
}
$system_dir = realpath($system_dir) === false ?
$system_dir : realpath($system_dir);
throw new Exception('Directory "'.$system_dir.'" not found.');
}
$version = $this->get_4images_version($system_dir);
$latest_version = $this->get_latest_version();
$this->setStatus(VNag::STATUS_OK);
$this->setHeadline("Version $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);
}
}
}