shoutcast server offline is er niet
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
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<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>
<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 >
Code (php)
1
2
2
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";
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!
Gewijzigd op 17/07/2017 18:59:12 door Klaas Vaak
Verder een goede tip: Zet je class in een apart bestand. Dan blijft het beter leesbaarder,
kan het niet eens vinden ....
etc class apart zetten en dan includen?
:) bedankt to zover Arien!
Code (php)
Of in .htaccess:
Bij voorkeur die log niet publiekelijk zetten!
heb ook al log geactiveerd op server zelf....
helaas krijg ik nu geen errors...
maar de pagina blijft maar laden en laden
en blijft leeg..
heb ook al geprobeerd om dan de errors te laten zien in php.ini
maar als er dan es een keer een error komt kan ik het niet lezen omdat FF direct crashed....
btw (ik had dit moeten vermelden het is voor shoutcast V1) sorry hiervoor!
Als Firefox crashed dan moet er wel sprake zijn van een 'infinite loop' ergens.