|
@@ -33,7 +33,6 @@ if (!list($Countries, $Rank, $CountryUsers, $CountryMax, $CountryMin, $LogIncrem
|
33
|
33
|
}
|
34
|
34
|
|
35
|
35
|
if (!$ClassDistribution = $Cache->get_value('class_distribution')) {
|
36
|
|
- include_once(SERVER_ROOT.'/classes/charts.class.php');
|
37
|
36
|
$DB->query("
|
38
|
37
|
SELECT p.Name, COUNT(m.ID) AS Users
|
39
|
38
|
FROM users_main AS m
|
|
@@ -41,125 +40,136 @@ if (!$ClassDistribution = $Cache->get_value('class_distribution')) {
|
41
|
40
|
WHERE m.Enabled = '1'
|
42
|
41
|
GROUP BY p.Name
|
43
|
42
|
ORDER BY Users DESC");
|
44
|
|
- $ClassSizes = $DB->to_array();
|
45
|
|
- $Pie = new PIE_CHART(750, 400, array('Other' => 1, 'Percentage' => 1));
|
46
|
|
- foreach ($ClassSizes as $ClassSize) {
|
47
|
|
- list($Label, $Users) = $ClassSize;
|
48
|
|
- $Pie->add($Label, $Users);
|
49
|
|
- }
|
50
|
|
- $Pie->transparent();
|
51
|
|
- $Pie->color('FF33CC');
|
52
|
|
- $Pie->generate();
|
53
|
|
- $ClassDistribution = $Pie->url();
|
|
43
|
+ $ClassDistribution = $DB->to_array();
|
54
|
44
|
$Cache->cache_value('class_distribution', $ClassDistribution, 3600 * 24 * 14);
|
55
|
45
|
}
|
56
|
46
|
if (!$PlatformDistribution = $Cache->get_value('platform_distribution')) {
|
57
|
|
- include_once(SERVER_ROOT.'/classes/charts.class.php');
|
58
|
|
-
|
59
|
47
|
$DB->query("
|
60
|
48
|
SELECT OperatingSystem, COUNT(UserID) AS Users
|
61
|
49
|
FROM users_sessions
|
62
|
50
|
GROUP BY OperatingSystem
|
63
|
51
|
ORDER BY Users DESC");
|
64
|
52
|
|
65
|
|
- $Platforms = $DB->to_array();
|
66
|
|
- $Pie = new PIE_CHART(750, 400, array('Other' => 1, 'Percentage' => 1));
|
67
|
|
- foreach ($Platforms as $Platform) {
|
68
|
|
- list($Label, $Users) = $Platform;
|
69
|
|
- $Pie->add($Label, $Users);
|
70
|
|
- }
|
71
|
|
- $Pie->transparent();
|
72
|
|
- $Pie->color('8A00B8');
|
73
|
|
- $Pie->generate();
|
74
|
|
- $PlatformDistribution = $Pie->url();
|
|
53
|
+ $PlatformDistribution = $DB->to_array();
|
75
|
54
|
$Cache->cache_value('platform_distribution', $PlatformDistribution, 3600 * 24 * 14);
|
76
|
55
|
}
|
77
|
56
|
|
78
|
57
|
if (!$BrowserDistribution = $Cache->get_value('browser_distribution')) {
|
79
|
|
- include_once(SERVER_ROOT.'/classes/charts.class.php');
|
80
|
|
-
|
81
|
58
|
$DB->query("
|
82
|
59
|
SELECT Browser, COUNT(UserID) AS Users
|
83
|
60
|
FROM users_sessions
|
84
|
61
|
GROUP BY Browser
|
85
|
62
|
ORDER BY Users DESC");
|
86
|
63
|
|
87
|
|
- $Browsers = $DB->to_array();
|
88
|
|
- $Pie = new PIE_CHART(750, 400, array('Other' => 1, 'Percentage' => 1));
|
89
|
|
- foreach ($Browsers as $Browser) {
|
90
|
|
- list($Label, $Users) = $Browser;
|
91
|
|
- $Pie->add($Label, $Users);
|
92
|
|
- }
|
93
|
|
- $Pie->transparent();
|
94
|
|
- $Pie->color('008AB8');
|
95
|
|
- $Pie->generate();
|
96
|
|
- $BrowserDistribution = $Pie->url();
|
|
64
|
+ $BrowserDistribution = $DB->to_array();
|
97
|
65
|
$Cache->cache_value('browser_distribution', $BrowserDistribution, 3600 * 24 * 14);
|
98
|
66
|
}
|
99
|
67
|
|
100
|
68
|
|
101
|
69
|
//Timeline generation
|
102
|
|
-if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('users_timeline')) {
|
|
70
|
+if (!list($Labels, $InFlow, $OutFlow) = $Cache->get_value('users_timeline')) {
|
103
|
71
|
$DB->query("
|
104
|
|
- SELECT DATE_FORMAT(JoinDate,'%b %y') AS Month, COUNT(UserID)
|
|
72
|
+ SELECT DATE_FORMAT(JoinDate,\"%b %Y\") AS Month, COUNT(UserID)
|
105
|
73
|
FROM users_info
|
106
|
74
|
GROUP BY Month
|
107
|
|
- ORDER BY JoinDate DESC");
|
|
75
|
+ ORDER BY JoinDate DESC
|
|
76
|
+ LIMIT 1, 11");
|
108
|
77
|
$TimelineIn = array_reverse($DB->to_array());
|
109
|
78
|
$DB->query("
|
110
|
|
- SELECT DATE_FORMAT(BanDate,'%b %y') AS Month, COUNT(UserID)
|
|
79
|
+ SELECT DATE_FORMAT(BanDate,\"%b %Y\") AS Month, COUNT(UserID)
|
111
|
80
|
FROM users_info
|
112
|
81
|
WHERE BanDate > 0
|
113
|
82
|
GROUP BY Month
|
114
|
|
- ORDER BY BanDate DESC");
|
|
83
|
+ ORDER BY BanDate DESC
|
|
84
|
+ LIMIT 1, 11");
|
115
|
85
|
$TimelineOut = array_reverse($DB->to_array());
|
116
|
|
- foreach ($TimelineIn as $Month) {
|
117
|
|
- list($Label, $Amount) = $Month;
|
118
|
|
- if ($Amount > $Max) {
|
119
|
|
- $Max = $Amount;
|
120
|
|
- }
|
121
|
|
- }
|
122
|
|
- foreach ($TimelineOut as $Month) {
|
123
|
|
- list($Label, $Amount) = $Month;
|
124
|
|
- if ($Amount > $Max) {
|
125
|
|
- $Max = $Amount;
|
126
|
|
- }
|
127
|
|
- }
|
128
|
86
|
|
129
|
87
|
$Labels = array();
|
130
|
|
- foreach ($TimelineIn as $Month) {
|
131
|
|
- list($Label, $Amount) = $Month;
|
132
|
|
- $Labels[] = $Label;
|
133
|
|
- $InFlow[] = number_format(($Amount / $Max) * 100, 4);
|
|
88
|
+ foreach($TimelineIn as $Month) {
|
|
89
|
+ list($Labels[], $InFlow[]) = $Month;
|
134
|
90
|
}
|
135
|
|
- foreach ($TimelineOut as $Month) {
|
136
|
|
- list($Label, $Amount) = $Month;
|
137
|
|
- $OutFlow[] = number_format(($Amount / $Max) * 100, 4);
|
|
91
|
+ foreach($TimelineOut as $Month) {
|
|
92
|
+ list(, $OutFlow[]) = $Month;
|
138
|
93
|
}
|
139
|
|
- $Cache->cache_value('users_timeline', array($Labels, $InFlow, $OutFlow, $Max), mktime(0, 0, 0, date('n') + 1, 2)); //Tested: fine for Dec -> Jan
|
|
94
|
+ $Cache->cache_value('users_timeline', array($Labels, $InFlow, $OutFlow), mktime(0, 0, 0, date('n') + 1, 2)); //Tested: fine for Dec -> Jan
|
140
|
95
|
}
|
141
|
96
|
//End timeline generation
|
142
|
97
|
|
143
|
|
-View::show_header('Detailed User Statistics');
|
|
98
|
+View::show_header('Detailed User Statistics', 'chart');
|
144
|
99
|
?>
|
145
|
100
|
<h3 id="User_Flow"><a href="#User_Flow">User Flow</a></h3>
|
146
|
101
|
<div class="box pad center">
|
147
|
|
- <img src="<?=str_replace(['+','%26%2339%3B'],['%2B','%27'],ImageTools::process('https://chart.googleapis.com/chart?cht=lc&chs=880x160&chco=000D99,99000D&chg=0,-1,1,1&chxt=y,x&chxs=0,h&chxl=1:|'.implode('|', $Labels).'&chxr=0,0,'.$Max.'&chd=t:'.implode(',', $InFlow).'|'.implode(',', $OutFlow).'&chls=2,4,0&chdl=New+Registrations|Disabled+Users&chf=bg,s,FFFFFF00&.png'))?>" alt="User Flow Chart" />
|
|
102
|
+ <canvas class="chart" id="chart_user_timeline"></canvas>
|
|
103
|
+ <script>
|
|
104
|
+ new Chart($('#chart_user_timeline').raw().getContext('2d'), {
|
|
105
|
+ type: 'line',
|
|
106
|
+ data: {
|
|
107
|
+ labels: <? print '["'.implode('","',$Labels).'"]'; ?>,
|
|
108
|
+ datasets: [ {
|
|
109
|
+ label: "New Registrations",
|
|
110
|
+ backgroundColor: "rgba(0,0,255,0.2)",
|
|
111
|
+ borderColor: "rgba(0,0,255,0.8)",
|
|
112
|
+ data: <? print "[".implode(",",$InFlow)."]"; ?>
|
|
113
|
+ }, {
|
|
114
|
+ label: "Disabled Users",
|
|
115
|
+ backgroundColor: "rgba(255,0,0,0.2)",
|
|
116
|
+ borderColor: "rgba(255,0,0,0.8)",
|
|
117
|
+ data: <? print "[".implode(",",$OutFlow)."]"; ?>
|
|
118
|
+ }]
|
|
119
|
+ }
|
|
120
|
+ })
|
|
121
|
+ </script>
|
148
|
122
|
</div>
|
149
|
123
|
<br />
|
150
|
124
|
<h3 id="User_Classes"><a href="#User_Classes">User Classes</a></h3>
|
151
|
125
|
<div class="box pad center">
|
152
|
|
- <img src="<?=preg_replace('/\+/','%2B',ImageTools::process($ClassDistribution.'&.png'))?>" alt="User Class Distribution" />
|
|
126
|
+ <canvas class="chart" id="chart_user_classes"></canvas>
|
|
127
|
+ <script>
|
|
128
|
+ new Chart($('#chart_user_classes').raw().getContext('2d'), {
|
|
129
|
+ type: 'pie',
|
|
130
|
+ data: {
|
|
131
|
+ labels: <? print '["'.implode('","', array_column($ClassDistribution, 'Name')).'"]'; ?>,
|
|
132
|
+ datasets: [ {
|
|
133
|
+ data: <? print "[".implode(",", array_column($ClassDistribution, 'Users'))."]"; ?>,
|
|
134
|
+ backgroundColor: ['#8a00b8','#a944cb','#be71d8','#e8ccf1', '#f3e3f9', '#fbf6fd', '#ffffff']
|
|
135
|
+ }]
|
|
136
|
+ }
|
|
137
|
+ })
|
|
138
|
+ </script>
|
153
|
139
|
</div>
|
154
|
140
|
<br />
|
155
|
141
|
<h3 id="User_Platforms"><a href="#User_Platforms">User Platforms</a></h3>
|
156
|
142
|
<div class="box pad center">
|
157
|
|
- <img src="<?=preg_replace('/\+/','%2B',ImageTools::process($PlatformDistribution.'&.png'))?>" alt="User Platform Distribution" />
|
|
143
|
+ <canvas class="chart" id="chart_user_platforms"></canvas>
|
|
144
|
+ <script>
|
|
145
|
+ new Chart($('#chart_user_platforms').raw().getContext('2d'), {
|
|
146
|
+ type: 'pie',
|
|
147
|
+ data: {
|
|
148
|
+ labels: <? print '["'.implode('","', array_column($PlatformDistribution, 'OperatingSystem')).'"]'; ?>,
|
|
149
|
+ datasets: [ {
|
|
150
|
+ data: <? print "[".implode(",", array_column($PlatformDistribution, 'Users'))."]"; ?>,
|
|
151
|
+ backgroundColor: ['#8a00b8','#9416bf','#9f2dc5','#a944cb','#b45bd2','#be71d8','#c988de','#d39fe5','#deb6eb','#e8ccf1', '#ffffff', '#ffffff', '#ffffff', '#ffffff']
|
|
152
|
+ }]
|
|
153
|
+ }
|
|
154
|
+ })
|
|
155
|
+ </script>
|
158
|
156
|
</div>
|
159
|
157
|
<br />
|
160
|
158
|
<h3 id="User_Browsers"><a href="#User_Browsers">User Browsers</a></h3>
|
161
|
159
|
<div class="box pad center">
|
162
|
|
- <img src="<?=preg_replace('/\+/','%2B',ImageTools::process($BrowserDistribution.'&.png'))?>" alt="User Browsers Market Share" />
|
|
160
|
+ <canvas class="chart" id="chart_user_browsers"></canvas>
|
|
161
|
+ <script>
|
|
162
|
+ new Chart($('#chart_user_browsers').raw().getContext('2d'), {
|
|
163
|
+ type: 'pie',
|
|
164
|
+ data: {
|
|
165
|
+ labels: <? print '["'.implode('","', array_column($BrowserDistribution, 'Browser')).'"]'; ?>,
|
|
166
|
+ datasets: [ {
|
|
167
|
+ data: <? print "[".implode(",", array_column($BrowserDistribution, 'Users'))."]"; ?>,
|
|
168
|
+ backgroundColor: ['#8a00b8','#9416bf','#9f2dc5','#a944cb','#b45bd2','#be71d8','#c988de','#d39fe5','#deb6eb','#e8ccf1', '#ffffff', '#ffffff', '#ffffff', '#ffffff']
|
|
169
|
+ }]
|
|
170
|
+ }
|
|
171
|
+ })
|
|
172
|
+ </script>
|
163
|
173
|
</div>
|
164
|
174
|
<br />
|
165
|
175
|
<h3 id="Geo_Dist_Map"><a href="#Geo_Dist_Map">Geographical Distribution Map</a></h3>
|