This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
profile.php
200 lines (188 loc) · 8.58 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
<?php
/*---------------------------------------------------------------------+
| ExiteCMS Content Management System |
+----------------------------------------------------------------------+
| Copyright 2006-2008 Exite BV, The Netherlands |
| for support, please visit http://www.exitecms.org |
+----------------------------------------------------------------------+
| Some code derived from PHP-Fusion, copyright 2002 - 2006 Nick Jones |
+----------------------------------------------------------------------+
| Released under the terms & conditions of v2 of the GNU General Public|
| License. For details refer to the included gpl.txt file or visit |
| http://gnu.org |
+----------------------------------------------------------------------+
| $Id:: $|
+----------------------------------------------------------------------+
| Last modified by $Author:: $|
| Revision number $Rev:: $|
+---------------------------------------------------------------------*/
require_once dirname(__FILE__)."/includes/core_functions.php";
require_once PATH_ROOT."/includes/theme_functions.php";
// only members have access to this module
if (!iMEMBER) fallback(BASEDIR."index.php");
// load the GeoIP module
require_once PATH_INCLUDES."geoip_include.php";
// load the locales for this module
locale_load("main.members-profile");
locale_load("main.user_fields");
// temp storage for template variables
$variables = array();
// set some flags used in the template
$variables['may_ban'] = checkrights("B") ? 1 : 0;
$variables['show_country'] = iADMIN || $settings['forum_flags'] ? 1 : 0;
$variables['show_email'] = iSUPERADMIN ? 1 : 0;
$variables['show_ip'] = iSUPERADMIN || $variables['may_ban'] ? 1 : 0;
// name explicitly passed instead of an user_id
if (isset($name) && !empty($name)) {
$lookup = $name;
}
// lookup the user (by id or name)
if (isset($lookup)) {
// make sure we're only displaying one type of profile
unset($group_id);
if (isNum($lookup)) {
// find a member by the ID in the database
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$lookup' LIMIT 1");
} else {
// find a member by username in the database
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_name='".stripinput($lookup)."' LIMIT 1");
}
if (dbrows($result)) {
$data = dbarray($result);
$lookup = $data['user_id'];
} else {
// if not found, return to the homepage
fallback("index.php");
}
// get country name and flag
$cc_name = GeoIP_Code2Name($data['user_cc_code']);
$cc_flag = GeoIP_Code2Flag($data['user_cc_code']);
if ($cc_flag == "" || empty($data['user_ip']) || $data['user_ip'] == "X" || $data['user_ip'] == "0.0.0.0") {
$cc_flag = "";
$cc_name = $locale['408'];
}
$data['cc_name'] = $cc_name;
$data['cc_flag'] = $cc_flag;
// check the avatar
if ($data['user_avatar'] != "" && !file_exists(PATH_IMAGES_AV.$data['user_avatar'])) {
$data['user_avatar'] = "imagenotfound.jpg";
}
// user level
$data['user_level'] = getuserlevel($data['user_level']);
// user's birthday (using the current locale for the month name)
if ($data['user_birthdate'] != "0000-00-00") {
$birthdate = explode("-", $data['user_birthdate']);
$data['user_birthdate'] = mktime(1,0,0,$birthdate[1],$birthdate[2],$birthdate[0]);
} else {
$data['user_birthdate'] = "";
}
if ($data['user_web']) {
$urlprefix = !strstr($data['user_web'], "http://") ? "http://" : "";
$data['user_web'] = $urlprefix.$data['user_web'];
}
$data['show_pm_button'] = (iMEMBER && $data['user_id'] != $userdata['user_id']);
if ($userdata['user_level'] >= 102) {
$ip = (empty($data['user_ip']) || $data['user_ip'] == "X" || $data['user_ip'] == "0.0.0.0") ? false : $data['user_ip'];
if ($ip) {
$host = gethostbyaddr($ip);
if ($ip != $host) $data['user_ip'] .= " (".$host.")";
} else {
unset($data['user_ip']);
}
}
if (dbtable_exists($db_prefix."shoutbox")) {
$data['shout_count'] = number_format(dbcount("(shout_id)", "shoutbox", "shout_name='".$data['user_id']."'"));
} else {
$data['shout_count'] = -1; // indicate no shoutbox is available
}
$data['comment_count'] = number_format(dbcount("(comment_id)", "comments", "comment_name='".$data['user_id']."'"));
$data['user_posts'] = number_format($data['user_posts']);
$data['show_viewposts_button'] = ($data['user_posts'] > 0 and file_exists(PATH_MODULES."forum_threads_list_panel/my_posts.php"));
if ($data['user_posts_unread']) {
$result = dbquery("
SELECT count(*) as unread
FROM ".$db_prefix."posts p
INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id
WHERE tr.user_id = '".$data['user_id']."'
AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")
AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read)
OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))"
, false);
} else {
$result = dbquery("
SELECT count(*) as unread
FROM ".$db_prefix."posts p
INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id
WHERE tr.user_id = '".$data['user_id']."'
AND p.post_author != '".$data['user_id']."'
AND p.post_edituser != '".$data['user_id']."'
AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")
AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read)
OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))"
, false);
}
$rows = mysqli_fetch_array($result);
$data['unread_count'] = $rows[0];
$data['user_email'] = str_replace("@","@",$data['user_email']);
if ($data['user_groups']) {
$groups = (strpos($data['user_groups'], ".") == 0 ? explode(".", substr($data['user_groups'], 1)) : explode(".", $data['user_groups']));
foreach ($groups as $group) {
// check if this groups has subgroups. If so, add them to the array
getsubgroups($group);
}
$c = 0;
$data['user_groups'] = array();
for ($i = 0;$i < count($groups);$i++) {
$groupname = getgroupname($groups[$i], array(1));
if (!empty($groupname)) {
$data['user_groups'][] = array('group' => $groups[$i], 'name' => $groupname);
}
}
}
// if the translators table is present, check if this user is a translator
$data['translations'] = array();
if (dbtable_exists($db_prefix."translators")) {
$result = dbquery("SELECT * FROM ".$db_prefix."translators t, ".$db_prefix."locale l WHERE t.translate_locale_code = l.locale_code AND t.translate_translator = '".$data['user_id']."'");
while ($data2 = dbarray($result)) {
$data['translations'][] = $data2;
};
}
// define the body panel variables
$variables['data'] = $data;
$template_panels[] = array('type' => 'body', 'name' => 'profile', 'template' => 'main.profile.members.tpl', 'locale' => array("main.members-profile", "main.user_fields"));
$template_variables['profile'] = $variables;
}
// list all the members of this group
if (isset($group_id)) {
// check if the group requested is a visible group
$result = dbquery("SELECT * FROM ".$db_prefix."user_groups WHERE group_id='$group_id' AND (group_visible & 1)");
if (dbrows($result) == 0) {
fallback(BASEDIR."index.php");
}
$data = dbarray($result);
// get the list of users that are a member of this group
$userlist = allusersingroup($group_id);
// store the amount of members retrieved
$data['member_count'] = sprintf((count($userlist)==1?$locale['411']:$locale['412']), count($userlist));
// save the group information
$variables['data'] = $data;
// gather member information
$members = array();
foreach($userlist as $data) {
if ($settings['forum_flags'] == 0 || empty($data['user_ip']) || $data['user_ip'] == "X" || $data['user_ip'] == "0.0.0.0") {
$cc_flag = "";
} else {
$cc_flag = GeoIP_Code2Flag($data['user_cc_code']);
if ($cc_flag == "") $cc_flag = " ";
}
$data['cc_flag'] = $cc_flag;
$members[] = $data;
}
// define the body panel variables
$variables['members'] = $members;
$template_panels[] = array('type' => 'body', 'name' => 'profile', 'template' => 'main.profile.groups.tpl', 'locale' => array("main.members-profile", "main.user_fields"));
$template_variables['profile'] = $variables;
}
// Call the theme code to generate the output for this webpage
require_once PATH_THEME."/theme.php";
?>