Old 15th October 2003, 14:15   #1
Blind-Summit
Junior Member
 
Join Date: Sep 2003
Location: High Wycombe, UK
Posts: 38
Send a message via ICQ to Blind-Summit Send a message via AIM to Blind-Summit Send a message via Yahoo to Blind-Summit
XML Data parsing

I have the following script, however the $song[x] does not seem to function?

the $currentlisteners and $maxlisteners varialbes are populated

What am I doing wrong?

Alex


PHP Code:
<?php
// This image you can call immediately from an html file in the image tag
// (i.e. <image src="black.php">)    easy huh?

    
Header("Content-type: image/png");

// Fill in your own server information here:    
    
$host "blind-summit.no-ip.com";
    
$port "8080";
    
$listenlink 'http://blind-summit.no-ip.com:8080/listen.pls';  
    
    
$fp fsockopen("$host"$port, &$errno, &$errstr30); //open 
connection
    
if(!$fp) {
        
$success=2;  //se-t if no connection
    
}
    if(
$success!=2){ //if connection
        
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter 
(Mozilla Compatible)\r\n\r\n"
); //get 7.html
        
while(!feof($fp)) {
            
$page .= fgets($fp1000);
        }
        
fclose($fp); //close connection
        
$page ereg_replace(".*<body>"""$page); //extract data
        
$page ereg_replace("</body>.*"","$page); //extract data
        
$numbers explode(",",$page); //extract data
        
$currentlisteners=$numbers[0]; //set variable
        
$connected=$numbers[1]; //set variable

        
if($connected==1//if DSP is connected
            
$wordconnected="yes"//set variable
        
else //if no DSP connection
            
$wordconnected="no"//set variable
        
$peaklisteners=$numbers[2]; //set variable
        
$maxlisteners=$numbers[3]; //set variable
        
$reportedlisteners=$numbers[4]; //set variable
    
}

// Image size can be changed here: (x, y)
    
$im ImageCreate(500,90);
    
// Background color in R(ed)G(reen)B(lue) below
    
$background_color ImageColorAllocate($im,255,255,255);
    
// text colors also in RGB
    
$text_color1 ImageColorAllocate($im,128,128,128);
    
$text_color2 ImageColorAllocate($im,128,128,128);
    
    if(
$success!=&& $connected==1){

// song information is splitted in artist - title: 
// This requires consistent artist & title format (no ' - ' in title/artist) // else you can use $numbers[6] as current song info below
        
$song=explode(" - ",$numbers[6]);
        
// strings can of course be replaced with your own bla
        
$string1"Now playing on Blind-Summit Radio";
        
$string2"Artist: $song[0]";
        
$string3"Track: $song[1]";
        
$string4"[$currentlisteners/$maxlisteners users]";
    }
    else {
        
$string1" Blind-Summit Radio is currently ";
        
$string2"  OFF THE AIR - Check back later ";
        
$string3"   Normal uptime 7am - 2am GMT   ";
        
$string4"  [url]http://www.blind-summit.co.uk[/url]  ";
    }
    
// positioning below
    
$px = (imagesx($im)-5*strlen($string1))/2;
    
ImageString($im,2,0,5,$string1,$text_color1);
//             (image,font (from 1 to 5),starting x position, y position,line 
of text,color)
    
$px = (imagesx($im)-5*strlen($string2))/2;
    
ImageString($im,2,0,20,$string2,$text_color2);
    
$px = (imagesx($im)-5*strlen($string3))/2;
    
ImageString($im,2,0,35,$string3,$text_color2);
    
$px = (imagesx($im)-5*strlen($string4))/2;
    
ImageString($im,2,0,50,$string4,$text_color1);
    
ImagePng($im);

    
ImageDestroy($im);
?>
Blind-Summit is offline   Reply With Quote
Old 15th October 2003, 16:00   #2
FesterHead
Alumni
 
FesterHead's Avatar
 
Join Date: Sep 2001
Location: Maui, Hawaii
Posts: 14,108
What is your Winamp/DSP combo input method?

FesterHead is offline   Reply With Quote
Old 15th October 2003, 17:45   #3
Blind-Summit
Junior Member
 
Join Date: Sep 2003
Location: High Wycombe, UK
Posts: 38
Send a message via ICQ to Blind-Summit Send a message via AIM to Blind-Summit Send a message via Yahoo to Blind-Summit
Winamp 2.91
SHOUTcast Source 1.8.2b
WWWinamp 2.5d

