-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.php
261 lines (247 loc) · 9.11 KB
/
profile.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
<?php
# **************************************************************************#
# MolyX2
# ------------------------------------------------------
# @copyright (c) 2009-2010 MolyX Group..
# @official forum http://molyx.com
# @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 2.0
#
# $Id$
# **************************************************************************#
define('THIS_SCRIPT', 'profile');
require_once('./global.php');
class profile
{
var $showdelclew = false;
function show()
{
global $forums, $DB, $_INPUT, $bbuserinfo, $bboptions;
$forums->func->load_lang('profile');
$forums->func->load_lang('post');//需要整理
if ($_INPUT['do'] == 'delete')
{
$this->delete_mestatus();
$showdelclew = $this->showdelclew;
$clewinfo = $forums->lang['deldoingsuc'];
}
$id = intval($_INPUT['u']);
if ($bbuserinfo['canviewmember'] != 1 AND $id != $bbuserinfo['id'])
{
$forums->func->standard_error("cannotviewthispage");
}
$info = array();
if (empty($id))
{
$forums->func->standard_error("cannotfindedituser");
}
$user = $DB->query_first("SELECT up.*, u.*, s.inforum, s.inthread, e.loanamount
FROM " . TABLE_PREFIX . "user u
LEFT JOIN " . TABLE_PREFIX . "session s
ON (s.userid = u.id)
LEFT JOIN " . TABLE_PREFIX . "userextra e
ON (e.id = u.id)
LEFT JOIN " . TABLE_PREFIX . "userexpand up
ON (up.id = u.id)
WHERE u.id = " . $id);
if (!$user)
{
$forums->func->standard_error("cannotfindedituser");
}
$info = $forums->func->fetch_user($user);
$forumids = array('0');
foreach($forums->forum->foruminfo as $i => $r)
{
if ($forums->func->fetch_permissions($r['canread'], 'canread') == true)
{
$forumids[] = $r['id'];
}
}
$percent = 0;
$allposts = $DB->query_first('SELECT SUM(post) as allposts
FROM ' . TABLE_PREFIX . "forum
WHERE parentid = '-1'");
$allposts = $allposts['allposts'];
if ($user['posts'] && $allposts)
{
$info['perdaypost'] = round($user['posts'] / (((TIMENOW - $user['joindate']) / 86400)), 1);
$info['totalpercent'] = sprintf('%.2f', ($user['posts'] / $allposts * 100));
}
if ($info['perdaypost'] > $user['posts'])
{
$info['perdaypost'] = $user['posts'];
}
$info['allposts'] = $allposts;
$info['lastactivity'] = $forums->func->get_date($user['lastactivity'], 1);
//这里需要处理会员自定义扩展字段
$timelimit = TIMENOW - $bboptions['cookietimeout'] * 60;
$info['status'] = 0;
$info['extra'] = "";
$forums->lang['totalpercent'] = sprintf($forums->lang['totalpercent'], $info['perdaypost'], $info['totalpercent']);
$forums->lang['userpercent'] = sprintf($forums->lang['userpercent'], $info['activeposts'], $info['percent']);
$user['options'] = intval($user['options']);
$forums->func->convert_bits_to_array($user, $user['options']);
if (($user['lastvisit'] > $timelimit || $user['lastactivity'] > $timelimit) && $user['invisible'] != 1 && $user['loggedin'] == 1)
{
$info['status'] = 1;
$where = "";
if ($user['inthread'])
{
$thread = $DB->query_first("SELECT tid, title, forumid FROM " . TABLE_PREFIX . "thread WHERE tid='" . $user['inthread'] . "'");
if ($thread['tid'])
{
if ($forums->func->fetch_permissions($forums->forum->foruminfo[$thread['forumid']]['canread'], 'canread') == true)
{
$where = "( " . $forums->lang['readthread'] . ": <a href='showthread.php{$forums->sessionurl}t=" . $thread['tid'] . "'>" . $thread['title'] . "</a> )";
}
}
}
else if ($user['inforum'])
{
if ($forums->func->fetch_permissions($forums->forum->foruminfo[$user['inforum']]['canread'], 'canread') == true)
{
$where = "( " . $forums->lang['viewforum'] . ": <a href='forumdisplay.php{$forums->sessionurl}f=" . $user['inforum'] . "'>" . $forums->forum->foruminfo[$user['inforum']]['name'] . "</a> )";
}
}
$info['extra'] = $where;
}
$info['avatar'] = $forums->func->get_avatar($user['id'], $user['avatar']);
require_once(ROOT_PATH . "includes/class_textparse.php");
$info['signature'] = textparse::convert_text($user['signature'], $bboptions['signatureallowhtml']);
$signature_path = split_todir($user['id'], $bboptions['uploadurl'] . '/user');
$signature_path = $signature_path[0] . '/';
$info['signature'] = str_replace('{$signature_path}', $signature_path, $info['signature']);
$info['website'] = ($user['website'] AND preg_match("/^http:\/\/\S+$/", $user['website'])) ? "<a href='" . $user['website'] . "' target='_blank'>" . $user['website'] . "</a>" : $forums->lang['noinfo'];
if ($user['birthday'])
{
$birthday = explode('-', $user['birthday']);
$info['birthday'] = ($birthday[0] == '0000') ? ($birthday[1] . "-" . $birthday[2]) : ($birthday[0] . "-" . $birthday[1] . "-" . $birthday[2]);
}
else
{
$info['birthday'] = $forums->lang['noinfo'];
}
$info['pm'] = ($user['usepm']) ? "<a href='private.php{$forums->sessionurl}do=newpm&u=" . $user['id'] . "'><strong>" . $forums->lang['sendpm'] . "</strong></a>" : $forums->lang['nousepm'];
$info['email'] = (! $user['hideemail']) ? "<a href='sendmessage.php{$forums->sessionurl}do=mailmember&u=" . $user['id'] . "'>" . $forums->lang['sendmail'] . "</a>" : $forums->lang['nouseemail'];
$info['post'] = fetch_number_format($info['post']);
//$creditlist = $forums->func->fetch_credit($user);
if ($creditlist)
{
$credits = explode('<br />', $creditlist);
foreach ($credits as $credit)
{
if ($credit) $expand_credit[] = explode(': ', $credit);
}
}
$posthash = $forums->func->md5_check();
if ($user['id'] == $bbuserinfo['id'])
{
$show['options'] = true;
}
/*好友信息*/
$userfriends = array();
$sql = 'SELECT pu.*, u.id, u.avatar, u.usercurdo, u.name, u.userdotime FROM ' . TABLE_PREFIX . 'pmuserlist pu
LEFT JOIN ' . TABLE_PREFIX . 'user u
ON u.id=pu.contactid
WHERE userid = ' . $user['id'] . '
ORDER BY pu.id DESC
LIMIT 20';
$DB->query($sql);
while ($row = $DB->fetch_array())
{
$row['avatar'] = $forums->func->get_avatar($row['id'], $row['avatar'], 1);//获取用户头像
$row['userdotime'] = $forums->func->get_date($row['userdotime']);
if (!$row['usercurdo'])
{
$row['usercurdo'] = $forums->lang['notfilldowhat'];
}
$userfriends[$row['id']] = $row;
}
/*结束*/
/*状态历程*/
$firstpost = $_INPUT['pp'] ? intval($_INPUT['pp']) : 0;
$showcondition = array();
if ($_INPUT['ufriendsdo'])
{
$this->extra = '&ufriendsdo=' . $_INPUT['ufriendsdo'];
$showufriendsdo = true;
if ($userfriends)
{
$showcondition[] = ' ud.userid IN (' . implode(',', array_keys($userfriends)) . ')';
}
else
{
$showcondition[] = ' ud.userid = 0';
}
}
else
{
$showufriendsdo = false;
$showcondition[] = ' ud.userid = ' . $user['id'];
}
$showcondition = ' WHERE ' . implode(',', $showcondition);
$sql = 'SELECT count(*) AS count FROM ' . TABLE_PREFIX . 'userdo ud
' . $showcondition;
$sqlcount = $DB->query_first($sql);
$perpage = 20;
$pagenav = $forums->func->build_pagelinks(array(
'totalpages' => $sqlcount['count'],
'perpage' => $perpage,
'curpage' => $firstpost,
'pagelink' => "profile.php{$forums->sessionurl}u={$user['id']}{$this->extra}",
));
$userjourney = array();
$sql = 'SELECT ud.*, u.name, u.avatar FROM ' . TABLE_PREFIX . 'userdo ud
LEFT JOIN ' . TABLE_PREFIX . 'user u
ON ud.userid = u.id
' . $showcondition . '
ORDER BY time DESC
LIMIT ' . $firstpost . ',' . $perpage;
$DB->query($sql);
while ($row = $DB->fetch_array())
{
$row['time'] = $forums->func->get_date($row['time']);
if ($row['touserid'])
{
$row['dowhat'] = '@<a href="./profile.php?u=' . $row['touserid'] . '">' . $row['tousername'] . '</a> ' . $row['dowhat'];
}
$row['avatar'] = $forums->func->get_avatar($row['userid'], $row['avatar'], '2');
$userjourney[$row['did']] = $row;
}
/*结束*/
$mxajax_register_functions = array('do_change_signature', 'delete_user_avatar'); //注册ajax函数
require_once(ROOT_PATH . 'includes/ajax/ajax.php');
add_head_element('js', ROOT_PATH . 'scripts/mxajax_user.js');
//加载简洁编辑器
load_editor_js('', 'quick');
$pagetitle = $forums->lang['profile'] . " - " . $bboptions['bbtitle'];
$nav = array($forums->lang['profile']);
include $forums->func->load_template('profile');
exit;
}
function delete_mestatus()
{
global $forums, $DB, $_INPUT, $bbuserinfo, $bboptions;
$doid = intval($_INPUT['doid']);
$sql = 'SELECT userid FROM ' . TABLE_PREFIX . 'userdo WHERE did=' . $doid;
$ret = $DB->query_first($sql);
if (!$bbuserinfo['supermod'] && $ret['userid'] != $bbuserinfo['id'])
{
$forums->func->standard_error("cannotdeldoing");
}
if (!$ret)
{
$forums->func->standard_error("doingnotexist");
}
$DB->delete(TABLE_PREFIX . 'userdo', 'did=' . $doid);
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'userdo
WHERE userid=' . $bbuserinfo['id'] . '
AND touserid=0
ORDER BY time DESC';
$lastdoing = $DB->query_first($sql);
$DB->update(TABLE_PREFIX . 'user', array('usercurdo' => $lastdoing['dowhat'], 'userdotime' => $lastdoing['time']), 'id = ' . intval($bbuserinfo['id']));
$this->showdelclew = true;
}
}
$output = new profile();
$output->show();
?>