Subversion Repositories vnag

Rev

Rev 57 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57 Rev 76
Line 1... Line 1...
1
<?php /* <ViaThinkSoftSignature>
1
<?php /* <ViaThinkSoftSignature>
2
Jwv2QTTUkaqqNzdKRCyG3W5V7ue0Kdy89/G/x4LhQxUQUZP0Erf3P2EI8rxUdQ2uA
2
zvqiPMHMNM4INK6Y/IBoEzPNOYtVgeI0+dmhSC5e5Uh72rP69jMsJe9VIffB7tFBM
3
0OjWHGS0+1D6yEB8M/HEFCTRzHnMsl8zzo4Uiemi+ZzJytqtYi93HrR6SOWNzzblN
3
pS4m/OTwpBhmpJkDSh+lGP8pF/pz/9YhEtCf5qbRJYeu+We6bEx8atpCH7k8TP3JN
4
iFhmDvZs6+4cmH17wvwXutfabzKhUaVFNMavBdkko6sH62dgy3+U5o/qhqAFoAccR
4
4hs5M5QvAsJEsgrSXkTPJYZc9Uhe1GaWL3I71h/Vrk5zvytRuj9RGj5UVVQZU1kup
5
FTvD3fMG9CSNnEGMVFcFjpKMIUWQjQj7bB0PA8EMawJlE7R9ydNJBLET0KMnMG6zD
5
tdenDjw4zE3t2mqPH1Mj4ageNgJz8B0DQFxtFRnvr48DLAlPzT8LsmdtDkEqRKMFk
6
LNF72ENl9mQ4tfLp1e9qYVJ68Lf2WGu0u4E1Vb2fDgT4c+d31WlmyrcgmqIfKM8hK
6
pZPP1nXc1rllYBBVmTVB9Cp1JJUFMMtaimHvwIWxvSa/3TSzA96X+/pcmZmLMVgjJ
7
U5ht/SvmM5OT9OOR6cjZBHVN+ulsibzCYq1szcpKUSlLHiLh0B5keoSpJduGxxz98
7
NugoMMO3KBuVxDfKP3eBU467rvtYfHnGrCBkmyq2KnU57A27b7+eb0q3pxX3Tb5LS
8
7ECTN/s0VWYo4AzwvqSlEl1wmlStXxyM2ixZXcLcSjKvTZEIUQOfoSM2Vx9hFrIQX
8
XDYeEaALnYvsRbbYuGn+DtQIREjGDyb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pJXRtJYoIG/RgH5k+6r613CSCrBFaIOETQQdrxcW
17
MNDzW12Ridr0Gnt5NGP8cA/hYZRlpy4kAPJFttA8TTbIdQZHhZaaQCBSfX45jSbPs
17
YQbiB+PHl0nn7m4QT7nQ4uIVpoBUVpl+lcZUC8zphPSx0pt2ks08qkpvJqsf+Ij1h
18
Mh9mJmjBvP3bXU4za3XrCxcK/aELxNvczp/UlmL5KDYMalA7arHhaIahLgN2sYNGh
18
cv1BFYVuMc2a5LdGJAG4/BquLuDjq55Vqr2t4w4c43zl6VgXnP5Rpl4OWkqbilRaN
19
2tzJywxNGVdWcRQJoFNRCbqRMcroP6ro/VAO4gELfq1RE7C3ZJqjcfwAno6XABi3I
19
jdp/ZH7vaiWk6jrAjUWMbT3UWpy4J49VI0p4CWP4Mv7SDQt3U85d1uJrEvKds1MRD
20
PuR+LzADuh9yM+1xdYrpAmYfrMEYgBzyx05vn33GDRsaryHYtvkjNRrjBAujnYY0n
20
v+aXp7GwIcAkTVx+sgKCf3CGrXGzBwkB6eGDSk+bg+AMPJtEag/nsdgQEcZRfIgF9
21
Obus4i/hVah6yUgURhprwARav1gPn4IaZbjV0C93CpIWvodwruNW1eTEMoPOw3Fl6
21
g5sgyJlo3Wze02/D0YXkCR/WtmYmRM17hxAU1RagCCEV21fpqLdwl7VIhtmfFzBtj
22
x4N1r5Q1uQpHkfJoOnEOSzUxVLa6kMYamF6fE9ckM55RkzJCX+ff4tUPzDGXhS6/x
22
q/qDiC/BExUUFgkUMbiKf7bBk+bPLjM/GT45eg+BPipUZWB5wk9H4D7hxWAdNNkvU
23
w==
23
w==
24
</ViaThinkSoftSignature> */ ?>
24
</ViaThinkSoftSignature> */ ?>
25
<?php
25
<?php
26
 
26
 
