Beispiel #1
0
 $publicKey = file_get_contents(dirname(__FILE__) . '/public.pem');
 $sigStartOffset = strpos($data, $sigStart) + strlen($sigStart);
 $sigEndOffset = strpos($data, $sigEnd);
 $asciiSignature = substr($data, $sigStartOffset, $sigEndOffset - $sigStartOffset);
 $binarySignature = base64_decode(str_replace(array($sigStart, $sigEnd, "\n"), '', $asciiSignature));
 // Strip away stub
 $data = substr($data, strpos($data, '__halt_compiler();') + 18);
 if (!(bool) openssl_verify($data, $binarySignature, $publicKey, OPENSSL_ALGO_SHA1)) {
     // Bad package signature
     $koala->queueScript('Koala.yg_updaterOnError(\'' . $installRevision['rev'] . '\', \'' . $itext['TXT_UPDATER_BAD_SIGNATURE'] . '\');');
 } else {
     // Read out package information
     $updatePath = $this->approot . sConfig()->getVar('CONFIG/DIRECTORIES/UPDATES');
     $updatePackage = $updatePath . basename($installRevision['url']);
     $currArchive = new PayloadTar($updatePackage, true);
     $metaData = $currArchive->extractInString('installer/config.xml');
     $metaDataXML = new SimpleXMLElement($metaData);
     // Check if all dependencies are installed/available
     $dependencyError = false;
     $versionInfo = new Updater();
     $currVersion = $versionInfo->current_version;
     $dependencies = array();
     foreach ($metaDataXML->dependencies->version as $dependencyItem) {
         $dependencyItemVersion = (int) implode('.', (string) $dependencyItem);
         if ($currVersion < $dependencyItemVersion) {
             $dependencies[] = (string) $dependencyItem;
         }
     }
     foreach ($dependencies as $dependency) {
         if (count(glob($updatePath . 'yeager_' . $dependency . '_r*.php')) == 0) {
             $dependencyError = true;
Beispiel #2
0
 /**
  * Gets all outstanding updates
  *
  * @return array Array containing update information with version/revision/date information
  */
 function getUpdates()
 {
     $currVersionNumeric = $this->current_version;
     $postFields = array('INFO' => serialize($_SERVER), 'VERSION' => $currVersionNumeric);
     $xmlString = getStringFromURL(YEAGER_UPDATER_URL . '?' . http_build_query($postFields), (int) YEAGER_UPDATER_TIMEOUT);
     if ($xmlString !== false) {
         // Online Mode
         $updateDataXML = new SimpleXMLElement($xmlString);
         $updatesArray = array();
         foreach ($updateDataXML->update as $updateItem) {
             $currDate = explode('-', (string) $updateItem->date);
             $currDate = gmmktime(0, 0, 0, $currDate[1], $currDate[2], $currDate[0]);
             $updateVersion = prettifyVersionString((string) $updateItem->version);
             $updateVersionNumeric = (int) str_replace('.', '', (string) $updateItem->version);
             $updatesArrayItem = array('TITLE' => stripCDATA((string) $updateItem->title), 'DATE' => $currDate, 'VERSION' => $updateVersion, 'VERSION_NUMERIC' => $updateVersionNumeric, 'REVISION' => (string) $updateItem->revision, 'DESCRIPTION' => stripCDATA((string) $updateItem->description), 'URL' => (string) $updateItem->url_update);
             foreach ($updateItem->dependencies->version as $dependencyItem) {
                 $updatesArrayItem['DEPENDENCIES'][] = (string) $dependencyItem;
             }
             $updatesArray[] = $updatesArrayItem;
         }
     } else {
         // Offline Mode
         $updatesDirectory = sApp()->approot . sConfig()->getVar('CONFIG/DIRECTORIES/UPDATES');
         $updatePackages = glob($updatesDirectory . 'yeager_*_r*.php');
         // Read out package information
         $updatesArray = array();
         foreach ($updatePackages as $updatePackage) {
             $currArchive = new PayloadTar($updatePackage, true);
             $metaData = $currArchive->extractInString('installer/config.xml');
             $metaDataXML = new SimpleXMLElement($metaData);
             $currDate = explode('-', (string) $metaDataXML->date);
             $currDate = gmmktime(0, 0, 0, $currDate[1], $currDate[2], $currDate[0]);
             $updateVersion = prettifyVersionString((string) $metaDataXML->version);
             $updateVersionNumeric = (int) str_replace('.', '', (string) $metaDataXML->version);
             $updatesArrayItem = array('TITLE' => stripCDATA((string) $metaDataXML->title), 'DATE' => $currDate, 'VERSION' => $updateVersion, 'VERSION_NUMERIC' => $updateVersionNumeric, 'REVISION' => (string) $metaDataXML->revision, 'DESCRIPTION' => str_replace('\\n', "\n", stripCDATA((string) $metaDataXML->description)), 'URL' => 'file://' . $updatePackage);
             foreach ($metaDataXML->dependencies->version as $dependencyItem) {
                 $updatesArrayItem['DEPENDENCIES'][] = (string) $dependencyItem;
             }
             $updatesArray[] = $updatesArrayItem;
         }
     }
     $neededUpdates = array();
     foreach ($updatesArray as $allUpdatesItem) {
         if ($allUpdatesItem['VERSION_NUMERIC'] > $currVersionNumeric) {
             $neededUpdates[] = $allUpdatesItem;
         }
     }
     $updatesArray = $neededUpdates;
     usort($updatesArray, function ($a, $b) {
         if ($a['REVISION'] == $b['REVISION']) {
             return 0;
         }
         return version_compare($b['VERSION'], $a['VERSION'], '>=') ? -1 : 1;
         /*return true;*/
     });
     return $updatesArray;
 }