-
Notifications
You must be signed in to change notification settings - Fork 33
/
ustatsg1.php
85 lines (59 loc) · 3.02 KB
/
ustatsg1.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
<?php
use src\Utils\Database\XDb;
use src\Utils\View\View;
use src\Models\ApplicationContainer;
require_once (__DIR__.'/lib/common.inc.php');
//user logged in?
if (!ApplicationContainer::GetAuthorizedUser()) {
$target = urlencode(tpl_get_current_page());
tpl_redirect('login.php?target=' . $target);
exit;
}
// check for old-style parameters
if (isset($_REQUEST['userid'])) {
$user_id = $_REQUEST['userid'];
}
/** @var View */
$view->setTemplate('ustat');
$view->setVar('userId', $user_id);
$view->setVar('displayFindStats', true);
$content = '';
$rsGeneralStat = XDb::xSql(
"SELECT hidden_count, founds_count, log_notes_count, notfounds_count, username
FROM `user` WHERE user_id=? ", $user_id);
$user_record = XDb::xFetchArray($rsGeneralStat);
tpl_set_var('username', htmlspecialchars($user_record['username']));
if ($user_record['hidden_count'] == 0) {
$content .= '<p> </p><p> </p><div class="content2-container bg-blue02">
<p class="content-title-noshade-size1">
<img src="/images/blue/cache.png" class="icon32" alt="Caches created" title="Caches created" />
' . tr("graph_created") . '</p></div><br /><br />
<p><b>' . tr("there_is_no_caches_registered") . '</b></p>';
} else {
// calculate diif days between date of register on OC to current date
$rdd = XDb::xSql(
"SELECT TO_DAYS(NOW()) - TO_DAYS(`date_created`) `diff` from `user`
WHERE user_id= ? ", $user_id);
$ddays = XDb::xFetchArray($rdd);
XDb::xFreeResults($rdd);
// calculate days caching
$rsGeneralStat = XDb::xSql(
"SELECT YEAR(`date_created`) usertime, hidden_count, founds_count, log_notes_count, username
FROM `user` WHERE user_id= ? ", $user_id);
if ($rsGeneralStat !== false) {
$user_record = XDb::xFetchArray($rsGeneralStat);
tpl_set_var('username', htmlspecialchars($user_record['username']));
}
$content .='<p> </p><p> </p><div class="content2-container bg-blue02"><p class="content-title-noshade-size1"> <img src="/images/blue/cache.png" class="icon32" alt="Caches created" title="Caches created" /> ' . tr("graph_created") . '</p></div><br />';
$content .= '<p><img src="graphs/PieGraphustat.php?userid=' . $user_id . '&t=cc' . '" border="0" alt="" width="500" height="300" /></p>';
$year = date("Y");
$content .= '<p><img src="graphs/BarGraphustat.php?userid=' . $user_id . '&t=ccm' . $year . '" border="0" alt="" width="500" height="200" /></p>';
if ($user_record['usertime'] != $year) {
$yearr = $year - 1;
$content .= '<p><img src="graphs/BarGraphustat.php?userid=' . $user_id . '&t=ccm' . $yearr . '" border="0" alt="" width="500" height="200" /></p>';
}
XDb::xFreeResults($rsGeneralStat);
$content .= '<p><img src="graphs/BarGraphustat.php?userid=' . $user_id . '&t=ccy" border="0" alt="" width="500" height="200" /></p>';
}
tpl_set_var('content', $content);
tpl_BuildTemplate();