forked from tylerhall/Shine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
77 lines (64 loc) · 2.11 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
<?PHP
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'stats';
$applications = DBObject::glob('Application', 'SELECT * FROM shine_applications ORDER BY name');
$db = Database::getDatabase();
$keys = $db->getValues("SELECT DISTINCT(`key`) FROM shine_sparkle_data");
$charts = array();
foreach($keys as $k)
{
$data = array();
$rows = $db->getRows("SELECT COUNT(*) as num, `data` FROM shine_sparkle_data WHERE `key` = '$k' GROUP BY `data` ORDER BY num DESC");
$count = 0;
$total = 0;
foreach($rows as $row)
{
if($count++ < 5) // Limit the pie chart to the top 5 values
{
$data[$row['data']] = $row['num'];
$total += $row['num'];
}
}
$charts[$k] = $data;
}
unset($charts['id']);
unset($charts['appName']);
unset($charts['appVersion']);
?>
<?PHP include('inc/header.inc.php'); ?>
<div id="bd">
<div id="yui-main">
<div class="yui-b"><div class="yui-g">
<div class="block tabs spaces">
<div class="hd">
<h2>Sparkle Stats</h2>
<ul>
<li class="<?PHP if(!isset($_GET['id'])) echo 'active'; ?>"><a href="stats.php">All Apps</a></li>
<?PHP foreach($applications as $a) : ?>
<li class="<?PHP if(@$_GET['id'] == $a->id) echo 'active'; ?>"><a href="stats.php?id=<?PHP echo $a->id; ?>"><?PHP echo $a->name; ?></a></li>
<?PHP endforeach; ?>
</ul>
<div class="clear"></div>
</div>
</div>
<?PHP foreach($charts as $title => $data) : ?>
<div class="block" style="float:left;margin-right:2em;">
<div class="hd">
<h2><?PHP echo $title; ?></h2>
</div>
<div class="bd">
<?PHP
$gc = new googleChart(implode(',', $data), 'pie');
$gc->setLabels(implode('|', array_keys($data)));
$gc->draw(true);
?>
</div>
</div>
<?PHP endforeach; ?>
</div></div>
</div>
<div id="sidebar" class="yui-b">
</div>
</div>
<?PHP include('inc/footer.inc.php'); ?>