27
/*
27
/*
28
 * VNag - Nagios Framework for PHP
28
 * VNag - Nagios Framework for PHP
29
 * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
29
 * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
30
 * Licensed under the terms of the Apache 2.0 license
30
 * Licensed under the terms of the Apache 2.0 license
31
 *
31
 *
32
 * Revision 2022-09-12
32
 * Revision 2023-10-13
33
 */
33
 */
34
 
34
 
35
declare(ticks=1);
35
declare(ticks=1);
36
 
36
 
37
class PhpMyAdminVersionCheck extends VNag {
37
class PhpMyAdminVersionCheck extends VNag {
Line 51... Line 51...
51
 
51
 
52
                // Individual (non-standard) arguments:
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.'));
53
                $this->addExpectedArgument($this->argSystemDir = new VNagArgument('d', 'directory', VNagArgument::VALUE_REQUIRED, 'phpmyadminPath', 'The local directory where your phpMyAdmin installation is located.'));
54
        }
54
        }
55
 
55
 
56
        protected function get_phpmyadmin_version($path) {
56
        protected function get_local_version($path) {
57
                $path = realpath($path) === false ? $path : realpath($path);
57
                $path = realpath($path) === false ? $path : realpath($path);
58
 
58
 
59
                if (file_exists($file = "$path/libraries/classes/Version.php")) { // Variant 3 (5.1.0+)
59
                if (file_exists($file = "$path/libraries/classes/Version.php")) { // Variant 3 (5.1.0+)
60
                        $regex = '@VERSION = \'(.*)\'@ismU';
60
                        $regex = '@VERSION = \'(.*)\'@ismU';
61
                } else if (file_exists($file = "$path/libraries/classes/Config.php")) { // Variant 2 (5.0.x)
61
                } else if (file_exists($file = "$path/libraries/classes/Config.php")) { // Variant 2 (5.0.x)
Line 72... Line 72...
72
                }
72
                }
73
 
73
 
74
                return $m[1];
74
                return $m[1];
75
        }
75
        }
76
 
76
 
-
 
77
        protected function get_latest_version() {
-
 
78
                $cont = $this->url_get_contents('https://www.phpmyadmin.net/home_page/version.json'); // alternatively version.php
-
 
79
                if ($cont === false) {
-
 
80
                        throw new Exception('Cannot parse version from phpMyAdmin website. The plugin probably needs to be updated. A');
-
 
81
                }
-
 
82
 
-
 
83
                $json = @json_decode($cont, true);
-
 
84
                if ($json === false) {
-
 
85
                        throw new Exception('Cannot parse version from phpMyAdmin website. The plugin probably needs to be updated. B');
-
 
86
                }
-
 
87
                return $json['version'];
-
 
88
        }
-
 
89
 
77
        protected function cbRun($optional_args=array()) {
90
        protected function cbRun($optional_args=array()) {
78
                $system_dir = $this->argSystemDir->getValue();
91
                $system_dir = $this->argSystemDir->getValue();
79
                if (empty($system_dir)) {
92
                if (empty($system_dir)) {
80
                        throw new Exception("Please specify the directory of the phpMyAdmin installation.");
93
                        throw new Exception("Please specify the directory of the phpMyAdmin installation.");
81
                }
94
                }
Line 83... Line 96...
83
 
96
 
84
                if (!is_dir($system_dir)) {
97
                if (!is_dir($system_dir)) {
85
                        throw new Exception('Directory "'.$system_dir.'" not found.');
98
                        throw new Exception('Directory "'.$system_dir.'" not found.');
86
                }
99
                }
87
 
100
 
88
                $version = $this->get_phpmyadmin_version($system_dir);
101
                $version = $this->get_local_version($system_dir);
89
 
-
 
90
                $cont = @file_get_contents('https://www.phpmyadmin.net/home_page/version.json'); // alternatively version.php
-
 
91
                if (!$cont) {
-
 
92
                        throw new Exception('Cannot parse version from phpMyAdmin website. The plugin probably needs to be updated.');
-
 
93
                }
-
 
94
 
102
 
95
                $json = json_decode($cont, true);
-
 
96
                $latest_version = $json['version'];
103
                $latest_version = $this->get_latest_version();
97
 
104
 
98
                if (version_compare($version,$latest_version) >= 0) {
105
                if (version_compare($version,$latest_version) >= 0) {
99
                        $this->setStatus(VNag::STATUS_OK);
106
                        $this->setStatus(VNag::STATUS_OK);
100
                        if ($version == $latest_version) {
107
                        if ($version == $latest_version) {
101
                                $this->setHeadline("Version $version (Latest version) at $system_dir", true);
108
                                $this->setHeadline("Version $version (Latest version) at $system_dir", true);