ADSL Modem 576/256
WinXp Pro SP1

As you see from the code, I pass my Ip to that NO-IP site, but I don't think this is the issue
Blind-Summit is offline   Reply With Quote
Old 15th October 2003, 17:55   #4
FesterHead
Alumni
 
FesterHead's Avatar
 
Join Date: Sep 2001
Location: Maui, Hawaii
Posts: 14,108
Quote:
What is your Winamp/DSP combo input method?
Winamp
-> SHOUTcast DSP
-> Input Tab
-> Input Configuration
-> Input Device

FesterHead is offline   Reply With Quote
Old 15th October 2003, 18:07   #5
Blind-Summit
Junior Member
 
Join Date: Sep 2003
Location: High Wycombe, UK
Posts: 38
Send a message via ICQ to Blind-Summit Send a message via AIM to Blind-Summit Send a message via Yahoo to Blind-Summit
Sorry,

MAIN:

Output 2 is active, others are "Not Connected"
Input leves both active


OUTPUT:

Output 2 selected
Status shows data sent OK
Connect At Startup checked
Make this server public is checked

Description: Blind-Summit
URL: http://www.blind-summit.co.uk
Genre: Metal & Rock
AIM: blindsumm
ICQ: 133221251
IRC: #Blind-Summit

Enable Title updates disabled. Does not work with it enabled either


ENCODER:

Encoder 2 set to 40kbps, 22.050kHz, Stereo


INPUT:

Winamp (reccomended)
Blind-Summit is offline   Reply With Quote
Old 15th October 2003, 18:10   #6
Blind-Summit
Junior Member
 
Join Date: Sep 2003
Location: High Wycombe, UK
Posts: 38
Send a message via ICQ to Blind-Summit Send a message via AIM to Blind-Summit Send a message via Yahoo to Blind-Summit
heh

sorted

I had enabled the titles but forgot to update my code.

How dumb do I feel


One last question tho,

can i include the php on a webpage, but not display the image. I then want to display the details into a table

ie <?php include "radioserver.php">

and then call the $song[0] into a <tr> </tr> set of tags for a table
Blind-Summit is offline   Reply With Quote
Old 15th October 2003, 18:12   #7
Blind-Summit
Junior Member
 
Join Date: Sep 2003
Location: High Wycombe, UK
Posts: 38
Send a message via ICQ to Blind-Summit Send a message via AIM to Blind-Summit Send a message via Yahoo to Blind-Summit
Last last question

what other things are passed to this php code?

what else can i display on my image? such a bitrate, server uptime, etc? or where can i look to find out?



And what is fart++ ?????


Thanks for your help tho, and bloody good site by the way, keep up the good work
Blind-Summit is offline   Reply With Quote
Old 15th October 2003, 20:20   #8
FesterHead
Alumni
 
FesterHead's Avatar
 
Join Date: Sep 2001
Location: Maui, Hawaii
Posts: 14,108
Q: can i include the php on a webpage, but not display the image.
A: You'll need to diable the image generation

You may find it easier to have two sets of code. One for the image and one for website display.

**************************

Q: what other things are passed to this php code?
A: Since you're using 7.html (from the DNAS readme)
Quote:
To snag a quick list of listener counts, server state, bitrate, and current
title, use the URL http://yourip:port/7.html
For other XML information, you'll need to gather the XML statistics from the admin interface (from the DNAS readme)
Quote:
XML Statistics:

The SHOUTcast DNAS provides an internal mechanism for providing statistics
to external applications via XML, which is useful for providing live
information on your DNAS embedded in other webpages via PHP, Perl, or
other methods which can implement XML. Accessing this data is a bit tricky,
so it's briefly explained here:

XML pages should be called via:

http://yourip:port/admin.cgi?pass=yourpass&mode=viewxml&page=0
http://yourip:port/admin.cgi?pass=yourpass&mode=viewxml&page=1
...

Where:
Page 0 is all DNAS data
Page 1 is only Main data
Page 2 is only Webdata Table
Page 3 is only Listener Table
Page 4 is only Songhistory Table

Your XML parser MUST send a User-Agent: HTTP header containing the
word "Mozilla" in order for the DNAS to recognize it as something
other than a listener.
**********************

Q: And what is fart++ ?????
A: I have gas

FesterHead is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump