웹마스터 팁

멀티서버의 주소를 첫번째 주소에 정보만 수집하는 버그가 발견되었습니다

어떤 분의 문의로 바뀌기 되었습니다 ^^;;

- 현재 시간 9월 12일 오전 8:01분 약간의 기능을 추가 수정합니다 -

  기능추가한것은 방송주소를 전달하지 않으면 무한루프를 도는현상...
  방송주소를 전달하지 않을경우 에러메세지 출력
  
  에러메세지 내용 - set_ip() 메서드 에러-방송주소를 써주세요

winamp 방송정보 클레스 정의 문서(cast_info.php)

<?

class winamp_cast_info {
#-----------------------------    

       var $ip;
       var $pls_file_name;
       var $port;
       var $use_server;
       var $server_type;
       var $m_server_ip_list = array();
       var $s_server_ip;
       var $info = array();
       var $onAir = 0;
      
       var $tmp_hms = array();
      
          
                
        # 서버가 죽었는가 않죽었는가
         function server_on(){
            
             if($this->port){
             $data = $this->Read_Data($this->ip,$this->port,$this->pls_file_name);
             }else{
               $data = $this->Read_Data($this->ip,80,$this->pls_file_name);
            
             }
                if(eregi("http://(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}):(([0-9]){1,})",  $data)){
                
                       $this->onAir = 1;
                }else{
                  
                      $this->onAir = 0;
                }

                

                //echo "$data";
         }
        

       #
        function set_ip($ip){
          
           if(!$ip){ echo "set_ip() 메서드 에러-방송주소를 써주세요"; exit;}

          # 아이피 필터
          $this->ip_filter($ip);
          
          # 어떤 회사서버 사용?
          $this->what_use_server();
          
          # 서버가 죽었나 살았나
          $this->server_on();

              if($this->onAir){
                  # 멀티서버인가?
                 $this->what_server_type();  
                  $this->cast_info();  

               }

                  
            
              
            

         }


        ##########################
        # 아이피필터  #
        ##########################
        function ip_filter($ip){

           $ip = str_replace("http://", "", $ip);
          
           # ip주소와 pls화일 이름 분리
           $ip_explode = explode("/",$ip);
           $this->pls_file_name = $ip_explode[1];

           # ip주소에서 ip 와 port 분리
           $ip_explode1 = explode(":",$ip_explode[0]);
          
           $this->ip = $ip_explode1[0];
           $this->port = $ip_explode1[1];

       }
      
       ##########################
       # 진짜 멀티서버인가 검사             #
       ##########################
        function real_m_server(){

            $r_data = $this->Read_Data($this->ip,80,$this->pls_file_name);
          
            $data_array = spliti( "file[0-9]{1,2}", $r_data);

            for($i=0;$i <= sizeof($data_array);$i++){

                if(eregi("http://(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}).(([a-zA-Z0-9]){1,}):(([0-9]){1,})", $data_array[$i],$aa)){

                 if($tmp  != $data_array[$i]){ $this->m_server_ip_list[] = $aa[0]; }
                   $tmp = $data_array[$i];
                 }

              }
              
               if(sizeof($this->m_server_ip_list) > 1){
                   $end = m;
               }else{
                   $end = s;
                   $this->s_server_ip = $this->m_server_ip_list[0];
                  
               }

           return $end;

        }


       ##########################
       # 서버 타입은 멀티냐 싱글이냐     #
       ##########################
       function what_server_type(){

            if($this->port){

               $this->server_type = "s";
               $this->s_server_ip = "http://" . $this->ip . ":". $this->port;

            }else if(!$this->port){
                
               $this->server_type = $this->real_m_server();
            
            }

       }

      
       ##########################
       # 어떤 회사의 서버를 사용하는가  #
       ##########################
       function what_use_server(){

           # 인라이브 서버
           if(eregi(".inlive.co.kr", $this->ip)){

             $this->use_server = "inLive";
          
          # 세이케스트 서버      
          }else if(eregi(".saycast.com",$this->ip)){
          
             $this->use_server = "sayCast";

           # 세이케스트 서버      
          }else if(eregi(".diodeo.com",$this->ip)){
                
             $this->use_server = "Diodeo";
          
          # 일반 서버
          }else{

             $this->use_server = "normal";
          
          }

       }

        
        #####################
        # 데이타 읽어오기 메소드   #
        #####################
        function Read_Data($ip,$port,$file_name){
                
                $fp = @fsockopen($ip, $port, $errno, $errstr);
                
                if($fp){
                  
                   if($file_name == "index.html"){
                    fputs ($fp, "GET /index.html HTTP/1.0nUser-Agent: Mozilla/4.0nn");
                   }else if($file_name == "played.html"){

                    fputs ($fp, "GET /played.html HTTP/1.0nUser-Agent: Mozilla/4.0nn");

                   }else {
                  
                   $out = "GET /${file_name} HTTP/1.1rn";
                   $out .= "Host: $iprn";
                   $out .= "Connection: Closernrn";
                   fputs($fp, $out);
                  
                   }
                  
                  
                  
                   while(!feof($fp)){  $data .= fgets($fp,1024);}                                
                  
                   fclose($fp);
                  
                }else{
                  
                     $data = 0;
                
                }
                
              
              
               return $data;

       }

