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.3 2004/11/18 17:49:45 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]);
37 FROM " . RANKS_TABLE . "
38 ORDER BY rank_special, rank_min";
39 if ( !($result = $db->sql_query($sql)) )
41 message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
45 while ( $row = $db->sql_fetchrow($result) )
49 $db->sql_freeresult($result);
52 // Output page header and profile_view template
54 $template->set_filenames(array(
55 'body' => 'profile_view_body.tpl')
57 make_jumpbox('viewforum.'.$phpEx);
60 // Calculate the number of days this user has been a member ($memberdays)
61 // Then calculate their posts per day
63 $regdate = $profiledata['user_regdate'];
64 $memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
65 $posts_per_day = $profiledata['user_posts'] / $memberdays;
67 // Get the users percentage of total posts
68 if ( $profiledata['user_posts'] != 0 )
70 $total_posts = get_db_stat('postcount');
71 $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
79 if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
81 switch( $profiledata['user_avatar_type'] )
83 case USER_AVATAR_UPLOAD:
84 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
86 case USER_AVATAR_REMOTE:
87 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
89 case USER_AVATAR_GALLERY:
90 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
97 if ( $profiledata['user_rank'] )
99 for($i = 0; $i < count($ranksrow); $i++)
101 if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
103 $poster_rank = $ranksrow[$i]['rank_title'];
104 $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
110 for($i = 0; $i < count($ranksrow); $i++)
112 if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )
114 $poster_rank = $ranksrow[$i]['rank_title'];
115 $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
120 $temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);
121 $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
122 $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
124 if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN )
126 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];
128 $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
129 $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
133 $email_img = ' ';
137 $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>' : ' ';
138 $www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : ' ';
140 if ( !empty($profiledata['user_icq']) )
142 $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>';
143 $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>';
144 $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>';
148 $icq_status_img = ' ';
153 $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>' : ' ';
154 $aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ' ';
156 $msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : ' ';
159 $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>' : '';
160 $yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
162 $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&showresults=posts");
163 $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
164 $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
169 $page_title = $lang['Viewing_profile'];
170 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
172 if (function_exists('get_html_translation_table'))
174 $u_search_author = urlencode(strtr($profiledata['username'], array_flip(get_html_translation_table(HTML_ENTITIES))));
178 $u_search_author = urlencode(str_replace(array('&', ''', '"', '<', '>'), array('&', "'", '"', '<', '>'), $profiledata['username']));
181 $template->assign_vars(array(
182 'USERNAME' => $profiledata['username'],
183 'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
184 'POSTER_RANK' => $poster_rank,
185 'RANK_IMAGE' => $rank_image,
186 'POSTS_PER_DAY' => $posts_per_day,
187 'POSTS' => $profiledata['user_posts'],
188 'PERCENTAGE' => $percentage . '%',
189 'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
190 'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
192 'SEARCH_IMG' => $search_img,
196 'EMAIL_IMG' => $email_img,
198 'WWW_IMG' => $www_img,
200 'ICQ_STATUS_IMG' => $icq_status_img,
201 'ICQ_IMG' => $icq_img,
203 'AIM_IMG' => $aim_img,
205 'MSN_IMG' => $msn_img,
207 'YIM_IMG' => $yim_img,
210 'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ',
211 'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ',
212 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ',
213 'AVATAR_IMG' => $avatar_img,
215 'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
216 'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
217 'L_AVATAR' => $lang['Avatar'],
218 'L_POSTER_RANK' => $lang['Poster_rank'],
219 'L_JOINED' => $lang['Joined'],
220 'L_TOTAL_POSTS' => $lang['Total_posts'],
221 'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
222 'L_CONTACT' => $lang['Contact'],
223 'L_EMAIL_ADDRESS' => $lang['Email_address'],
224 'L_EMAIL' => $lang['Email'],
225 'L_PM' => $lang['Private_Message'],
226 'L_ICQ_NUMBER' => $lang['ICQ'],
227 'L_YAHOO' => $lang['YIM'],
228 'L_AIM' => $lang['AIM'],
229 'L_MESSENGER' => $lang['MSNM'],
230 'L_WEBSITE' => $lang['Website'],
231 'L_LOCATION' => $lang['Location'],
232 'L_OCCUPATION' => $lang['Occupation'],
233 'L_INTERESTS' => $lang['Interests'],
235 'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . $u_search_author),
237 'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
240 $template->pparse('body');
242 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);