Old 28th September 2006, 11:32   #1
5h4d0vv
Junior Member
 
Join Date: Sep 2006
Posts: 3
Hi, whos good with HTML??

Hi, i need Radio Stats in HTML, but.. ive been looking around.. and some sites have 10 last played songs, an i was wondering how u do this..

Kind Regards, Andrew
5h4d0vv is offline   Reply With Quote
Old 28th September 2006, 12:20   #2
tuckerm
Forum Emo
 
tuckerm's Avatar
 
Join Date: Mar 2005
Posts: 8,364
Have you tried viral sound's plugin? Download it and customize your image and then it'll show anything thats playing in your winamp, this is how i got by with my old station.
tuckerm is offline   Reply With Quote
Old 28th September 2006, 21:54   #3
VIPrecordsInc
Junior Member
 
Join Date: Aug 2005
Location: USA
Posts: 12
Send a message via Yahoo to VIPrecordsInc
I haven't ran into any HTML that can do that but here is something that works great for me in PHP...Change the X's to your IP address and port and you should be good to go.
COPY ENTIRE CODE BELOW AND UPLOAD IT TO YOUR SERVER.

<?php
// last10.php -- get and display last n tracks...
// URL syntax:
// last10.php?host={XXX.XX.XXX.XX}&port={8000}&n={lastN}
//
// {bracketed} items need to be replaced or they will default as below.
//
// I can return Javascript or HTML only.
//
/* keep warnings from our output */
error_reporting(E_ERROR);
// -- Server Info here -- //
$yourIP = 'XX.XXX.XXX.XX';
$yourPORT = 'XXXX';
// -- Tweak Display Here -- //
$bgcolor = '#000000'; // Page background color
$tablew = '215'; // Table width
$toprow = '#ff0000'; // Top background color
$bottom = '#999999'; // Bottom background color
$border = '#000000'; // Border color
$thickness = '2'; // Border thickness
$padding = '4'; // Cell padding
$font = 'Bradley Hand ITC'; // Font
$fontsize = '2'; // Font size
$refresh = '15'; // How often should it refresh? (seconds)
// Return JavaScript or HTML
$jsOutput=FALSE; // TRUE=js | FALSE=HTML
// try to get the target from the url...
$host = $_REQUEST[host];
if (!$host) $host = $yourIP;
$port = $_REQUEST[port];
if (!$port) $port = $yourPORT;
$lf = chr(10); // 0x0A [\n]
// The lastN is configurable at the DNAS with, ShowLastSongs= it defaults to 10 and has a maximum of 20
$t_max = $_REQUEST[n];
if (!t_max || $t_max<1 || $t_max>19) $t_max=10;
//19 is the max here because 20=current_track+19
// Let's get /index.html first... to keep this short, there is no code to handle the dnas being down
// or not running, so the script will display nothing in those cases.
$connect_timeout=5;
$success=0;
$fp1 = fsockopen($host, $port, &$errno, &$errstr, $connect_timeout); //open connection
if(!$fp1) { //if this fails, I'm done....
fclose($fp1);
$success++;
} else {
$request="GET /index.html HTTP/1.1\r\nHost:" . $host . ":" . $port . "\r\nUser-Agent: SHOUTcast DNAS Status [index] * (Mozilla/PHP)\r\nConnection: close\r\n\r\n"; //get index.html
fputs($fp1,$request,strlen($request));
$page='';
while(!feof($fp1)) {
$page .= fread($fp1, 16384);
}
fclose($fp1);
// now I have the entire /index.html in $page -- all I want from here is the current track...
// (hint-hint)
$song00 = ereg_replace("</b></td>.*", "", ereg_replace(".*Current Song: </font></td><td><font class=default><b>", "", $page)); // easy, right <img src="images/smilies/smile.gif" border="0" alt="">
// now let's get /played.html... (this is kinda long)
$fp = fsockopen($host, $port, &$errno, &$errstr, $connect_timeout);
if(!$fp) { //if connection could not be made
fclose($fp);
$success++;
} else {
$request="GET /played.html HTTP/1.1\r\nHost: " . $host . ":" . $port . "\r\nUser-Agent: SHOUTcast DNAS Status [played] * (Mozilla/PHP)\r\n"."Connection: close\r\n\r\n";
fputs($fp,$request,strlen($request));
$page='';
while (!feof($fp)) {
$page .= fread($fp, 16384);
}
fclose($fp); //close connection
$played_html=$page;
if ($played_html) {
$played_html= ereg_replace('<x>','|-|',ereg_replace('</tr>','',ereg_replace('</td><td>','<x>',ereg_replace('<tr><td>','',ereg_replace('</tr>','</tr>' . $lf,ereg_replace('-->','--]',ereg_replace('<!--','[!--',ereg_replace('</table><br><br>.*','',ereg_replace('.*<b>Current Song</b></td></tr>','',$played_html)))))))));
$xxn=strlen($played_html);
$r=2;
$t_count=0;
$reading=0;
$track[0]=$song00;
while ($r<$xxn & $t_count<=$t_max){
$cur=substr($played_html,$r,1);
if ($cur==$lf) $reading=0;
if ($reading==1) $track[$t_count] .= $cur;
if ($cur=="|" & substr($played_html,$r-1,1)=="-" & substr($played_html,$r-2,1)=="|") {
$reading=1;
$t_count++;
}
$r++;
}
}
}
}
// I now have $track[0-N] containg the current plus last N tracks...
// Output time...
if ($success==0) {
if ($jsOutput) { // JavaScript - used as <script src=...></script>
header('Content-type: text/javascript');
} else { // HTML... (iFrames anyone?)
echo '<HTML>
<HEAD><TITLE>Now Playing: ' . $track[0] . '</title>
<meta http-equiv="refresh" content="' . $refresh . ';URL=' . $_SERVER['PHP_SELF'] . '?host=' . $host . '&port=' . $port . '">
</head>
<BODY bgcolor=' . $bgcolor . '>';
}
$r=0;
$output_string='';
//tweak the output string (the table init) here....
$output_string .= '<table width="' . $tablew . '" style="border-collapse: collapse" border="' . $thickness . '" bordercolor="' . $border . '"><tr bgcolor="' . $toprow . '"><td>
<table width="100%" border="0" cellpadding="' . $padding . '"><tr><td>
<font face=' . $font . ' size=' . $fontsize . '>'; //Now playing...
while ($r<=$t_max){
if ($r==0) $output_string .= '<b>Now Playing:</b><br> '.str_replace("'", "'",str_replace('"', '"',$track[$r])).'</b></td></tr></table></td></tr><tr><td><table bgcolor=' . $bottom . ' width="100%" border="0" cellpadding="' . $padding . '"><tr><td><br><font face=' . $font . ' size=' . $fontsize . '><b><i>Just Played:</b></i><br><br>';
else $output_string .= str_replace("'", "'",str_replace('"', '"',$track[$r])) . '<br>';
$r++;
}
// I also want to close the table code now....
$output_string .= '</td></tr></table></td></tr></font></td></tr></table>';
if ($jsOutput) {
echo "document.write('" . $output_string . "');";
} else {
echo $output_string . '</body></html>';
}
} else { // I couldn't connect to the DNAS
if ($jsOutput) echo "document.write('Off Air');";
else echo "<HTML><HEAD><TITLE>XXXXXXXXXXXXXX</title></head>
<BODY bgcolor= blue" . $bgcolor . "><font face=" . $font . " size=" . $fontsize . "><b>OFF AIR Please try back later</b></body></html>";
}
?>
VIPrecordsInc is offline   Reply With Quote
Old 29th September 2006, 08:42   #4
5h4d0vv
Junior Member
 
