PDA

View Full Version : Can someone tell me if these codes are right



Mr Me
09-01-2007, 08:24 PM
For some reason my radio stats dont seem to be working properly could someone tell me if they are right so i know im doing something wrong

Thank You

radio_stats.php



<?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;Radio:</b>&nbsp;'.$servertitle.'</font></p>
<font face="arial" size="2"><b>&nbsp;Listeners:</b>&nbsp;'.$currentlisteners.' / 1000</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="">
Radio Offline!
</body>
</html>';
}
?>


config_radio.php



<?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 = "Habbo-Charm"; // Default station name to display when server or stream is down
$scip = "Shoutcastservers.info"; // ip or url of shoutcast server (DO NOT ADD HTTP:// don't include the port)
$scport = "8116"; // port of shoutcast server
$scpass = "I Know Pass Goes Here Im Just Not Gunna Tell Anyone Now Am I"; // password to shoutcast server
//End configuration
?>


Thank You and yes i do know the password goes there it there on the one of my Cpanel i just dont want no1 contecting

Moh
09-01-2007, 09:04 PM
whats the problem

Mr Me
09-01-2007, 09:18 PM
whats the problem

They wont show up on my site which is here (http://www.habbocharm.co.uk)

beer
09-01-2007, 09:22 PM
Seem to be right. Is your host fsock enabled? If not, then ur stats wont work. I can host them 4 u if u want. Just PM me ur pass ill put em on my old site. All im using it 4 now is hosting stuff. (i promise i wont connect i got my own site to dj on neway and i hardly eva dj). Btw shoutcastservers.info rawk. Its what I use.

Mr Me
09-01-2007, 10:14 PM
Seem to be right. Is your host fsock enabled? If not, then ur stats wont work. I can host them 4 u if u want. Just PM me ur pass ill put em on my old site. All im using it 4 now is hosting stuff. (i promise i wont connect i got my own site to dj on neway and i hardly eva dj). Btw shoutcastservers.info rawk. Its what I use.

They where working before i put this layout up and im using the same code :s

Invent
10-01-2007, 01:21 PM
Im probs wrong but Lolly, fsock isnt something you "enable". Im sure its just a PHP Function?..

Mr Me
11-01-2007, 06:38 PM
ITs all confusing lol :s

Replicada
11-01-2007, 06:52 PM
config_radio.php

<?php
//////////////////////////////////////////////////////////////////////////////////////////////
// Stats Information
// Grabs the xml from your radio server and displays it in a iframe that refreshes every 30 seconds.
//////////////////////////////////////////////////////////////////////////////////////////////
//Configuration
$scdef = "Habbo Shack Radio"; // Default station name to display when server or stream is down
$scip = "Nor this.. But i do sell reseller shoutcast."; // ip or url of shoutcast server
$scport = "8002"; // port of shoutcast server
$scpass = "Same Im not entering mine ^.^"; // password to shoutcast server
//End configuration

?>

And another file you'll need.

radio_stats.php


<html>

<head>
<TEXT="ffffff">
<body bgcolor="ffffff">
<font color="ffffff"><?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// Coded by Daniel Brown. Edited by Nick Coates [SharpeHosting.com] [SharpeNews] KEEP THIS INTACT!!!
// 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, 10);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.'Radio Is Currently 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">
<link rel=stylesheet href="" type="text/css">
<title>'.$scdef.'</title>
</head>
<body text="ffffff" bgcolor="ffffff">

<font color="black"><font face="verdana" size="1"><b>DJ:</b>&nbsp;'.$servertitle.'</font><br>
<font color="black"><font face="verdana" size="1"><b>Listeners:</b>&nbsp;'.$currentlisteners.' / 500</font><br>
<font face="verdana" size="1" color="black"><b>Current Song:</b>&nbsp;'.$song[0].'</font><br>
</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="10;URL=radio_stats.php">
<link rel=stylesheet href="" type="text/css">
<title>Radio Is Curently Offline</title>
</head>

<body text="ffffff" bgcolor=""><STYLE type=text/css>
UNKNOWN {
FONT-SIZE: 10px; COLOR: #black; FONT-FAMILY: verdana
}
BODY {
BACKGROUND-COLOR: ffffff
}
A:link {
COLOR: ; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #000000; TEXT-DECORATION: underline
}
A:active {
TEXT-DECORATION: none
}
BODY {
FONT-SIZE: 10px; COLOR: ffffff; FONT-FAMILY: verdana
}
TD {
FONT-SIZE: 10px; COLOR: ffffff; FONT-FAMILY: verdana
}
TH {
FONT-SIZE: 10px; COLOR: ffffff; FONT-FAMILY: verdana
}
.style5 {font-size: 50px}
</STYLE>
<div><center><BR><BR><img src="images/offline.jpg"></img><BR>
<BR><b>Radio is Currently</b><BR>
<b>Offline</b>
</center></div>
</body>

</html>';
}
?></font>
</body>


Use these on my fansite. so i know they work..

Rep please ^.^

Heinous
11-01-2007, 10:03 PM
Im probs wrong but Lolly, fsock isnt something you "enable". Im sure its just a PHP Function?..
You are wrong. Some hosts disable fsockopen, like many other functions.

Invent
12-01-2007, 12:12 AM
Ahh okay thanks. I got confused with him saying he has used the code before and it worked fine.

Mr Me
14-01-2007, 07:27 PM
Okay rep given Thx you all

beer
15-01-2007, 02:51 PM
Invent just want to say remove the last line from ur sig or ill report. Thanks.

Invent
15-01-2007, 07:45 PM
Dude, this is a forum. Do you really think i care if you report me?

ScottDiamond
15-01-2007, 07:51 PM
Laughing my *Text Removed* off.

Edited by Mattps22004 (Forum Moderator): Please don't avoid the filter.

Invent
15-01-2007, 08:04 PM
About..........

Mr Me
15-01-2007, 08:13 PM
Please dont use this thread to argue on !

ScottDiamond
15-01-2007, 09:41 PM
Dude, this is a forum. Do you really think i care if you report me?

At that. And Mattps, warn me all you like - I don't care to be truthfully honest.

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