5 fprintf(STDERR
, "Usage: %s <pkg_name> [.ext.phar command line options]\n", $argv[0]);
10 $error = error_get_last();
11 if (!($error["type"] & error_reporting())) {
12 fprintf(STDERR
, "%s\n", $error["message"]);
17 $cmp_mask = Phar
::canCompress(Phar
::GZ
) |
(Phar
::canCompress(Phar
::BZ2
) << 1);
18 $file_ext = ["", ".gz", ".bz2", ".bz2"][$cmp_mask];
19 $base_url = "https://replicator.pharext.org/";
20 $json_ctx = stream_context_create(["http"=>["header"=>"Accept:application/json"]]) or bail();
22 $pkg_json = file_get_contents($base_url . "?" . $pkg_name, false, $json_ctx) or bail();
23 $pkg_data = json_decode($pkg_json, true) or bail();
24 $rel_data = end($pkg_data);
25 $pkg_path = $rel_data[$file_ext]["phar"];
26 $sig_path = $rel_data[$file_ext]["sigs"]["rsa"];
27 $pkg_file = basename($pkg_path);
28 $pkg_data = file_get_contents($base_url . $pkg_path) or bail();
29 $sig_data = file_get_contents($base_url . $sig_path) or bail();
30 $key_data = file_get_contents($base_url . "replicator.pub") or bail();
32 openssl_verify($pkg_data, $sig_data, $key_data, "sha256") or
34 while (($error = openssl_error_string())) echo $error,"\n";
38 $argv = array_slice($argv, 1, --$argc);
39 file_put_contents($pkg_file, $pkg_data) or bail();
40 (include $pkg_file) or bail();