Subversion Repositories oidplus

Rev

Rev 1061 | Rev 1116 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. namespace ViaThinkSoft\OIDplus;
  21.  
  22. // phpcs:disable PSR1.Files.SideEffects
  23. \defined('INSIDE_OIDPLUS') or die;
  24. // phpcs:enable PSR1.Files.SideEffects
  25.  
  26. class OIDplusPageAdminSoftwareUpdate extends OIDplusPagePluginAdmin {
  27.  
  28.         public function init($html=true) {
  29.         }
  30.  
  31.         private function getGitCommand() {
  32.                 return 'git --git-dir='.escapeshellarg(OIDplus::findGitFolder().'/').' --work-tree='.escapeshellarg(OIDplus::localpath()).' -C "" pull origin master -s recursive -X theirs';
  33.         }
  34.  
  35.         private function getSvnCommand() {
  36.                 return 'svn update --accept theirs-full';
  37.         }
  38.  
  39.         public function action($actionID, $params) {
  40.                 if ($actionID == 'update_now') {
  41.                         @set_time_limit(0);
  42.  
  43.                         if (!OIDplus::authUtils()->isAdminLoggedIn()) {
  44.                                 throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
  45.                         }
  46.  
  47.                         if (OIDplus::getInstallType() === 'git-wc') {
  48.                                 $cmd = $this->getGitCommand().' 2>&1';
  49.  
  50.                                 $ec = -1;
  51.                                 $out = array();
  52.                                 exec($cmd, $out, $ec);
  53.  
  54.                                 $res = _L('Execute command:').' '.$cmd."\n\n".trim(implode("\n",$out));
  55.                                 if ($ec === 0) {
  56.                                         $rev = 'HEAD'; // do not translate
  57.                                         return array("status" => 0, "content" => $res, "rev" => $rev);
  58.                                 } else {
  59.                                         return array("status" => -1, "error" => $res, "content" => "");
  60.                                 }
  61.                         }
  62.                         else if (OIDplus::getInstallType() === 'svn-wc') {
  63.                                 $cmd = $this->getSvnCommand().' 2>&1';
  64.  
  65.                                 $ec = -1;
  66.                                 $out = array();
  67.                                 exec($cmd, $out, $ec);
  68.  
  69.                                 $res = _L('Execute command:').' '.$cmd."\n\n".trim(implode("\n",$out));
  70.                                 if ($ec === 0) {
  71.                                         $rev = 'HEAD'; // do not translate
  72.                                         return array("status" => 0, "content" => $res, "rev" => $rev);
  73.                                 } else {
  74.                                         return array("status" => -1, "error" => $res, "content" => "");
  75.                                 }
  76.                         }
  77.                         else if (OIDplus::getInstallType() === 'svn-snapshot') {
  78.  
  79.                                 $rev = $params['rev'];
  80.  
  81.                                 $update_version = isset($params['update_version']) ? $params['update_version'] : 1;
  82.                                 if (($update_version != 1) && ($update_version != 2)) {
  83.                                         throw new OIDplusException(_L('Unknown update version'));
  84.                                 }
  85.  
  86.                                 // Download and unzip
  87.  
  88.                                 $cont = false;
  89.                                 for ($retry=1; $retry<=3; $retry++) {
  90.                                         if (function_exists('gzdecode')) {
  91.                                                 $url = sprintf(OIDplus::getEditionInfo()['update_package_gz'], $rev-1, $rev);
  92.                                                 $cont = url_get_contents($url);
  93.                                                 if ($cont !== false) $cont = @gzdecode($cont);
  94.                                         } else {
  95.                                                 $url = sprintf(OIDplus::getEditionInfo()['update_package'], $rev-1, $rev);
  96.                                                 $cont = url_get_contents($url);
  97.                                         }
  98.                                         if ($cont !== false) {
  99.                                                 break;
  100.                                         } else {
  101.                                                 sleep(1);
  102.                                         }
  103.                                 }
  104.                                 if ($cont === false) throw new OIDplusException(_L("Update %1 could not be downloaded from ViaThinkSoft server. Please try again later.",$rev));
  105.  
  106.                                 // Check signature...
  107.  
  108.                                 if (function_exists('openssl_verify')) {
  109.  
  110.                                         $m = array();
  111.                                         if (!preg_match('@<\?php /\* <ViaThinkSoftSignature>(.+)</ViaThinkSoftSignature> \*/ \?>\n@ismU', $cont, $m)) {
  112.                                                 throw new OIDplusException(_L("Update package file of revision %1 not digitally signed",$rev));
  113.                                         }
  114.                                         $signature = base64_decode($m[1]);
  115.  
  116.                                         $naked = preg_replace('@<\?php /\* <ViaThinkSoftSignature>(.+)</ViaThinkSoftSignature> \*/ \?>\n@ismU', '', $cont);
  117.                                         $hash = hash("sha256", $naked."update_".($rev-1)."_to_".($rev).".txt");
  118.  
  119.                                         $public_key = file_get_contents(__DIR__.'/public.pem');
  120.                                         if (!openssl_verify($hash, $signature, $public_key, OPENSSL_ALGO_SHA256)) {
  121.                                                 throw new OIDplusException(_L("Update package file of revision %1: Signature invalid",$rev));
  122.                                         }
  123.  
  124.                                 }
  125.  
  126.                                 // All OK! Now write file
  127.  
  128.                                 $tmp_filename = 'update_'.generateRandomString(10).'.tmp.php';
  129.                                 $local_file = OIDplus::localpath().$tmp_filename;
  130.  
  131.                                 @file_put_contents($local_file, $cont);
  132.  
  133.                                 if (!file_exists($local_file) || (@file_get_contents($local_file) !== $cont)) {
  134.                                         throw new OIDplusException(_L('Update file could not written. Probably there are no write-permissions to the root folder.'));
  135.                                 }
  136.  
  137.                                 if ($update_version == 1) {
  138.                                         // Now call the written file
  139.                                         // Note: we may not use eval($cont) because the script uses die(),
  140.                                         // and things in the script might collide with currently (un)loaded source code files, shutdown procedues, etc.
  141.                                         $web_file = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE).$tmp_filename; // NOT canonical URL! This might fail with reverse proxies which can only be executed from outside
  142.                                         $res = url_get_contents($web_file);
  143.                                         if ($res === false) {
  144.                                                 throw new OIDplusException(_L('Update-script %1 could not be executed',$web_file));
  145.                                         }
  146.                                         return array("status" => 0, "content" => $res, "rev" => $rev);
  147.                                 } else if ($update_version == 2) {
  148.                                         // In this version, the client will call the web-update file.
  149.                                         // This has the advantage that it will also work if the system is htpasswd protected
  150.                                         return array("status" => 0, "update_file" => $tmp_filename, "rev" => $rev);
  151.                                 }
  152.                         }
  153.                         else {
  154.                                 throw new OIDplusException(_L('Multiple version files/directories (oidplus_version.txt, .version.php, .git, or .svn) are existing! Therefore, the version is ambiguous!'));
  155.                         }
  156.                 }
  157.         }
  158.  
  159.         public function gui($id, &$out, &$handled) {
  160.                 $parts = explode('.',$id,2);
  161.                 if (!isset($parts[1])) $parts[1] = '';
  162.                 if ($parts[0] == 'oidplus:software_update') {
  163.                         @set_time_limit(0);
  164.  
  165.                         $handled = true;
  166.                         $out['title'] = _L('Software update');
  167.                         $out['icon']  = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png';
  168.  
  169.                         if (!OIDplus::authUtils()->isAdminLoggedIn()) {
  170.                                 $out['icon'] = 'img/error.png';
  171.                                 $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
  172.                                 return;
  173.                         }
  174.  
  175.                         $out['text'] .= '<div id="update_versioninfo">';
  176.  
  177.                         $out['text'] .= '<p><u>'._L('There are three possibilities how to keep OIDplus up-to-date').':</u></p>';
  178.  
  179.                         if (isset(OIDplus::getEditionInfo()['svnrepo']) && (OIDplus::getEditionInfo()['svnrepo'] != '')) {
  180.                                 $out['text'] .= '<p><b>'._L('Method A').'</b>: '._L('Install OIDplus using the subversion tool in your SSH/Linux shell using the command <code>svn co %1</code> and update it regularly with the command <code>svn update</code> . This will automatically download the latest version and check for conflicts.',htmlentities(OIDplus::getEditionInfo()['svnrepo']).'/trunk/');
  181.                                 if (!str_starts_with(PHP_OS, 'WIN')) {
  182.                                         $out['text'] .= ' '._L('Make sure that you invoke the <code>%1</code> command as the user who runs PHP or that you <code>chown -R</code> the files after invoking <code>%1</code>','svn update');
  183.                                 }
  184.                                 $out['text'] .= '</p>';
  185.                         } else {
  186.                                 $out['text'] .= '<p><b>'._L('Method A').'</b>: '._L('Distribution via %1 is not possible with this edition of OIDplus','GIT').'</p>';
  187.                         }
  188.  
  189.                         if (isset(OIDplus::getEditionInfo()['gitrepo']) && (OIDplus::getEditionInfo()['gitrepo'] != '')) {
  190.                                 $out['text'] .= '<p><b>'._L('Method B').'</b>: '._L('Install OIDplus using the Git client in your SSH/Linux shell using the command <code>git clone %1</code> and update it regularly with the command <code>git pull</code> . This will automatically download the latest version and check for conflicts.',htmlentities(OIDplus::getEditionInfo()['gitrepo'].'.git'));
  191.                                 if (!str_starts_with(PHP_OS, 'WIN')) {
  192.                                         $out['text'] .= ' '._L('Make sure that you invoke the <code>%1</code> command as the user who runs PHP or that you <code>chown -R</code> the files after invoking <code>%1</code>','git pull');
  193.                                 }
  194.                                 $out['text'] .= '</p>';
  195.                         } else {
  196.                                 $out['text'] .= '<p><b>'._L('Method B').'</b>: '._L('Distribution via %1 is not possible with this edition of OIDplus','SVN').'</p>';
  197.                         }
  198.  
  199.                         if (isset(OIDplus::getEditionInfo()['downloadpage']) && (OIDplus::getEditionInfo()['downloadpage'] != '')) {
  200.                                 $out['text'] .= '<p><b>'._L('Method C').'</b>: '._L('Install OIDplus by downloading a TAR.GZ file from %1, which contains an SVN snapshot, and extract it to your webspace. The TAR.GZ file contains a file named ".version.php" which contains the SVN revision of the snapshot. This update-tool will then try to update your files on-the-fly by downloading them from the ViaThinkSoft SVN repository directly into your webspace directory. A change conflict detection is NOT implemented. It is required that the files on your webspace have create/write/delete permissions. Only recommended if you have no access to the SSH/Linux shell.','<a href="'.OIDplus::getEditionInfo()['downloadpage'].'">'.parse_url(OIDplus::getEditionInfo()['downloadpage'])['host'].'</a>').'</p>';
  201.                         } else {
  202.                                 $out['text'] .= '<p><b>'._L('Method C').'</b>: '._L('Distribution via %1 is not possible with this edition of OIDplus','Snapshot').'</p>';
  203.                         }
  204.  
  205.  
  206.                         $out['text'] .= '<hr>';
  207.  
  208.                         $installType = OIDplus::getInstallType();
  209.  
  210.                         if ($installType === 'ambigous') {
  211.                                 $out['text'] .= '<font color="red">'.mb_strtoupper(_L('Error')).': '._L('Multiple version files/directories (oidplus_version.txt, .version.php, .git, or .svn) are existing! Therefore, the version is ambiguous!').'</font>';
  212.                                 $out['text'] .= '</div>';
  213.                         } else if ($installType === 'unknown') {
  214.                                 $out['text'] .= '<font color="red">'.mb_strtoupper(_L('Error')).': '._L('The version cannot be determined, and the update needs to be applied manually!').'</font>';
  215.                                 $out['text'] .= '</div>';
  216.                         } else if (($installType === 'svn-wc') || ($installType === 'git-wc') || ($installType === 'svn-snapshot')) {
  217.                                 if ($installType === 'svn-wc') {
  218.                                         $out['text'] .= '<p>'._L('You are using <b>method A</b> (SVN working copy).').'</p>';
  219.                                         $requireInfo = _L('shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension');
  220.                                         $updateCommand = $this->getSvnCommand();
  221.                                 } else if ($installType === 'git-wc') {
  222.                                         $out['text'] .= '<p>'._L('You are using <b>method B</b> (Git working copy).').'</p>';
  223.                                         $requireInfo = _L('shell access with Git client');
  224.                                         $updateCommand = $this->getGitCommand();
  225.                                 } else if ($installType === 'svn-snapshot') {
  226.                                         $out['text'] .= '<p>'._L('You are using <b>method C</b> (Snapshot TAR.GZ file with .version.php file).').'</p>';
  227.                                         $requireInfo = ''; // unused
  228.                                         $updateCommand = ''; // unused
  229.                                 }
  230.  
  231.                                 $local_installation = OIDplus::getVersion();
  232.                                 $newest_version = $this->getLatestRevision();
  233.  
  234.                                 $out['text'] .= _L('Local installation: %1',($local_installation ? $local_installation : _L('unknown'))).'<br>';
  235.                                 $out['text'] .= _L('Latest published version: %1',($newest_version ? $newest_version : _L('unknown'))).'<br><br>';
  236.  
  237.                                 if (!$newest_version) {
  238.                                         if (!function_exists('curl_init')) {
  239.                                                 $out['text'] .= '<p><font color="red">'._L('OIDplus could not determine the latest version.').'<br>'._L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl').'</font></p>';
  240.                                         } else {
  241.                                                 $out['text'] .= '<p><font color="red">'._L('OIDplus could not determine the latest version.').'<br>'._L('Probably the ViaThinkSoft server could not be reached.').'</font></p>';
  242.                                         }
  243.                                         $out['text'] .= '</div>';
  244.                                 } else if (!$local_installation) {
  245.                                         if ($installType === 'svn-snapshot') {
  246.                                                 $out['text'] .= '<p><font color="red">'._L('OIDplus could not determine its version.').'</font></p>';
  247.                                         } else {
  248.                                                 $out['text'] .= '<p><font color="red">'._L('OIDplus could not determine its version. (Required: %1). Please update your system manually via the "%2" command regularly.',$requireInfo,$updateCommand).'</font></p>';
  249.                                         }
  250.                                         $out['text'] .= '</div>';
  251.                                 } else if (version_compare($local_installation, $newest_version) >= 0) {
  252.                                         $out['text'] .= '<p><font color="green">'._L('You are already using the latest version of OIDplus.').'</font></p>';
  253.                                         $out['text'] .= '</div>';
  254.                                 } else {
  255.                                         if (($installType === 'svn-wc') || ($installType === 'git-wc')) {
  256.                                                 $out['text'] .= '<p><font color="blue">'._L('Please enter %1 into the SSH shell to update OIDplus to the latest version.','<code>'.$updateCommand.'</code>').'</font></p>';
  257.                                                 $out['text'] .= '<p>'._L('Alternatively, click this button to execute the command through the web-interface (command execution and write permissions required).').'</p>';
  258.                                         }
  259.  
  260.                                         $out['text'] .= '<p><input type="button" onclick="OIDplusPageAdminSoftwareUpdate.doUpdateOIDplus('.((int)substr($local_installation,4)+1).', '.substr($newest_version,4).')" value="'._L('Update NOW').'"></p>';
  261.  
  262.                                         // TODO: Open "system_file_check" without page reload.
  263.                                         // TODO: Only show link if the plugin is installed
  264.                                         $out['text'] .= '<p><font color="red">'.mb_strtoupper(_L('Warning')).': '._L('Please make a backup of your files before updating. In case of an error, the OIDplus system (including this update-assistant) might become unavailable. Also, since the web-update does not contain collision-detection, changes you have applied (like adding, removing or modified files) might get reverted/lost! (<a href="%1">Click here to check which files have been modified</a>) In case the update fails, you can download and extract the complete <a href="%s">SVN-Snapshot TAR.GZ file</a> again. Since all your data should lay inside the folder "userdata" and "userdata_pub", this should be safe.','?goto='.urlencode('oidplus:system_file_check'),OIDplus::getEditionInfo()['downloadpage']).'</font></p>';
  265.  
  266.                                         $out['text'] .= '</div>';
  267.  
  268.                                         $out['text'] .= $this->showPreview($local_installation, $newest_version);
  269.                                 }
  270.                         }
  271.                 } else {
  272.                         $handled = false;
  273.                 }
  274.         }
  275.  
  276.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  277.                 if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
  278.  
  279.                 if (file_exists(__DIR__.'/img/main_icon16.png')) {
  280.                         $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
  281.                 } else {
  282.                         $tree_icon = null; // default icon (folder)
  283.                 }
  284.  
  285.                 $json[] = array(
  286.                         'id' => 'oidplus:software_update',
  287.                         'icon' => $tree_icon,
  288.                         'text' => _L('Software update')
  289.                 );
  290.  
  291.                 return true;
  292.         }
  293.  
  294.         public function tree_search($request) {
  295.                 return false;
  296.         }
  297.  
  298.         private $releases_ser = null;
  299.  
  300.         private function showChangelog($local_ver) {
  301.  
  302.                 try {
  303.                         if (is_null($this->releases_ser)) {
  304.                                 if (function_exists('gzdecode')) {
  305.                                         $url = OIDplus::getEditionInfo()['revisionlog_gz'];
  306.                                         $cont = url_get_contents($url);
  307.                                         if ($cont !== false) $cont = @gzdecode($cont);
  308.                                 } else {
  309.                                         $url = OIDplus::getEditionInfo()['revisionlog'];
  310.                                         $cont = url_get_contents($url);
  311.                                 }
  312.                                 if ($cont === false) return false;
  313.                                 $this->releases_ser = $cont;
  314.                         } else {
  315.                                 $cont = $this->releases_ser;
  316.                         }
  317.                         $content = '';
  318.                         $ary = @unserialize($cont);
  319.                         if ($ary === false) return false;
  320.                         krsort($ary);
  321.                         foreach ($ary as $rev => $data) {
  322.                                 if (version_compare("svn-$rev", $local_ver) <= 0) continue;
  323.                                 $comment = empty($data['msg']) ? _L('No comment') : $data['msg'];
  324.                                 $tex = _L("New revision %1 by %2",$rev,$data['author'])." (".$data['date'].") ";
  325.                                 $content .= trim($tex . str_replace("\n", "\n".str_repeat(' ', strlen($tex)), $comment));
  326.                                 $content .= "\n";
  327.                         }
  328.                         return $content;
  329.                 } catch (\Exception $e) {
  330.                         return false;
  331.                 }
  332.  
  333.         }
  334.  
  335.         private function getLatestRevision() {
  336.                 try {
  337.                         if (is_null($this->releases_ser)) {
  338.                                 if (function_exists('gzdecode')) {
  339.                                         $url = OIDplus::getEditionInfo()['revisionlog_gz'];
  340.                                         $cont = url_get_contents($url);
  341.                                         if ($cont !== false) $cont = @gzdecode($cont);
  342.                                 } else {
  343.                                         $url = OIDplus::getEditionInfo()['revisionlog'];
  344.                                         $cont = url_get_contents($url);
  345.                                 }
  346.                                 if ($cont === false) return false;
  347.                                 $this->releases_ser = $cont;
  348.                         } else {
  349.                                 $cont = $this->releases_ser;
  350.                         }
  351.                         $ary = @unserialize($cont);
  352.                         if ($ary === false) return false;
  353.                         krsort($ary);
  354.                         $max_rev = array_keys($ary)[0];
  355.                         $newest_version = 'svn-' . $max_rev;
  356.                         return $newest_version;
  357.                 } catch (\Exception $e) {
  358.                         return false;
  359.                 }
  360.         }
  361.  
  362.         private function showPreview($local_installation, $newest_version) {
  363.                 $out = '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
  364.  
  365.                 ob_start();
  366.                 try {
  367.                         $cont = $this->showChangelog($local_installation);
  368.                 } catch (\Exception $e) {
  369.                         $cont = _L('Error: %1',$e->getMessage());
  370.                 }
  371.                 ob_end_clean();
  372.  
  373.                 $cont = preg_replace('@!!!(.+)\\n@', '<font color="red">!!!\\1</font>'."\n", "$cont\n");
  374.  
  375.                 $out .= '<pre id="update_infobox">'.$cont.'</pre>';
  376.  
  377.                 return $out;
  378.         }
  379.  
  380.         public function implementsFeature($id) {
  381.                 if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
  382.                 return false;
  383.         }
  384.  
  385.         public function getNotifications($user=null): array {
  386.                 // Interface 1.3.6.1.4.1.37476.2.5.2.3.8
  387.                 $notifications = array();
  388.                 if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
  389.  
  390.                         // Following code is based on the VNag plugin (admin 901) code
  391.  
  392.                         $installType = OIDplus::getInstallType();
  393.  
  394.                         if ($installType === 'ambigous') {
  395.                                 $out_stat = 'WARN';
  396.                                 $out_msg  = _L('Multiple version files/directories (oidplus_version.txt, .version.php, .git, or .svn) are existing! Therefore, the version is ambiguous!');
  397.                         } else if ($installType === 'unknown') {
  398.                                 $out_stat = 'WARN';
  399.                                 $out_msg  = _L('The version cannot be determined, and the update needs to be applied manually!');
  400.                         } else if (($installType === 'svn-wc') || ($installType === 'git-wc')) {
  401.                                 $local_installation = OIDplus::getVersion();
  402.                                 $newest_version = $this->getLatestRevision();
  403.  
  404.                                 $requireInfo = ($installType === 'svn-wc') ? _L('shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension') : _L('shell access with Git client');
  405.                                 $updateCommand = ($installType === 'svn-wc') ? 'svn update' : 'git pull';
  406.  
  407.                                 if (!$newest_version) {
  408.                                         $out_stat = 'WARN';
  409.                                         if (!function_exists('curl_init')) {
  410.                                                 $out_msg  = _L('OIDplus could not determine the latest version.').' '._L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl');
  411.                                         } else {
  412.                                                 $out_msg  = _L('OIDplus could not determine the latest version.').' '._L('Probably the ViaThinkSoft server could not be reached.');
  413.                                         }
  414.                                 } else if (!$local_installation) {
  415.                                         $out_stat = 'WARN';
  416.                                         $out_msg  = _L('OIDplus could not determine its version (Required: %1). Please update your system manually via the "%2" command regularly.', $requireInfo, $updateCommand);
  417.                                 } else if (version_compare($local_installation, $newest_version) >= 0) {
  418.                                         $out_stat = 'INFO';
  419.                                         $out_msg  = _L('You are using the latest version of OIDplus (%1 local / %2 remote)', $local_installation, $newest_version);
  420.                                 } else {
  421.                                         $out_stat = 'WARN';
  422.                                         $out_msg  = _L('OIDplus is outdated. (%1 local / %2 remote)', $local_installation, $newest_version);
  423.                                 }
  424.                         } else if ($installType === 'svn-snapshot') {
  425.                                 $local_installation = OIDplus::getVersion();
  426.                                 $newest_version = $this->getLatestRevision();
  427.  
  428.                                 if (!$newest_version) {
  429.                                         $out_stat = 'WARN';
  430.                                         if (!function_exists('curl_init')) {
  431.                                                 $out_msg  = _L('OIDplus could not determine the latest version.').' '._L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl');
  432.                                         } else {
  433.                                                 $out_msg  = _L('OIDplus could not determine the latest version.').' '._L('Probably the ViaThinkSoft server could not be reached.');
  434.                                         }
  435.                                 } else if (version_compare($local_installation, $newest_version) >= 0) {
  436.                                         $out_stat = 'INFO';
  437.                                         $out_msg  = _L('You are using the latest version of OIDplus (%1 local / %2 remote)', $local_installation, $newest_version);
  438.                                 } else {
  439.                                         $out_stat = 'WARN';
  440.                                         $out_msg  = _L('OIDplus is outdated. (%1 local / %2 remote)', $local_installation, $newest_version);
  441.                                 }
  442.                         } else {
  443.                                 assert(false);
  444.                                 return $notifications;
  445.                         }
  446.  
  447.                         if ($out_stat != 'INFO') {
  448.                                 $out_msg = '<a '.OIDplus::gui()->link('oidplus:software_update').'>'._L('Software update').'</a>: ' . $out_msg;
  449.  
  450.                                 $notifications[] = array($out_stat, $out_msg);
  451.                         }
  452.  
  453.                 }
  454.                 return $notifications;
  455.         }
  456.  
  457. }
  458.