Join Date: Sep 2006
Posts: 3
Aww cool thnaks, ill get going stright away
5h4d0vv is offline   Reply With Quote
Old 29th September 2006, 08:55   #5
5h4d0vv
Junior Member
 
Join Date: Sep 2006
Posts: 3
Hi, i aint too good with PHP, so how about..

Hi, i aint too good with PHP, so how about if i give as much info about our server.. and maybe (if you dont mind) filling it out for me?? just take out what you need to fill it out.. BUT i noticed that it says below..

Show last songs, Songs to list in the /played.html
Dose that do what i want it to do ??


Port Base
Port Base
1446

Max Users
the maximum allowed listeners
200

Bitrate
The maximum bitrate allowed by the dj
24

Logfile
Specify the file for logging
../../logs/sc_1158574847_1446.log


Show last songs
songs to list in the /played.html


Tch Log

Yes

Web Log

No

W3C enable

Yes

W3C log

w3c_1158574847_1446.log

Y Port

80

Meta-interval

32768
5h4d0vv is offline   Reply With Quote
Old 29th September 2006, 12:41   #6
sputnik radio
Major Dude
 
sputnik radio's Avatar
 
Join Date: Feb 2006
Location: Dallas
Posts: 871
you dont have to be good with php.

first you have to change the filename that you want this to appear on to something.php. Thats all

Then copy his ENTIRE script above and paste it on that page wherever you want it to appear. Just make sure to change the xxxxx to your info

ie. your ip and your port.


hope this helps
sputnik radio is offline   Reply With Quote
Old 30th September 2006, 03:34   #7
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
VIPrecordsInc

Thanks! simple as hell to past in and have a nice output.

FYI: you will need php and an web server that supports fsock calls via php (talk to your web host for that).



~ D

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork 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