forked from ABroadcasting/streamingplayer
/
parser.php
102 lines (70 loc) · 2.82 KB
/
parser.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
<?php
session_start();
//Icecast stats.xml parser
include_once('channel.conf');
class Icestat {
private $xml = array();
private $stat = array();
var $current = array();
function getfile($user, $pass, $serv, $port) {
$url = "http://".$user.":".$pass."@".$serv.":".$port."/admin/stats.xml";
$this->xml = simplexml_load_file($url);
}
function parsefile() {
$mcount = count($this->xml->source);
for ($i=0; $i<$mcount; $i++) {
foreach ($this->xml->source as $arr) {
$mnt=str_replace("/","",$arr['mount']);
$this->stat[$mnt]['mount_name'] = $mnt;
$this->stat[$mnt]['audio_info'] = $arr->audio_info;
$this->stat[$mnt]['bitrate'] = $arr->bitrate;
$this->stat[$mnt]['genre'] = $arr->genre;
$this->stat[$mnt]['listener_peak'] = $arr->listener_peak;
$this->stat[$mnt]['listeners'] = $arr->listeners;
$this->stat[$mnt]['max_listeners'] = $arr->max_listeners;
$this->stat[$mnt]['server_description'] = $arr->server_description;
$this->stat[$mnt]['server_name'] = $arr->server_name;
$this->stat[$mnt]['title'] = $arr->title;
}
}
return $this->current;
}
function currentmount() {
require('channel.conf');
if (!$this->stat[$stream_mount]['audio_info']) {
$this->current = $this->stat[$stream_nonstop];
} else {
$this->current = $this->stat[$stream_mount];
}
$this->stat = 0;
}
function printcurrent() {
//Output data (+ design if you need). You can change it as you wish
print "
<nowrap>
Active mount: ".$this->current['mount_name']."<br />
Mount name: ".$this->current['server_name']."<br />
Mount description: ".$this->current['server_description']."<br />
Now playing: ".$this->current['title']."<br />";
if (!$this->current['bitrate']) {
print "
Bitrate: 96 Kb/s<br />";
} else {
print "
Bitrate: ".$this->current['bitrate']." Kb/s<br />";
}
print "
Listeners: ".$this->current['listeners']."<br />
Listeners peak: ".$this->current['listener_peak']."
</nowrap>";
}
}
//Directly output
$output = new Icestat;
$output->getfile($stream_admin, $stream_password, $stream_server, $stream_port);
$output->parsefile();
//$output->currentmount();
//$output->printcurrent();
//echo $output->current['title'];
//End of file
?>