PDA

View Full Version : [PHP] Making Radio Stats Tutoial (Thanks Danny (Luckyrare))



:Blob
05-06-2005, 04:08 PM
Making Radio Stats Tutoial. Ideas from Danny (Luckyrare), thanks

First make a file called config_radio.php

Then edit it to make it include:
<?php
//////////////////////////////////////////////////////////////////////////////////////////////
// Dinghy Radio Stats Information
// Grabs the xml from your radio server and displays it in a iframe that refreshes every 30 seconds.
// ©Daniel Brown www.gmtt.co.uk
//////////////////////////////////////////////////////////////////////////////////////////////
//Configuration
$scdef = "NAME RADIO HERE"; // Default station name to display when server or stream is down
$scip = "IP HERE"; // ip or url of shoutcast server (DO NOT ADD HTTP:// don't include the port)
$scport = "PORT HERE"; // port of shoutcast server
$scpass = "PASS HERE"; // password to shoutcast server
//End configuration

?>

Then click save

After that, make a page called radio_stats.php

This page should include:
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ©2004-2005 Daniel Brown http://www.gmtt.co.uk
// Please refer to the readme file for use.
include('config_radio.php'); //you may edit this path to fit your server environment otherwise leave it alone
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' is Offline';
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
################################################## ################################################## ##################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);

// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements
################################################## ################################################## ##################
################################################## ################################################## ##################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info

fclose($scfp);
}

//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo'
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="REFRESH" CONTENT="30;URL=radio_stats.php">
<link rel=stylesheet href="" type="text/css">
<title>'.$scdef.'</title>
</head>

<body text="verdana" bgcolor="#FFFFFF">




<p align="center"><center>

<font face="arial" size="2"><b>&nbsp;Server Name:</b>&nbsp;'.$servertitle.'</font></p>
<font face="arial" size="2"><b>&nbsp;Listeners:</b>&nbsp;'.$currentlisteners.' / 20</font></p>

<font face="verdana" size="2" color=""><b>

Current Song:</b> '.$song[0].'</font></p>
<b>


<font face="arial" size="2">
Past Songs:</font></b>
<font color=""><font face="verdana" size="2">
<p align="center">
<b>1.</b> '.$song[1].'<BR>
<b>2.</b> '.$song[2].'<BR>
<b>3.</b> '.$song[3].'<BR>
</font>
<BR>
</p></p>
</body>

</html>';
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
echo'
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="REFRESH" CONTENT="30;URL=radio_stats.php">
<link rel=stylesheet href="" type="text/css">
<title>Radio Server Is Offline</title>
</head>

<body text="" bgcolor="">
Server Offline!
</body>

</html>';
}
?>

You may edit were it tell you to

If you like it, please rep Luckyrare™

Hope it helps

Dunko

[Edited By Partie2] (Forum Moderator) Stickered by partie2, great Job :)

iRoss
05-06-2005, 04:20 PM
You didn't do that bit where if the radio is offline it displays a message like...

" The Radio Is Currently Offline- Please try later! "

:)

:Blob
05-06-2005, 04:21 PM
You didn't do that bit where if the radio is offline it displays a message like...

" The Radio Is Currently Offline- Please try later! "

:)

Did :P


<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="REFRESH" CONTENT="30;URL=radio_stats.php">
<link rel=stylesheet href="" type="text/css">
<title>Radio Server Is Offline</title>
</head>

iRoss
05-06-2005, 04:24 PM
Rofl.

I didn't look at it properly.

Well done :)

:Blob
05-06-2005, 04:26 PM
Thanks :D

I wish people replied to my domain tutorial (Take 2)

Luckyrare
07-06-2005, 06:18 PM
Well done :)

I will link this tutorial on my sticky :)

zainx
07-06-2005, 07:03 PM
u need to stop sticking tutorials and stuff it will be coverd in them soon, if people need help with installing they should just use the search button

:JaMhEd
07-06-2005, 07:05 PM
All the good tutorials are stikies because it saves people from looking all over the place, if they need to know NOW.

It's what any good forum would do :p

zainx
07-06-2005, 07:13 PM
but each page holds 35 threads, 15 of them are sticked and more people are still making tutorials

jamie5k
07-06-2005, 07:48 PM
I think we need to cut down on sticking threads as if u notice this forum is already overloded with them. Good tut.

dani342us
12-06-2005, 08:05 PM
But then how do I make it display on the site?I dont understand.

