Rev Author Line No. Line
130 kaklik 1 <?php
2 /***************************************************************************
3 * usercp_viewprofile.php
4 * -------------------
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
8 *
9 * $Id: usercp_viewprofile.php,v 1.5.2.6 2005/09/14 18:14:30 acydburn Exp $
10 *
11 *
12 ***************************************************************************/
13  
14 /***************************************************************************
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 *
22 ***************************************************************************/
23  
24 if ( !defined('IN_PHPBB') )
25 {
26 die("Hacking attempt");
27 exit;
28 }
29  
30 if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
31 {
32 message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
33 }
34 $profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);
35  
36 if (!$profiledata)
37 {
38 message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
39 }
40  
41 $sql = "SELECT *
42 FROM " . RANKS_TABLE . "
43 ORDER BY rank_special, rank_min";
44 if ( !($result = $db->sql_query($sql)) )
45 {
46 message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
47 }
48  
49 $ranksrow = array();
50 while ( $row = $db->sql_fetchrow($result) )
51 {
52 $ranksrow[] = $row;
53 }
54 $db->sql_freeresult($result);
55  
56 //
57 // Output page header and profile_view template
58 //
59 $template->set_filenames(array(
60 'body' => 'profile_view_body.tpl')
61 );
62 make_jumpbox('viewforum.'.$phpEx);
63  
64 //
65 // Calculate the number of days this user has been a member ($memberdays)
66 // Then calculate their posts per day
67 //
68 $regdate = $profiledata['user_regdate'];
69 $memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
70 $posts_per_day = $profiledata['user_posts'] / $memberdays;
71  
72 // Get the users percentage of total posts
73 if ( $profiledata['user_posts'] != 0 )
74 {
75 $total_posts = get_db_stat('postcount');
76 $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
77 }
78 else
79 {
80 $percentage = 0;
81 }
82  
83 $avatar_img = '';
84 if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
85 {
86 switch( $profiledata['user_avatar_type'] )
87 {
88 case USER_AVATAR_UPLOAD:
89 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
90 break;
91 case USER_AVATAR_REMOTE:
92 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
93 break;
94 case USER_AVATAR_GALLERY:
95 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
96 break;
97 }
98 }
99  
100 $poster_rank = '';
101 $rank_image = '';
102 if ( $profiledata['user_rank'] )
103 {
104 for($i = 0; $i < count($ranksrow); $i++)
105 {
106 if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
107 {
108 $poster_rank = $ranksrow[$i]['rank_title'];
109 $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
110 }
111 }
112 }
113 else
114 {
115 for($i = 0; $i < count($ranksrow); $i++)
116 {
117 if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )
118 {
119 $poster_rank = $ranksrow[$i]['rank_title'];
120 $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
121 }
122 }
123 }
124  
125 $temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=" . $profiledata['user_id']);
126 $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
127 $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
128  
129 if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN )
130 {
131 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];
132  
133 $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
134 $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
135 }
136 else
137 {
138 $email_img = '&nbsp;';
139 $email = '&nbsp;';
140 }
141  
142 $www_img = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '&nbsp;';
143 $www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : '&nbsp;';
144  
145 if ( !empty($profiledata['user_icq']) )
146 {
147 $icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
148 $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
149 $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>';
150 }
151 else
152 {
153 $icq_status_img = '&nbsp;';
154 $icq_img = '&nbsp;';
155 $icq = '&nbsp;';
156 }
157  
158 $aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '&nbsp;';
159 $aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '&nbsp;';
160  
161 $msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : '&nbsp;';
162 $msn = $msn_img;
163  
164 $yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
165 $yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&amp;.src=pg">' . $lang['YIM'] . '</a>' : '';
166  
167 $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&amp;showresults=posts");
168 $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" title="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" border="0" /></a>';
169 $search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '</a>';
170  
171 //
172 // Generate page
173 //
174 $page_title = $lang['Viewing_profile'];
175 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
176  
177 if (function_exists('get_html_translation_table'))
178 {
179 $u_search_author = urlencode(strtr($profiledata['username'], array_flip(get_html_translation_table(HTML_ENTITIES))));
180 }
181 else
182 {
183 $u_search_author = urlencode(str_replace(array('&amp;', '&#039;', '&quot;', '&lt;', '&gt;'), array('&', "'", '"', '<', '>'), $profiledata['username']));
184 }
185  
186 $template->assign_vars(array(
187 'USERNAME' => $profiledata['username'],
188 'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
189 'POSTER_RANK' => $poster_rank,
190 'RANK_IMAGE' => $rank_image,
191 'POSTS_PER_DAY' => $posts_per_day,
192 'POSTS' => $profiledata['user_posts'],
193 'PERCENTAGE' => $percentage . '%',
194 'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
195 'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
196  
197 'SEARCH_IMG' => $search_img,
198 'SEARCH' => $search,
199 'PM_IMG' => $pm_img,
200 'PM' => $pm,
201 'EMAIL_IMG' => $email_img,
202 'EMAIL' => $email,
203 'WWW_IMG' => $www_img,
204 'WWW' => $www,
205 'ICQ_STATUS_IMG' => $icq_status_img,
206 'ICQ_IMG' => $icq_img,
207 'ICQ' => $icq,
208 'AIM_IMG' => $aim_img,
209 'AIM' => $aim,
210 'MSN_IMG' => $msn_img,
211 'MSN' => $msn,
212 'YIM_IMG' => $yim_img,
213 'YIM' => $yim,
214  
215 'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : '&nbsp;',
216 'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : '&nbsp;',
217 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '&nbsp;',
218 'AVATAR_IMG' => $avatar_img,
219  
220 'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
221 'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
222 'L_AVATAR' => $lang['Avatar'],
223 'L_POSTER_RANK' => $lang['Poster_rank'],
224 'L_JOINED' => $lang['Joined'],
225 'L_TOTAL_POSTS' => $lang['Total_posts'],
226 'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
227 'L_CONTACT' => $lang['Contact'],
228 'L_EMAIL_ADDRESS' => $lang['Email_address'],
229 'L_EMAIL' => $lang['Email'],
230 'L_PM' => $lang['Private_Message'],
231 'L_ICQ_NUMBER' => $lang['ICQ'],
232 'L_YAHOO' => $lang['YIM'],
233 'L_AIM' => $lang['AIM'],
234 'L_MESSENGER' => $lang['MSNM'],
235 'L_WEBSITE' => $lang['Website'],
236 'L_LOCATION' => $lang['Location'],
237 'L_OCCUPATION' => $lang['Occupation'],
238 'L_INTERESTS' => $lang['Interests'],
239  
240 'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . $u_search_author),
241  
242 'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
243 );
244  
245 $template->pparse('body');
246  
247 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
248  
249 ?>