Subversion Repositories oidplus

Rev

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

Rev 635 Rev 648
Line 15... Line 15...
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
include '../../../../vendor/danielmarschall/vnag/framework/vnag_framework.inc.php';
20
include __DIR__ . '/../../../../vendor/danielmarschall/vnag/framework/vnag_framework.inc.php';
21
include '../../../../includes/oidplus.inc.php';
21
include __DIR__ . '/../../../../includes/oidplus.inc.php';
22
 
22
 
23
define('OIDPLUS_VNAG_MAX_CACHE_AGE', 60); // seconds (TODO: in base config?)
23
define('OIDPLUS_VNAG_MAX_CACHE_AGE', 60); // seconds (TODO: in base config?)
24
 
24
 
25
OIDplus::init(false);
25
OIDplus::init(false);
26
 
26
 
Line 66... Line 66...
66
        } else if ($installType === 'unknown') {
66
        } else if ($installType === 'unknown') {
67
                $out_stat = VNag::STATUS_UNKNOWN;
67
                $out_stat = VNag::STATUS_UNKNOWN;
68
                $out_msg  = 'The version cannot be determined, and the update needs to be applied manually!'; // do not translate
68
                $out_msg  = 'The version cannot be determined, and the update needs to be applied manually!'; // do not translate
69
        } else if (($installType === 'svn-wc') || ($installType === 'git-wc')) {
69
        } else if (($installType === 'svn-wc') || ($installType === 'git-wc')) {
70
                $local_installation = OIDplus::getVersion();
70
                $local_installation = OIDplus::getVersion();
71
                try {
-
 
72
                        $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
73
                        $newest_version = 'svn-' . $svn->getVersion();
71
                $newest_version = getLatestRevision();
74
                } catch (Exception $e) {
-
 
75
                        $newest_version = false;
-
 
76
                }
-
 
77
 
72
 
78
                $requireInfo = ($installType === 'svn-wc') ? 'shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension' : 'shell access with Git client'; // do not translate
73
                $requireInfo = ($installType === 'svn-wc') ? 'shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension' : 'shell access with Git client'; // do not translate
79
                $updateCommand = ($installType === 'svn-wc') ? 'svn update' : 'git pull';
74
                $updateCommand = ($installType === 'svn-wc') ? 'svn update' : 'git pull';
80
 
75
 
81
                if (!$newest_version) {
76
                if (!$newest_version) {
Line 91... Line 86...
91
                        $out_stat = VNag::STATUS_WARNING;
86
                        $out_stat = VNag::STATUS_WARNING;
92
                        $out_msg  = 'OIDplus is outdated. (' . $local_installation . ' local / ' . $newest_version . ' remote)'; // do not translate
87
                        $out_msg  = 'OIDplus is outdated. (' . $local_installation . ' local / ' . $newest_version . ' remote)'; // do not translate
93
                }
88
                }
94
        } else if ($installType === 'svn-snapshot') {
89
        } else if ($installType === 'svn-snapshot') {
95
                $local_installation = OIDplus::getVersion();
90
                $local_installation = OIDplus::getVersion();
96
                try {
-
 
97
                        $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
98
                        $newest_version = 'svn-' . $svn->getVersion();
91
                $newest_version = getLatestRevision();
99
                } catch (Exception $e) {
-
 
100
                        $newest_version = false;
-
 
101
                }
-
 
102
 
92
 
103
                if (!$newest_version) {
93
                if (!$newest_version) {
104
                        $out_stat = VNag::STATUS_UNKNOWN;
94
                        $out_stat = VNag::STATUS_UNKNOWN;
105
                        $out_msg  = 'OIDplus could not determine the latest version. Probably the ViaThinkSoft server could not be reached.'; // do not translate
95
                        $out_msg  = 'OIDplus could not determine the latest version. Probably the ViaThinkSoft server could not be reached.'; // do not translate
106
                } else if ($local_installation == $newest_version) {
96
                } else if ($local_installation == $newest_version) {
Line 129... Line 119...
129
if (OIDplus::getPkiStatus()) {
119
if (OIDplus::getPkiStatus()) {
130
        $job->privkey = OIDplus::config()->getValue('oidplus_private_key');
120
        $job->privkey = OIDplus::config()->getValue('oidplus_private_key');
131
}
121
}
132
$job->run();
122
$job->run();
133
unset($job);
123
unset($job);
-
 
124
 
-
 
125
# ---
-
 
126
 
-
 
127
function getLatestRevision() {
-
 
128
        try {
-
 
129
                $url = "https://www.oidplus.com/updates/releases.ser"; // TODO: in consts.ini
-
 
130
                $cont = @file_get_contents($url);
-
 
131
                if ($cont === false) return false;
-
 
132
                $ary = @unserialize($cont);
-
 
133
                if ($ary === false) return false;
-
 
134
                krsort($ary);
-
 
135
                $max_rev = array_keys($ary)[0];
-
 
136
                return 'svn-' . $max_rev;
-
 
137
        } catch (Exception $e) {
-
 
138
                return false;
-
 
139
        }
-
 
140
}
-
 
141