ED::
03-07-2005, 08:43 PM
your a legend helps me wel ldz

dani342us
05-07-2005, 03:26 PM
This dosent work for me plz HELP

:Blob
05-07-2005, 03:55 PM
This dosent work for me plz HELP

Does your host support PHP?

dani342us
08-07-2005, 03:20 AM
Yes,my host does support PHP

Tomm
10-07-2005, 05:22 PM
theres something called a manual - y do ppl keep making these tutorials

:Blob
10-07-2005, 05:29 PM
theres something called a manual - y do ppl keep making these tutorials

There aint a manual in a shoutcast server to make stats?

dani342us
11-07-2005, 01:51 AM
No,there isnt I have checked.Anyways IT DOSENT WORK FOR ME

:Blob
11-07-2005, 03:04 PM
PM me with ya stufff, ill set it up

dani342us
11-07-2005, 07:01 PM
I know were to add all the info of radio and stuff and i also make the 2ppages but then when i do the radio stats thing the second thing that shows the stats im like having trouble with that

:Blob
11-07-2005, 07:12 PM
Link of ya stats please

dani342us
11-07-2005, 08:12 PM
The link is http://farvista.net/members/filemanager/?action=view&file=radio_stats.php ... IT DOSENT WORK -crys-

:Blob
12-07-2005, 03:13 PM
The link is http://farvista.net/members/filemanager/?action=view&file=radio_stats.php ... IT DOSENT WORK -crys-


Dont make it at a PHP link, make it a file called radio_stats.php not a wierd link

Recomendz
17-07-2005, 03:46 PM
well done with this uve tryed hard i like it

dani342us
19-07-2005, 05:40 PM
it dosent work -crys- my host dosent let me make files

splintercell!
21-07-2005, 07:10 AM
whats ur host does it support php??

:Blob
21-07-2005, 03:47 PM
whats ur host does it support php??
Naa, hes freewebs, im hosting his stats now

Rob
28-07-2005, 10:36 AM
How do u edit how many listeners u can get upto?

:Blob
28-07-2005, 01:15 PM
Scan through radio_stats.php and find the word 20, rename that to how many listeners

Rob
28-07-2005, 02:22 PM
Ok thanks, and you mean the number 20 :P

:Blob
28-07-2005, 05:07 PM
Yes i do.

RoyalStar
18-09-2005, 03:48 PM
OK, I followed your tutorial, now how do i get it to be displayed on my radio page ? is there a tutorial ?

Bog
20-09-2005, 12:35 AM
Freaking hell, like a slap in the face. My stats were broke, came on habbox and theres a tut :D

DJ-Bahrami
24-09-2005, 07:56 AM
:d Nice Job +rep

:Blob
24-09-2005, 05:12 PM
:d Nice Job +rep

Thanks

DJ-Cookeh
01-10-2005, 09:41 AM
nice helped me well :D

dani342us
24-12-2005, 07:38 PM
im gaving problems, go to www.habpagefm.net/radio_stats.php i dont know what that means, how can i fix that.

Recursion
29-12-2005, 08:17 PM
I need a radio stats that DOESNT say FSOCK OPEN BLA BLA BLA when the server has been closed. Any1 no of 1????? :) thanks

Motobin
05-02-2006, 03:21 PM
Can You Have Radio Stats In Html Cuz I Dont Know How To use Php !

sock
25-03-2006, 01:57 PM
Thank you.

Tomm
26-03-2006, 08:03 AM
Can You Have Radio Stats In Html Cuz I Dont Know How To use Php !

No you can only have a PHP one... Unless you use ASP or Coldfusion or a Java server like tomcat..

TheUntoldTruth
29-04-2006, 03:03 PM
ok well ive come to the conclusion your radio status dnt work "/ can any1 provide a proper radio status

DJ-Cookeh
30-04-2006, 05:57 AM
it dont work

Jamie.
05-05-2006, 10:06 AM
they work just you havnt coded ptroperly or didnt put ure shoutcast details in =]

Recursion
10-05-2006, 07:01 PM
worked for me

Geo23
21-05-2006, 05:08 PM
where do we put the php code

Matt.
22-05-2006, 06:32 AM
where do we put the php code
http://www.habboxforum.com/showpost.php?p=396219&postcount=1
?:s

Matt.
22-05-2006, 02:43 PM
Sorry I didn't read it right:( any way you make new 2 new pages.

Want to hide these adverts? Register an account for free!