View difference between Paste ID: JDtr2rJb and Ke8vnGc5
SHOW: | | - or go back to the newest paste.
1
<?php
2
ini_set('user_agent', 'iTunes-AppleTV/4.1');
3
4
if(empty($_GET["f"])) {
5
	die;
6
} else {
7
	$f = $_GET["f"];
8
	
9
	// Get file from URL that is in $f
10
	$m3u8 = file_get_contents($f);
11
	
12
	// Parse URL from input
13
	$domain = parse_url($f);
14
	$scheme = $domain['scheme'];
15
	$host = $domain['host'];
16
	$path = $domain['path'];
17
	
18
	// Get file from URL
19
	$file = basename($domain['path']);
20
	
21
	// Remove file from path
22
	$path = preg_replace("/$file/",'',$domain['path']);
23
	
24
	// Put URL back together without filename
25
	$baseUrl = $scheme . "://" . $host . $path;
26
	
27
	// Pull out .m3u8 from file and replace with proxy php
28
	$m3u8 = preg_replace('/^(?!\#)(.*\.m3u8).*/m',"http://yourserver.com/m3u8_fix.php?f=$baseUrl$1",$m3u8);
29
	// Pull out .ts files from final m3u8 and make sure they point at their CDN
30
	$m3u8 = preg_replace('/^(.*\.ts).*/m',"$baseUrl$1",$m3u8);
31-
	// Removing their key redirect and replacing with root CDN
31+
	// Removing their key redirect and replacing with other server IP
32
	$m3u8 = preg_replace('/nlsk.neulion.com/m', "192.241.136.149",$m3u8);
33
	$m3u8 = preg_replace('/http:\/\/nlsk[0-9]{1,3}.neulion.com/m', "192.241.136.149",$m3u8);
34
	
35
	// Set headers for m3u8 file we're returning to browser
36
	header("Content-type: application/x-mpegURL");
37
	header("Content-Disposition: attachment; filename=$file");
38
	header("Pragma: no-cache");
39
	header("Expires: 0");
40
	
41
	echo $m3u8;
42
}