Skocz do zawartości

Statystyki przez php z servera ShoutCast 1.9.8


bela

Rekomendowane odpowiedzi

Witam czy ktoś posiada jakieś fajne skrypty php do pobierania statystyk z servera  ShoutCast 1.9.8  ? 

 

Ja posiadam statystyki co aktualnie jest grane

 

<?php
/* ----------- Server configuration ---------- */

$ip = "s8.myradiostream.com";
$port = "7882";

/* ----- No need to edit below this line ----- */
/* ------------------------------------------- */
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) 
	{ 
	echo "I Love Big Brother - We are not playing now"; // Diaplays when sever is offline
	} 
	else
	{ 
	fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
	while (!feof($fp)) 
		{
		$info = fgets($fp);
		}
	$info = str_replace('</body></html>', "", $info);
	$split = explode(',', $info);
	if (empty($split[6]) )
		{
		echo "I Love Big Brother - We are not playing now"; // Diaplays when sever is online but no song title
		}
	else
		{
		$title = str_replace('\'', '`', $split[6]);
		$title = str_replace(',', ' ', $title);
		echo "$title"; // Diaplays song
		}
	}
?>

 

później ilość słuchaczy, lecz kod nie jest cały bo ino tyle zeń potrzebowałem

 

 <?php
error_reporting(0);
define ("DEBUG", "0");
$shoutcast_host = 's8.myradiostream.com';  // SHOUTcast station url
$shoutcast_port = '7882';      // SHOUTcast station port number
$shoutcast_password = 'HASLO';  // SHOUTcast password
$shoutcast_url = "http://" . $shoutcast_host . ':' . $shoutcast_port . "/listen.pls";
$fsock_time_out = 1;
$fsock_error_number = 0;
$fsock_error_text = "";
$shoutcast_data = array(
                        'currentlisteners' => '');
$shoutcast_xml = "";
global $shoutcast_data, $shoutcast_xml_element;
if (!function_exists('startElement')) {
  function startElement($parser, $name, $attrs) {
      global $shoutcast_xml_element;
      // track which xml element is being parsed
      $shoutcast_xml_element = strtolower($name);
  }
}
if (!function_exists('endElement')) {
  function endElement($parser, $name) {
      global $shoutcast_xml_element;
      // forget which xml element was being parsed
      $shoutcast_xml_element = '';
  }
}
if (!function_exists('handleData')) {
  function handleData($parser, $data) {
      global $shoutcast_data, $shoutcast_xml_element;
      $shoutcast_data[$shoutcast_xml_element] .= $data;
  }
}
if (!function_exists('defaultHandler')) {
  function defaultHandler($parser, $data) {}
}
$shoutcast_fp = fsockopen($shoutcast_host,
                          $shoutcast_port, 
                          $fsock_error_number,
                          $fsock_error_text,
                          $fsock_time_out);
if($shoutcast_fp) {
    // socket connection is established, so the station is on-line
    // set 1 second timeout for communication with the station
    // stream_set_timeout($shoutcast_fp, 1);
    
    // build a string containing an HTTP request to your SHOUTcast server
    $shoutcast_httpreq = "GET /admin.cgi?pass=$shoutcast_password&mode=viewxml
      HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n";
    // send HTTP request to shoutcast server
    fputs($shoutcast_fp, $shoutcast_httpreq);
    // read entire xml output stream
    while(!feof($shoutcast_fp)) {
        $shoutcast_xml .= fgets($shoutcast_fp, 1000);
    }
  
    // close the socket now we no longer need it
    fclose($shoutcast_fp);
    // if we have got some XML back  then we need to strip away some
    // stuff that we don't need  
    if ($shoutcast_xml != '')
        $shoutcast_xml = strstr($shoutcast_xml, '<SHOUTCASTSERVER>');
    // create an instane of the EXPAT XML parser
    $xml_parser = xml_parser_create();
    // set element start and end element handler functions
    xml_set_element_handler($xml_parser, 'startElement', 'endElement');
    // set character data handler function
    xml_set_character_data_handler($xml_parser, 'handleData');
  xml_set_default_handler($xml_parser, 'defaultHandler');
  
    // activate the XML parser
  $parsed = xml_parse($xml_parser, $shoutcast_xml, 1);
    // some debugging code
    if (DEBUG) {
        echo $shoutcast_xml;
        print_r ($shoutcast_data);
    }
    // check that the parsing operation worked correctly
    if ($parsed) {
        // it worked, so report the station status
        if ($shoutcast_data['streamstatus'] == '1') {
    
        // streaming content is available
        echo $shoutcast_data['currentlisteners'];
		}
        
    }
    else {
        // parsing failed
      if (DEBUG) {
          echo 'XML Parser reported the following error:' . '<br />';
          echo xml_error_string(xml_get_error_code($xml_parser)) . ' in line ';
          echo xml_get_current_line_number($xml_parser) . '<br />';
      }
    }
    // the xml parser is no longer required
    xml_parser_free($xml_parser);
} else {
    // socket connection could not be established
    echo 'X';
}
?> 

 

Tabela z historią tworów

<?php

