Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4 | daniel-mar | 1 | <?php /* <ViaThinkSoftSignature> |
2 | q6gx+eKOBlrjudngDLewBu36ohNJSKufLoPCxcLlswvaRLCe6fNoEPFIkS4FW748J |
||
3 | C+3c7H3HZx4oyqEztzYqaG53xpaM4jFKsRs4hYPsxLmOtXyiXUhk5bTeZzyGYQpTH |
||
4 | IquBkUBcworlVKxaTTdipcytlq0e9bTWMNd1vivtttYdpJd+UkiaQL/Mb/AwvU62Q |
||
5 | y27URiKSiLx356H9XQbZl7NvSxnrvDwcV/1+tAp/XpFh3F+BK88+y6hs7oNsN9D9H |
||
6 | c2dw3sSPH1b75HQTyDD8yyBxqGqxAEDYUNBEQPHnxYk2uLagolfiLXiyrUkJr8New |
||
7 | attBAECBmfFjXjOvhVz4ggPYKVjOL5i1cKviwsiHo5BFH7H5QECqUbGyHNm+Ce6IJ |
||
8 | 5o5wveQG+JCzNjH1BifZZ/dNM26PbyVyOLiFok8dc/fkdLmbj1x5hYY4nvhL92QUT |
||
9 | 83XBDzXV/2QIiiQTnwi89V3iOv4bfLEc9OcEDM0m+dKKrista+btJLw8u7NV4PXYE |
||
10 | 1U/UBpH+NjJ6uJ9nitVfOYN8LgwerGhFN/WYxjiBgRdhbux2/YQvH2V0yX0+sNn5t |
||
11 | RLi45LRLM5VoCg56r6vhNaYRoYTeluSJ57FwMVong1JLv/kW07/wHQ0PBRs3tDEPf |
||
12 | JnatiJxYhhJKd04QdEfYuQj5o+51u3OIDMLNh/3IQtxM1La6I7dBA4vpq/o3+Tg5x |
||
13 | E5HouzDPelo8OTzB/7sVsFHIFah1BI3PoIcbNBKNuMz34KU3ZQAs8LnYDutTKLtEX |
||
14 | FOOhROidGochYXUG71guCH8byMo+tJ8ISzzNQCslvcbL2Xc3jlQwlsKtxB3bLJxs0 |
||
15 | pWbJ73MY4w2lDUBtXPmF3Qdw1n4CoWs09EJAxYU1ZvtwftTtfIEOV3YODIC5QzZ1z |
||
16 | H6yDDvjPJ2WTLbIIXrsC00a0KM8aek8lHog9a/ypZKFZ+QEw5kWSVkp7hALM3jwxr |
||
17 | SNF6gnf0Rnmw6V6MltZI+MhfSYsb0YyINvhQaiI0hyeeIEMSyZZfMRhDCKmg09ee/ |
||
18 | pkUD/d5lOQ0/Nb0fhdL4MCsR4X8YoG+OFgZ3D47Mvw9qpOw2m5SQonMVDJQFLH+qN |
||
19 | gSqlcoJbqy0ElBK1eUHP9aHUyMVugxR8v383ernTsUhBja76w2lJ1d4Cd9Gfh0ASK |
||
20 | O8ApnxCH4//R34u0DX5VIZHHQRZa3BoyjdsS+2FnEEcjZXYmT+O89+m0bjNqnMvkR |
||
21 | 82YKssUPI1DW+OwoE06TQX0jyOkFmGEFnkJEOa6ScnjiCRLc4T65ABbK2xKTo65yl |
||
22 | S5zMY6/QmbNCoteoq9f9RelLyK6Ra3io8pjQemdyLBiHq+NySUK75dO7YxUuZJJsw |
||
23 | Q== |
||
24 | </ViaThinkSoftSignature> */ ?> |
||
2 | daniel-mar | 25 | <?php |
26 | |||
27 | /* |
||
28 | * VNag - Nagios Framework for PHP |
||
29 | * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com> |
||
30 | * Licensed under the terms of the Apache 2.0 license |
||
31 | * |
||
32 | * Revision 2018-07-15 |
||
33 | */ |
||
34 | |||
35 | declare(ticks=1); |
||
36 | |||
37 | class PhpMyAdminVersionCheck extends VNag { |
||
38 | protected $argSystemDir = null; |
||
39 | |||
40 | public function __construct() { |
||
41 | parent::__construct(); |
||
42 | |||
43 | $this->registerExpectedStandardArguments('Vht'); |
||
44 | |||
45 | $this->getHelpManager()->setPluginName('check_phpmyadmin_version'); |
||
46 | $this->getHelpManager()->setVersion('1.0'); |
||
47 | $this->getHelpManager()->setShortDescription('This plugin checks if a local phpMyAdmin system has the latest version installed.'); |
||
48 | $this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.'); |
||
49 | $this->getHelpManager()->setSyntax('$SCRIPTNAME$ [-d <directory>]'); |
||
50 | $this->getHelpManager()->setFootNotes('If you encounter bugs, please contact ViaThinkSoft at www.viathinksoft.com'); |
||
51 | |||
52 | // Individual (non-standard) arguments: |
||
53 | $this->addExpectedArgument($this->argSystemDir = new VNagArgument('d', 'directory', VNagArgument::VALUE_REQUIRED, 'phpmyadminPath', 'The local directory where your phpMyAdmin installation is located.')); |
||
54 | } |
||
55 | |||
56 | protected function get_phpmyadmin_version($path) { |
||
57 | $path = realpath($path) === false ? $path : realpath($path); |
||
58 | |||
59 | if (file_exists($file = "$path/libraries/classes/Config.php")) { |
||
60 | $cont = file_get_contents($file); |
||
61 | } else if (file_exists($file = "$path/libraries/Config.class.php")) { // older phpMyAdmin versions |
||
62 | $cont = file_get_contents($file); |
||
63 | } else { |
||
64 | throw new Exception("Cannot find the phpMyAdmin version information at $path"); |
||
65 | } |
||
66 | |||
67 | if (!preg_match('@\$this->set\(\'PMA_VERSION\', \'(.*)\'\);@ismU', $cont, $m)) { |
||
68 | throw new Exception("Cannot parse the phpMyAdmin version information at $path"); |
||
69 | } |
||
70 | |||
71 | return $m[1]; |
||
72 | } |
||
73 | |||
74 | protected function cbRun($optional_args=array()) { |
||
75 | $system_dir = $this->argSystemDir->getValue(); |
||
76 | if (empty($system_dir)) { |
||
77 | throw new Exception("Please specify the directory of the phpMyAdmin installation."); |
||
78 | } |
||
79 | $system_dir = realpath($system_dir) === false ? $system_dir : realpath($system_dir); |
||
80 | |||
81 | if (!is_dir($system_dir)) { |
||
82 | throw new Exception('Directory "'.$system_dir.'" not found.', false); |
||
83 | } |
||
84 | |||
85 | $version = $this->get_phpmyadmin_version($system_dir); |
||
86 | |||
87 | $cont = @file_get_contents('https://www.phpmyadmin.net/home_page/version.json'); // alternatively version.php |
||
88 | if (!$cont) { |
||
89 | throw new Exception('Cannot parse version from phpMyAdmin website. The plugin probably needs to be updated.', false); |
||
90 | } |
||
91 | |||
92 | $json = json_decode($cont, true); |
||
93 | $latest_version = $json['version']; |
||
94 | |||
95 | if ($version == $latest_version) { |
||
96 | $this->setStatus(VNag::STATUS_OK); |
||
97 | $this->setHeadline("Version $version (Latest version) at $system_dir", true); |
||
98 | } else { |
||
99 | $this->setStatus(VNag::STATUS_WARNING); |
||
100 | $this->setHeadline("Version $version is outdated (Latest version is $latest_version) at $system_dir", true); |
||
101 | } |
||
102 | } |
||
103 | } |