        #####################
        # 방송정보 설정 메소드      #
        #####################
        function  set_cast_info($info_data){

             $info_data = strip_tags ("$info_data");

                  if(eregi("with (([0-9]){1,}) of (([0-9]){1,}) listeners", $info_data,$arr)){
                  
                   if($this->server_type == "m"){
                  # 청취자수
                 $this->info[now_listen] +=  $arr[1];
                  # 최대 청취자수
                  $this->info[max_listen_persons] +=  $arr[3];
                  
                                  

                                   }else if($this->server_type == "s"){
                  # 청취자수
                  $this->info[now_listen] =  $arr[1];
                  # 최대 청취자수
                 $this->info[max_listen_persons] =  $arr[3];
                   }
                  
                  }  
                  if(eregi("(([1-9]){2,3}) kbps",$info_data,$arr)){ $this->info[kbps] =  $arr[1]; }
                  
                      $one = explode ("Listener Peak:", $info_data);
                      $two = explode ("Average Listen Time:",$one[1]);
                        if($this->server_type == "m"){
                      $this->info[peak] += $two[0];
                       }else if($this->server_type == "s"){
                         $this->info[peak] = $two[0];
                       }
                      $data = $two[1];

                     # --------------------

                      $val = array("a_l_time","title","genre","url","aim","irc");

                      $explode_word = array("Stream Title:","Stream Genre:","Stream URL:","Stream AIM:","Stream IRC:","Current Song:");

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

                          $one = explode ($explode_word[$i], $data);
                        
                          $this->info[$val[$i]] = $one[0];
                          
                          $data = $one[1];

                      }
                   # --------------------
                      
                    

                    $this->info[song] = $data;

                    $this->info[title] = $this->str_re(title,$this->info[title]);
                    $this->info[song] = $this->str_re(song,$this->info[song]);
                   $this->info[aim] = urldecode($this->info[aim]);
                   $this->tmp_hms[]  = $this->info[a_l_time];

                  if($this->server_type == "m"){
                    
                    $this->time_array_exe();

                 }

       }

        #####################
        # 방송정보 가져오기 시작   #
        #####################
        function cast_info(){

             if($this->server_type == "s"){
                
                      
                  $ip = str_replace("http://", "", $this->s_server_ip);
          
                  # ip주소에서 ip 와 port 분리
                  $ip_explode = explode(":",$ip);
          
                  $ip = $ip_explode[0];
                  $port = $ip_explode[1];

                  $info_data = $this->Read_Data($ip,$port,"index.html");

                  # 방송정보 설정
                  $this->set_cast_info($info_data);

                

             }else if($this->server_type == "m"){

                  for($i=0;$i < sizeof($this->m_server_ip_list);$i++){

                  $ip = str_replace("http://", "", $this->m_server_ip_list[$i]);

                  # ip주소에서 ip 와 port 분리
                  $ip_explode = explode(":",$ip);
          
                  $ip = $ip_explode[0];
                  $port = $ip_explode[1];
                  
                  

                  $info_data = $this->Read_Data($ip,$port,"index.html");

                       # 방송정보 설정
                       $this->set_cast_info($info_data);
                    
                    

                  }

             }
        
             //return $info_data;
        }

