Files
MediaFire-Stream-API/mediafire.php
HKLCF 9d1b6314fb preg_match update
fix mediafire html update #10
2018-09-22 16:45:50 +08:00

36 lines
901 B
PHP

<?php
/*
Version: 1.2.1
Author: HKLCF
Copyright: HKLCF
Last Modified: 22/09/2018
*/
$url = isset($_GET['url']) ? htmlspecialchars($_GET['url']) : null;
$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 mediafire url.';
exit;
}
}
$result = file_get_contents($url, false, stream_context_create(['socket' => ['bindto' => '0:0']])); // force IPv4
preg_match('/<a href=\'(.*)\' onclick=\'DLP_mOnDownload\(this\); return true;\'>/', $result, $matches);
$result = urldecode($matches[1]);
$output = [];
$output[] = ['label' => 'Original', 'file' => $result, 'type' => 'video/mp4'];
$output = json_encode($output);
echo $output;
?>