-
Notifications
You must be signed in to change notification settings - Fork 16
/
stats.php
87 lines (76 loc) · 3.13 KB
/
stats.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
<?php
// Grab all the stuff we need
require_once './vendor/autoload.php';
use ChrisJP\TTS\Stats;
// Instantiate the TTS Stats class
$tts = new Stats();
$stats = $tts->stats();
require_once 'include/header.php';
?>
<div class="box">
<h2 id="stats" class="subtitle is-4">Statistics</h2>
<div class="columns my-2">
<div class="column">
<table class="table table-stats">
<tbody>
<tr><td class="has-text-weight-bold">Total files</td><td class="has-text-weight-bold"><?php echo $stats->total_files; ?></td></tr>
<tr><td class="has-text-weight-bold">Total playlists</td><td class="has-text-weight-bold"><?php echo $stats->total_playlists; ?></td></tr>
</tbody>
</table>
</div>
<div class="column">
<p><b>Services used:</b></p>
<table class="table table-stats">
<tbody>
<?php
// Put data into an array and sort it in descending order
$serviceStats = [];
foreach ($stats->by_service as $serviceName => $servNumUses) {
$serviceStats[$serviceName] = $servNumUses;
}
arsort($serviceStats);
$pos = 0;
foreach ($serviceStats as $serviceName => $servNumUses) {
$pos++;
echo '<tr><td>' . $pos . '.</td><td>'. $serviceName . '</td><td>' . $servNumUses . '</td></tr>' . PHP_EOL;
}
?>
</tbody>
</table>
</div>
<div class="column">
<p><b>Voices used:</b></p>
<table class="table table-stats">
<tbody>
<?php
// Put data into an array and sort it in descending order
$voiceStats = [];
foreach ($stats->by_voice as $voiceId => $voiceNumUses) {
$voiceStats[$voiceId] = $voiceNumUses;
}
arsort($voiceStats);
$pos = 0;
foreach ($voiceStats as $voiceId => $voiceNumUses) {
$pos++;
$voiceParts = explode(' - ', $voiceId);
$hiddenRow = $pos > 10 ? ' is-hidden' : '';
echo '<tr class="table-row-voice' . $hiddenRow . '" data-pos="' . $pos . '">' . PHP_EOL;
echo '<td>' . $pos . '.</td><td>'. $voiceParts[1] . '<br /><span class="is-size-7">' . $voiceParts[0] . '</span></td>' . PHP_EOL;
echo '<td>' . $voiceNumUses . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL;
}
?>
</tbody>
<tfoot>
<tr><td colspan="3"><a id="stats-voices-toggle">Show/Hide full table</a></td></tr>
</tfoot>
</table>
</div>
</div>
<p class="is-italic is-size-7">
Last generated on <?php echo date(DATE_RFC2822, $stats->gen_time); ?> (updated hourly)<br />
Files are held on the server for <?php echo HOURS_TO_KEEP; ?> hours before being purged. Figures will fluctuate accordingly.
</p>
</div>
<?php
require_once 'include/footer.php';