function get_history(){
      
        if($this->server_type == "m"){
        
             //$m_server_ip_list[0];
  
             //$this->m_server_ip_list[0];
            
             $this->ip_filter($this->m_server_ip_list[0]);

            $info_data = $this->Read_Data($this->ip,$this->port,"played.html");

        }else if($this->server_type == "s"){

            $this->ip_filter($this->s_server_ip);

            $info_data = $this->Read_Data($this->ip,$this->port,"played.html");
        
        }
        
          $info_data = eregi_replace ("Copyright Nullsoft Inc. 1998-200([0-9]){1}", "", $info_data);
        
         $info_data = strip_tags ("$info_data",'<td>'+ ');
          
            $haha = explode ("<td>", $info_data);
          
              for($i=0;$i <= sizeof($haha);$i++){
                  
                  #$haha 배열변수의 $i번째에 속한것이 시간이면  배열변수  $time에 넣는다
                  if(eregi("(([0-9]){2}):(([0-9]){2}):(([0-9]){2})", $haha[$i])){
                     $time[] = strip_tags ($haha[$i]);
                  }else{
                     $tmp[] = $haha[$i];
                  }
              
              }
              
             for($i=0;$i <= sizeof($tmp)-1;$i++){
                      
                      # $tmp배열에 $i 번째에 속한 내용이 타이틀을 경우 배열변수 $history_title에 넣는다
                      if(!$this->history_title_ck($tmp[$i])){ $history_title[] = strip_tags ($tmp[$i]); }

              }

          # 이차원 배열로 시간과 타이틀을 묶어버린다
           $history  = array("time" => $time, "title" => $history_title);  
        
           return $history;
        //echo "$info_data";
        
}

# 방송히스토리 타이틀인가 아닌가를 구분
function history_title_ck($title){


            if(eregi("HTTP/1.0 200 OK",$title) or eregi("Server Version",$title) or eregi("Played @",$title)
                or eregi("Song Title",$title) or eregi("Current Song",$title) or eregi("Written by Stephen 'Tag Loomis",$title) or eregi("Copyright Nullsoft Inc. 1998-200([0-9]){1}",$title)){ $v = 1; }else{ $v = 0; }

    

  
    return $v;

}



# 특정문자 없애기
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);
                      
                       $end = eregi_replace ("Copyright Nullsoft Inc. 1998-200([0-9]){1}", "", $end);


                      //$end = str_replace("Copyright Nullsoft Inc. 1998-2000","",$end);
                     //$end = str_replace("Copyright Nullsoft Inc. 1998-2002","", $end);
                      //$end = str_replace("Copyright Nullsoft Inc. 1998-2004","", $end);


                 }

    
       return $end;
    
}

# 멀티 서버의 평균청취시간을 구하는 메소드
function time_array_exe(){

     # ---- 루프문 ----
     for($i=0;$i < sizeof($this->tmp_hms);$i++){
            
            ### 시간
            if(eregi("([0-9]{1,2})h",$this->tmp_hms[$i],$tmp_array)){
                $h += $tmp_array[1];      
            }else{
               $h += 0;
            }
           ### 분
            if(eregi("([0-9]{1,2})m",$this->tmp_hms[$i],$tmp_array)){
                $m += $tmp_array[1];      
            }else{
               $m += 0;
            }
            ### 초
            if(eregi("([0-9]{1,2})s",$this->tmp_hms[$i],$tmp_array)){
                $s += $tmp_array[1];      
            }else{
               $s += 0;
            }

            
            
            if($s >= 60){
               $m +=1;
               $s = $s - 60;
  
                  if($s == 60){
                     $m +=1;
                     $s = 0;
                   }
             }

           if($m >= 60){
              $h +=1;
              $m = $m - 60;
  
                 if($m == 60){
                    $h +=1;
                    $m = 0;
                 }
            }


     }
    # ---- 루프문 ----
    
    $this->info[a_l_time]  = "${h}h ${m}m ${s}s";

}

#-----------------------------
}



?>



winamp 방송정보를 확인하는 문서(cast_view_info.php)


<?

include("cast_info.php");

$winamp = new winamp_cast_info;


# 테스트 할때 ip주소에서 주석문만 빼주세요

// 마이케스트 주소
//$ip = "http://mycast2003.inlive.co.kr/listen.pls";

// 뮤클케스트 주소
//$ip = "http://www.mukulcast.com/listen.pls";

// 세이개인 방송주소는 http://www.saycast.com/CJ아이디.pls 입니다
//$ip = "http://www.saycast.com/tkfkd144000.pls";
//$ip = "http://www.saycast.com/zylove3478.pls";

// 세이케스트에속한 미인방송국 주소
$ip = "http://miin.jukeonfm.com/listen.pls";

// 디어데오 서버를 사용하는 티나방송국
//$ip = "http://TINA24.diodeo.com/listen.pls";



$winamp->set_ip($ip);




