Showing 7 changed files with 1273 additions and 0 deletions
+285
functions.php
... ...
@@ -0,0 +1,285 @@
1
+<?php
2
+require_once('sentences.php');
3
+require_once('shoutcast.php');
4
+require_once('json.php');
5
+$file_contents_playlist=file_get_contents( "playlist.xml" );
6
+$xml = simplexml_load_string($file_contents_playlist);
7
+$json = json_encode($xml);
8
+$array = json_decode($json,TRUE);
9
+
10
+function print_radio_details($name, $artist, $title, $url, $big = true )
11
+{
12
+	$SIZE=48;
13
+	$MAX_LEN_STR=32;
14
+	$now_playing = $_GET["title"];
15
+	$artist=sentence_case($artist);
16
+	$title=sentence_case($title);
17
+	if( $MAX_LEN_STR < strlen($artist) )
18
+	{
19
+		$artist=substr($artist,0,$MAX_LEN_STR);
20
+		$artist.="...";
21
+	}
22
+	if( $MAX_LEN_STR < strlen($title) )
23
+	{
24
+		$title=substr($title,0,$MAX_LEN_STR);
25
+		$title.="...";
26
+	}
27
+	if( true === $big )
28
+	{
29
+		echo "<div class=\"radio_box_list\">\n";
30
+	}
31
+	else
32
+	{
33
+		echo "<div class=\"radio_box_list_compact\">\n";
34
+	}
35
+	if( $now_playing == $name )
36
+	{
37
+		echo "<div class=\"radio_name_list_active\" id=\"$name\">$name</div>\n";
38
+	}
39
+	else
40
+	{
41
+		echo "<div class=\"radio_name_list\" id=\"$name\">$name</div>\n";
42
+	}
43
+	if( true === $big )
44
+	{
45
+		echo "<div class=\"radio_url_list\"><img src=\"$url\" width=\"$SIZE\" height=\"$SIZE\"></div>\n";
46
+	}
47
+	echo "<div class=\"radio_artist_list\">$artist</div>\n";
48
+	if( ( "" != $title ) && ( "unknown" != $title ) )
49
+	{
50
+		echo "<div class=\"radio_title_list\">$title</div>\n";
51
+	}
52
+	else
53
+	{
54
+		echo "<div class=\"radio_title_list\">&nbsp;</div>\n";
55
+	}
56
+	echo "<div class=\"radio_add\"></div>\n";
57
+	echo "</div>\n";
58
+}
59
+$DATE_REFRESH=date("Y-m-d H:i:s",time());
60
+
61
+//COVERS
62
+$RESOURCE_PATH="resource/";
63
+$bassdrive_url = $RESOURCE_PATH."bassdrive.jpg";
64
+$bbcws_url = $RESOURCE_PATH."bbcws.jpg";
65
+$caribbean_url = $RESOURCE_PATH."caribbean.jpg";
66
+$classic_21_url = $RESOURCE_PATH."classic_21.jpg";
67
+$covers_url = $RESOURCE_PATH."covers.jpg";
68
+$europe1_url = $RESOURCE_PATH."europe1.jpg";
69
+$fculture_url = $RESOURCE_PATH."fculture.jpg";
70
+$finfo_url = $RESOURCE_PATH."finfo.jpg";
71
+$finter_url = $RESOURCE_PATH."finter.jpg";
72
+$fipradio_url = $RESOURCE_PATH."fipradio.jpg";
73
+$flemme_url = $RESOURCE_PATH."flemme.jpg";
74
+$fmusique_url = $RESOURCE_PATH."fmusique.jpg";
75
+$groove_salad_url = $RESOURCE_PATH."groovesalad.jpg";
76
+$lemouv_url = $RESOURCE_PATH."lemouv.jpg";
77
+$lgr_metal_url = $RESOURCE_PATH."lgr_metal.jpg";
78
+$lgr_reggae_url = $RESOURCE_PATH."lgr_reggae.jpg";
79
+$lgr_rock_url = $RESOURCE_PATH."lgr_rock.jpg";
80
+$radio_classique_url = $RESOURCE_PATH."radio_classique.jpg";
81
+$radio_nova_url = $RESOURCE_PATH."radio_nova.jpg";
82
+$reggaewc_url = $RESOURCE_PATH."reggaewc.jpg";
83
+$rfi_url = $RESOURCE_PATH."rfi.jpg";
84
+$rruk_url = $RESOURCE_PATH."rruk.jpg";
85
+$stellar_url = $RESOURCE_PATH."stellar.jpg";
86
+$suburbs_of_goa_url = $RESOURCE_PATH."suburbsofgoa.jpg";
87
+
88
+$bbcws_artist="Live";
89
+$bbcws_title="Live";
90
+$rfi_title="Le Direct";
91
+$rfi_artist="Le Direct";
92
+$finfo_artist="Le Direct";
93
+$finfo_title="Le Direct";
94
+$rruk_artist="An Error Occured";
95
+$rruk_title="An Error Occured";
96
+$stellar_artist="An Error Occured";
97
+$stellar_title="An Error Occured";
98
+$europe1_artist="An Error Occured";
99
+$europe1_title="An Error Occured";
100
+$radio_classique_artist="An Error Occured";
101
+$radio_classique_title="An Error Occured";
102
+$caribbean_artist="An Error Occured";
103
+$caribbean_title="An Error Occured";
104
+$reggaewc_artist="An Error Occured";
105
+$reggaewc_title="An Error Occured";
106
+$bassdrive_artist="An Error Occured";
107
+$bassdrive_title="An Error Occured";
108
+$lgr_reggae_artist="An Error Occured";
109
+$lgr_reggae_title="An Error Occured";
110
+$lgr_metal_artist="An Error Occured";
111
+$lgr_metal_title="An Error Occured";
112
+$lgr_rock_artist="An Error Occured";
113
+$lgr_rock_title="An Error Occured";
114
+$suburbs_of_goa_artist="An Error Occured";
115
+$suburbs_of_goa_title="An Error Occured";
116
+$groove_salad_artist="An Error Occured";
117
+$groove_salad_title="An Error Occured";
118
+$covers_artist="An Error Occured";
119
+$covers_title="An Error Occured";
120
+$flemme_artist="An Error Occured";
121
+$flemme_title="An Error Occured";
122
+//~ if(0)
123
+{
124
+	$t =array();
125
+	$t = get_shoutcast_tags('http://str45.streamakaci.com:8014/;895614762790501stream.nsv');
126
+	if( isset($t[0]) ) {
127
+		$flemme_artist=$t[0];
128
+	}
129
+	if( isset($t[1]) ) {
130
+		$flemme_title=clean_string($t[1]);
131
+	}
132
+		
133
+	$t = get_shoutcast_tags('http://ice.somafm.com:80/suburbsofgoa');
134
+	if( isset($t[0]) ) {
135
+		$suburbs_of_goa_artist=$t[0];
136
+	}
137
+	if( isset($t[1]) ) {
138
+		$suburbs_of_goa_title=$t[1];
139
+	}
140
+	
141
+	$t = get_shoutcast_tags('http://ice.somafm.com:80/groovesalad');
142
+	if( isset($t[0]) ) {
143
+		$groove_salad_artist=$t[0];
144
+	}
145
+	if( isset($t[1]) ) {
146
+		$groove_salad_title=$t[1];
147
+	}
148
+	
149
+	$t = get_shoutcast_tags('http://ice.somafm.com:80/covers');
150
+	if( isset($t[0]) ) {
151
+		$covers_artist=$t[0];
152
+	}
153
+	if( isset($t[1]) ) {
154
+		$covers_title=$t[1];
155
+	}
156
+
157
+	$t = get_shoutcast_tags('http://hd.lagrosseradio.info:8500/;stream.nsv');
158
+	if( isset($t[0]) ) {
159
+		$lgr_rock_artist=$t[0];
160
+	}
161
+	if( isset($t[1]) ) {
162
+		$lgr_rock_title=$t[1];
163
+	}
164
+	$lgr_rock_url=get_lgr_rock_url();
165
+	
166
+	$t = get_shoutcast_tags('http://hd.lagrosseradio.info:8200/;stream.nsv');
167
+	if( isset($t[0]) ) {
168
+		$lgr_metal_artist=$t[0];
169
+	}
170
+	if( isset($t[1]) ) {
171
+		$lgr_metal_title=$t[1];
172
+	}
173
+	$lgr_metal_url=get_lgr_metal_url();
174
+	
175
+	$t = get_shoutcast_tags('http://hd.lagrosseradio.info:8300/;stream.nsv');
176
+	if( isset($t[0]) ) {
177
+		$lgr_reggae_artist=$t[0];
178
+	}
179
+	if( isset($t[1]) ) {
180
+		$lgr_reggae_title=$t[1];
181
+	}
182
+	$lgr_reggae_url=get_lgr_reggae_url();
183
+	
184
+	$t = get_shoutcast_tags('http://amsterdam2.shouthost.com.streams.bassdrive.com:8000/;stream.nsv');
185
+	if( isset($t[0]) ) {
186
+		$bassdrive_artist=$t[0];
187
+	}
188
+	if( isset($t[1]) ) {
189
+		$bassdrive_title=clean_string($t[1]);
190
+	}
191
+	
192
+	$t = get_shoutcast_tags('http://sc-reggae-128kmp3.1.fm:80/;stream.mp3');
193
+	if( isset($t[0]) ) {
194
+		$caribbean_artist=$t[0];
195
+	}
196
+	if( isset($t[1]) ) {
197
+		$caribbean_title=$t[1];
198
+	}
199
+	
200
+	$t = get_shoutcast_tags('http://198.154.106.102:8567/stream');
201
+	if( isset($t[0]) ) {
202
+		$rruk_artist=$t[0];
203
+	}
204
+	if( isset($t[1]) ) {
205
+		$rruk_title=$t[1];
206
+	}
207
+	
208
+	$t = get_shoutcast_tags('http://77.68.36.137:8000/stream');
209
+	if( isset($t[0]) ) {
210
+		$stellar_artist=$t[0];
211
+	}
212
+	if( isset($t[1]) ) {
213
+		$stellar_title=$t[1];
214
+	}
215
+	
216
+	$t = get_shoutcast_tags('http://mp3lg4.tdf-cdn.com:80/9240/lag_180945.mp3');
217
+	if( isset($t[0]) ) {
218
+		$europe1_artist=$t[0];
219
+	}
220
+	if( isset($t[1]) ) {
221
+		$europe1_title=$t[1];
222
+	}
223
+	
224
+	$t = get_shoutcast_tags('http://radioclassique.ice.infomaniak.ch:80/radioclassique-high.mp3');
225
+	if( isset($t[0]) ) {
226
+		$radio_classique_artist=clean_string($t[0]);
227
+	}
228
+	if( isset($t[1]) ) {
229
+		$radio_classique_title=clean_string($t[1]);
230
+		$pos_start = stripos($radio_classique_title, "@classiquelive" );
231
+		if( false !== $pos_start ) {
232
+			$radio_classique_title=substr($radio_classique_title,0,$pos_start);
233
+		}
234
+	}
235
+		
236
+	$t = get_shoutcast_tags('http://67.212.163.150:80/;stream.nsv');
237
+	if( isset($t[0]) ) {
238
+		$reggaewc_artist=$t[0];
239
+	}
240
+	if( isset($t[1]) ) {
241
+		$reggaewc_title=$t[1];
242
+	}
243
+	
244
+	$t = get_fipradio_tags();
245
+	$fip_artist=clean_string($t[0]);
246
+	$fip_title=clean_string($t[1]);
247
+	$fip_url=clean_string($t[2]);
248
+	
249
+	$t = get_lemouv_tags();
250
+	$lemouv_artist=clean_string($t[0]);
251
+	$lemouv_title=clean_string($t[1]);
252
+	$lemouv_url=clean_string($t[2]);
253
+	
254
+	$t = get_fculture_tags();
255
+	$fculture_artist=clean_string($t[0]);
256
+	$fculture_title=clean_string($t[1]);
257
+		
258
+	$t = get_finter_tags();
259
+	$finter_artist=clean_string($t[0]);
260
+	if( 2 <= count($t) ) {
261
+		$finter_title=clean_string($t[1]);
262
+	} else {
263
+		$finter_title="An Error Occured";
264
+	}
265
+	
266
+	$t = get_fmusique_tags();
267
+	$fmusique_artist=clean_string($t[0]);
268
+	if( 2 <= count($t) ) {
269
+		$fmusique_title=clean_string($t[1]);
270
+	} else {
271
+		$fmusique_title="An Error Occured";
272
+	}
273
+	
274
+	$t = get_classic21_tags();
275
+	$classic21_artist = $t[0];
276
+	$classic21_title = $t[1];
277
+	$classic21_url = $t[2];
278
+	
279
+	$t = get_radio_nova_tags();
280
+	$radio_nova_artist=$t[0];
281
+	$radio_nova_title=$t[1];
282
+	$radio_nova_url=$t[2];
283
+}
284
+?>
285
+
+232
index.php
... ...
@@ -0,0 +1,232 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<meta charset=utf-8 />
5
+	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6
+	<meta name="viewport" content="width=420px, user-scalable=no">
7
+	<link rel="shortcut icon" href="resource/radio.ico" />
8
+	<link rel="stylesheet" href="style.css">
9
+	<link rel="stylesheet" href="functional.css">
10
+	<!-- <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> -->
11
+	<!-- <script src="http://releases.flowplayer.org/js/flowplayer-3.2.13.min.js"></script> -->
12
+	<script src="jquery-1.11.2.min.js"></script>
13
+	<script src="flowplayer.min.js"></script>
14
+
15
+	<!-- Touch Screen Detection -->
16
+	<script>
17
+	function isTouchDevice(){
18
+		return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
19
+	}
20
+	</script>
21
+	<script>
22
+	function strcmp(a, b) { 
23
+		a = a.toString(), b = b.toString();
24
+		for (var i=0,n=Math.max(a.length, b.length); i<n && a.charAt(i) === b.charAt(i); ++i);
25
+		if (i === n) return 0;
26
+		return a.charAt(i) > b.charAt(i) ? -1 : 1;
27
+	}
28
+
29
+	flowplayer(function(api, root) {
30
+		api.on("load", function() {
31
+			console.info("flowplayer:load", api.engine.engineName);
32
+			document.getElementById("playing").innerHTML="true";
33
+		}).on("ready", function() {
34
+			var duration = api.video.duration;
35
+			//console.info("flowplayer:ready duration", duration);
36
+			//console.info("flowplayer:ready api.video.title", api.video.title);
37
+			//console.info("flowplayer:ready api.video.type", api.video.type);
38
+			console.info("flowplayer:ready api.video.url", api.video.url);
39
+		    var clipSelector = document.getElementById("fp-playlist");
40
+			var clipFields = clipSelector.getElementsByTagName("ul");
41
+			for (i = 0; i < clipFields.length; i += 1) {
42
+				if( 0 == strcmp(api.video.url, clipFields[i].getElementsByTagName("a")[0].href) ) {
43
+					var title = clipFields[i].getElementsByTagName("a")[0].title;
44
+					var artist = clipFields[i].getElementsByTagName("a")[0].innerHTML;
45
+					console.info("title", title);
46
+					console.info("artist", artist);
47
+					document.getElementById("trackinfo").innerHTML=artist;
48
+					document.getElementById("image").style.display = "none";
49
+					onRefresh();
50
+					<?php
51
+					echo "if (Notification.permission === \"granted\") {\n";
52
+					//~ echo "	var notification=new Notification(artist,{body: \"\", icon: \"resource/\" + title + \".jpg\" });\n";
53
+					//~ echo "	setTimeout(function(){\n";
54
+					//~ echo "		notification.close(); //closes the notification\n";
55
+					//~ echo "	},3000);\n";
56
+					echo "} else if (Notification.permission !== 'denied') {\n";
57
+					echo "	Notification.requestPermission(function (permission) {\n";
58
+					echo "		// If the user accepts, let's create a notification\n";
59
+					echo "		if (permission === \"granted\") {\n";
60
+					echo "			var notification = new Notification(artist,{body: title, icon: \"resource/radio.ico\" });\n";
61
+					echo "			setTimeout(function(){\n";
62
+					echo "				notification.close(); //closes the notification\n";
63
+					echo "			},3000);\n";
64
+					echo "		}\n";
65
+					echo "	});\n";
66
+					echo "}\n";
67
+					?>
68
+				}
69
+			}
70
+		}).on("pause", function() {
71
+			document.getElementById("playing").innerHTML="false";
72
+		}).on("resume", function() {
73
+			document.getElementById("playing").innerHTML="true";
74
+		});
75
+	});
76
+	</script>
77
+	<script type="text/javascript">
78
+		setInterval(function(){ onRefresh(); }, 20000);
79
+	</script>
80
+	<script>
81
+	function onRefresh()
82
+	{
83
+		var xmlhttp;
84
+		xmlhttp=new XMLHttpRequest();
85
+		xmlhttp.onreadystatechange=function()
86
+		{
87
+			if (xmlhttp.readyState==4 && xmlhttp.status==200)
88
+			{
89
+				document.getElementById("list").innerHTML=xmlhttp.responseText;
90
+			}
91
+		}
92
+		var track_current_title=document.getElementById("trackinfo").innerHTML;
93
+		xmlhttp.open("GET","onrefresh.php?title="+track_current_title,true);
94
+		xmlhttp.send();
95
+		
96
+		onUpdate();
97
+	}
98
+	function onUpdate()
99
+	{
100
+		var xmlhttp;
101
+		xmlhttp=new XMLHttpRequest();
102
+		xmlhttp.onreadystatechange=function()
103
+		{
104
+			if (xmlhttp.readyState==4 && xmlhttp.status==200)
105
+			{
106
+				var is_playing=document.getElementById("playing").innerHTML;
107
+				console.log("onUpdate() : is_playing : ["+is_playing+"]");
108
+				if( is_playing != "false" ) {
109
+					var old_info = document.getElementById("current_track").innerHTML;
110
+					var new_info = xmlhttp.responseText;
111
+					//console.log("onUpdate() : new_info : ["+new_info+"]");
112
+					//Old Info
113
+					if( old_info != "" ) {
114
+						var old_artist =document.getElementById("current_track").getElementsByClassName("radio_artist")[0].innerHTML;
115
+						var old_title =document.getElementById("current_track").getElementsByClassName("radio_title")[0].innerHTML;
116
+						//console.log("onUpdate() : old_artist : ["+old_artist+"]");
117
+						//console.log("onUpdate() : old_title : ["+old_title+"]");
118
+					}
119
+					
120
+					//New Info
121
+					var div = document.createElement("div");
122
+					div.innerHTML = xmlhttp.responseText;
123
+					var new_artist =div.getElementsByClassName("radio_artist")[0].innerHTML;
124
+					var new_title =div.getElementsByClassName("radio_title")[0].innerHTML;
125
+					var new_image_full =div.getElementsByTagName("img")[0].outerHTML;
126
+					var res = new_image_full.match("src=\"(.*)\" width=\"128\" height=\"128\">");
127
+					var new_image = res[1];
128
+					
129
+					//console.log("onUpdate() : new_artist : ["+new_artist+"]");
130
+					//console.log("onUpdate() : new_title : ["+new_title+"]");
131
+					//console.log("onUpdate() : new_image : ["+new_image+"]");
132
+					if( 0 !== strcmp(old_info, new_info)) {
133
+						document.getElementById("current_track").innerHTML=new_info;
134
+					}
135
+					if( ( 0 !== strcmp(old_artist, new_artist) ) ||
136
+						( 0 !== strcmp(old_title, new_title) ) ) {
137
+						console.log("onUpdate() : change detected");
138
+						if (Notification.permission === "granted") {
139
+							var notification=new Notification(new_artist,{body: new_title, icon: new_image });
140
+							setTimeout(function(){
141
+								notification.close(); //closes the notification
142
+							},3000);
143
+						}
144
+					}
145
+				}		
146
+			}
147
+		}
148
+		var track_current_title=document.getElementById("trackinfo").innerHTML;
149
+		xmlhttp.open("GET","onupdate.php?title="+track_current_title,true);
150
+		xmlhttp.send();
151
+	}
152
+	</script>
153
+	<title>Radio</title>
154
+</head>
155
+<body onload="onRefresh()">
156
+<div id="header" class="box">
157
+<div id="image" width="420px" style="display: none;"><img id="coverimage" src="resource/radio-big.png" width="200px" height="200px"></div>
158
+<div id="current_track" style="display: block;"></div>
159
+
160
+<div id="trackinfo" style="display: none;">France Info</div>
161
+<div id="playing" style="display: none;">false</div>
162
+</div>
163
+
164
+<div id="content">
165
+<!-- <div id="basic-playlist" class="flowplayer fixed-controls play-button no-toggle" data-embed="false" data-splash="true" data-loop="true" data-autoplay="true" data-ratio="0.5625" data-fullscreen="false">
166
+<div class="fp-ratio" style="padding-top: 56.25%;"></div> -->
167
+<div id="basic-playlist" class="flowplayer fixed-controls no-toggle astime" data-live="live" data-embed="false" data-splash="true" data-loop="true" data-autoplay="true" data-ratio="0.20" data-fullscreen="false">
168
+<!-- <div id="basic-playlist" class="flowplayer fixed-controls no-toggle astime" data-live="false" data-embed="false" data-splash="true" data-loop="true" data-autoplay="false" data-ratio="0.20" data-fullscreen="false"> -->
169
+<!-- <div id="basic-playlist" class="flowplayer fixed-controls no-toggle no-time" data-live="true" data-embed="false" data-splash="true" data-loop="true" data-autoplay="true" data-ratio="0.20" data-fullscreen="false"> -->
170
+<div class="fp-ratio" style="padding-top: 20%;"></div>
171
+<div class="fp-player">
172
+<video type="audio/mpeg" src="https://files.kawi.fr:8000/finfo64" class="fp-engine"></video>
173
+<a id="id-prev" class="fp-prev" title="prev">&lt;</a>
174
+<a id="id-next" class="fp-next" title="next">&gt;</a>
175
+<div id="fp-playlist" class="fp-playlist">
176
+<?php
177
+$file_contents_playlist=file_get_contents( "playlist.xml" );
178
+$xml = simplexml_load_string($file_contents_playlist);
179
+$json = json_encode($xml);
180
+$array = json_decode($json,TRUE);
181
+$CPTMAX=0;
182
+foreach ( $array as $channel_list )
183
+{
184
+	$cpt = 1;
185
+	foreach ( $channel_list as $channel )
186
+	{
187
+		$cptnice=$cpt;
188
+		if(10>$cpt) {
189
+			$cptnice="0$cpt";
190
+		}
191
+		echo "<ul><li><a id=\"id-item$cptnice\" class=\"item$cptnice\" type=\"audio/mpeg\" href=\"".$channel['mp3']."\" alt=\"".$channel['shortname']."\" title=\"".$channel['shortname']."\">".$channel['title']."</a></li></ul>\n";
192
+		$cpt=$cpt+1;
193
+	}
194
+	$CPTMAX=$cpt;
195
+}
196
+?>
197
+</div>
198
+<div id="download">
199
+	<!-- DO NOTHING HERE -->
200
+</div>
201
+
202
+<script type="text/javascript">
203
+	document.getElementById("id-prev").style.top = "-150px";
204
+	document.getElementById("id-next").style.top = "-150px";
205
+	/* Hack for Mobile */
206
+	if(isTouchDevice()===true) {
207
+		document.getElementById("ul").style.height = "38px";
208
+		document.getElementById("ul").style.fontSize = "24px";
209
+<?php
210
+for( $i = 1; $i < $CPTMAX; $i++ ) {
211
+	$cptnice=$i;
212
+	if(10>$i) {
213
+		$cptnice="0$i";
214
+	}
215
+	echo "\t\tdocument.getElementById(\"id-item$cptnice\").style.height = \"36px\"\n";
216
+	echo "\t\tdocument.getElementById(\"id-item$cptnice\").style.fontSize = \"24px\"\n";
217
+}
218
+?>
219
+	}
220
+</script>
221
+	
222
+<div id="trackinfo_full"></div>
223
+<script type="text/javascript">
224
+/* Hack for Mobile */
225
+if(isTouchDevice()===true) {
226
+	document.getElementById("trackinfo_full").style.width = "410px";
227
+}
228
+</script>
229
+<div id="list"><img src="resource/loading.gif" width="100px" align="center"></div>
230
+<!-- <div id="list">Loading Metadatas...</div> -->
231
+</body>
232
+</html>
+323
json.php
... ...
@@ -0,0 +1,323 @@
1
+<?php 
2
+//Set $DEBUG to 1 at the end of the file to enable JSON debug
3
+    
4
+function get_fipradio_tags() {
5
+	$metadata = array();
6
+	$jsondata=file_get_contents("http://www.fipradio.fr/sites/default/files/import_si/si_titre_antenne/FIP_player_current.json");
7
+	$array_json = json_decode($jsondata,TRUE);
8
+	$fipradio_artist = "An Error Occured";
9
+	$fipradio_title = "An Error Occured";
10
+	$fipradio_url = "";
11
+	if( isset($array_json["current"]["song"]) ) {
12
+		$fipradio_title=$array_json["current"]["song"]["titre"];
13
+		if( isset($array_json["current"]["song"]["interpreteMorceau"]) ) {
14
+			$fipradio_artist=$array_json["current"]["song"]["interpreteMorceau"];
15
+		}
16
+		$fipradio_url=$array_json["current"]["song"]["visuel"]["small"];
17
+	}
18
+	$metadata[0]=$fipradio_artist;
19
+	$metadata[1]=$fipradio_title;
20
+	$metadata[2]=$fipradio_url;
21
+	return $metadata; 
22
+}
23
+
24
+function get_lemouv_tags() {
25
+	$metadata = array();
26
+	//~ $jsondata=file_get_contents("http://www.lemouv.fr/sites/default/files/direct.json");
27
+	$jsondata=file_get_contents("http://www.mouv.fr/sites/default/files/import_si/si_titre_antenne/leMouv_player_current.json");
28
+	//~ echo "[$jsondata]<br>\n";
29
+	$array_json = json_decode($jsondata,TRUE);
30
+	//~ $lemouv_title=$array_json["rf_titre_antenne"]["titre"];
31
+	//~ $lemouv_artist=$array_json["rf_titre_antenne"]["interprete"];
32
+	//~ $lemouv_url=$array_json["rf_titre_antenne"]["image"];
33
+	$lemouv_title=$array_json["current"]["emission"]["titre"];
34
+	$lemouv_artist=$array_json["current"]["emission"]["lien"];
35
+	$lemouv_url=$array_json["current"]["emission"]["visuel"]["small"];
36
+	//~ echo "[DEBUG] lemouv_title : [$lemouv_title]<br>\n";
37
+	//~ echo "[DEBUG] lemouv_artist : [$lemouv_artist]<br>\n";
38
+	//~ echo "[DEBUG] lemouv_url : [$lemouv_url]<br>\n";
39
+	if( 0 == strcmp("null",$lemouv_title) )
40
+	{
41
+		$lemouv_title = "An Error Occured";
42
+	}
43
+	if( 0 == strcmp("null",$lemouv_artist) )
44
+	{
45
+		$lemouv_artist = "An Error Occured";
46
+	}
47
+	if( 0 == strcmp("null",$lemouv_url) )
48
+	{
49
+		$lemouv_url = "";
50
+	}
51
+	$metadata[0]=$lemouv_artist;
52
+	$metadata[1]=$lemouv_title;
53
+	$metadata[2]=$lemouv_url;
54
+	return $metadata; 
55
+}
56
+
57
+function get_fculture_tags() {
58
+	$metadata = array();
59
+	$epochLocal = time();
60
+	$jsondata=file_get_contents("http://www.franceculture.fr/programmes?xmlHttpRequest=1");
61
+	$array_json = json_decode($jsondata,TRUE);
62
+	$i = 0;
63
+	$fculture_artist="An Error Occured";
64
+	$fculture_title="An Error Occured";
65
+	$metadata[0]=$fculture_artist;
66
+	$metadata[1]=$fculture_title;
67
+	while( isset($array_json[$i]) ) {
68
+		$time_start=$array_json[$i]["start"];
69
+		$time_stop=$array_json[$i]["end"];	
70
+		if( ( $time_start <= $epochLocal ) &&
71
+      ( $time_stop >= $epochLocal ) ) {
72
+        if( isset($array_json[$i]["surtitle"])) {
73
+          $fculture_artist=$array_json[$i]["surtitle"];
74
+        }
75
+        if( isset($array_json[$i]["surtitle"])) {
76
+				  $fculture_title=$array_json[$i]["title"];
77
+        }
78
+        $metadata[0]=$fculture_artist;
79
+				$metadata[1]=$fculture_title;
80
+		}
81
+		$i++;
82
+	}
83
+	return $metadata; 
84
+}
85
+
86
+function get_finter_tags() {
87
+	$metadata = array();
88
+	$epochts=time();
89
+	$epochLocal = $epochts;
90
+	$modSeconds=$epochts % 3600;
91
+	$modHours = $epochts / 3600 % 24;
92
+	$epochts=$epochts - $modHours*3600 - $modSeconds - 7200;
93
+	$finter_artist="An Error Occured";
94
+	$finter_title="An Error Occured";
95
+	//$jsondata=file_get_contents("http://www.franceinter.fr/sites/default/files/conducteur/direct_$epochts.json");
96
+	$jsondata=false;
97
+	if( false === $jsondata ) {
98
+		$metadata[0]=$finter_artist;
99
+		$metadata[1]=$finter_title;
100
+		return $metadata;
101
+	}
102
+	$array_json = json_decode($jsondata,TRUE);
103
+	$i = 0;
104
+	while( isset($array_json[$i]) ) {
105
+		$time_start=$array_json[$i]["date_debut"];
106
+		$time_stop=$array_json[$i]["date_fin"];
107
+		if( ( $time_start <= $epochLocal ) &&
108
+			( $time_stop >= $epochLocal ) ) {
109
+				$finter_title=$array_json[$i]["titre_diffusion"];
110
+				$finter_artist=$array_json[$i]["titre_emission"];
111
+				$metadata[0]=$finter_artist;
112
+				$metadata[1]=$finter_title;
113
+		}
114
+		$i++;
115
+	}
116
+	return $metadata; 
117
+}
118
+
119
+function get_fmusique_tags() {
120
+  $metadata = array();
121
+  /*
122
+	$epochts=time();
123
+	//~ echo "[DEBUG] epochts_org : $epochts<br>\n";
124
+	$modSeconds=$epochts % 3600;
125
+	$epochts=$epochts + 7*3600 + 3600 - $modSeconds;
126
+	//~ echo "[DEBUG] epochts : $epochts<br>\n";
127
+	$jsondata=file_get_contents("http://www.francemusique.fr/sites/default/files/lecteur_commun_json/reecoute-$epochts.json");
128
+	$array_json = json_decode($jsondata,TRUE);
129
+	$fmusique_title=$array_json["diffusions"][0]["title_diff"];
130
+  $fmusique_artist=$array_json["diffusions"][0]["title_emission"];
131
+   */
132
+	$fmusique_artist = "An Error Occured";
133
+	$fmusique_title = "An Error Occured";
134
+	$metadata[0]=$fmusique_artist;
135
+	$metadata[1]=$fmusique_title;
136
+	return $metadata; 
137
+}
138
+
139
+function get_classic21_tags() {
140
+	$currDate = time();
141
+	$fake_json_data=file_get_contents("http://np.maradio.be/qp/v3/events?rpId=2&serviceNameSize=200&nameSize=200&artistNameSize=200&descriptionSize=200&callback=radioplayer.playing.receive&_=".$currDate );
142
+	$pos_start = strlen("radioplayer.playing.receive(");
143
+	$pos_end = strlen( $fake_json_data ) - 1;
144
+	$jsondata = substr($fake_json_data, $pos_start, $pos_end - $pos_start );
145
+	$array_json = json_decode($jsondata,TRUE);
146
+	$classic21_artist = "An Error Occured";
147
+	$classic21_title = "An Error Occured";
148
+	$classic21_url = "";
149
+	if( isset($array_json["results"]["now"]["name"]) ) {
150
+		$classic21_title=$array_json["results"]["now"]["name"];
151
+	}
152
+	if( isset($array_json["results"]["now"]["artistName"]) ) {
153
+		$classic21_artist=$array_json["results"]["now"]["artistName"];
154
+	}
155
+	$classic21_url=$array_json["results"]["now"]["imageUrl"];
156
+	$metadata[0]=$classic21_artist;
157
+	$metadata[1]=$classic21_title;
158
+	$metadata[2]=$classic21_url;
159
+	return $metadata; 
160
+}
161
+
162
+function get_lgr_rock_url() {
163
+	$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
164
+	$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
165
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
166
+	if( false !== $pos_start ) {
167
+		$SEARCHSUB='" width="80" height="80"';
168
+		$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
169
+		//30 = strlen('<img class="border_gris" src="');
170
+		$url = substr($htmldata, $pos_start+30, $pos_stop - $pos_start - 30 );
171
+		return $url;
172
+	}
173
+	return "";
174
+}
175
+
176
+function get_lgr_metal_url() {
177
+	$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
178
+	$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
179
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
180
+	if( false !== $pos_start ) {
181
+		$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/art_pochettes/';
182
+		$pos_start2 = strpos($htmldata, $SEARCHSUB, $pos_start+strlen($SEARCHSUB) );
183
+		if( false !== $pos_start2 ) {
184
+			$SEARCHSUB='" width="80" height="80"';
185
+			$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start2 );
186
+			//30 = strlen('<img class="border_gris" src="');
187
+			$url = substr($htmldata, $pos_start2+30, $pos_stop - $pos_start2 - 30 );
188
+			return $url;
189
+		}
190
+	}
191
+	return "";
192
+}
193
+
194
+function get_lgr_reggae_url() {
195
+	$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
196
+	$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
197
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
198
+	if( false !== $pos_start ) {
199
+		$pos_start2 = strpos($htmldata, $SEARCHSUB, $pos_start+strlen($SEARCHSUB) );
200
+		if( false !== $pos_start2 ) {
201
+			$pos_start3 = strpos($htmldata, $SEARCHSUB, $pos_start2+strlen($SEARCHSUB) );
202
+			if( false !== $pos_start3 ) {
203
+				$SEARCHSUB='" width="80" height="80"';
204
+				$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start3 );
205
+				//30 = strlen('<img class="border_gris" src="');
206
+				$url = substr($htmldata, $pos_start3+30, $pos_stop - $pos_start3 - 30 );
207
+				return $url;
208
+			}
209
+		}
210
+	}
211
+	return "";
212
+}
213
+
214
+function get_radio_nova_tags() {
215
+	$metadata = array();
216
+	$radio_nova_artist = "An Error Occured";
217
+	$radio_nova_title = "An Error Occured";
218
+	$radio_nova_url = "";
219
+	$jsondata=file_get_contents("http://www.novaplanet.com/radionova/ontheair");
220
+	$array_json = json_decode($jsondata,TRUE);
221
+	$htmldata=$array_json['track']['markup'];
222
+
223
+	//title
224
+	$SEARCHSUB='<div class="title">';
225
+	//19 = strlen($SEARCHSUB);
226
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
227
+	if( false !== $pos_start ) {
228
+		$SEARCHSUB='</div>';
229
+		$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
230
+		
231
+		$radio_nova_title = substr($htmldata, $pos_start+19, $pos_stop - $pos_start - 19 );
232
+	}
233
+
234
+	//artist
235
+	$SEARCHSUB='<div class="artist">';
236
+	//20 = strlen($SEARCHSUB);
237
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
238
+	if( false !== $pos_start ) {
239
+		$SEARCHSUB='</div>';
240
+		$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
241
+		
242
+		$radio_nova_artist = substr($htmldata, $pos_start+20, $pos_stop - $pos_start - 20 );
243
+		$pattern = '<a href';
244
+		if (preg_match("/<a href/", $radio_nova_artist)) {
245
+			$SEARCHSUB='>      ';
246
+			$pos_start = strpos($radio_nova_artist, $SEARCHSUB, 0 );
247
+			if( false !== $pos_start ) {
248
+				$SEARCHSUB='    </a>';
249
+				$pos_stop = strpos($radio_nova_artist, $SEARCHSUB, $pos_start );
250
+				$radio_nova_artist = substr($radio_nova_artist, $pos_start+7, $pos_stop - $pos_start - 7 );
251
+			}
252
+		}
253
+		echo "<br>\n";
254
+	}
255
+	
256
+	//url
257
+	$SEARCHSUB='<img src="';
258
+	//10 = strlen($SEARCHSUB);
259
+	$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
260
+	if( false !== $pos_start ) {
261
+		$SEARCHSUB = '" alt="" title="" width="84"';
262
+		$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
263
+		$radio_nova_url = substr($htmldata, $pos_start+10, $pos_stop - $pos_start - 10 );
264
+	}
265
+	$metadata[0]=$radio_nova_artist;
266
+	$metadata[1]=$radio_nova_title;
267
+	$metadata[2]=$radio_nova_url;
268
+	return $metadata; 
269
+}
270
+
271
+$DEBUG=0;
272
+if( $DEBUG != 0 )
273
+{
274
+	$tags = array();
275
+	$tags = get_fipradio_tags();
276
+	echo "[DEBUG] fipradio<br>\n";
277
+	echo "[DEBUG] artist : $tags[0]<br>\n";
278
+	echo "[DEBUG] title  : $tags[1]<br>\n";
279
+	echo "[DEBUG] url    : $tags[2]<br>\n";
280
+	echo "<br>\n";
281
+	$tags = get_lemouv_tags();
282
+	echo "[DEBUG] lemouv<br>\n";
283
+	echo "[DEBUG] artist : $tags[0]<br>\n";
284
+	echo "[DEBUG] title  : $tags[1]<br>\n";
285
+	echo "[DEBUG] url    : $tags[2]<br>\n";
286
+	echo "<br>\n";
287
+	$tags = get_fculture_tags();
288
+	echo "[DEBUG] fculture<br>\n";
289
+	echo "[DEBUG] artist : $tags[0]<br>\n";
290
+	echo "[DEBUG] title  : $tags[1]<br>\n";
291
+	echo "<br>\n";
292
+	$tags = get_finter_tags();
293
+	echo "[DEBUG] finter<br>\n";
294
+	echo "[DEBUG] artist : $tags[0]<br>\n";
295
+	echo "[DEBUG] title  : $tags[1]<br>\n";
296
+	echo "<br>\n";
297
+	$tags = get_fmusique_tags();
298
+	echo "[DEBUG] fmusique<br>\n";
299
+	echo "[DEBUG] artist : $tags[0]<br>\n";
300
+	echo "[DEBUG] title  : $tags[1]<br>\n";
301
+	echo "<br>\n";
302
+	$tags = get_classic21_tags();
303
+	echo "[DEBUG] classic21<br>\n";
304
+	echo "[DEBUG] artist : $tags[0]<br>\n";
305
+	echo "[DEBUG] title  : $tags[1]<br>\n";
306
+	echo "<br>\n";
307
+	$url = get_lgr_rock_url();
308
+	echo "[DEBUG] lgrrock : $url<br>\n";
309
+	echo "<br>\n";
310
+	$url = get_lgr_metal_url();
311
+	echo "[DEBUG] lgrmetal : $url<br>\n";
312
+	echo "<br>\n";
313
+	$url = get_lgr_reggae_url();
314
+	echo "[DEBUG] lgrreggae : $url<br>\n";
315
+	echo "<br>\n";
316
+	$tags = get_radio_nova_tags();
317
+	echo "[DEBUG] radio_nova<br>\n";
318
+	echo "[DEBUG] artist : $tags[0]<br>\n";
319
+	echo "[DEBUG] title  : $tags[1]<br>\n";
320
+	echo "[DEBUG] url    : $tags[2]<br>\n";
321
+	echo time();
322
+}
323
+?>
+121
onrefresh.php
... ...
@@ -0,0 +1,121 @@
1
+<html>
2
+<head>
3
+	<link rel="stylesheet" type="text/css" href="style.css" />
4
+</head>
5
+<body>
6
+<?php
7
+require_once('sentences.php');
8
+
9
+function print_radio_details($name, $artist, $title, $url, $big = true )
10
+{
11
+	$SIZE=40;
12
+	$MAX_LEN_STR_ARTIST=26;
13
+	$MAX_LEN_STR=28;
14
+	$now_playing = "Make your choice";
15
+	if(isset($_GET["title"]) ) {
16
+		$now_playing = $_GET["title"];
17
+	}
18
+	$artist=sentence_case($artist);
19
+	$title=sentence_case($title);
20
+	$org_artist=$artist;
21
+	$org_title=$title;
22
+	if( $MAX_LEN_STR_ARTIST < strlen($artist) )
23
+	{
24
+		$artist=substr($artist,0,$MAX_LEN_STR_ARTIST);
25
+		$artist.="...";
26
+	}
27
+	if( $MAX_LEN_STR < strlen($title) )
28
+	{
29
+		$title=substr($title,0,$MAX_LEN_STR);
30
+		$title.="...";
31
+	}
32
+	if( true === $big )
33
+	{
34
+		echo "<div class=\"radio_box_list\">\n";
35
+	}
36
+	else
37
+	{
38
+		echo "<div class=\"radio_box_list_compact\">\n";
39
+  }
40
+  $enc_artist=urlencode($org_artist);
41
+  $enc_title=urlencode($org_title);
42
+  $search_details="<a href=\"https://www.qwant.com/?r=music&q=$enc_artist+$enc_title\" target=\"new-$name\"><img src=\"qwant.ico\" alt=\"?\" title=\"search Qwant\" width=\"10px\" height=\"10px\"></a>";
43
+	if( $now_playing == $name )
44
+	{
45
+		echo "\t<div class=\"radio_name_list_active\" id=\"$name\">$name&nbsp;$search_details</div>\n";
46
+		$active_artist=$artist;
47
+		$active_title=$title;
48
+		$active_url=$url;
49
+	}
50
+	else
51
+	{
52
+		echo "\t<div class=\"radio_name_list\" id=\"$name\">$name&nbsp;$search_details</div>\n";
53
+	}
54
+	if( true === $big )
55
+	{
56
+		echo "\t<div class=\"radio_url_list\"><img src=\"$url\" width=\"$SIZE\" height=\"$SIZE\"></div>\n";
57
+	}
58
+	if( ( "" != $artist ) && ( "unknown" != $artist ) && ( "An Error Occured" != $artist ) )
59
+	{
60
+		echo "\t<div class=\"radio_artist_list\">$artist</div>\n";
61
+	}
62
+	else
63
+	{
64
+		echo "\t<div class=\"radio_artist_list\"></div>\n";
65
+  }
66
+	if( ( "" != $title ) && ( "unknown" != $title ) && ( "An Error Occured" != $title ) )
67
+	{
68
+		echo "\t<div class=\"radio_title_list\">$title</div>\n";
69
+	}
70
+	else
71
+	{
72
+		echo "\t<div class=\"radio_title_list\"></div>\n";
73
+	}
74
+	echo "\t<div class=\"radio_add\"></div>\n";
75
+	echo "</div>\n";
76
+}
77
+
78
+echo "<table>\n";
79
+$file_contents_playlist=file_get_contents( "tags.xml" );
80
+$xml = simplexml_load_string($file_contents_playlist);
81
+$json = json_encode($xml);
82
+$array = json_decode($json,TRUE);
83
+$CPTMAX=0;
84
+if( is_array($array) ){
85
+foreach ( $array as $channel_list )
86
+{
87
+	$cpt=0;
88
+	foreach ( $channel_list as $channel )
89
+	{
90
+			if( 0 == ($cpt%4)) {
91
+				echo "<tr>\n<td>\n";
92
+			}
93
+			if(isset($channel['track_url']) ) {
94
+			$url_image=$channel['track_url'];
95
+			if( true === is_array($url_image) ) {
96
+					$url_image="resource/".$channel['shortname'].".jpg";
97
+			} else {
98
+				$ext=substr($url_image,strlen($url_image)-3);
99
+				if( ("jpg" != $ext) && ( "png" != $ext ) ) {
100
+					$url_image="resource/".$channel['shortname'].".jpg";
101
+				}
102
+			}
103
+			print_radio_details($channel['title'], $channel['track_artist'], $channel['track_title'], $url_image, true );
104
+			echo "</td><td>\n";
105
+			if( 3 == ($cpt%4)) {
106
+				echo "</td>\n</tr>\n";
107
+			}
108
+			}/* else {
109
+				print_radio_details("error", "error", "error", "", true);
110
+			}*/
111
+			$cpt++;
112
+	}
113
+}
114
+}else{
115
+  echo "Erreur";
116
+}
117
+echo "</table>\n";
118
+?>
119
+</body>
120
+</html>
121
+
+123
onupdate.php
... ...
@@ -0,0 +1,123 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="style.css" />
5
+</head>
6
+<body>
7
+<?php
8
+require_once('sentences.php');
9
+$active_artist="";
10
+$active_title="";
11
+$active_url="resource/radio-big.png";
12
+
13
+function print_radio_details($name, $artist, $title, $url, $big = true )
14
+{
15
+	$SIZE=40;
16
+	$MAX_LEN_STR_ARTIST=26;
17
+	$MAX_LEN_STR=28;
18
+	$now_playing = $_GET["title"];
19
+	$artist=sentence_case($artist);
20
+	$title=sentence_case($title);
21
+	if( $MAX_LEN_STR_ARTIST < strlen($artist) )
22
+	{
23
+		$artist=substr($artist,0,$MAX_LEN_STR_ARTIST);
24
+		$artist.="...";
25
+	}
26
+	if( $MAX_LEN_STR < strlen($title) )
27
+	{
28
+		$title=substr($title,0,$MAX_LEN_STR);
29
+		$title.="...";
30
+	}
31
+	if( true === $big )
32
+	{
33
+		echo "<div class=\"radio_box_list\">\n";
34
+	}
35
+	else
36
+	{
37
+		echo "<div class=\"radio_box_list_compact\">\n";
38
+	}
39
+	if( $now_playing == $name )
40
+	{
41
+		echo "\t<div class=\"radio_name_list_active\" id=\"$name\">$name</div>\n";
42
+		$active_artist=$artist;
43
+		$active_title=$title;
44
+		$active_url=$url;
45
+	}
46
+	else
47
+	{
48
+		echo "\t<div class=\"radio_name_list\" id=\"$name\">$name</div>\n";
49
+	}
50
+	if( true === $big )
51
+	{
52
+		echo "\t<div class=\"radio_url_list\"><img src=\"$url\" width=\"$SIZE\" height=\"$SIZE\"></div>\n";
53
+	}
54
+	echo "\t<div class=\"radio_artist_list\">$artist</div>\n";
55
+	if( ( "" != $title ) && ( "unknown" != $title ) && ( "An Error Occured" != $title ) )
56
+	{
57
+		echo "\t<div class=\"radio_title_list\">$title</div>\n";
58
+	}
59
+	else
60
+	{
61
+		echo "\t<div class=\"radio_title_list\"></div>\n";
62
+	}
63
+	echo "\t<div class=\"radio_add\"></div>\n";
64
+	echo "</div>\n";
65
+}
66
+
67
+$file_contents_playlist=file_get_contents( "tags.xml" );
68
+$xml = simplexml_load_string($file_contents_playlist);
69
+$json = json_encode($xml);
70
+$array = json_decode($json,TRUE);
71
+$CPTMAX=0;
72
+$now_playing = $_GET["title"];
73
+$SIZE=128;
74
+$active_artist="";
75
+$active_title="";
76
+$active_url="resource/radio-big.png";
77
+if( is_array($array)) {
78
+foreach ( $array as $channel_list )
79
+{
80
+	$cpt=0;
81
+	foreach ( $channel_list as $channel )
82
+	{
83
+			if( $now_playing == $channel['title'] ) {
84
+				$url_image=$channel['track_url'];
85
+				if( true === is_array($url_image) ) {
86
+						$url_image="resource/".$channel['shortname'].".jpg";
87
+				} else {
88
+					$ext=substr($url_image,strlen($url_image)-3);
89
+					if( ("jpg" != $ext) && ( "png" != $ext ) ) {
90
+						$url_image="resource/".$channel['shortname'].".jpg";
91
+					}
92
+				}
93
+				$active_artist=$channel['track_artist'];
94
+				$active_title=$channel['track_title'];
95
+				if( ( "unknown" == $channel['track_artist'] ) ||
96
+					( "An Error Occured" == $channel['track_artist'] ) ) {
97
+					$active_artist = $channel['title'];
98
+				}
99
+				if( ( "unknown" == $channel['track_title'] ) ||
100
+					( "An Error Occured" == $channel['track_title'] ) ) {
101
+					$active_title = "";
102
+				}
103
+				$active_artist=sentence_case($active_artist);
104
+				$active_title=sentence_case($active_title);
105
+				echo "<table><tr>\n";
106
+				echo "<td><div class=\"radio_url\"><img src=\"".$url_image."\" width=\"".$SIZE."\" height=\"".$SIZE."\"></div></td>";
107
+				echo "<td>\n";
108
+				echo "<div class=\"radio_artist\">".$active_artist."</div>\n";
109
+				echo "<div class=\"radio_title\">".$active_title."</div>\n";
110
+				echo "</td>\n";
111
+				echo "</tr></table>\n";
112
+				exit;
113
+			}
114
+			$cpt++;
115
+	}
116
+}
117
+} else {
118
+  echo "Erreur"; 
119
+}
120
+?>
121
+</body>
122
+</html>
123
+
+24
sentences.php
... ...
@@ -0,0 +1,24 @@
1
+<?php
2
+function clean_string($string)
3
+{
4
+	$search = array('\\','u00e9','u00e0', 'u00e8', 'u20ac', 'U00e9', 'U00e0', 'U00c9', 'U00b0', 'u2019', 'U2019', 'u00ea', 'u00ea', 'u00e2', '    U00e2', 'u00f4', 'U00f4');
5
+	$replace = array( '', 'e', 'a', 'e', 'e', 'e', 'a', 'e', '°', "'", "'", 'e', 'e', 'a', 'a', 'o', 'o' );
6
+	$substring = str_replace($search, $replace, $string);
7
+	return $substring;
8
+}
9
+
10
+function sentence_case($string) { 
11
+  if( !is_string($string) )
12
+    return "";
13
+	$sentences = preg_split('/([.?!]+)/', $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE); 
14
+  $new_string = ''; 
15
+  if( is_array($sentences)) {
16
+  	foreach ($sentences as $key => $sentence) { 
17
+  		$new_string .= ($key & 1) == 0? 
18
+  		ucwords(mb_strtolower(trim($sentence))) : 
19
+  		$sentence.' '; 
20
+    } 
21
+  }
22
+	return trim($new_string); 
23
+} 
24
+?>
+165
shoutcast.php
... ...
@@ -0,0 +1,165 @@
1
+<?php
2
+
3
+function get_shoutcast_tags($string) {
4
+	$headers = array();
5
+	$metadata = array();
6
+	$useragent = 'Winamp 2.81';
7
+	$t = parse_url($string);
8
+    $sock = fsockopen($t['host'], $t['port'], $errno, $errstr, 5);
9
+    $path = isset($t['path'])?$t['path']:'/';
10
+    if ($sock){
11
+		$request = 'GET '.$path.' HTTP/1.0'."\r\n".
12
+            'Host: '.$t['host']."\r\n".
13
+            'Connection: Close'."\r\n". 
14
+            'User-Agent: '.$useragent."\r\n".
15
+            'Accept: */*'."\r\n".
16
+            'icy-metadata: 1'."\r\n".
17
+            'icy-prebuffer: 65536'."\r\n\r\n";
18
+		if (fwrite($sock, $request)){
19
+            $theaders = $line = '';
20
+            $count=0;
21
+
22
+            while (!feof($sock)){ 
23
+                $line = fgets($sock, 4096); 
24
+                $count += strlen($line);
25
+                //~ echo ". ";
26
+                if('' == trim($line)){
27
+                    break;
28
+                }                
29
+                $theaders .= $line;
30
+            }
31
+			$theaders = explode("\r\n", $theaders);
32
+            foreach ($theaders as $header){
33
+                $t = explode(':', $header); 
34
+                if (isset($t[0]) && trim($t[0]) != ''){
35
+                    $name = preg_replace('/[^a-z][^a-z0-9]*/i','', strtolower(trim($t[0])));
36
+                    array_shift($t);
37
+                    $value = trim(implode(':', $t));
38
+                    if ($value != ''){
39
+                        if (is_numeric($value)){
40
+                            $headers[$name] = (int)$value;
41
+                        }else{
42
+                            $headers[$name] = $value;
43
+                        }
44
+                    }
45
+                }
46
+            }
47
+            if (!isset($headers['icymetaint'])){
48
+                $data = ''; $metainterval = 512;
49
+                while(!feof($sock)){
50
+                    $data .= fgetc($sock);
51
+                    if (strlen($data) >= $metainterval) break;
52
+                }
53
+				        //print_data($data);
54
+                $matches = array();
55
+                preg_match_all('/([\x00-\xff]{2})\x0\x0([a-z]+)=/i', $data, $matches, PREG_OFFSET_CAPTURE);
56
+				preg_match_all('/([a-z]+)=([a-z0-9\(\)\[\]., ]+)/i', $data, $matches, PREG_SPLIT_NO_EMPTY);
57
+                $title = $artist = '';
58
+                foreach ($matches[0] as $nr => $values){
59
+                  $offset = $values[1];
60
+                  $length = ord($values[0]{0}) + 
61
+                            (ord($values[0]{1}) * 256)+ 
62
+                            (ord($values[0]{2}) * 256*256)+ 
63
+                            (ord($values[0]{3}) * 256*256*256);
64
+                  $info = substr($data, $offset + 4, $length);
65
+                  $seperator = strpos($info, '=');
66
+                  $metadata[substr($info, 0, $seperator)] = substr($info, $seperator + 1);
67
+                    if (substr($info, 0, $seperator) == 'title') $title = substr($info, $seperator + 1);
68
+                    if (substr($info, 0, $seperator) == 'artist') $artist = substr($info, $seperator + 1);
69
+                }
70
+                $metadata['streamtitle'] = $artist . ' - ' . $title;
71
+            }else{
72
+                $metainterval = $headers['icymetaint'];
73
+                $intervals = 0;
74
+                $metadata = '';
75
+                while(1){
76
+                    $data = '';
77
+                    while(!feof($sock)){
78
+                        $data .= fgetc($sock);
79
+                        if (strlen($data) >= $metainterval) break;
80
+                    }
81
+                    //print_data($data);
82
+                    //~ $len = join(unpack('c', fgetc($sock))) * 16;
83
+                    $len = @join(@unpack('c', fgetc($sock))) * 16;
84
+                    if ($len > 0){
85
+                        $metadata = str_replace("\0", '', fread($sock, $len));
86
+                        break;
87
+                    }else{
88
+                        $intervals++;
89
+                        if ($intervals > 100) break;
90
+                    }
91
+                }
92
+                $metarr = explode(';', $metadata);
93
+                foreach ($metarr as $meta){
94
+					$pos_StreamTitle = strpos($meta, "StreamTitle=", 0 );
95
+					if( 0 === $pos_StreamTitle )
96
+					{
97
+						$t = explode('=', $meta);
98
+						if (isset($t[0]) && trim($t[0]) != ''){
99
+							$name = preg_replace('/[^a-z][^a-z0-9]*/i','', strtolower(trim($t[0])));
100
+							array_shift($t);
101
+							$value = trim(implode('=', $t));
102
+							if (substr($value, 0, 1) == '"' || substr($value, 0, 1) == "'"){
103
+								$value = substr($value, 1);
104
+							}
105
+							if (substr($value, -1) == '"' || substr($value, -1) == "'"){
106
+								$value = substr($value, 0, -1);
107
+							}
108
+							if ($value != ''){		
109
+								$valuearr = explode(' - ', $value);
110
+								return $valuearr;
111
+							}
112
+						}
113
+					}
114
+                }
115
+            }
116
+            fclose($sock);
117
+		}
118
+
119
+	} else {
120
+		$metadata[0]='An Error Occured';
121
+		$metadata[1]=$errstr;
122
+		return $metadata;
123
+	}
124
+}
125
+
126
+function print_data($data){
127
+    $data = str_split($data);
128
+    $c = 0;
129
+    $string = '';
130
+    echo "<pre>\n000000 ";
131
+    foreach ($data as $char){
132
+        $string .= addcslashes($char, "\n\r\0\t");
133
+        $hex = dechex(join(unpack('C', $char)));
134
+        if ($c % 4 == 0) echo ' ';
135
+        if ($c % (4*4) == 0 && $c != 0){
136
+          foreach (str_split($string) as $s){
137
+            //echo " $string\n";
138
+            if (ord($s) < 32 || ord($s) > 126){
139
+              echo '\\'.ord($s);
140
+            }else{
141
+              echo $s;
142
+            }
143
+          }
144
+          echo "\n";
145
+          $string = '';
146
+          echo str_pad($c, 6, '0', STR_PAD_LEFT).'  ';
147
+        }
148
+        if (strlen($hex) < 1) $hex = '00';
149
+        if (strlen($hex) < 2) $hex = '0'.$hex;
150
+          echo $hex.' ';
151
+        $c++;
152
+    }
153
+    echo "  $string\n</pre>";
154
+}
155
+
156
+$DEBUG=0;
157
+if( $DEBUG != 0 )
158
+{
159
+	$STREAMURL="http://67.212.163.150:80/;stream.nsv";
160
+	echo "[DEBUG] stream : $STREAMURL<br>\n";
161
+	clean_string('http://str45.streamakaci.com:8014/;895614762790501stream.nsv');
162
+	$tags = array();
163
+	$tags = get_shoutcast_tags($STREAMURL);
164
+}
165
+?>