mirror of
https://github.com/hklcf/MediaFire-Stream-API
synced 2026-01-13 13:24:29 -08:00
Create mediafire.php
This commit is contained in:
35
mediafire.php
Normal file
35
mediafire.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
Version: 1.0
|
||||
Author: HKLCF
|
||||
Copyright: HKLCF
|
||||
Last Modified: 06/05/2018
|
||||
*/
|
||||
|
||||
$url = htmlspecialchars($_GET['url']);
|
||||
$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) {
|
||||
echo 'Please input a valid google drive url.';
|
||||
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;
|
||||
?>
|
||||
Reference in New Issue
Block a user