예제 #1
0
 /**
  * Fetches an update file and verifies its authenticity before returning
  * the file contents. Returns false on failure.
  */
 public static function fetch($path)
 {
     self::$error = false;
     $file_url = self::$updates . $path;
     $sha_url = self::$checksums . $path . '.sha';
     $file = fetch_url($file_url);
     if (!$file) {
         self::$error = 'Unable to fetch file.';
         return false;
     }
     $sha = fetch_url($sha_url);
     if (!$sha) {
         self::$error = 'Unable to fetch checksum file.';
         return false;
     }
     if (!self::test_checksum($file, $sha)) {
         self::$error = 'Checksum failed!';
         return false;
     }
     return $file;
 }
예제 #2
0
파일: update.php 프로젝트: Selwyn-b/elefant
         echo "Fetching new patch: {$base}\n";
         $contents = Updater::fetch($patch_file);
         if (!$contents) {
             Cli::out('Error: ' . Updater::error() . ' ' . $patch_file, 'error');
             return;
         }
         file_put_contents('conf/updates/' . $base, $contents);
     }
 }
 foreach ($res->scripts as $script_file) {
     $base = basename($script_file);
     if (!file_exists('conf/updates/' . $base)) {
         echo "Fetching new db update: {$base}\n";
         $contents = Updater::fetch($script_file);
         if (!$contents) {
             Cli::out('Error: ' . Updater::error() . ' ' . $script_file, 'error');
             return;
         }
         file_put_contents('conf/updates/' . $base, $contents);
     }
 }
 $versions = cli_get_versions(ELEFANT_VERSION, $latest);
 // Test and apply the patches and db updates in sequence
 foreach ($versions as $version) {
     printf("Testing patch: %s\n", basename($version['patch']));
     exec('patch --dry-run -p1 -f -i ' . $version['patch'], $output);
     $output = join("\n", $output);
     if (strpos($output, 'FAILED')) {
         Cli::out('Error applying patch ' . $version['patch'], 'error');
         echo "See conf/updates/error.log for details.\n";
         file_put_contents('conf/updates/error.log', $output);