$server_ip = "s8.myradiostream.com";
$portbase = "7882";

if (!is_numeric($portbase)) {
	print "Invalid port";
	exit;
}
$fp = @fsockopen($server_ip,$portbase,$errno,$errstr,1);
if (!$fp) { 
	print "<table border=0 cellpadding=2 cellspacing=2><tr><td>I Love Big Brother - We are not playing now</td></tr></table>";
	exit;
} else { 
	fputs($fp, "GET /played.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
	while (!feof($fp)) {
		$info = fgets($fp);
	}
	$content = get_string_between($info, "Admin Login</a></font></td></tr></table></td></tr></table><br>", "<br><br><table");
	print $content;
	fclose($fp);
}

function get_string_between($string, $start, $end) {
	$string = " " . $string;
	$ini = strpos($string, $start);
	if ($ini == 0)
	  return "";
	$ini += strlen($start);
	$len = strpos($string, $end, $ini) - $ini;
	return substr($string, $ini, $len);
}
?>

a tutaj kod CSS do niej a na dole html:

/* _________   H I S T O R Y   _________ */

body {
margin: 0 !important;
background-color:#222;
font-weight: bold;
color: #fff;
letter-spacing: 1px;
text-shadow: 1px 1px #000, 2px 2px #000;
transition: all .3s ease-in-out;	
}
body div {
transition: all .3s ease-in-out;		
}
body a {	
color: #ccc;
text-decoration: none;
transition: all .3s ease-in-out;
}
img {
transition: all .3s ease-in-out;	
}
#container {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
margin-left: auto;
margin-right: auto;
max-width: 1250px;
padding: 30px 0px 70px 0px;
}
#tablebox {
display: flex;
align-items: center;
justify-content: center;
width:90%;
}
#table {
display: flex;
align-items: center;
justify-content: center;
margin: 20px 0px 20px 0px;
box-shadow:0 10px 20px 0px #000;
border-radius:15px;
}
#table:hover {
box-shadow:0 0px 30px 0px #eee;
}
table {
padding:10px;
color: #ccc;
font-weight: bold;	
letter-spacing: 1px;
text-shadow: 1px 1px #000, 2px 2px #000;
font-size: 20px;
background-color: #333;
box-shadow:0 0px 20px 0px #000 inset;
border: 3px solid #ccc;
border-radius: 15px;
}
#table:hover table {
color: #fff;
border: 3px solid #eee;
}
td {
text-align:center;
border: 1px solid #999;
}
/* ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ LOGO ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ */ 	
.logo {
display: flex;
align-items: center;
justify-content: space-around;
width: 95%;
height: 60px;
background-image:radial-gradient(ellipse at bottom, #333 5%, transparent 130%);
box-shadow:0 0px 20px 0px #333 inset;
border-radius: 15px;
}
.logo div {
display: flex;
align-items: center;
justify-content: center;
height: 60px;
}
.logotitle {
min-width: 300px;
}
.logotitle div {
border-radius: 15px;	
box-shadow:0 10px 20px 0px #000;
}
.logotitle div:hover {
border-radius: 15px;	
box-shadow:0 0px 30px 10px #A62A2A;
}
.logoimg {
min-width:100px;	
background: url("../image/history.png") no-repeat center;
background-size: 50px 50px;
}
.logotitle a {
font-size: 25px;
padding: 15px 15px 15px 20px;
letter-spacing: 5px;
border: 3px solid #ccc;
background-image:radial-gradient(ellipse at bottom, #666 10%, #000 130%);
box-shadow:0 0px 10px 0px #666 inset;
text-shadow:  1px 1px #000, 2px 2px #000, 3px 3px #000, 4px 4px #000;
border-radius: 15px;
} 
.logotitle a:hover {
color: #fff;
font-size: 28px;
border: 4px solid #eee;
background-image:radial-gradient(ellipse at bottom, #A62A2A 10%, #111 130%);
box-shadow:0 0px 20px 0px #A62A2A inset;
} 
.logohome {
min-width:85px;	
}
.logohome img {
width: 60px;	
border: 2px solid #ccc;
border-radius: 15px;	
}
.logohome img:hover {
width: 65px;	
border: 3px solid #eee;
-webkit-filter: brightness(120%); 
filter: brightness(120%);
}	
#bgimage {
height: 0;
width: 0;
}
#topbox {
display: none;
}
/* ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ 1150PX ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ */ 	
@media screen and (min-width: 1150px) {
#bgimage {
height: auto;
width: 100%;
position: fixed;
z-index: -100;
left: 0px;
min-height: 938px;
min-width: 1250px;
-webkit-filter: brightness(100%); 
filter: brightness(100%);
}		
#container {
padding: 0px 0px 70px 0px;
}	
/* ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ TOP BOX ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ */ 
#topbox {
display: flex;
align-items:  center;
justify-content: center;
width: 100%;
margin-top:5px;
}
#fb {
display: flex;
align-items: center;
justify-content: flex-start;
width: 50%;
height: 40px;
margin-left: 30px;
}
#top {
display: flex;
align-items: center;
justify-content: flex-end;
width: 50%;
height: 40px;
margin-right: 30px;
}
#onlineboxshadow {	
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100%;
}
#onlinebox {	
display: flex;
align-items: center;
justify-content: flex-end;
height: 35px;
padding: 0px 10px 0px 40px;
border:1px solid #000;
box-shadow:0 0px 30px 5px #000 inset;
border-radius:10px;
color: #fff;
font-size: 25px;
background: url("../image/listener.png") 8px no-repeat;
background-size: 25px 25px;
transition: all .3s ease-in-out;	
}
#onlinebox:hover {	
color: #fff;
font-size: 30px;
background-size: 30px 30px;
}		
.logohome img {
width: 70px;	
border: 2px solid #ccc;
border-radius: 15px;	
}
.logohome img:hover {
width: 75px;	
border: 3px solid #eee;
-webkit-filter: brightness(120%); 
filter: brightness(120%);
}	

}
 /* ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ 1150PX END ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ */ 	
/* ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ 400PX ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ */ 	
@media screen and (max-width: 400px) {
#container {
padding:0px;
}	
.logo {
display:none;
}
table {
font-size: 16px;
color: #fff;
}
#table:hover table {
border: 3px solid #ccc;
}
#table:hover {
box-shadow:0 10px 20px 0px #000;
}
	
}	
<html>
<head>
<title>Historia Tworów</title>
<meta name="description" content="Historia Tworów z radia I Love Big Brother" />
<meta name="keywords" content="I Love Big Brother, historia tworów" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="shortcut icon" href="../favicon.ico" />
<link rel="stylesheet" type="text/css" href="../style/history.css" />
</head>
<body>
<img src="../image/background.jpg" id="bgimage" alt="Background image" />
	<div id="container" > 
<!-- ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ TOP ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ -->		
		<div id="topbox" >
			<div id="fb" >
				<div class="fb-like" data-href="https://www.facebook.com/ILoveBigBrother/" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
			</div>		
			<div id="top" >
				<div id="onlineboxshadow" ><div id="onlinebox" title="Amount of people online" >
					<span id="online" >1</span></div>
				</div>		
			</div>
		</div>	
<!-- ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ LOGO ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ -->	
		<div class="logo" >
			<div class="logoimg" ></div>
			<div class="logohome" >
				<a href="../pl.html" target="_blank" ><img src="../image/logo.gif" alt="SZCZUROWNIA" title="SZCZUROWNIA" /></a>
			</div>
			<div class="logotitle" >
				<div><div><a href="" title="Historia Tworów" >Historia</a></div></div>
			</div>
			<div class="logohome" >
				<a href="../pl.html" target="_blank" ><img src="../image/logo2.gif" alt="SZCZUROWNIA" title="SZCZUROWNIA" /></a>
			</div>
			<div class="logoimg" ></div>
		</div>
<!-- ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ TABLE ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ -->	
		<div id="tablebox" >	
			<div id="table" >
				<span id="historypl" >
					<table border=0 cellpadding=2 cellspacing=2><tr><td>Played @</td><td><b>Song Title</b></td></tr><tr><td>14:34:39</td><td>Cactophage - Tesselation<td><b>Current Song</b></td></tr><tr><td>14:31:19</td><td>Handbook - Serious</tr><tr><td>14:28:58</td><td>deeB - deeB - Bouquet (Anonymous Musik & Dj Dash vocal edit)</tr><tr><td>14:23:55</td><td>Ars Mars - Sewer Loops</tr><tr><td>14:20:09</td><td>Ensa - Po P�nocy (Instrumental)</tr><tr><td>14:17:23</td><td>mhzesent - Big Things</tr><tr><td>14:14:42</td><td>Da Vosk Docta - Transgender (Da Vosk Docta Remix)</tr><tr><td>14:08:30</td><td>Acrid Lemon - Tribe101 Wounder//Kik</tr><tr><td>14:04:08</td><td>ISLIM - 22</tr><tr><td>14:01:33</td><td>Rowlf The Dawg - U So Good ('08 Flow)</tr></table>
				</span>
			</div>
		</div>	
<!-- ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ LOGO ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ -->	
		<div class="logo" >
			<div class="logoimg" ></div>
			<div class="logohome" >
				<a href="../pl.html" target="_blank" ><img src="../image/logo.gif" alt="SZCZUROWNIA" title="SZCZUROWNIA" /></a>
			</div>
			<div class="logotitle" >
			</div>
			<div class="logohome" >
				<a href="../pl.html" target="_blank" ><img src="../image/logo2.gif" alt="SZCZUROWNIA" title="SZCZUROWNIA" /></a>
			</div>
			<div class="logoimg" ></div>
		</div>
	</div>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>	
<script type="text/javascript" src="../js/historypl.js"></script>	
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/pl_PL/sdk.js#xfbml=1&version=v2.5";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>		
</body>
</html>

 

Edytowane przez bela
Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Gość
Dodaj odpowiedź do tematu...

×   Wklejono zawartość z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Strona korzysta z plików cookie. Korzystając z forum, wyrażasz zgodę na: Warunki użytkowania, Polityka prywatności.