forked from edoreld/learning-with-texts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistics.php
executable file
·309 lines (266 loc) · 17.2 KB
/
statistics.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php
/**************************************************************
"Learning with Texts" (LWT) is free and unencumbered software
released into the PUBLIC DOMAIN.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a
compiled binary, for any purpose, commercial or non-commercial,
and by any means.
In jurisdictions that recognize copyright laws, the author or
authors of this software dedicate any and all copyright
interest in the software to the public domain. We make this
dedication for the benefit of the public at large and to the
detriment of our heirs and successors. We intend this
dedication to be an overt act of relinquishment in perpetuity
of all present and future rights to this software under
copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: statistics.php
Display statistics
***************************************************************/
require_once( 'settings.inc.php' );
require_once( 'connect.inc.php' );
require_once( 'dbutils.inc.php' );
require_once( 'utilities.inc.php' );
pagestart('My Statistics',true);
?>
<h4>Breakdown by Language and Term Status<br />(Click on numbers to see the list of terms)</h4>
<table class="tab3" cellspacing="0" cellpadding="5">
<tr>
<th class="th1">Language</th>
<th class="th1">Total<br /></th>
<th class="th1">Active<br />(1..5)</th>
<th class="th1">Learning<br />(1..4)</th>
<th class="th1">Unknown<br />(1)</th>
<th class="th1">Learning<br />(2)</th>
<th class="th1">Learning<br />(3)</th>
<th class="th1">Learning<br />(4)</th>
<th class="th1">Learned<br />(5)</th>
<th class="th1">Well<br />Known<br />(99)</th>
<th class="th1">Known<br />(5+99)</th>
<th class="th1">Ign.<br />(98)</th>
</tr>
<?php
$sum1 = 0;
$sum2 = 0;
$sum3 = 0;
$sum4 = 0;
$sum5 = 0;
$sum98 = 0;
$sum99 = 0;
$sum14 = 0;
$sum15 = 0;
$sum599 = 0;
$sumall = 0;
$sql = 'SELECT LgID, LgName FROM ' . $tbpref . 'languages ORDER BY LgName';
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$lang = $record['LgID'];
flush();
$s1 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 1');
$s2 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 2');
$s3 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 3');
$s4 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 4');
$s5 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 5');
$s98 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 98');
$s99 = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus = 99');
$s14 = $s1 + $s2 + $s3 + $s4;
$s15 = $s14 + $s5;
$s599 = $s5 + $s99;
$all = $s15 + $s98 + $s99;
$sum1 += $s1;
$sum2 += $s2;
$sum3 += $s3;
$sum4 += $s4;
$sum5 += $s5;
$sum98 += $s98;
$sum99 += $s99;
$sum14 += $s14;
$sum15 += $s15;
$sum599 += $s599;
$sumall += $all;
echo '<tr>';
echo '<td class="td1">' . tohtml($record['LgName']) . '</td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=&tag12=0&tag2=&tag1="><b>' . $all . '</b></a></td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=15&tag12=0&tag2=&tag1="><b>' . $s15 . '</b></a></td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=14&tag12=0&tag2=&tag1="><b>' . $s14 . '</b></a></td>';
echo '<td class="td1 center"><span class="status1"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=1&tag12=0&tag2=&tag1=">' . $s1 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status2"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=2&tag12=0&tag2=&tag1=">' . $s2 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status3"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=3&tag12=0&tag2=&tag1=">' . $s3 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status4"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=4&tag12=0&tag2=&tag1=">' . $s4 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status5"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=5&tag12=0&tag2=&tag1=">' . $s5 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status99"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=99&tag12=0&tag2=&tag1=">' . $s99 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status5stat"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=599&tag12=0&tag2=&tag1="><b>' . $s599 . '</b></a> </span></td>';
echo '<td class="td1 center"><span class="status98"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=98&tag12=0&tag2=&tag1="><b>' . $s98 . '</b></a> </span></td>';
echo '</tr>';
}
mysqli_free_result($res);
echo '<tr>';
echo '<th class="th1"><b>TOTAL</b></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=&tag12=0&tag2=&tag1="><b>' . $sumall . '</b></a></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=15&tag12=0&tag2=&tag1="><b>' . $sum15 . '</b></a></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=14&tag12=0&tag2=&tag1="><b>' . $sum14 . '</b></a></th>';
echo '<th class="th1 center"><span class="status1"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=1&tag12=0&tag2=&tag1="><b>' . $sum1 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status2"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=2&tag12=0&tag2=&tag1="><b>' . $sum2 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status3"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=3&tag12=0&tag2=&tag1="><b>' . $sum3 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status4"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=4&tag12=0&tag2=&tag1="><b>' . $sum4 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status5"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=5&tag12=0&tag2=&tag1="><b>' . $sum5 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status99"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=99&tag12=0&tag2=&tag1="><b>' . $sum99 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status5stat"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=599&tag12=0&tag2=&tag1="><b>' . $sum599 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status98"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=98&tag12=0&tag2=&tag1="><b>' . $sum98 . '</b></a> </span></th>';
echo '</tr>';
?>
</table>
<?php
$sumct = 0;
$sumat = 0;
$sumkt = 0;
$sumcy = 0;
$sumay = 0;
$sumky = 0;
$sumcw = 0;
$sumaw = 0;
$sumkw = 0;
$sumcm = 0;
$sumam = 0;
$sumkm = 0;
$sumca = 0;
$sumaa = 0;
$sumka = 0;
$sumcall = 0;
$sumaall = 0;
$sumkall = 0;
?>
<h4>Breakdown by Language and Time Range<br />(Terms created (C), Terms changed status = Activity (A), Terms set to "Known" (K))</h4>
<table class="tab3" cellspacing="0" cellpadding="5">
<tr>
<th class="th1" rowspan="2">Language</th>
<th class="th1" colspan="3">Today</th>
<th class="th1" colspan="3">Yesterday</th>
<th class="th1" colspan="3">Last 7 d</th>
<th class="th1" colspan="3">Last 30 d</th>
<th class="th1" colspan="3">Last 365 d</th>
<th class="th1" colspan="3">All Time</th>
</tr>
<tr>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
</tr>
<?php
$sql = 'SELECT LgID, LgName FROM ' . $tbpref . 'languages ORDER BY LgName';
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$lang = $record['LgID'];
flush();
$ct = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) = curdate()');
$at = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) = curdate()');
$kt = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) = curdate()');
$cy = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) = subdate(curdate(), \'1 day\')');
$ay = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) = subdate(curdate(), \'1 day\')');
$ky = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) = subdate(curdate(), \'1 day\')');
$cw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'6 day\') and curdate()');
$aw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'6 day\') and curdate()');
$kw = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'6 day\') and curdate()');
$cm = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'29 day\') and curdate()');
$am = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'29 day\') and curdate()');
$km = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'29 day\') and curdate()');
$ca = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoCreated as date) between subdate(curdate(), \'364 day\') and curdate()');
$aa = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'364 day\') and curdate()');
$ka = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99) and cast(WoStatusChanged as date) between subdate(curdate(), \'364 day\') and curdate()');
$call = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99)');
$aall = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (1,2,3,4,5,99)');
$kall = get_first_value('select count(WoID) as value from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoStatus in (5,99)');
$sumct += $ct;
$sumat += $at;
$sumkt += $kt;
$sumcy += $cy;
$sumay += $ay;
$sumky += $ky;
$sumcw += $cw;
$sumaw += $aw;
$sumkw += $kw;
$sumcm += $cm;
$sumam += $am;
$sumkm += $km;
$sumca += $ca;
$sumaa += $aa;
$sumka += $ka;
$sumcall += $call;
$sumaall += $aall;
$sumkall += $kall;
echo '<tr>';
echo '<td class="td1">' . tohtml($record['LgName']) . '</td>';
echo '<td class="td1 center"><span class="status1"> ' . $ct . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $at . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kt . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cy . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $ay . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $ky . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cw . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aw . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kw . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cm . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $am . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $km . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $ca . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aa . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $ka . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $call . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aall . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kall . ' </span></td>';
echo '</tr>';
}
mysqli_free_result($res);
echo '<tr>';
echo '<th class="th1"><b>TOTAL</b></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumct . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumat . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkt . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcy . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumay . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumky . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcw . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaw . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkw . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcm . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumam . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkm . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumca . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaa . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumka . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcall . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaall . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkall . ' </span></th>';
echo '</tr>';
?>
</table>
<p><input type="button" value="<< Back" onclick="location.href='index.php';" /></p>
<?php
pageend();
?>