View Single Post
Old 24th October 2017, 16:10   #4
djSpinnerCee
Forum King
 
djSpinnerCee's Avatar
 
Join Date: Aug 2004
Location: Hollis, Queens/The Bronx, NYC
Posts: 3,528
sc_played_v2.php - v2 dnas history

ok- simple fix. basically the admin.cgi url needed tweaking.
PHP Code:
<?php

error_reporting
(0);

$scip           "127.0.0.1";   // Server IP/hostname

$scport         "8000";   // Port

$scpass         "changeme";   // Password

$scversion      "2";   // Shoutcast Version

$scID           "1";   // Server ID [sid=]

$imgKey         "MYAPI";   // LastFM api to Get Images


$scfp fsockopen($scip$scport, &$errno, &$errstr30);

if(!
$scfp) {

  
$scsuccs=1;
  echo
'Offline';

}

if(
$scsuccs!=1){

//fputs ($scfp, "GET /admin.cgi?sid=$scID&pass=$scpass&mode=viewxml&page=4 HTTP/1.1\r\nHost: $scip:$scport\r\nUser-Agent: User (Mozilla Compatible)\r\nAuthorization: Basic ".base64_encode ("admin:$scpass")."\r\n\r\n");

//get correct v2 page...
fputs ($scfp"GET /admin.cgi?sid=".$scID."&pass=".$scpass."&mode=viewxml HTTP/1.1\r\nHost: ".$scip.":".$scport."\r\nUser-Agent: User (Mozilla Compatible)\r\n\r\n");

while(!
feof($scfp)) {

  
$page .= fgets($scfp,4096);

}

fclose($scfp);

// to dump the admin.cgi for debugging... 
//echo "<!-- ".$page." -->\n\n";

 
$loop = array("STREAMSTATUS""BITRATE");

 
$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);

 
$a 0;

 
$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]);

  list (
$artiest$titel) = explode(" - "$song[$t]); 

  
$rij_kleur = ($a++ % 2) ? "#f5f5f5" "#e8e8e8"

if (
$imgKey<>"MYAPI") {

  
$xml simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=".$artiest."&api_key=".$imgKey);

  
$trackimg $xml->artist->image[2];

}

if (
$trackimg == "") {

    
$trackimg "../noIMG.png";

}



if ((
$artiest == "LIVE") && ($titel == "-=ON AIR=-")) {

    
$trackimg "../live.jpg";

}



echo
'<div style="background-color: '.$rij_kleur.';>

<p style="width: 65px;"><img style="margin-top:5px; margin-left:5px; border-radius: 100%; border: 1px solid #ff1190; width: 60px; height: 60px;" src="'
.$trackimg.'" /></p>

<div style="display:block; margin: -66px 0px 0px 80px; float:left;">

<i class="fa fa-microphone"></i> <strong>'
.$artiest.'</strong><br />'.$titel.'</a>

</div></div>'
;



$r++; }

}

?>
djSpinnerCee is online now   Reply With Quote