forked from tylerhall/Shine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
stats.php
94 lines (80 loc) · 2.61 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
88
89
90
91
92
93
94
<?PHP
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'stats';
$applications = DBObject::glob('Application', 'SELECT * FROM applications ORDER BY name');
$db = Database::getDatabase();
$keys = $db->getValues("SELECT DISTINCT(`key`) FROM sparkle_data");
$charts = array();
foreach($keys as $k)
{
$data = array();
$rows = $db->getRows("SELECT COUNT(*) as num, `data` FROM 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']);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Shine</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
<link rel="stylesheet" href="css/yuiapp.css" type="text/css">
</head>
<body class="rounded">
<div id="doc3" class="yui-t0">
<div id="hd">
<?PHP include('inc/header.inc.php'); ?>
</div>
<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>
<div id="ft"></div>
</div>
</body>
</html>