1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * adm_payment.php |
||||||
5 | * |
||||||
6 | * @version 1.0 |
||||||
7 | * @copyright 2013 by Gorlum for http://supernova.ws |
||||||
8 | */ |
||||||
9 | define('INSIDE', true); |
||||||
10 | define('INSTALL', false); |
||||||
11 | define('IN_ADMIN', true); |
||||||
12 | |||||||
13 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
||||||
14 | |||||||
15 | |||||||
16 | function admin_date_sort($a, $b) |
||||||
17 | { |
||||||
18 | return $a['DATE'] == $b['DATE'] ? 0 : ($a['DATE'] > $b['DATE'] ? 1 : -1); |
||||||
19 | } |
||||||
20 | |||||||
21 | if($user['authlevel'] < 3) |
||||||
22 | { |
||||||
23 | AdminMessage($lang['adm_err_denied']); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
24 | } |
||||||
25 | |||||||
26 | $template = SnTemplate::gettemplate('admin/adm_user_stat', true); |
||||||
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
27 | |||||||
28 | $dt_from = sys_get_param_date_sql('dt_from', '2000-01-01'); |
||||||
29 | if(strlen($dt_from) == 4) |
||||||
30 | { |
||||||
31 | $dt_from .= '-01'; |
||||||
32 | } |
||||||
33 | $dt_to = sys_get_param_date_sql('dt_to', date('Y-m-d', SN_TIME_NOW + PERIOD_DAY)); |
||||||
34 | if(strlen($dt_to) == 4) |
||||||
35 | { |
||||||
36 | $dt_to .= '-01'; |
||||||
37 | } |
||||||
38 | $sql_date = |
||||||
39 | ($dt_from ? " AND register_time >= UNIX_TIMESTAMP(STR_TO_DATE('{$dt_from}', '%Y-%m-%d %H:%i:%s')) " : '') . |
||||||
40 | ($dt_to ? " AND register_time < UNIX_TIMESTAMP(STR_TO_DATE('{$dt_to}', '%Y-%m-%d %H:%i:%s')) " : ''); |
||||||
41 | |||||||
42 | $min_max_dates = doquery($q = "SELECT min(register_time) AS min_register, max(register_time) AS max_register, avg(onlinetime - register_time) AS avg_play_time, STR_TO_DATE('{$dt_to}', '%Y-%m-%d %H:%i:%s') FROM {{users}} WHERE 1 " . $sql_date, true); |
||||||
0 ignored issues
–
show
true of type true is incompatible with the type string expected by parameter $table of doquery() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
43 | |||||||
44 | $interval = $min_max_dates['max_register'] - $min_max_dates['min_register']; |
||||||
45 | |||||||
46 | switch(true) |
||||||
47 | { |
||||||
48 | case $interval >= PERIOD_YEAR * 4: |
||||||
49 | $sql_group_format = "%Y"; |
||||||
50 | $sql_date_add = 'year'; |
||||||
51 | break; |
||||||
52 | |||||||
53 | case $interval > PERIOD_DAY * 32: |
||||||
54 | $sql_group_format = "%Y-%m"; |
||||||
55 | $sql_date_add = 'month'; |
||||||
56 | break; |
||||||
57 | |||||||
58 | case $interval > PERIOD_DAY: |
||||||
59 | $sql_group_format = "%Y-%m-%d"; |
||||||
60 | $sql_date_add = 'day'; |
||||||
61 | break; |
||||||
62 | |||||||
63 | default: |
||||||
64 | $sql_group_format = "%Y-%m-%d %H:00:00"; |
||||||
65 | $sql_date_add = 'hour'; |
||||||
66 | $stop_next = true; |
||||||
67 | break; |
||||||
68 | } |
||||||
69 | |||||||
70 | $stat_date = array(); |
||||||
71 | $max_registered = 0; |
||||||
72 | $max_accounts = 0; |
||||||
73 | |||||||
74 | $sql_group_by2 = "DATE_FORMAT(account_register_time, '{$sql_group_format}')"; |
||||||
75 | $sql_date2 = |
||||||
76 | ($dt_from ? " AND account_register_time >= (STR_TO_DATE('{$dt_from}', '%Y-%m-%d %H:%i:%s')) " : '') . |
||||||
77 | ($dt_to ? " AND account_register_time < (STR_TO_DATE('{$dt_to}', '%Y-%m-%d %H:%i:%s')) " : ''); |
||||||
78 | $query = doquery( |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
79 | "SELECT |
||||||
80 | count(*) AS the_count, |
||||||
81 | DATE_FORMAT(account_register_time, '{$sql_group_format}') AS the_date, |
||||||
82 | DATE_FORMAT(account_register_time, '%a') AS DoW, |
||||||
83 | DATE_FORMAT(DATE_ADD(account_register_time, INTERVAL 1 {$sql_date_add}), '{$sql_group_format}') AS date_next |
||||||
84 | FROM {{account}} WHERE 1 " . $sql_date2 . " GROUP BY {$sql_group_by2}"); |
||||||
85 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
86 | { |
||||||
87 | $stat_date[$row['the_date']] = array( |
||||||
88 | 'DATE' => $row['the_date'], |
||||||
89 | 'DOW' => $row['DoW'], |
||||||
90 | 'DATE_URL' => urlencode($row['the_date']), |
||||||
91 | 'DATE_NEXT_URL' => urlencode($row['date_next']), |
||||||
92 | 'ACCOUNTS' => $row['the_count'], |
||||||
93 | ); |
||||||
94 | |||||||
95 | $max_accounts = max($max_accounts, $row['the_count']); |
||||||
96 | } |
||||||
97 | |||||||
98 | $sql_group_by = "DATE_FORMAT(FROM_UNIXTIME(register_time), '{$sql_group_format}')"; |
||||||
99 | $query = doquery("SELECT count(*) AS the_count, {$sql_group_by} AS the_date, DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(register_time), INTERVAL 1 {$sql_date_add}), '{$sql_group_format}') AS date_next |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
100 | FROM {{users}} WHERE user_as_ally IS NULL " . $sql_date . " GROUP BY {$sql_group_by}"); |
||||||
101 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
102 | { |
||||||
103 | $stat_date[$row['the_date']]['REGISTERED'] = $row['the_count']; |
||||||
104 | |||||||
105 | $max_registered = max($max_registered, $row['the_count']); |
||||||
106 | } |
||||||
107 | |||||||
108 | $query = doquery("SELECT count(*) AS the_count, {$sql_group_by} AS the_date FROM {{users}} WHERE user_as_ally IS NULL " . |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
109 | " AND onlinetime <= register_time + " . PERIOD_DAY . |
||||||
110 | ' AND UNIX_TIMESTAMP(NOW()) >= register_time + ' . PERIOD_DAY . |
||||||
111 | $sql_date . " GROUP BY {$sql_group_by}"); |
||||||
112 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
113 | { |
||||||
114 | $stat_date[$row['the_date']]['REJECTED'] = $row['the_count']; |
||||||
115 | } |
||||||
116 | |||||||
117 | $query = doquery("SELECT count(*) AS the_count, {$sql_group_by} AS the_date FROM {{users}} WHERE user_as_ally IS NULL " . |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
118 | " AND onlinetime > register_time + " . PERIOD_DAY . |
||||||
119 | ' AND onlinetime <= register_time + ' . PERIOD_WEEK . |
||||||
120 | ' AND UNIX_TIMESTAMP(NOW()) >= register_time + ' . PERIOD_WEEK . |
||||||
121 | $sql_date . " GROUP BY {$sql_group_by}"); |
||||||
122 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
123 | { |
||||||
124 | $stat_date[$row['the_date']]['LEAVED'] = $row['the_count']; |
||||||
125 | } |
||||||
126 | |||||||
127 | $query = doquery("SELECT count(*) AS the_count, {$sql_group_by} AS the_date FROM {{users}} WHERE user_as_ally IS NULL " . |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
128 | ' AND UNIX_TIMESTAMP(NOW()) - onlinetime <= ' . PERIOD_DAY . |
||||||
129 | ' AND UNIX_TIMESTAMP(NOW()) - register_time >= ' . PERIOD_DAY . |
||||||
130 | $sql_date . " GROUP BY {$sql_group_by}"); |
||||||
131 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
132 | { |
||||||
133 | $stat_date[$row['the_date']]['ACTIVE'] = $row['the_count']; |
||||||
134 | } |
||||||
135 | |||||||
136 | $query = doquery("SELECT count(*) AS the_count, {$sql_group_by} AS the_date FROM {{users}} WHERE user_as_ally IS NULL " . |
||||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
137 | ' AND UNIX_TIMESTAMP(NOW()) - onlinetime > ' . PERIOD_DAY . |
||||||
138 | ' AND UNIX_TIMESTAMP(NOW()) - onlinetime <= ' . PERIOD_WEEK . |
||||||
139 | ' AND UNIX_TIMESTAMP(NOW()) - register_time >= ' . PERIOD_WEEK . |
||||||
140 | $sql_date . " GROUP BY {$sql_group_by}"); |
||||||
141 | while($row = db_fetch($query)) |
||||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
142 | { |
||||||
143 | $stat_date[$row['the_date']]['DORMANT'] = $row['the_count']; |
||||||
144 | } |
||||||
145 | |||||||
146 | uasort($stat_date, 'admin_date_sort'); |
||||||
147 | |||||||
148 | $total = array(); |
||||||
149 | foreach($stat_date as $key => &$value) |
||||||
150 | { |
||||||
151 | $value['TOTAL'] = $value['REJECTED'] + $value['LEAVED']; |
||||||
152 | $value['LEAVED_PERCENT'] = $value['REGISTERED'] ? round($value['TOTAL'] / $value['REGISTERED'] * 100) : 0; |
||||||
153 | $value['ACTIVE_PERCENT'] = $value['REGISTERED'] ? round($value['ACTIVE'] / $value['REGISTERED'] * 100) : 0; |
||||||
154 | $value['DORMANT_PERCENT'] = $value['REGISTERED'] ? round($value['DORMANT'] / $value['REGISTERED'] * 100) : 0; |
||||||
155 | foreach($value as $key2 => $value2) |
||||||
156 | { |
||||||
157 | $total[$key2] += $value2; |
||||||
158 | } |
||||||
159 | $value['REGISTERED_PERCENT'] = ceil($max_registered ? $value['REGISTERED'] * 100 / $max_registered : 0); |
||||||
160 | $template->assign_block_vars('stats', $value); |
||||||
161 | } |
||||||
162 | $total['DATE'] = 'Всего'; |
||||||
163 | $total['TH'] = 1; |
||||||
164 | $total['LEAVED_PERCENT'] = count($stat_date) ? round($total['TOTAL'] / $total['REGISTERED'] * 100) : 0; |
||||||
165 | $total['ACTIVE_PERCENT'] = count($stat_date) ? round($total['ACTIVE'] / $total['REGISTERED'] * 100) : 0; |
||||||
166 | $total['DORMANT_PERCENT'] = count($stat_date) ? round($total['DORMANT'] / $total['REGISTERED'] * 100) : 0; |
||||||
167 | $template->assign_block_vars('stats', $total); |
||||||
168 | |||||||
169 | $template->assign_vars(array( |
||||||
170 | 'AVG_PLAY_TIME' => round($min_max_dates['avg_play_time'] / PERIOD_DAY, 2), |
||||||
171 | 'STOP_NEXT' => intval($stop_next), |
||||||
172 | 'INTERVAL' => $sql_date_add, |
||||||
173 | )); |
||||||
174 | |||||||
175 | SnTemplate::display($template, $lang['adm_user_stat'], false, '', true); |
||||||
0 ignored issues
–
show
The call to
SnTemplate::display() has too many arguments starting with false .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
176 |