config.php
Código PHP:
<?
$scip = "radioonline42.no-ip.org"; // IP adress
$scport = 80; // Port
$scpass = "forgot"; // SHOUTcast Password
?>
getinfo.php
Código PHP:
<?php
include "config.php";
ini_set("display_errors", "0");
$scfp = fsockopen($scip, $scport, &$errno, &$errstr, 1);
if(!$scfp) {
$scsuccs=1;
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?sid=1&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);
}
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE", "NEXTTITLE","SONGTITLE");
$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 )
$$scphp = urldecode($$scphp);
$y++;
}
$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++;
}
fclose($scfp);
}
if(isset($_GET['status'])){
$status = $_GET['status'];
} else{
$status = "stop";
}
if(isset($_GET['z'])){
$z = $_GET['z'];
} else{
$z = "flash";
}
if ($z == 'wmp'){
$mode = 'real';
$mode2 ='qp';
$mode3='flash';
} elseif ($z == 'real'){
$mode = 'wmp';
$mode2 ='qp';
$mode3='flash';
} elseif ($z == 'qp'){
$mode = 'wmp';
$mode2 ='real';
$mode3='flash';
} elseif ($z == 'flash'){
$mode = 'wmp';
$mode2 ='real';
$mode3='qp';
}
?>
next_song.php
Código PHP:
<? include "getinfo.php";?>
<?php echo $nexttitle;
?>
cur_song.php
Código PHP:
<? include "getinfo.php";?>
<?php echo $songtitle;
?>
Script para mostrar currentsong y nextsong y se actualicen cada 2 segundos
Código:
<script>
window.onload=function windows(){
sndReq();
}
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq() {
http.open('post', 'cur_song.php');
http.onreadystatechange = handleResponse;
http.send(null);
setTimeout("sndReqe()", 2000);
}
function sndReqe() {
http.open('post', 'next_song.php');
http.onreadystatechange = handleResponses;
http.send(null);
setTimeout("sndReq()", 2000);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
if (response != responseold || responsecheck != 1) {
var responsecheck = 1;
document.getElementById("currentsong").innerHTML = http.responseText;
var responseold = response;
}
}
}
function handleResponses() {
if(http.readyState == 4){
var response = http.responseText;
if (response != responseold || responsecheck != 1) {
var responsecheck = 1;
document.getElementById("nextsong").innerHTML = http.responseText;
var responseold = response;
}
}
}
</script>