mirror of
https://github.com/datajerk/sendalo.git
synced 2025-01-28 07:30:45 +00:00
Fixes and better proxying
This commit is contained in:
parent
150b1e9be4
commit
0bb0a0921e
@ -112,10 +112,10 @@
|
|||||||
|
|
||||||
var pb = document.getElementById('playbutton');
|
var pb = document.getElementById('playbutton');
|
||||||
pb.value = 'Please wait...';
|
pb.value = 'Please wait...';
|
||||||
pb.enabled = false;
|
pb.disabled = true;
|
||||||
document.getElementById('url').enabled = false;
|
document.getElementById('url').disabled = true;
|
||||||
document.getElementById('upload').enabled = false;
|
document.getElementById('upload').disabled = true;
|
||||||
document.getElementById('format').enabled = false;
|
document.getElementById('format').disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadComplete(what) {
|
function downloadComplete(what) {
|
||||||
@ -148,10 +148,10 @@
|
|||||||
|
|
||||||
var pb = document.getElementById('playbutton');
|
var pb = document.getElementById('playbutton');
|
||||||
pb.value = 'Play!';
|
pb.value = 'Play!';
|
||||||
pb.enabled = false;
|
pb.disabled = false;
|
||||||
document.getElementById('url').enabled = true;
|
document.getElementById('url').disabled = false;
|
||||||
document.getElementById('upload').enabled = true;
|
document.getElementById('upload').disabled = false;
|
||||||
document.getElementById('format').enabled = true;
|
document.getElementById('format').disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetFile() {
|
function resetFile() {
|
||||||
@ -174,7 +174,7 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<form>
|
<form onsubmit="return false;">
|
||||||
<input type="text" onkeypress="resetFile()" placeholder="https://..." id="url"/><br/>
|
<input type="text" onkeypress="resetFile()" placeholder="https://..." id="url"/><br/>
|
||||||
<div id="fc"><input type="file" onchange="resetURL()" id="upload" /></div><br/>
|
<div id="fc"><input type="file" onchange="resetURL()" id="upload" /></div><br/>
|
||||||
<input id="format" type="checkbox"><label for="format"><small>Format disk?</small></label><br/><br/>
|
<input id="format" type="checkbox"><label for="format"><small>Format disk?</small></label><br/><br/>
|
||||||
|
@ -1,10 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$alldata = "";
|
||||||
|
function curl_callback($handle, $data) {
|
||||||
|
global $alldata;
|
||||||
|
$alldata .= $data;
|
||||||
|
if (strlen($alldata) > 150000) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
else return strlen($data);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST["url"])) {
|
if (isset($_REQUEST["url"])) {
|
||||||
$url = $_REQUEST["url"];
|
$url = $_REQUEST["url"];
|
||||||
|
|
||||||
|
if (
|
||||||
|
substr($url, 0, strlen('http://')) !== 'http://'
|
||||||
|
&& substr($url, 0, strlen('https://')) !== 'https://'
|
||||||
|
) die();
|
||||||
|
|
||||||
|
$ch = curl_init($url);
|
||||||
|
$headers = array('X-Forwarded-For: ' . $_SERVER['REMOTE_ADDR']);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||||
|
curl_setopt ($ch, CURLOPT_WRITEFUNCTION, 'curl_callback');
|
||||||
|
|
||||||
|
curl_exec($ch);
|
||||||
|
|
||||||
header('Content-type: application/octet-stream');
|
header('Content-type: application/octet-stream');
|
||||||
$data = file_get_contents($url, $maxlen=150000);
|
file_put_contents("php://output", $alldata);
|
||||||
file_put_contents("php://output", $data);
|
|
||||||
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user