묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
winamp방송정보 알아오기 (status.inc.php) 부탁합니다.
2005.08.28 23:06
잘되다가 갑자기 $fp = fsockopen($host, $port, &$errno, &$errstr, 5); 여기가 에러가 난다고 하네요 왜그러죠 ㅠ,.ㅜ;;; 알려주세요 네!
<?php
function GetSCStatus($host, $port) {
$fp = fsockopen($host, $port, &$errno, &$errstr, 5);
if($fp) {
fputs($fp,"GET /index.html HTTP/1.0n");
fputs($fp,"User-Agent: Mozilla/4.0n");
fputs($fp,"n");
while(!feof($fp)) {
$contents .= fgets($fp,128);
}
fclose($fp);
if(eregi("Server is currently down",$contents)) $onair = 0;
else $onair = 1;
if($onair) {
$contents = substr($contents,strpos($contents,"Stream is up at")+16);
$rtn["format"] = ereg_replace("^([0-9]+) kbps(.+)$","\1",$contents);
$contents = substr($contents,strpos($contents,"with <B>")+8);
$listeners = substr($contents,0,strpos($contents,"unique"));
$listeners = ereg_replace("([[:space:]])+",":",trim(ereg_replace("[^[:digit:]]"," ",$listeners)));
$listeners = split(":",$listeners);
$rtn["listeners"] = $listeners[0];
$rtn["listenersmax"] = $listeners[1];
$rtn["uniquelisteners"] = $listeners[2];
$lpeak = substr($contents,strpos($contents,"Listener Peak:")+54);
$rtn["listenerpeak"] = substr($lpeak,0,strpos($lpeak,"</b>"));
$alt = substr($contents,strpos($contents, "Average Listen Time:")+60);
$alt = substr($alt,0,strpos($alt,"</b>"));
$rtn["avglistentime"] = $alt;
$title = substr($contents,strpos($contents,"Stream Title:")+53);
$rtn["title"] = substr($title,0,strpos($title,"</b>"));
$genre = substr($contents,strpos($contents,"Stream Genre:")+53);
$rtn["genre"] = substr($genre,0,strpos($genre,"</b>"));
$url = substr($contents,strpos($contents,"Stream URL:")+51);
$url = substr($url,0,strpos($url,"</b>"));
$rtn["url"] = ereg_replace("<a href="(.+)">(.+)</a>","\1",$url);
if(ereg("Stream ICQ:",$contents)) {
$icq = substr($contents,strpos($contents,"Stream ICQ:")+51);
$icq = substr($icq,0,strpos($icq,"</b>"));
$rtn["icq"] = ereg_replace("<a href="http://wwp.icq.com/scripts/contact.dll?msgto=(.*)">(.+)","\1",$icq);
}
$aim = substr($contents,strpos($contents,"Stream AIM:")+51);
$aim = substr($aim,0,strpos($aim,"</b>"));
$rtn["aim"] = urldecode(ereg_replace("<a href="aim:goim?screenname=(.*)">(.+)","\1",$aim));
$irc = substr($contents,strpos($contents,"Stream IRC:")+51);
$irc = substr($irc,0,strpos($irc,"</b>"));
$rtn["irc"] = ereg_replace("<a href="http://www.shoutcast.com/chat.phtml?dc=(.*)">(.+)","\1",$irc);
$rtn["irc"] = urldecode(urldecode($rtn["irc"]));
$song = substr($contents,strpos($contents,"Current Song:")+53);
$rtn["song"] = substr($song,0,strpos($song,"</b>"));
$rtn["status"] = 1;
}
else {
$rtn["status"] = 0;
}
}
else {
$rtn["status"] = -1;
}
return $rtn;
}
?>
<?php
function GetSCStatus($host, $port) {
$fp = fsockopen($host, $port, &$errno, &$errstr, 5);
if($fp) {
fputs($fp,"GET /index.html HTTP/1.0n");
fputs($fp,"User-Agent: Mozilla/4.0n");
fputs($fp,"n");
while(!feof($fp)) {
$contents .= fgets($fp,128);
}
fclose($fp);
if(eregi("Server is currently down",$contents)) $onair = 0;
else $onair = 1;
if($onair) {
$contents = substr($contents,strpos($contents,"Stream is up at")+16);
$rtn["format"] = ereg_replace("^([0-9]+) kbps(.+)$","\1",$contents);
$contents = substr($contents,strpos($contents,"with <B>")+8);
$listeners = substr($contents,0,strpos($contents,"unique"));
$listeners = ereg_replace("([[:space:]])+",":",trim(ereg_replace("[^[:digit:]]"," ",$listeners)));
$listeners = split(":",$listeners);
$rtn["listeners"] = $listeners[0];
$rtn["listenersmax"] = $listeners[1];
$rtn["uniquelisteners"] = $listeners[2];
$lpeak = substr($contents,strpos($contents,"Listener Peak:")+54);
$rtn["listenerpeak"] = substr($lpeak,0,strpos($lpeak,"</b>"));
$alt = substr($contents,strpos($contents, "Average Listen Time:")+60);
$alt = substr($alt,0,strpos($alt,"</b>"));
$rtn["avglistentime"] = $alt;
$title = substr($contents,strpos($contents,"Stream Title:")+53);
$rtn["title"] = substr($title,0,strpos($title,"</b>"));
$genre = substr($contents,strpos($contents,"Stream Genre:")+53);
$rtn["genre"] = substr($genre,0,strpos($genre,"</b>"));
$url = substr($contents,strpos($contents,"Stream URL:")+51);
$url = substr($url,0,strpos($url,"</b>"));
$rtn["url"] = ereg_replace("<a href="(.+)">(.+)</a>","\1",$url);
if(ereg("Stream ICQ:",$contents)) {
$icq = substr($contents,strpos($contents,"Stream ICQ:")+51);
$icq = substr($icq,0,strpos($icq,"</b>"));
$rtn["icq"] = ereg_replace("<a href="http://wwp.icq.com/scripts/contact.dll?msgto=(.*)">(.+)","\1",$icq);
}
$aim = substr($contents,strpos($contents,"Stream AIM:")+51);
$aim = substr($aim,0,strpos($aim,"</b>"));
$rtn["aim"] = urldecode(ereg_replace("<a href="aim:goim?screenname=(.*)">(.+)","\1",$aim));
$irc = substr($contents,strpos($contents,"Stream IRC:")+51);
$irc = substr($irc,0,strpos($irc,"</b>"));
$rtn["irc"] = ereg_replace("<a href="http://www.shoutcast.com/chat.phtml?dc=(.*)">(.+)","\1",$irc);
$rtn["irc"] = urldecode(urldecode($rtn["irc"]));
$song = substr($contents,strpos($contents,"Current Song:")+53);
$rtn["song"] = substr($song,0,strpos($song,"</b>"));
$rtn["status"] = 1;
}
else {
$rtn["status"] = 0;
}
}
else {
$rtn["status"] = -1;
}
return $rtn;
}
?>