span style="color: #0000BB"><?phpdefine("BLOCK", 8 * 1024);# Надеюсь всем понятно что такое $url$url = "http://vk.com/video_ext.php?oid=-26208303&id=162713839&hash=e83192de1a010111&hd=3";$ch = curl_init();$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.2.13) ' . 'Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729)';curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);curl_setopt($ch, CURLOPT_HEADER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);curl_setopt($ch, CURLOPT_VERBOSE, 1);$vk = curl_exec($ch);curl_close($ch);preg_match('|host=(.*)&|Uis', $vk, $host);preg_match('|uid=(.*)&|Uis', $vk, $uid);preg_match('|vtag=(.*)&|Uis', $vk, $vtag);preg_match('|vkid=(.*)&|Uis', $vk, $vkid);preg_match('|no_flv=(.*)&|Uis', $vk, $no_flv);preg_match('|thumb=(.*)&|Uis', $vk, $thumb);preg_match('|md_title=(.*)&|Uis', $vk, $title);$title = urldecode($title['1']);if ($_GET['type'] == 'image') { $link = $thumb['1']; $header = get_headers($link, 0); $fp = fopen($link, "rb"); if (isset($header)) { foreach ($header as $v) { header($v); } } while (!feof($fp)) { echo fread($fp, BLOCK); }} else { if ($host) { $oldVideo = false; if ($uid['1'] == '0') { $oldVideo = true; } if ($oldVideo) { header('Content-Disposition: attachment; filename="' . $title . '.flv"'); $link = 'http://' . $host['1'] . '/assets/videos/' . $vtag['1'] . $vkid['1'] . '.vk.flv'; $header = get_headers($link, 0); $fp = fopen($link, "rb"); if (isset($header)) { foreach ($header as $v) { header($v); } } while (!feof($fp)) { echo fread($fp, BLOCK); } } else { if ($no_flv['1'] == '1') { header('Content-Disposition: attachment; filename="' . $title . '.mp4"'); $link = $host['1'] . 'u' . $uid['1'] . '/video/' . $vtag['1'] . '.240.mp4'; $header = get_headers($link, 0); $fp = fopen($link, "rb"); if (isset($header)) { foreach ($header as $v) { header($v); } } while (!feof($fp)) { echo fread($fp, BLOCK); } fclose($fp); } else { header('Content-Disposition: attachment; filename="' . $title . '.flv"'); $link = $host['1'] . 'u' . $uid['1'] . '/video/' . $vtag['1'] . '.flv'; $header = get_headers($link, 0); $fp = fopen($link, "rb"); if (isset($header)) { foreach ($header as $v) { header($v); } } while (!feof($fp)) { echo fread($fp, BLOCK); } fclose($fp); } } } else { header("HTTP/1.0 404 Not Found"); }} |