misc_stat.php
4.26 KB
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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_stat.php 34937 2014-09-04 03:08:56Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(empty($_G['setting']['updatestat'])) {
showmessage('not_open_updatestat');
}
$stat_hash = md5($_G['setting']['siteuniqueid']."\t".substr($_G['timestamp'], 0, 6));
if(!checkperm('allowstatdata') && $_GET['hash'] != $stat_hash) {
showmessage('no_privilege_statdata');
}
$cols = array();
$cols['login'] = array('login','mobilelogin','connectlogin','register','invite','appinvite');
if(!$_G['setting']['connect']['allow']) {
unset($cols['login'][2]);
}
$cols['forum'] = array('thread', 'poll', 'activity', 'reward', 'debate', 'trade', 'post');
$cols['tgroup'] = array('group', 'groupthread', 'grouppost');
$cols['home'] = array('doing', 'docomment', 'blog', 'blogcomment', 'pic', 'piccomment', 'share', 'sharecomment');
$cols['space'] = array('wall', 'poke', 'click', 'sendpm', 'addfriend', 'friend');
$type = !empty($_GET['types']) ? array() : (empty($_GET['type'])?'all':$_GET['type']);
$primarybegin = !empty($_GET['primarybegin']) ? $_GET['primarybegin'] : dgmdate($_G['timestamp']-2592000, 'Y-m-d');
$primaryend = !empty($_GET['primaryend']) ? $_GET['primaryend'] : dgmdate($_G['timestamp'], 'Y-m-d');
$beginunixstr = strtotime($primarybegin);
$endunixstr = strtotime($primaryend);
if($beginunixstr > $endunixstr) {
showmessage('start_time_is_greater_than_end_time', NULL, array(), array('return'=>true));
} else if($beginunixstr == $endunixstr) {
showmessage('start_time_end_time_is_equal_to', NULL, array(), array('return'=>true));
}
if(!empty($_GET['xml'])) {
$xaxis = '';
$graph = array();
$count = 1;
$begin = dgmdate($beginunixstr, 'Ymd');
$end = dgmdate($endunixstr, 'Ymd');
$field = '*';
if(!empty($_GET['merge'])) {
if(empty($_GET['types'])) {
$_GET['types'] = array_merge($cols['login'], $cols['forum'], $cols['tgroup'], $cols['home'], $cols['space']);
}
if (!array_diff($_GET['types'], array_merge($cols['login'], $cols['forum'], $cols['tgroup'], $cols['home'], $cols['space']))) {
$field = 'daytime,`' . implode('`+`', $_GET['types']) . '` AS statistic';
}
$type = 'statistic';
}
foreach(C::t('common_stat')->fetch_all($begin, $end, $field) as $value) {
$xaxis .= "<value xid='$count'>".substr($value['daytime'], 4, 4)."</value>";
if($type == 'all') {
foreach ($cols as $ck => $cvs) {
if($ck == 'login') {
$graph['login'] .= "<value xid='$count'>$value[login]</value>";
$graph['register'] .= "<value xid='$count'>$value[register]</value>";
} else {
$num = 0;
foreach ($cvs as $cvk) {
$num = $value[$cvk] + $num;
}
$graph[$ck] .= "<value xid='$count'>".$num."</value>";
}
}
} else {
if(empty($_GET['types']) || !empty($_GET['merge'])) {
$graph[$type] .= "<value xid='$count'>".$value[$type]."</value>";
} else {
foreach($_GET['types'] as $t) {
$graph[$t] .= "<value xid='$count'>".$value[$t]."</value>";
}
}
}
$count++;
}
$xml = '';
$xml .= '<'."?xml version=\"1.0\" encoding=\"utf-8\"?>";
$xml .= '<chart><xaxis>';
$xml .= $xaxis;
$xml .= "</xaxis><graphs>";
$count = 0;
foreach ($graph as $key => $value) {
$xml .= "<graph gid='$count' title='".diconv(lang('spacecp', "do_stat_$key"), CHARSET, 'utf8')."'>";
$xml .= $value;
$xml .= '</graph>';
$count++;
}
$xml .= '</graphs></chart>';
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
@header("Content-type: application/xml; charset=utf-8");
echo $xml;
exit();
}
$actives = array($type => ' class="a"');
require_once libfile('function/home');
$siteurl = getsiteurl();
$types = '';
$merge = !empty($_GET['merge']) ? '&merge=1' : '';
foreach($_GET['types'] as $value) {
$types .= '&types[]='.$value;
$actives[$value] = ' class="a"';
}
$statuspara = "path=&settings_file=data/stat_setting.xml&data_file=".urlencode("misc.php?mod=stat&op=trend&xml=1&type=$type&primarybegin=$primarybegin&primaryend=$primaryend{$types}{$merge}&hash=$stat_hash");
include template('home/misc_stat');
?>