if($_GET['metacafe']) {
// It has so run function "metacafe_t" and redirect to that.
$download = meta_t($_GET['metacafe']);
header("Location: $download");
} else {
// It hasn't so show them the form.
echo '
Source';
}
function meta_t ($url) {
$page = g_page($url);
if ($page === false)
{
die("Metacafe down?");
}
preg_match('/http:\/\/(.*?).metacafe.com\/ItemFiles\/%5BFrom%20www.metacafe.com%5D%(.*?).flv/', $page, $match);
if(!$match[1]){
die("Error no matches - wrong metacafe page?");
}
$match1 = "http://";
$match1 .= $match[1];
$match1 .= ".metacafe.com/ItemFiles/%5BFrom%20www.metacafe.com%5D%";
$match1 .= $match[2];
$match1 .= ".flv";
return $match1;
}
// G_Page, this grabs the page
function g_page ($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl);
// check for errors
if (curl_errno($curl))
{
trigger_error('CURL error: "' . curl_error($curl) . '"', E_USER_WARNING);
$output = false;
}
curl_close($curl);
return $output;
}
?>