<?php
$i = $_GET['dwnld'];
$dwnld_link = GetAllFiles($i);
$dwnld_link = (array) $dwnld_link[0];
$redirect = $dwnld_link['download_link'];
header('Location: ' . $redirect);
class CMFile
{
public $name = "";
public $output = "";
public $link = "";
public $download_link = "";
function __construct($name, $output, $link, $download_link)
{
$this->name = $name;
$this->output = $output;
$this->link = $link;
$this->download_link = $download_link;
}
}
function GetAllFiles($link, $folder = "")
{
global $base_url, $id;
$page = get(pathcombine($link, $folder));
if ($page === false) { echo "Error $link\r\n"; return false; }
if (($mainfolder = GetMainFolder($page)) === false) { echo "Cannot get main folder $link\r\n"; return false; }
if (!$base_url) $base_url = GetBaseUrl($page);
if (!$id && preg_match('~\/public\/(.*)~', $link, $match)) $id = $match[1];
$cmfiles = array();
if ($mainfolder["name"] == "/") $mainfolder["name"] = "";
foreach ($mainfolder["list"] as $item)
{
if ($item["type"] == "folder")
{
$files_from_folder = GetAllFiles($link, pathcombine($folder, rawurlencode(basename($item["name"]))));
if (is_array($files_from_folder))
{
foreach ($files_from_folder as $file)
{
if ($mainfolder["name"] != "")
$file->output = $mainfolder["name"] . "/" . $file->output;
}
$cmfiles = array_merge($cmfiles, $files_from_folder);
}
}
else
{
$fileurl = pathcombine($folder, rawurlencode($item["name"]));
if (strpos($id, $fileurl) !== false) $fileurl = "";
$cmfiles[] = new CMFile($item["name"],
pathcombine($mainfolder["name"], $item["name"]),
pathcombine($link, $fileurl),
pathcombine($base_url, $id, $fileurl));
}
}
return $cmfiles;
}
function GetMainFolder($page)
{
if (preg_match('~"folder":\s+(\{.*?"id":\s+"[^"]+"\s+\})\s+}~s', $page, $match)) return json_decode($match[1], true);
else return false;
}
function GetBaseUrl($page)
{
if (preg_match('~"weblink_get":.*?"url":\s*"(https:[^"]+)~s', $page, $match)) return $match[1];
else return false;
}
function get($url)
{
$proxy = null;
$http["method"] = "GET";
if ($proxy) { $http["proxy"] = "tcp://" . $proxy; $http["request_fulluri"] = true; }
$options['http'] = $http;
$context = stream_context_create($options);
$body = @file_get_contents($url, NULL, $context);
return $body;
}
function pathcombine()
{
$result = "";
foreach (func_get_args() as $arg)
{
if ($arg !== '')
{
if ($result && substr($result, -1) != "/") $result .= "/";
$result .= $arg;
}
}
return $result;
}
?>
<?php
$i = $_GET['url'];
$dwnld_link = GetAllFiles($i);
$dwnld_link = (array) $dwnld_link[0];
$redirect = $dwnld_link['download_link'];
$file = $redirect;
if (ob_get_level()) {
ob_end_clean();
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile($file);
exit;
class CMFile
{
public $name = "";
public $output = "";
public $link = "";
public $download_link = "";
function __construct($name, $output, $link, $download_link)
{
$this->name = $name;
$this->output = $output;
$this->link = $link;
$this->download_link = $download_link;
}
}
function GetAllFiles($link, $folder = "")
{
global $base_url, $id;
$page = get(pathcombine($link, $folder));
if ($page === false) { echo "Error $link\r\n"; return false; }
if (($mainfolder = GetMainFolder($page)) === false) { echo "Cannot get main folder $link\r\n"; return false; }
if (!$base_url) $base_url = GetBaseUrl($page);
if (!$id && preg_match('~\/public\/(.*)~', $link, $match)) $id = $match[1];
$cmfiles = array();
if ($mainfolder["name"] == "/") $mainfolder["name"] = "";
foreach ($mainfolder["list"] as $item)
{
if ($item["type"] == "folder")
{
$files_from_folder = GetAllFiles($link, pathcombine($folder, rawurlencode(basename($item["name"]))));
if (is_array($files_from_folder))
{
foreach ($files_from_folder as $file)
{
if ($mainfolder["name"] != "")
$file->output = $mainfolder["name"] . "/" . $file->output;
}
$cmfiles = array_merge($cmfiles, $files_from_folder);
}
}
else
{
$fileurl = pathcombine($folder, rawurlencode($item["name"]));
if (strpos($id, $fileurl) !== false) $fileurl = "";
$cmfiles[] = new CMFile($item["name"],
pathcombine($mainfolder["name"], $item["name"]),
pathcombine($link, $fileurl),
pathcombine($base_url, $id, $fileurl));
}
}
return $cmfiles;
}
function GetMainFolder($page)
{
if (preg_match('~"folder":\s+(\{.*?"id":\s+"[^"]+"\s+\})\s+}~s', $page, $match)) return json_decode($match[1], true);
else return false;
}
function GetBaseUrl($page)
{
if (preg_match('~"weblink_get":.*?"url":\s*"(https:[^"]+)~s', $page, $match)) return $match[1];
else return false;
}
function get($url)
{
$proxy = null;
$http["method"] = "GET";
if ($proxy) { $http["proxy"] = "tcp://" . $proxy; $http["request_fulluri"] = true; }
$options['http'] = $http;
$context = stream_context_create($options);
$body = @file_get_contents($url, NULL, $context);
return $body;
}
function pathcombine()
{
$result = "";
foreach (func_get_args() as $arg)
{
if ($arg !== '')
{
if ($result && substr($result, -1) != "/") $result .= "/";
$result .= $arg;
}
}
return $result;
}
?>