Login   Register  
PHP Classes
elePHPant
Icontem

File: hn_ShoutCast/hn_shoutcast.example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Horst Nogajski  >  HN Shoutcast  >  hn_ShoutCast/hn_shoutcast.example2.php  >  Download  
File: hn_ShoutCast/hn_shoutcast.example2.php
Role: Example script
Content type: text/plain
Description: example for use in web-environment
Class: HN Shoutcast
Retrieve status information of a Shoutcast server
Author: By
Last change:
Date: 2005-01-05 15:48
Size: 3,526 bytes
 

Contents

Class file image Download
<?PHP
/*******************************************************************************
  * PHP-Script:
  *
  * Example 2 for hn_Shoutcast.class.php
  *
  * Website-Example (really, don't use at commandline)
  *
  * For latest version of classfile go to:
  * - http://hn273.users.phpclasses.org/browse/author/45770.html
  * and select the desired classpage, or go directly to:
  * - http://hn273.users.phpclasses.org/browse/package/2049.html
  *
  ******************************************************************************
  *
  * @Author:    Horst Nogajski <horst@nogajski.de>
  * @Copyright: (c) 1999 - 2005
  * @Licence:   GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
  * @Version:   1.0
  *
  * $Id: hn_shoutcast.example2.php,v 1.4 2005/01/05 23:44:23 horst Exp $
  *
  * Tabsize: 4
  *
  **/


    
require_once('hn_shoutcastinfo.class.php');

    
$proxy NULL;
    
// If you want use or must use a HTTP-Proxy, please specify all needed
    // credentials in plaintext like one of the following examples:
    //
    // $proxy = 'http://username:password@servername_OR_ip:port';
    // $proxy = 'http://servername_OR_ip:port';
    //
    // and pass it as second argument to the method query_URL !
    //$proxy = 'http://name:pass@server:port';



    // Shoutcast-URLs we want information about = http://server:port
    
$urls = array(
                    
'http://208.53.131.220:8006',
                    
'http://165.132.105.182:8002',
                    
'http://208.53.131.220:8006',
                    
'http://213.203.207.194:8050',
                    
'http://64.236.34.97:80',
                    
'http://66.240.193.254:9000',
                    
'http://64.236.34.97:80',
                    
'http://64.202.98.51:6390',
                    
'http://207.150.170.30:9100',
                    
'http://216.117.139.179:8000',
                    
'http://82.182.81.202:9000',
                    
'http://216.240.152.157:8668'
            
);


    
// instantiate classinstance, without debugging
    // We use the class extension: hn_ShoutcastInfo
    
$sc =& new hn_ShoutcastInfo();



$html_head = <<< heredoc_htmlhead
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Shoutcast-Server-Infos</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<H3>Shoutcast-Server-Infos with PHP-Class hn_ShoutcastInfo</H3>
<HR>
<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=1>
  <TR>
    <TD colspan=4>SERVER</TD>
    <TD>ONLINE</TD>
    <TD>BANDWIDTH</TD>
  </TR>
  <TR>
    <TD>STATION</TD>
    <TD>URL</TD>
    <TD>GENRE</TD>
    <TD>CURRENT SONG</TD>
    <TD>LISTENERS</TD>
    <TD>MAX LISTENERS</TD>
  </TR>
heredoc_htmlhead;

$html_foot = <<< heredoc_htmlfoot
</TABLE>
</BODY>
</HTML>
heredoc_htmlfoot;


    echo 
$html_head;
    
flush();

    foreach(
$urls as $url)
    {
        if(isset(
$_SERVER['HTTP_HOST']))
        {
            @
ini_set('max_execution_time',"240");
            @
ini_set('implicit_flush',"1");
        }
        
// call method to query url and parse response
        
$sc->query_URL($url,$proxy);
        echo 
"  <TR>\n";
        echo 
"    <TD colspan=4>Server: $url - &nbsp;&nbsp;<a href=\"{$url}/listen.pls\">stream</a></TD>\n";
        echo 
"    <TD>".($sc->is_online() ? "YES" "NO")."</TD>\n";
        echo 
"    <TD>".$sc->bandwidth()."</TD>\n";
        echo 
"  </TR>\n";
        echo 
"  <TR>\n";
        echo 
"    <TD>".$sc->station()."</TD>\n";
        echo 
"    <TD>".$sc->url()."</TD>\n";
        echo 
"    <TD>".$sc->genre()."</TD>\n";
        echo 
"    <TD>".$sc->song()."</TD>\n";
        echo 
"    <TD>".$sc->listeners()."</TD>\n";
        echo 
"    <TD>".$sc->maxlisteners()."</TD>\n";
        echo 
"  </TR>\n";
        
flush();
    }

    echo 
$html_foot;

?>