Login   Register  
PHP Classes
elePHPant
Icontem

File: hn_ShoutCast/hn_shoutcast.example1.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.example1.php  >  Download  
File: hn_ShoutCast/hn_shoutcast.example1.php
Role: Example script
Content type: text/plain
Description: example for use on commandline
Class: HN Shoutcast
Retrieve status information of a Shoutcast server
Author: By
Last change:
Date: 2005-01-05 15:47
Size: 3,334 bytes
 

Contents

Class file image Download
<?PHP
/*******************************************************************************
  * PHP-Script:
  *
  * Example 1 for hn_Shoutcast.class.php
  *
  * Commandline-Example   - but you may call in web-environment too, ;-)
  *
  * 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.example1.php,v 1.5 2005/01/05 23:44:21 horst Exp $
  *
  * Tabsize: 4
  *
  **/



    
require_once(dirname(__FILE__).'/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';



    // A Shoutcast-URL we want information about = http://server:port
    
$url 'http://165.132.105.182:8002';


    
// instantiate classinstance, with optional first boolean param to switch
    // on debugging
    
$sc =& new hn_shoutcast(TRUE);


    
// call method to query url and parse response
    
$sc->query_URL($url,$proxy);


    
// Now you have all Information available in an assoziative array: $sc-info
    // If the Server is online, $sc->online is TRUE, otherwise it is FALSE



// To do more testing, comment out the next line! =:)
exit(0);



    
// You also can use it for batch-execution:
    
$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 of classextension without debugging
    
$sc =& new hn_ShoutcastInfo();

    
// This should be example for commandline, but who knows if you care, ;-)
    
if(isset($_SERVER['HTTP_HOST']))
    {
        @
ini_set('max_execution_time',"240");
        
//@ini_set('output_buffering',"0");
        
@ini_set('implicit_flush',"1");
        echo 
'<pre>';
    }
    
$i 0;
    foreach(
$urls as $url)
    {
        echo 
"\n---".(++$i)."/".count($urls)."-----------------------";
        echo 
"\nQuery: $url";
        
$sc->query_URL($url,$proxy);
        if(
$sc->online)
        {
            echo 
"\nResult: ONLINE!";
            echo 
"\n - Station: ".$sc->station();
            echo 
"\n - Current Song: ".$sc->song();
            if(isset(
$_SERVER['HTTP_HOST'])) echo "\n - Want listen to this station? <a href=\"{$url}/listen.pls\">YES</a>";
        }
        else
        {
            echo 
"\nResult: is offline";
        }
        echo 
"\n------------------------------\n";
        
flush();
    }
    if(isset(
$_SERVER['HTTP_HOST'])) echo '</pre>';


?>