Skip to content

Instantly share code, notes, and snippets.

@z3nth10n
Created July 23, 2019 04:04
Show Gist options
  • Save z3nth10n/2183820d7697731429577de5dc3ad832 to your computer and use it in GitHub Desktop.
Save z3nth10n/2183820d7697731429577de5dc3ad832 to your computer and use it in GitHub Desktop.
<?php
if(@$_GET["debug"] !== null) {
error_reporting(E_ALL);
ini_set("display_errors", 1);
}
$url="https://api.github.com/gists/";
$dlgitlab_url=$url."425549fbcb38834e551aea7521f5b9b1";
$dlvm_url=$url."cf4f8f439e8058c2b5b60d83ce1ad3a9";
$action=@$_GET["action"];
switch($action) {
case "download-vm":
get_latest_release($dlvm_url);
break;
case "download-gitlab":
get_latest_release($dlgitlab_url);
break;
default:
die("Not recognized action '".$action."'!");
break;
}
function get_latest_release($url)
{
$contents = json_decode(curl($url), true);
$gist_content = json_decode(curl($contents["history"][0]["url"]), true);
$files = $gist_content["files"];
$keys = array_keys($files);
return $files[$keys[0]]["raw_url"];
}
function curl($url)
{
$context = stream_context_create(
array(
"http" => array(
"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
)
)
);
return file_get_contents($url, false, $context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment