<?php
if ($_GET['p'])
{
$tUrl = $_GET['p'];
$rUrl = $_GET['r']; //Referer
if ( empty($rUrl) ) {
$rUrl = $tUrl;
}
$path_parts = pathinfo($tUrl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $tUrl);
curl_setopt($ch, CURLOPT_REFERER, $rUrl);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30) ');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$f = curl_exec($ch);
curl_close($ch);
$len = strlen($f);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=".$path_parts['basename']);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' .$len);
echo ($f);
}
Created
May 1, 2019 02:25
-
-
Save min-ji-kim/65c0c7a58fe7c62d129a57516b5e7325 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment