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1rLmO
kV8CTAW6zEhBCrgGHhaaGMV0RTc6ygnkVjPyZ3c6p6bxlc3DJgJ7E1dDNOqWH/mzO
n61R6pl7ISJ9/Js0FJkL5WcvCbjao2QuJD00gyGsJpOt3WfCCHGjif/VWZo4M9Y/K
GDyE+Lwq2690k+K2876Y+rdXoopjhLv6GYXXrjPhUTRMtzXkK5tiVjRzLMN5T2fvC
gWLFxi5J1qM4DV4AGLF245144Stsa3j558edqgWEK4CVTsHGT1YiQFF0omFVlG9IT
cMeslXPMLRwpyx2Z/UoMBiTsc+7lazwlZ/w9RutNd7pRWA1E3GcIC4AO4NPLQ/1nW
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 2023-10-13
*/
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_local_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() {
$cont = $this->url_get_contents('https://www.4homepages.de/download-4images');
if ($cont === false) {
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_local_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);
}
}
}