웹마스터 팁

몇몇 분들이 저에게 다중서버정보를 어떻게 알아내느냐는 메일을 보내셔서
이렇게 정보를 공유하겠습니다

방송정보 알아내기 구조체 화일 (winamp_cast_information.php) 내용

<?



class winamp_cast_information {

          var $now_listen;
                  var $max_listen_persons;
          var $cast_title;
                  var $cast_song;

     # 단일서버 정보 얻어 오기 메소드 시작
        function winamp_cast($cast_ip){

          $listen = $this->winamp_shoutcast_listen($cast_ip);            

               # 현재 청취자수 와 최대청취할수 있는 인원
               $this->now_listen += $listen[0];
                           $this->max_listen_persons +=  $listen[1];  
              
                           $cast_info = $this->winamp_shoutcast_info($cast_ip);

               $this->cast_title = $this->str_re("title",$cast_info[title]);
                           $this->cast_song =  $this->str_re("song",$cast_info[song]);

              

        }
      # 단일서버 정보 얻어 오기 메소드 시작  


     # 멀티방송 서버 정보 얻어 오기 메소드 시작
      function winamp_cast_array_list($array_cast_ip_list){

            for($i=0;$i < sizeof($array_cast_ip_list);$i++){  
                        
                          $server_ip =  $array_cast_ip_list[$i];
                                

               $listen = $this->winamp_shoutcast_listen($server_ip);            

               # 현재 청취자수 와 최대청취할수 있는 인원
               $this->now_listen += $listen[0];
                           $this->max_listen_persons +=  $listen[1];  
              
                           $cast_info = $this->winamp_shoutcast_info($server_ip);

               $this->cast_title = $this->str_re("title",$cast_info[title]);
                           $this->cast_song =  $this->str_re("song",$cast_info[song]);

                         }
          
           }
      # 멀티방송 서버 정보 얻어 오기 메소드 끝



     ### 방송정보를 알아내는 메소드 시작 - 방송제목(title), 현재곡(song) ###
     function winamp_shoutcast_info($server_ip){

                  $server_ip = str_replace("http://", "", $server_ip);
                  $server_ip = str_replace("/", "", $server_ip);  

                  $info = array();

                  # 방송주소을 (:)으로 주소(ip)와 포트(port)로 나눈다
                  $addre = explode(":","$server_ip");

                  $address = $addre[0];
                  $port = $addre[1];

                  $fp1 = fsockopen("$address", $port, $errno, $errstr);

                   #문단 1 시작
                  if(!$fp1){
                                          
                                          $info[ok] = 0;

                     #문단 1 끝
                                         #문단 2 시작
                     }else{

                      $info[ok] = 1;

                         # 소켓을 이용해서 서버에 html 형태로 테이타를 보내라고 명령한다
                     fputs ($fp1, "GET /index.html HTTP/1.0nUser-Agent: Mozilla/4.0nn");

                    # 소켓의 마지막(eof) 까지 데이타를 읽는다(1024바이트씩)
                    while(!feof($fp1)){
        
                            $end .= fgets($fp1,1024);

                              }                                

                   # 소켓을 닫는다
                   fclose($fp1);

                  $end = strip_tags ("$end");

                  if(eregi("(([1-9]){2,3}) kbps",$end,$arr)){
                  $info[kbps] =  $arr[1];
                   }
      

         # $end 부분에서 방송제목과 장르, 홈주소 그리고 지금나오는 음악제목를 얻는다  
            #array("URL:","Stream")
       #array("Genre:","Stream")

      $info_spl = array(array("Title:","Stream Genre:"),array("Song:","Copyright"));

      $val = array("title","song");


     for($i=0;$i<2;$i++){

          $one = explode ($info_spl[$i][0], $end);
          $two = explode($info_spl[$i][1],$one[1]);

          $info[$val[$i]] = $two[0];

          $end = $one[1];

      }

    
      #문단 2 끝
         }

# 결과 리턴
return $info;


}  
### 방송정보를 알아내는 메소드 끝 - 방송제목(title), 현재곡(song) ###

     # 청취자수 알아내는 메소드 시작
     function winamp_shoutcast_listen($server_ip){

          $listen = array();

          $server_ip = str_replace("http://", "", $server_ip);
          $server_ip = str_replace("/", "", $server_ip);  

          # 방송주소을 (:)으로 주소(ip)와 포트(port)로 나눈다
          $addre = explode(":","$server_ip");
  
          $address = $addre[0];
          $port = $addre[1];

          $fp1 = fsockopen("$address", $port, $errno, $errstr);

          #문단 1 시작
          if(!$fp1){
                          
                          # 청취자수
                  $listen[0] =  0;
                  
                                  # 최대 청취자수
                                  $listen[1] =  0;

          #문단 1 끝
                  #문단 2 시작
          }else{

                  # 소켓을 이용해서 서버에 html 형태로 테이타를 보내라고 명령한다
              fputs ($fp1, "GET /index.html HTTP/1.0nUser-Agent: Mozilla/4.0nn");

             # 소켓의 마지막(eof) 까지 데이타를 읽는다(1024바이트씩)
             while(!feof($fp1)){
        
                      $end .= fgets($fp1,1024);

                 }                                

            # 소켓을 닫는다
            fclose($fp1);

            $end = strip_tags ("$end");

           if(eregi("with (([0-9]){1,}) of (([0-9]){1,}) listeners",$end,$arr)){
                  
                                  # 청취자수
                  $listen[0] =  $arr[1];
                  
                                  # 최대 청취자수
                                  $listen[1] =  $arr[3];
                          
                           }  
  
         #문단 2 끝
         }

       # 결과 리턴
       return $listen;

   # 청취자수 알아내는 메소드 끝
   }
  
