
17.01.2008, 13:50
|
|
Познающий
Регистрация: 06.01.2007
Сообщений: 44
С нами:
10180537
Репутация:
32
|
|
Мой первый сексуальный опыт с пхп.
Граббер радиостанций с shoutcast.org
PHP код:
<table cellpadding="0" cellspacing="0" style="border:1px solid #000000">
<tr>
<th>
<?
if (!$addr){
$EXTERNALPAGE = importPage("http://www.shoutcast.com/directory/index.phtml?startat=0&numresult=30&s=gabber");
}
else {
$EXTERNALPAGE = importPage($addr);
}
function importPage( $addr ) {
$pattern1 = '|(http://)([^/]*)/{0,1}(.*)|';
$base = "";
if (preg_match($pattern1, $addr, $list)) {
$server = "http://".$list[2];
$fullpath = $list[3];
$pattern11 = '|(.*)/([^/]*)$|';
if ( preg_match($pattern11, $fullpath, $list) ) {
$path = $list[1];
$fname = $list[2];
} else {
$path = "";
$fname = $fullpath;
}
if ($path) $path = "/".$path;
$base = $server.$path;
}
$arr = @file($addr);
if ( !$arr ) return "Page not found!";
$str = join( "", $arr );
$pattern2 = '|<table border="0" cellpadding="0" cellspacing="0" align="center">(.*)<td nowrap align="center" width="10">|sei';
if (preg_match($pattern2, $str, $list)) $str = $list[1];
$pattern3 =
'/(<img\s.*?src\s*=\s*("{0,1}))([^">]*)(\2[^>]*>)/sei';
$str = preg_replace($pattern3,
"stripslashes((strpos('\\3','ttp:')<=0) ".
"?((strspn('\\3','/')<=0)".
"?'\\1$base/\\3\\4'".
":'\\1$server\\3\\4' )".
":'\\0')",
$str);
$pattern4 =
'/(<a\s.*?href\s*=\s*("{0,1}))([^">]*)(\2[^>]*>)/sei';
$str = preg_replace($pattern4,
"stripslashes((strpos('\\3','ttp:')<=0)&&".
"(strpos('\\3','ailto:')<=0) &&".
"(Ord('\\3')!=Ord('#')) ".
"?((strspn('\\3','/')<=0)".
"?'\\1$base/\\3\\4'".
":'\\1$server\\3\\4' )".
":'\\0')",
$str);
$str= str_replace('<a href="http://www.shoutcast.com/directory/index.phtml?orderby=title&s=drum&numresult=30 "id="dirlinks">Description</a>', 'Description', $str);
$str= str_replace('<a href="http://www.shoutcast.com/directory/index.phtml?orderby=listeners&s=drum&numresult=30 "id="dirlinks">Listeners/Max</a>', 'Listeners / Max', $str);
$str= str_replace('<a href="http://www.shoutcast.com/directory/index.phtml?orderby=bitrate&s=drum&numresult=30 "id="dirlinks">Bitrate</a>', 'Bitrate', $str);
$str= str_replace('<a href="http://www.shoutcast.com/directory/index.phtml?orderby=content&s=drum&numresult=30 "id="dirlinks">Type</a>', 'Type', $str);
return $str;
}
?>
<?= $EXTERNALPAGE?>
</th>
</tr>
</table>
ЗЫ. Щас я видоуроки с евгением поповым досмотрю еще че нить придумаю... 
|
|
|