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 | 1BHpcBSx7ON/HUpCcUkKhSUoiYXQMQtnAdXX2iAlOl/JzKKg6SFnZOPnKWmR7wB3g |
||
3 | ptP+9uUjA6jE2DUc43XLKjhqhDCzZRlDPpTSxjfIz0b096R2o1AHchZq+IM/CoSWE |
||
4 | R0vlvFuA6Xw4XT5wT394u1Ndj49cBNf59F3cPnWO+vPK2PZwnKs7jgYAUssOErx5C |
||
5 | 47o2B1iYx5iWZu7TvW/8WKEKXBzHC0rvmT1qF0wvcyx6kQKoRENBHdZsRoVjDAuff |
||
6 | Y6YRXBiNfIcOWn4lu9hZqyWufxSJ3f18RTpul67YbcI5G+MNUqQmn6aDtf9NSiafi |
||
7 | RLngQwU52ihlEHHTZWfAu4oKRWXzMHhgvrjel8B3a7nOl3iDUmvCVIw2tjGCCzeS9 |
||
8 | kTDEWBu+Uy6r8T5AjHkYcLRV2Icl4c4qQNQWt68VC2AVUIqIPpHqIITI4tluiY5Yo |
||
9 | QLiPqNgtI362fWzkMivY4Ybj2+G4llNd4OUCA3ob5jG3CoqNCOt0wtyDnXsMUGzV3 |
||
10 | 114FR0TNYkI7SSaJsXZ5kMeUxh1Fq1axclrmL/ABRvmwpYl6OfJtNRTYM+YBh9NZn |
||
11 | dDDHOZaJkl31q8CqPzSbOX6YNeJx1u/qFPFl1y4LRW+KS9uT3xCSZKfik9gHSNBt/ |
||
12 | bGyytmBpJMSZcLB5Br/qB0A+IVNBdslvoJ02SDLyWLfC8/PffgedJCi1BbFJ3V6uP |
||
13 | kTlAOiJTKYYB4CMXjlfByMMKZ6WzJR2KoT/yvn3ulOWU4tFK54p+2DTfSQWK+i7Jm |
||
14 | w8klkRrFNLbUnBnoMSADYFaOEco/6SzCbaWUOWuwBCPk+HmmOTMLUrsGwiyXT8EKT |
||
15 | eghRtKBb3F8RWVNFN8mW+yraq4a04JZfQQMXUwwaW7Uq9Z9gBsBSkzw/2kbKsqfj9 |
||
16 | TE3GuaNweD9yd3Pfy3j88F9Hx55AsNpF+nxk/3Q4RbiGtE5o7/lD2GG50Jbnvj/tM |
||
17 | Rxd5jAepzZHcs9SkxHNmGA0DfGHZuDQ53Yx2+KnQKFP3FJ7JKtn3WB6ia3KvafDxY |
||
18 | qSFaZAiIT7B6Z/7cDIxQ2QJH6F7mh5UXcg06mtoBuHyEiyQnp8vW9ayyDMRR7VAYg |
||
19 | jTu5RBLZ+9woEBB9/hZv3M79Vzrrvou6/Z2oyoVp2LcOBJlu5HZYClL56s0gXFaQ/ |
||
20 | /7KN6mNB0mB+kfLOHw0Yy9tqh8HPASh51IaLBO1J7b+YErbRP4GSs5zjgcU0rOvBH |
||
21 | lhcyOpYqm8xlXCtpNrwYfprWXxV7YZdTSGK7vlIq5tIK/C5nkrf4md7gIdzSQ2CI2 |
||
22 | wcTytO6uQWTuNlEm25bx7VJUdj+T+s7em9GLkXyMaI3nfgnU+gl8sr95AEoP+45X9 |
||
23 | A== |
||
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 RoundcubeVersionCheck 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_roundcube_version'); |
||
46 | $this->getHelpManager()->setVersion('1.0'); |
||
47 | $this->getHelpManager()->setShortDescription('This plugin checks if a local Roundcube Webmail 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, 'roundcubePath', 'The local directory where your Roundcube installation is located.')); |
||
54 | } |
||
55 | |||
56 | protected function get_roundcube_version($path) { |
||
57 | $path = realpath($path) === false ? $path : realpath($path); |
||
58 | |||
59 | $cont = @file_get_contents("$path/program/lib/Roundcube/bootstrap.php"); |
||
60 | if (!preg_match("@define\('RCUBE_VERSION', '(.*)'\);@ismU", $cont, $m)) { |
||
61 | throw new Exception("Cannot find version information at $path"); |
||
62 | } |
||
63 | |||
64 | return $m[1]; |
||
65 | } |
||
66 | |||
67 | protected function cbRun($optional_args=array()) { |
||
68 | $system_dir = $this->argSystemDir->getValue(); |
||
69 | if (empty($system_dir)) { |
||
70 | throw new Exception("Please specify the directory of the Roundcube installation."); |
||
71 | } |
||
72 | $system_dir = realpath($system_dir) === false ? $system_dir : realpath($system_dir); |
||
73 | |||
74 | if (!is_dir($system_dir)) { |
||
75 | throw new Exception('Directory "'.$system_dir.'" not found.', false); |
||
76 | } |
||
77 | |||
78 | $version = $this->get_roundcube_version($system_dir); |
||
79 | |||
80 | $cont = @file_get_contents('https://roundcube.net/download/'); |
||
81 | if (!preg_match_all('@https://github.com/roundcube/roundcubemail/releases/download/([^/]+)/@ismU', $cont, $m)) { |
||
82 | throw new Exception('Cannot parse version from Roundcube website. The plugin probably needs to be updated.', false); |
||
83 | } |
||
84 | |||
85 | $latest_version = $m[1][0]; |
||
86 | |||
87 | if (in_array($version, $m[1])) { |
||
88 | if ($version === $latest_version) { |
||
89 | $this->setStatus(VNag::STATUS_OK); |
||
90 | $this->setHeadline("Version $version (Latest Stable version) at $system_dir", true); |
||
91 | } else { |
||
92 | $this->setStatus(VNag::STATUS_OK); |
||
93 | $this->setHeadline("Version $version (Old Stable / LTS version; latest version is $latest_version) at $system_dir", true); |
||
94 | } |
||
95 | } else { |
||
96 | $this->setStatus(VNag::STATUS_WARNING); |
||
97 | $this->setHeadline("Version $version is outdated (Latest version is $latest_version) at $system_dir", true); |
||
98 | } |
||
99 | } |
||
100 | } |
||
101 |