Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tunelling link data through PHP?

Tags:

php

tunnel

I want to be able to go to mydoma.in/tunnel.php?file=http://otherdoma.in/music.mp3, and then get the data of http://otherdoma.in/music.mp3 streamed to the client.

I tried doing this via Header();, but it redirects instead of "tunelling" the data.

How can i do this?

like image 817
Jacob Pedersen Avatar asked Jun 21 '26 21:06

Jacob Pedersen


1 Answers

Use cURL for streaming:

<?php

$url = $_GET["file"];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);

curl_exec($ch);
curl_close($ch);

?>
like image 113
KikoV Avatar answered Jun 24 '26 10:06

KikoV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!