     function str_re($what,$value){
      
         if($what == "title"){

            $end = str_replace("Content Type: audio/mpeg","", $value);

         }else if($what == "song"){

                     $end = str_replace("Written by Stephen 'Tag Loomis, Tom Pepper and Justin Frankel","", $value);
                
                 }

    
       return $end;
    
}




}


?>

방송정보 알아내기 객체를 생성 정보를 알아내는 소스 (winamp_info.php) 내용

<?

# mysql_db 구조체를 만들어놓은 화일 읽어
include("winamp_cast_information.php");

# 새로운 객체($mysqldb)를 생성
$winamp = new winamp_cast_information;

# Mycast(My portrait of Youthful day) 방송국 방송 주소
$cast_ip = "http://218.145.30.154:11100";

$winamp->winamp_cast($cast_ip);

echo "청취자수 : ";
echo $winamp->now_listen;
echo "<br>";
echo "최대가능청취자수 : ";
echo $winamp->max_listen_persons;
echo "<br>";
echo "방송제목 : ";
echo $winamp->cast_title;
echo "<br>";
echo "현재나가는곡 : ";
echo $winamp->cast_song;
echo "<br><br>";


# 뮤클케스트 방송국 방송 주소들
$cast_ip_array = array();

$cast_ip_array[0] = "http://cast1.mukulcast.com:11000";
$cast_ip_array[1] = "http://cast2.mukulcast.com:11000";
$cast_ip_array[2] = "http://cast3.mukulcast.com:11000";

$winamp->winamp_cast_array_list($cast_ip_array);

echo "청취자수 : ";
echo $winamp->now_listen;
echo "<br>";
echo "최대가능청취자수 : ";
echo $winamp->max_listen_persons;
echo "<br>";
echo "방송제목 : ";
echo $winamp->cast_title;
echo "<br>";
echo "현재나가는곡 : ";
echo $winamp->cast_song;


?>

이상 끝!!

젊은날의 초상 My portrait of Youthful day  MyCast  웹디팀 MyWD연필(흑심품은연필)......
방송주소 - http://218.145.30.154:11100/
제목 글쓴이 날짜
검정 배경 홈페이지용 회원 정보 스킨 file LutZ 2010.08.03
문서 서식에 관한 정보 [4] YO-DA 2010.08.06
회원 정보 및 회원 리스트에 회원 성별 앞에 아이콘 넣기 [5] file 늘푸른이 2010.08.06
탈퇴한 회원이 재가입 못하게 막는 방법 & 탈퇴한 회원 정보 보전 방법 [9] sejin7940 2010.09.17
인코딩 정보 일본어, 중국어, 스페인어 [3] 탐그루 2002.03.16
날씨/운세/뉴스/달력/검색등 메인용 귀연 정보박스[미리보기] [12] 뽀因㉦ㅓо Ø Γ 2006.07.19
cron을 이용해 윈앰프 방송정보를 빠르게 분석. [9] Romeo 2002.01.15
[추천 팁] 폴더내의 파일중에서 특정정보만 뽑아오기. [2] M2Vis 2002.07.12
제로보드로 유료 사이트 만들기 (결제 정보 저장) [1] 한꼬마 2002.11.06
국내 IP정보를 조회하는 클래스 [7] 행복한고니 2003.01.04
객체를 이용한 winamp 방송정보 알아내는 소스 [4] 흑심품은연필 2003.04.07
PHP 확장 함수를 이용한 exif 정보 출력 [1] file NoSoRi 2003.04.30
[허접팁]윈엠프 리스트창에 방송정보 보여주기;;[수정] [5] file 『처니리♂』 2004.02.29
주식정보출력코드 [2] 김재경 2004.06.01
-긴급소스 수정본- winamp 방송정보 알아내기 file 이승원 2004.09.11
winamp 방송정보 읽어오기 심각한 문제해결 file 이승원 2005.05.04
winamp 방송정보 알아오기 (2005년 새로 코딩한 버전) [8] file 이승원 2005.05.06
Apache + PHP + Mysql확실한 연동 및 리눅스 재설치 정보 [2] file 최종우 2002.11.26
ie60이상버전의 개인정보기능으로 인한 서비스문제 [2] 날파리 2003.05.21
포트 스캐닝 감시 및 OS 정보 숨기기 [3] 좋은진호 2003.10.30