2 /***************************************************************************
3 * usercp_viewprofile.php
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: usercp_viewprofile.php,v 1.5.2.6 2005/09/14 18:14:30 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
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.
22 ***************************************************************************/
24 if ( !defined('IN_PHPBB') )
26 die("Hacking attempt");
30 if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
32 message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
34 $profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);
38 message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
42 FROM " . RANKS_TABLE . "
43 ORDER BY rank_special, rank_min";
44 if ( !($result = $db->sql_query($sql)) )
46 message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
50 while ( $row = $db->sql_fetchrow($result) )
54 $db->sql_freeresult($result);
57 // Output page header and profile_view template
59 $template->set_filenames(array(
60 'body' => 'profile_view_body.tpl')
62 make_jumpbox('viewforum.'.$phpEx);
65 // Calculate the number of days this user has been a member ($memberdays)
66 // Then calculate their posts per day
68 $regdate = $profiledata['user_regdate'];
69 $memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
70 $posts_per_day = $profiledata['user_posts'] / $memberdays;
72 // Get the users percentage of total posts
73 if ( $profiledata['user_posts'] != 0 )
75 $total_posts = get_db_stat('postcount');
76 $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
84 if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
86 switch( $profiledata['user_avatar_type'] )
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" />' : '';
91 case USER_AVATAR_REMOTE:
92 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
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" />' : '';
102 if ( $profiledata['user_rank'] )
104 for($i = 0; $i < count($ranksrow); $i++)
106 if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
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 />' : '';
115 for($i = 0; $i < count($ranksrow); $i++)
117 if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )
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 />' : '';
125 $temp_url = append_sid("privmsg.$phpEx?mode=post&" . 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>';
129 if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN )
131 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];
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>';
138 $email_img = ' ';
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>' : ' ';
143 $www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : ' ';
145 if ( !empty($profiledata['user_icq']) )
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>';
153 $icq_status_img = ' ';
158 $aim_img = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : ' ';
159 $aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ' ';
161 $msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : ' ';
164 $yim_img = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.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'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
167 $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&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>';
174 $page_title = $lang['Viewing_profile'];
175 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
177 if (function_exists('get_html_translation_table'))
179 $u_search_author = urlencode(strtr($profiledata['username'], array_flip(get_html_translation_table(HTML_ENTITIES))));
183 $u_search_author = urlencode(str_replace(array('&', ''', '"', '<', '>'), array('&', "'", '"', '<', '>'), $profiledata['username']));
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),
197 'SEARCH_IMG' => $search_img,
201 'EMAIL_IMG' => $email_img,
203 'WWW_IMG' => $www_img,
205 'ICQ_STATUS_IMG' => $icq_status_img,
206 'ICQ_IMG' => $icq_img,
208 'AIM_IMG' => $aim_img,
210 'MSN_IMG' => $msn_img,
212 'YIM_IMG' => $yim_img,
215 'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ',
216 'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ',
217 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ',
218 'AVATAR_IMG' => $avatar_img,
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'],
240 'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . $u_search_author),
242 'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
245 $template->pparse('body');
247 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);