<?php $url = 'http://download.java.net/jdk7/binaries'; $base = 'http://www.java.net'; $var = fread_url($url); preg_match_all("/a[\\s]+[^>]*?href[\\s]?=[\\s\"\\']+" . "(.*?)[\"\\']+.*?>" . "([^<]+|.*?)?<\\/a>/", $var, &$matches); $matches = $matches[1]; $list = array(); foreach ($matches as $var) { if (preg_match("/linux-i586.*\\d.bin/", $var)) { header("Location:{$base}{$var}"); break; } } // The fread_url function allows you to get a complete // page. If CURL is not installed replace the contents with // a fopen / fget loop function fread_url($url, $ref = "") { if (function_exists("curl_init")) { $ch = curl_init(); $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; " . "Windows NT 5.0)"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
function converturl($url) { $var = fread_url($url); preg_match_all("/a[\\s]+[^>]*?href[\\s]?=[\\s\"\\']+" . "(.*?)[\"\\']+.*?>" . "([^<]+|.*?)?<\\/a>/", $var, $matches); $matches = $matches[1]; $list = array(); foreach ($matches as $var) { $link = $url . $var; $dtitle = $var; $dtitle = str_replace('+', ' ', $dtitle); $dtitle = str_replace('.', ' ', $dtitle); $dtitle = str_replace(' TehMovies com ', '', $dtitle); $dtitle = str_replace('%5D', ']', $dtitle); $dtitle = str_replace('%5B', '[', $dtitle); $dtitle = str_replace('%28', '(', $dtitle); $dtitle = str_replace('%29', ')', $dtitle); $dtitle = str_replace('%26amp%3B', ' ', $dtitle); $dtitle = str_replace('%40', '@', $dtitle); $dtitle = str_replace('%2', '-', $dtitle); $dtitle = substr($dtitle, 0, -3); if ($dtitle != '') { echo "<item>\r\n<title>" . $dtitle . "</title>\r\n<link>" . $link . "</link>\r\n<thumbnail></thumbnail>\r\n</item>\r\n\r\n"; } // echo '<a href="'.$sUrl.'" title="Download '.$dtitle.' via magnet link">'.$dtitle.'</a><br>'; } }