het probleem is als volgt....
als de stream online is werkt het als een speer..
maar als het offline is krijg ik gewoon een blanko scherm end de link blijft maar laden
totdat er een 500 internal server error verschijnt
ik zou graag willen aanpassen dat als hij de connectie checkt
hij kan aangeven >>> server is nu offline!
is dit mogelijk?
heb al op diverse webs gezien en ook een zogenaamde fix...
maar werkt ook niet.... bvd! Klaas
<html>
<head>
<meta http-equiv="Content-Language" content="nl">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="refresh" content="30;URL=/Music/Radio/stats/">
<meta name="robots" content="noindex,nofollow">
<link rel="SHORTCUT ICON" href="/Music/Radio/stats/stats.ico">
<title>SHOUTcast | Radio Stats V3</title>
</head>
<style>
<!--
body {
scrollbar-face-color: #444444;
scrollbar-shadow-color: #222222;
scrollbar-track-color: #222222;
scrollbar-highlight-color: #222222;
scrollbar-arrow-color: #222222;
scrollbar-base-color: #222222;
scrollbar-darkshadow-color: #222222;
background:#222222;
color: #ffffff;
}
td {border: none;}
table {
-moz-border-radius: 05px;
-khtml-border-radius: 05px;
-webkit-border-radius :05px;
border-radius: 05px;
Font-size:9px;
Font-family: Verdana, Arial, Helvetica, sans-serif;
color: #ffffff;
}
-->
</style>
<script type="text/javascript">
/*
Klapper de klap
*/
function showcodes(a,codediv)
{
var divje = document.getElementById( codediv );
if (divje.style.display == "block")
{
divje.style.display = "none";
a.innerHTML='Song History here';
}
else
{
divje.style.display = "block";
a.innerHTML='Shrink Song history';
}
}
</script>
<table border=1>
<td>
<a href=https://sage.websavers.ca:2199/tunein/thhughes.pls><img src=Images/Winamp.png height=20 width=20></a><br>
<a href=https://sage.websavers.ca:2199/tunein/thhughes.asx><img src=Images/Wmp.png height=20 width=20></a><br>
<a href=https://sage.websavers.ca:2199/tunein/thhughes.ram><img src=Images/RealPlayer.png height=20 width=20></a><br>
<a href=https://sage.websavers.ca:2199/tunein/thhughes.qtl><img src=Images/Quicktime.png height=20 width=20></a><br>
</td>
<td><img src=Images/Online.png height=80 width=155></td>
<td>
<?php
##################################
##### This document contains a class that will allow you to easily extract data from online radiostations
##### Also, an example is provided at the bottom
#####
##### This class has been written by Martijn Korse and may be freely used, but only for non-profit purposes
##### When in doubt, please contact me : marty[at]excudo[dot]net
##### http://start.excudo.net
#####
##### (ps: a handwritten version of the stripos() function has also been included in this document, for those
##### without PHP 5)
##################################
error_reporting(E_ALL);
#
# The Class
#
class Radio
{
var $fields;
var $very_first_str;
function Radio($array=array())
{
$this->setFields($array);
$this->setOffset("Current Stream Information");
}
function setFields($array)
{
$this->fields = $array;
}
function setOffset($string)
{
$this->very_first_str = $string;
}
function getData($url, $port, $display_array=null, $very_first_str=null)
{
if (!isset($display_array))
$display_array = $this->fields;
if (!isset($very_first_str))
$very_first_str = $this->very_first_str;
$domain = (substr($url, 0, 7) == "http://") ? substr($url, 7) : $url;
// opening a connection and reading the contents
if (@$fp = fsockopen($domain, $port, $errno, $errstr, 2))
{
$contents = "";
fputs($fp, "GET / HTTP/1.1\r\n".
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\r\n".
"Host: ".$domain."\r\n\r\n");
while (!feof($fp))
{
$contents .= fgets($fp, 256);
}
fclose ($fp);
// parsing the contents
foreach ($display_array AS $key => $item)
{
$very_first_pos = stripos($contents, $very_first_str);
$first_pos = stripos($contents, $item, $very_first_pos);
$line_start = strpos($contents, "<td>", $first_pos);
$line_end = strpos($contents, "</td>", $line_start) + 4;
$difference = $line_end - $line_start;
$line = substr($contents, $line_start, $difference);
$data[$key] = strip_tags($line);
}
return $data;
}
else
{
return $errstr." (".$errno.")";
}
}
}
// schaamteloos van php.net gekopieerd
if (!function_exists("stripos"))
{
function stripos($haystack, $needle, $offset=0)
{
return strpos(strtoupper($haystack), strtoupper($needle), $offset);
}
}
#
# The example
#
?>
<img src=Images/RadioTower1.gif align=right height=80 width=50>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ars6Togo Radio!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<table>
<?php
/******
* $display_array determines the data that will be displayed
* ==============
* Posibilities:
* --------------
* - Server Status
* - Stream Status
* - Listener Peak
* - Average Listen Time
* - Stream Title
* - Content Type
* - Stream Genre
* - Stream URL
* - Stream AIM
* - Stream IRC
* - Current Song
***/
$display_array = array("Stream Status","Listener Peak","Stream Title","Current Song");
$radio = new Radio($display_array);
$data_array = $radio->getData("192.99.105.197",9014);
if (is_array($data_array))
{
foreach ($display_array AS $i => $text)
{
if ($text == "Stream Genre")
$datastring = "<span style=\"color: green;\">".$data_array[$i]."</span>";
elseif ($text == "Stream URL")
$datastring = "<a href=\"".$data_array[$i]."\" target=\"_blank\">".$data_array[$i]."</a>";
else
$datastring = $data_array[$i];
echo "<tr>\n <td>".$text.":</td>\n";
echo " <td>".$datastring."</td>\n</tr>\n";
}
}
else
{
if ($data_array == "Connection timed out (110)")
echo "<tr>\n <td colspan=\"2\" style=\"color: red;\">Er is op dit momend geen uitzending</td>\n</tr>\n";
else
echo "<tr>\n <td colspan=\"2\" style=\"color: red;\">".$data_array."</td>\n</tr>\n";
}
?>
</table>
<p style="margin-left:3; margin-top: 0">
<span style="cursor: pointer;" onclick="showcodes(this,'div_tekst');">Song History: <font color="yellow">here</font></span>
<div id="div_tekst" style="display: none; height: 1">
<table border=1><br><br>
<?php
set_time_limit(0);
$open = fsockopen("192.99.105.197",9014,$errno,$errstr,1);
$out = "GET /played.html HTTP/1.1\nUser-Agent:Mozilla\n\n";
fwrite($open,$out);
while (!feof($open)) {
$data = fgets($open, 2000000);
}
$data = explode("Song Title",$data);
$data = explode("</table>",$data[1]);
$data = str_replace("</b>","",$data[0]);
$data = str_replace("<b>Current Song","<b>",$data);
echo $data;
fclose($open);
?>
</table>
op lijn 208 en 209
was de zogenaamde fix >
if ($data_array == "Connection timed out (110)")
echo "<tr>\n <td colspan=\"2\" style=\"color: red;\">Er is op dit momend geen uitzending</td>\n</tr>\n";
maar dat wil ook niet
bvd Klaas!