Files
MediaFire-Stream-API/mediafire.php

36 lines
843 B
PHP
Raw Normal View History

2018-05-06 18:51:38 +08:00
<?php
/*
Version: 1.1
2018-05-06 18:51:38 +08:00
Author: HKLCF
Copyright: HKLCF
Last Modified: 06/05/2018
*/
$url = isset($_GET['url']) ? htmlspecialchars($_GET['url']) : null;
2018-05-06 18:51:38 +08:00
$support_domain = 'www.mediafire.com';
if(empty($url)) {
$url = 'http://www.mediafire.com/file/8x5ol3r8wpb477a/small.mp4'; // sample link
}
if($url) {
preg_match('@^(?:http?://)?([^/]+)@i', $url, $matches);
$host = $matches[1];
if($host != $support_domain) {
2018-05-06 19:19:20 +08:00
echo 'Please input a valid mediafire url.';
2018-05-06 18:51:38 +08:00
exit;
}
}
$result = file_get_contents($url, false, stream_context_create(['socket' => ['bindto' => '0:0']])); // force IPv4
preg_match('/kNO = "(.*)"/', $result, $matches);
$result = urldecode($matches[1]);
$output = [];
$output[] = ['label' => 'Original', 'file' => $result, 'type' => 'video/mp4'];
$output = json_encode($output);
echo $output;
?>