주간 베스트 월간 베스트 3개월 베스트 베스트 게시물
꽃배달 한국, 중국 전지역배송

윈앰 방송 정보 출력....

네로 | 2003.02.24 03:46:16 댓글: 0 조회: 524 추천: 9
분류웹 프로그래밍 https://life.moyiza.kr/itstudy/1758919
윈앰 방송 정보 출력...

심심해서.
문자열 가공~ ^-^v

소스보기 ::: http://roma.x-y.net/bihon/cast.inc.phps
미리보기 ::: http://roma.x-y.net/bihon/webcast.php

<?
/*
--------------------------------------------------------------------------------
::: BiHon's DreamPHP.com ::: // master@dreamphp.com // http://dreamphp.com
--------------------------------------------------------------------------------
▷ 비혼의 방송정보표시

...심심하다는 이유 하나로 -_-v

array get_info("주소:포트"); // 방송 정보를 가져옴
+--------------------------------------+--------------------------------------+
| air : [0] 방송안함 [1] 방송중 | version : 버전 |
| server : 서버상태 | stream : 정보 |
| spped : 속도 | listen : 청취자수 |
| maxlisten : 최대 청취자수 | unique : 청취자수 (동일 IP 제외) |
| peak : 최고 청취자수 | time : 방송시간 |
| title : 제목 | genre : 장르 |
| url : 주소 | icq : ICQ |
| aim : AIM | irc : IRC |
| song : 노래 | |
+--------------------------------------+--------------------------------------+
[표:인자값]
--------------------------------------------------------------------------------
2001.08.11.(토) */

function get_info($address) {
$url_temp = explode(":",$address); // 콜론(:) 기준 분리해 배열에 저장
$url = $url_temp[0]; // 주소 분리
$port = $url_temp[1]; // 포트 분리
$fp = fsockopen($url, $port, &$errno, &$errstr, 5); // 소켓 연결
if($fp) { // 연결 성공시
fputs($fp,"GET /index.html HTTP/1.0nUser-Agent: Mozilla/4.0nn"); // 헤더 보냄
while(!feof($fp)) $temp .= fgets($fp,1024); // 파일이 끝날때까지 1024바이트씩 가져옴
fclose($fp); // 접속 해제
//------------------------------------------------------------------------------// 가공시작
$keyword = array( // 찾을 값 (2차원 배열)
array("version" => "SHOUTcast Server Version"),
array("server" => "Server Status:"),
array("stream" => "Stream Status:"),
array("peak" => "Listener Peak:"),
array("time" => "Average Listen Time:"),
array("title" => "Stream Title:"),
array("genre" => "Stream Genre:"),
array("url" => "Stream URL:"),
array("icq" => "Stream ICQ:"),
array("aim" => "Stream AIM:"),
array("irc" => "Stream IRC:"),
array("song" => "Current Song:"),
);
$size = sizeof($keyword); // 배열의 크기 구함
$temp = strip_tags( // 4) 모든 태그 제거
implode("n<tr", // 3) n<tr 문자열로 다시 결합
explode("<tr", // 2) <tr 기준으로 분리 -> 배열값
str_replace(" "," ",$temp)))); // 1) 를 공백으로 바꿈
for ($i=0; $i<$size; $i++) { // 배열의 크기만큼 반복
$t_key = array_keys($keyword[$i]); // 키값을 가져옴
$t_key1 = $t_key[0]; // 처음키
$t_key2 = $keyword[$i][$t_key1]; // 키에 해당하는 값을 가져옴
$address = strpos($temp,$t_key2); // 키에 해당하는 위치값 구함
if ($address) { // 위치값이 있을 경우
$start = $address+strlen($t_key2); // 시작위치값 저장 (+길이)
$end = $start; // 시작위치값 저장 (증가치)
while(substr($temp,$end,1)!="n") $end++; // 다음줄 찾기 전까지 반복
$temp2[$t_key1] = trim(substr($temp,$start,$end-$start)); // 찾은 결과값 출력
if ($t_key1=="aim") $temp2[$t_key1] = urldecode($temp2[$t_key1]); // AIM은 디코드
}
}
//------------------------------------------------------------------------------// 가공끝
}
$stream = explode(" ",$temp2[stream]); // stream 문자열 공백 기준 분리
$temp2[speed] = trim($stream[4])." ".trim($stream[5]); // 방송속도 : 4,5번째 요소 가져옴
$temp2[listen] = trim($stream[7]); // 청취자 : 7번째 요소
$temp2[maxlisten] = trim($stream[9]); // 최대청취인원 : 9번째 요소
$temp2[unique] = str_replace("(","",trim($stream[11])); // 청취자 : 11번째 요소 (동일 IP 제외)
$temp2[time] = str_replace("h","시간",str_replace("m","분",str_replace("s","초",$temp2[time]))); // 시간,분,초 변환
if ($temp2[server]=="Server is currently up and public.") $temp2[air] = 1; // 방송중
elseif ($temp2[server]=="Server is currently down.") $temp2[air] = 0; // 방송안함
else $temp2[air] = -1; // 찾지 못함
return $temp2; // 값 반환
}

?>

* 전설님에 의해서 게시물 이동되었습니다 (2004-05-30 17:07)
* 이동한 이유 :
* 원래의 위치 : 웹 공부 >> 웹 프로그래밍
* 이동후 위치 : 웹 공부 >>

* 전설님에 의해서 게시물 이동되었습니다 (2004-05-30 17:12)
* 이동한 이유 :
* 원래의 위치 : 웹 공부 >>
* 이동후 위치 : 웹 공부 >> 웹 프로그래밍
추천 (9) 선물 (0명)
IP: ♡.27.♡.234
3,006 개의 글이 있습니다.
제목 글쓴이 날짜 조회
관리자
2003-09-20
11940
관리자
2003-09-20
11488
관리자
2003-09-20
20621
지구인
2010-08-27
19413
지구인
2009-09-07
13735
SOLIDH
2010-01-29
15693
엔죠라이프
2004-10-07
16784
네로
2003-02-24
756
네로
2003-02-24
524
네로
2003-02-24
546
네로
2003-02-24
593
네로
2003-02-24
464
네로
2003-02-24
579
네로
2003-02-24
504
네로
2003-02-24
488
네로
2003-02-24
474
네로
2003-02-24
596
네로
2003-02-24
614
네로
2003-02-24
479
네로
2003-02-24
636
네로
2003-02-24
507
네로
2003-02-24
462
네로
2003-02-24
1849
네로
2003-02-24
493
네로
2003-02-24
501
네로
2003-02-24
534
네로
2003-02-24
573
네로
2003-02-24
852
모이자 모바일