# 방송중인지 아닌지 알려주는
# 변수 $winamp->onAir (1(참): On-Air,0(거짓): Off-air)
if($winamp->onAir){


# 방송주소 - $winamp->ip;
# pls화일이름 - $winamp->pls_file_name;
# 사용서버(inLive,sayCast,Diodeo) - $winamp->use_server;
# 서버타입(멀티(m) or 싱글(s)) - $winamp->server_type;

# 서버정보 $winamp->info[원하는값];
# kbps - 방송음질
# title - 방송제목
# song - 현재음악
# genre - 장르
# url - URL
# aim - aim값 (보통이값은 인라이브에서 CJ이름으로 쓰임)
# irc - irc 채팅채널 이름
# a_l_time - 방송청취평균시간
# now_listen - 현재청취자수
# max_listen_persons - 최고청취가능인원
# peak - 최대로 청취한 인원
# 예) $winamp->info[kbps];

# 주의

echo $winamp->ip;

echo "<br>";
echo "서버타입:" . $winamp->server_type;
echo "<br>";

echo "방송제목:" . $winamp->info[title];
echo "<br>";
echo  "나오는곡:" . $winamp->info[song];

echo "<br>";


                  echo   "청취자수:" . $winamp->info[now_listen];
echo "<br>";
                  # 최대 청취자수
                  echo   "최대청취가능수:" . $winamp->info[max_listen_persons];

echo "<br>";


                  echo   "최고청취률:". $winamp->info[peak];

echo "<br>";
                

# 서버가 멀티 서버일경우 ip주소는
# $winamp->m_server_ip_list 라는 배열 변수에 넣어진다
# 싱글서버일 경우 ip주소는 $winamp->s_server_ip

if($winamp->server_type == "m"){

       for($i=0; $i < sizeof($winamp->m_server_ip_list);$i++){
            
                        echo $winamp->m_server_ip_list[$i];
                        
            echo "<br>";
          }

}else if($winamp->server_type == "s"){
      
      echo $winamp->s_server_ip;
      echo "<br>";

}

## 방송히스토리
#$history = $winamp->get_history();

## 배열변수로 전달됩니다

  #$title = $history["title"];
  #$time = $history["time"];  
  
#for($i=0;$i < sizeof($title)-1;$i++){

#echo "$i $title[$i] ";
#echo "$time[$i]";
#echo "<br>";
#}


}else{

echo "방송중이지 않습니다";

}





?>
제목 글쓴이 날짜
신촌오피 신촌OP ⦑오피.CLUB⦒ 신촌휴게텔 신촌오피 신촌오피 koykoyah 2025.02.22
세종오피 ⦑출장마사지안내.COM⦒ 세종마사지 세종오피 세종오피 세종OP koykoyah 2025.02.22
서초오피 서초출장안마 ⦑오피.CLUB⦒ 서초OP 서초오피 서초오피 koykoyah 2025.02.22
제주오피 제주출장안마 ⦑오피쓰.COM⦒ 제주OP 제주오피 제주오피 koykoyah 2025.02.22
가락오피 가락OP ⦑출장안마사이트.COM⦒ 가락휴게텔 가락오피 가락오피 koykoyah 2025.02.22
구미오피 구미OP ⦑출장마사지안내.COM⦒ 구미휴게텔 구미오피 구미오피 koykoyah 2025.02.22
영등포오피 ⦑오피.CLUB⦒ 영등포오피 영등포출장마사지 영등포오피 영등포OP koykoyah 2025.02.22
대구오피 ⦑오피쓰주소.COM⦒ 대구오피 대구OP 대구건마 대구오피 koykoyah 2025.02.22
수원오피 수원출장안마 ⦑오피.CLUB⦒ 수원OP 수원오피 수원오피 koykoyah 2025.02.22
강동오피 ⦑오피쓰.COM⦒ 강동OP 강동오피 강동출장샵 강동오피 koykoyah 2025.02.22
익산오피 익산오피 ⦑출장마사지안내.COM⦒ 익산OP 익산스파 익산오피 koykoyah 2025.02.22
광주오피 ⦑오피.CLUB⦒ 광주마사지 광주오피 광주오피 광주OP koykoyah 2025.02.22
신촌오피 ⦑오피쓰주소.COM⦒ 신촌OP 신촌오피 신촌출장샵 신촌오피 koykoyah 2025.02.22
평택오피 ⦑오피사이트.NET⦒ 평택오피 평택출장마사지 평택오피 평택OP koykoyah 2025.02.22
천안오피 ⦑출장안마사이트.COM⦒ 천안마사지 천안오피 천안오피 천안OP koykoyah 2025.02.22
신천오피 ⦑오피쓰주소.COM⦒ 신천오피 신천출장마사지 신천오피 신천OP koykoyah 2025.02.22
영등포오피 영등포오피 ⦑오피사이트.NET⦒ 영등포OP 영등포스파 영등포오피 koykoyah 2025.02.22
판교오피 판교OP ⦑오피.CLUB⦒ 판교휴게텔 판교오피 판교오피 koykoyah 2025.02.22
압구정오피 ⦑출장안마사이트.COM⦒ 압구정오피 압구정OP 압구정건마 압구정오피 koykoyah 2025.02.22
부산오피 ⦑오피사이트.NET⦒ 부산OP 부산오피 부산출장샵 부산오피 koykoyah 2025.02.22