Subversion Repositories vnag

Rev

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

Rev 76 Rev 77
Line 1... Line 1...
1
<?php /* <ViaThinkSoftSignature>
1
<?php /* <ViaThinkSoftSignature>
2
L2cLimf5MKzRpuLa3QN3ZXwPjg1yIeFbWqIvkJGaSwRxKCg/LL/E2yEQHXu1mHH/8
2
OpbezgMkPVeK+pfO9zIJJPwMOQ4+s630AKA2J/Ty+RAdDwFg0cUT39SNttpTBpK+a
3
kBIyH2DQ/9fSsSlcNOt4mJfZQ6Ij6999+3AYLR/IGbDTfug1+zvwYwHx4zRSQS2fo
3
y9RxTZ11ln3kvaw6NbOHSPswfOZX9+jl8IhgpzQzDE+ha0JA0WFrDv342DgcWgap7
4
PSHsUL6lAp2G7s+PhLAZywm+vlz1AGHQmXrmPkD8WVlxX9dNpeyGmVpQh+I8+LcRf
4
hWCbucAj/9aOpPT3j5tBxsUs8FON297kr5dQwtSmHcsPIauu2tsaAOOUdDouEO8Ua
5
WDdLjeW3MphaOWSh6/MQxG60BZEJHjDpGcPiJm38FRBq0l5nH/2pEV0XkRwOsKHbx
5
xPrpdQ6oN5tpiBlWh5RBTn+19N0ra96MUXi02Tk4+6axIQ8xrkeTNb8LLkQM/h3J7
6
hHLc5scufol/6b5GYAG0aiKrbml4mSO41J8r3k0eVdeeXpYJzUR2yDYacOxas/HKZ
6
oVndkbnF/xVrtMxjz7pB+0IxiTAREM6cRBfVsrMawyPWp075iqiVuea3XCy2Di1rW
7
+7G7DsgXpY31ELTHIf52h9PIils+DYM2ZG5oGYn85jhqLGAKgd2ZHSTw7ZZ1AZkwY
7
3hbfWg0QfYX63ft4Ag7HyxANs9NMcNEDU3tdotae+Rs7W8L7c7Gu1+Pc6wTjX1gBV
8
g+7dZmRZ6Z0QgFTA0eOTpQx61KWxQTFfhEqchtrmeL1xhOG3KPVaNfDJFIqeZV8HJ
8
Y0am+pP0Uceug2sR7nCi6Ew9ff6XQE9D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YxHr7otFoEScMkI5I4hsKIB0QA4RssthlKAwsxnVxUhiKn4u
17
VvXpPBGJjA1UYAmLmcyjkMFY4j0qkY+sRmPTXAVPE1H9GbK2GSNlR2amB98SNxBit
17
U3Id6tZ9y3Wy0652VSeD4R1PZPnyy8lGKzZ1LfxKyPUWpcZLSQwdHPWRxzd6gp1aw
18
fch507ub1jAAS+a8M3p69Hb9Mv9ljrQpanbabN01rFTuI2yToxTBqdPgUpejKnVpz
18
98+Iwqt9nezuum+PcAVYNEaU7bJ8UNVLlsviBNevKGcW5Q5WSK97w6BZ03uwFHSmb
19
1XjeghVz6ODfDnpyzPhlHzgF2fLj3YZ1SiWVHq+Oeni3uUfSI60Ps0IBQb8MI0+Sj
19
HT6n2/lSw8yL1j4eShi0kK/kEhmB0GenuwlZpBnyIpSSvKhDENsQMqUpQc/r1zqp/
20
nJ9w+9y7AuyruCuE0duli9wzNGJOqHYPLmOAxv780dnkFkFK3JUZowaJbpEJAauZ3
20
V7IQM0V1sU35flp486GhDpEwX2XrIFM7ChCXONQpfv8LXS0Q5UUVimlner5YotdmJ
21
2kybuyOSwa+hYX4jonikPuQoIKKFZAOEMVUvJK4Rswq2H8jb3y28XHrisPm2f0thM
21
WnCwWLdyGLDPQGTtsyTQOa0QqVgn6vruU99wjtmKuamiG/VvtRu/iinzQRgOsAYLV
22
iAWxG+mm7Fam9DYtIRKzJNKNrYyB1NBMnHa3ev5bxrhCkma9Zj04re8tAZUNSj3Sy
22
+xFTcloIlYqMBcTYbmE8P31rqnVKmFOH0SjiGDzi5VT21s1H4UKdcf4DX5TUklTTw
23
A==
23
A==
24
</ViaThinkSoftSignature> */ ?>
24
</ViaThinkSoftSignature> */ ?>
25
<?php
25
<?php
26
 
26
 
