-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.php
144 lines (125 loc) · 5.04 KB
/
index.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
<?php
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
require('sslib.php');
$server = $_GET['server'];
$servers = GetServerList();
if(!file_exists(SS_PATH_GFX))
mkdir(SS_PATH_GFX,0777);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<?php if (strlen($server)) : ?>
<title>Shoutstats for <?php echo SS_NAME?> - <?php echo $server?></title>
<?php else: ?>
<title>Shoutstats for <?php echo SS_NAME?></title>
<?php endif; ?>
<meta http-equiv="refresh" content="300" />
<link rel="stylesheet" href="shoutstats.css" type="text/css" media="screen" />
</head>
<body>
<h1>Shoutstats for <?php echo SS_NAME?></h1>
<form action="<?php echo basename($SCRIPT_FILENAME)?>" method="get">
<fieldset>
<legend>Shoutstats Server Selection</legend>
<label for="server">Show statistics for</label>
<select name="server" id="server">
<option value="">All servers together</option>
<?php
// combobox items generation of a list of server
foreach ($servers as $c_name => $c_server)
{
if ($c_name == $server) : ?>
<option value="<?php echo $c_name?>" selected><?php echo $c_name?> (<?php echo $servers[$c_name]['type']?>)</option>
<?php else: ?>
<option value="<?php echo $c_name?>"><?php echo $c_name?> (<?php echo $servers[$c_name]['type']?>)</option>
<?php endif;
}
?>
</select>
<input type="submit" value="Select" />
</fieldset>
</form>
<?php
// a specific server has been selected
if(strlen($server)):
if($servers[$server]['type']=='icecast') $mp=".".$servers[$server]['mpoint'];
// generate and display the 24 hours server specific graph
$txt_freq = 'hourly';
$rrdgfx=SS_PATH_GFX."/hourly-{$servers[$server]['host']}.{$servers[$server]['port']}{$mp}.png";
$rrdfile=SS_PATH_RRD."/{$servers[$server]['host']}.{$servers[$server]['port']}{$mp}.rrd";
exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 7 days server specific graph
$txt_freq = 'daily';
$rrdgfx=SS_PATH_GFX."/daily-{$servers[$server]['host']}.{$servers[$server]['port']}{$mp}.png";
exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1w DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 5 weeks server specific graph
$txt_freq = 'weekly';
$rrdgfx=SS_PATH_GFX."/weekly-{$servers[$server]['host']}.{$servers[$server]['port']}{$mp}.png";
exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-5w DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 12 months server specific graph
$txt_freq = 'monthly';
$rrdgfx=SS_PATH_GFX."/monthly-{$servers[$server]['host']}.{$servers[$server]['port']}{$mp}.png";
exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1y DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
DisplayGraph($txt_freq, $rrdgfx);
// no server has been selected
else:
$rrdexecend = ' ';
$i = 0;
foreach ($servers as $n => $s)
{
$mp=""; if($s['type']=='icecast') $mp=".".$s['mpoint'];
$rrdfile = SS_PATH_RRD."/{$s['host']}.{$s['port']}{$mp}.rrd";
$rrdexecend .= "DEF:myaudience$i=$rrdfile:audience:AVERAGE ";
$rrdexecend .= "CDEF:audience$i=myaudience$i,UN,0,myaudience$i,IF ";
$i++;
}
if(count($servers)>1) {
$rrdexecend .= 'CDEF:mytotal=';
for($i=0; $i<count($servers); $i++)
$rrdexecend .= "audience$i,";
for($i=0; $i<count($servers)-2; $i++)
$rrdexecend .= '+,';
$rrdexecend .= '+ ';
} else {
$rrdexecend .= 'CDEF:mytotal=audience0 ';
}
$rrdexecend .= 'LINE2:mytotal#FF0000';
// generate and display the 24 hours graph
$txt_freq = 'hourly';
$rrdgfx = SS_PATH_GFX.'/hourly-all.png';
$rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG";
exec($rrdexecstart.$rrdexecend);
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 7 days graph
$txt_freq = 'daily';
$rrdgfx = SS_PATH_GFX.'/daily-all.png';
$rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1w";
exec($rrdexecstart.$rrdexecend);
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 5 weeks graph
$txt_freq = 'weekly';
$rrdgfx = SS_PATH_GFX.'/weekly-all.png';
$rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-5w";
exec($rrdexecstart.$rrdexecend);
DisplayGraph($txt_freq, $rrdgfx);
// generate and display the 12 months graph
$txt_freq = 'monthly';
$rrdgfx = SS_PATH_GFX.'/monthly-all.png';
$rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1y";
exec($rrdexecstart.$rrdexecend);
DisplayGraph($txt_freq, $rrdgfx);
endif;
?>
<p>
<a href="http://www.gnu.org/copyleft/gpl.html">GPL</a>
<a href="http://www.glop.org/shoutstats/">Shoutstats</a>
<a href="CHANGES"><?php echo SS_VERSION?></a> -
<a href="http://validator.w3.org/check?uri=referer">XHTML/1.1</a> and
<a href="http://jigsaw.w3.org/css-validator/check/referer">CSS2</a> compliant
</p>
</body>
</html>