27
/*
27
/*
Line 55... Line 55...
55
 
55
 
56
        protected function get_local_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
                $cont = @file_get_contents("$path/program/lib/Roundcube/bootstrap.php");
59
                $cont = @file_get_contents("$path/program/lib/Roundcube/bootstrap.php");
-
 
60
                if ($cont === false) {
-
 
61
                        throw new VNagException("Cannot find version information at $path (cannot find bootstrap.php)");
-
 
62
                }
60
                if (!preg_match("@define\('RCUBE_VERSION', '(.*)'\);@ismU", $cont, $m)) {
63
                if (!preg_match("@define\('RCUBE_VERSION', '(.*)'\);@ismU", $cont, $m)) {
61
                        throw new Exception("Cannot find version information at $path");
64
                        throw new VNagException("Cannot find version information at $path (cannot find RCUBE_VERSION)");
62
                }
65
                }
63
 
66
 
64
                return $m[1];
67
                return $m[1];
65
        }
68
        }
66
 
69
 
67
        protected function get_latest_version() {
70
        protected function get_latest_version() {
68
                $cont = $this->url_get_contents('https://api.github.com/repos/roundcube/roundcubemail/releases/latest');
71
                $cont = $this->url_get_contents('https://api.github.com/repos/roundcube/roundcubemail/releases/latest');
69
                if ($cont === false) {
72
                if ($cont === false) {
70
                        throw new Exception('Cannot parse version from GitHub API. The plugin probably needs to be updated. A');
73
                        throw new VNagException('Cannot parse version from GitHub API. The plugin probably needs to be updated. (Cannot access api.github.com)');
71
                }
74
                }
72
 
75
 
73
                $data = @json_decode($cont, true);
76
                $data = @json_decode($cont, true);
74
                if ($data === false) {
77
                if ($data === false) {
75
                        throw new Exception('Cannot parse version from GitHub API. The plugin probably needs to be updated. B');
78
                        throw new VNagException('Cannot parse version from GitHub API. The plugin probably needs to be updated. (Invalid JSON at api.github.com)');
76
                }
79
                }
77
 
80
 
78
                return $data['tag_name']; // e.g. "1.6.3"
81
                return $data['tag_name']; // e.g. "1.6.3"
79
        }
82
        }
80
 
83
 
81
        protected function get_latest_versions_with_lts() {
84
        protected function get_latest_versions_with_lts() {
82
                $cont = $this->url_get_contents('https://roundcube.net/download/');
85
                $cont = $this->url_get_contents('https://roundcube.net/download/');
83
                if ($cont === false) {
86
                if ($cont === false) {
84
                        throw new Exception('Cannot parse version from Roundcube website. The plugin probably needs to be updated. A');
87
                        throw new VNagException('Cannot parse version from Roundcube website. The plugin probably needs to be updated. (Cannot access roundcube.net)');
85
                }
88
                }
86
 
89
 
87
                if (!preg_match_all('@https://github.com/roundcube/roundcubemail/releases/download/([^/]+)/@ismU', $cont, $m)) {
90
                if (!preg_match_all('@https://github.com/roundcube/roundcubemail/releases/download/([^/]+)/@ismU', $cont, $m)) {
88
                        throw new Exception('Cannot parse version from Roundcube website. The plugin probably needs to be updated. B');
91
                        throw new VNagException('Cannot parse version from Roundcube website. The plugin probably needs to be updated. (Regex mismatch at roundcube.net)');
89
                }
92
                }
90
 
93
 
91
                return $m[1];
94
                return $m[1];
92
        }
95
        }
93
 
96
 
94
        protected function cbRun($optional_args=array()) {
97
        protected function cbRun($optional_args=array()) {
95
                $system_dir = $this->argSystemDir->getValue();
98
                $system_dir = $this->argSystemDir->getValue();
96
                if (empty($system_dir)) {
99
                if (empty($system_dir)) {
97
                        throw new Exception("Please specify the directory of the Roundcube installation.");
100
                        throw new VNagException("Please specify the directory of the Roundcube installation.");
98
                }
101
                }
99
                $system_dir = realpath($system_dir) === false ? $system_dir : realpath($system_dir);
102
                $system_dir = realpath($system_dir) === false ? $system_dir : realpath($system_dir);
100
 
103
 
101
                if (!is_dir($system_dir)) {
104
                if (!is_dir($system_dir)) {
102
                        throw new Exception('Directory "'.$system_dir.'" not found.');
105
                        throw new VNagException('Directory "'.$system_dir.'" not found.');
103
                }
106
                }
104
 
107
 
105
                $version = $this->get_local_version($system_dir);
108
                $version = $this->get_local_version($system_dir);
106
 
109
 
107
                try {
110
                try {