PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/upload/includes/ucp/usercp_viewprofile.php

http://torrentpier2.googlecode.com/
PHP | 241 lines | 202 code | 30 blank | 9 comment | 57 complexity | be1a66679075072bf35d14930afda11c MD5 | raw file
  1. <?php
  2. if (!defined('BB_ROOT')) die(basename(__FILE__));
  3. require(INC_DIR .'bbcode.php');
  4. $datastore->enqueue(array(
  5. 'ranks',
  6. ));
  7. if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == GUEST_UID)
  8. {
  9. bb_die($lang['NO_USER_ID_SPECIFIED']);
  10. }
  11. if (!$profiledata = get_userdata($_GET[POST_USERS_URL]))
  12. {
  13. bb_die($lang['NO_USER_ID_SPECIFIED']);
  14. }
  15. if (!$userdata['session_logged_in'])
  16. {
  17. redirect(LOGIN_URL . "?redirect={$_SERVER['REQUEST_URI']}");
  18. }
  19. if (!$ranks = $datastore->get('ranks'))
  20. {
  21. $datastore->update('ranks');
  22. $ranks = $datastore->get('ranks');
  23. }
  24. $poster_rank = $rank_image= $rank_style = $rank_select = '';
  25. if ($user_rank = $profiledata['user_rank'] AND isset($ranks[$user_rank]))
  26. {
  27. $rank_image = ($ranks[$user_rank]['rank_image']) ? '<img src="'. $ranks[$user_rank]['rank_image'] .'" alt="" title="" border="0" />' : '';
  28. $poster_rank = $ranks[$user_rank]['rank_title'];
  29. $rank_style = $ranks[$user_rank]['rank_style'];
  30. }
  31. if (IS_ADMIN)
  32. {
  33. $rank_select = array($lang['NONE'] => 0);
  34. foreach ($ranks as $row)
  35. {
  36. $rank_select[$row['rank_title']] = $row['rank_id'];
  37. }
  38. $rank_select = build_select('rank-sel', $rank_select, $user_rank);
  39. }
  40. if (bf($profiledata['user_opt'], 'user_opt', 'viewemail') || $profiledata['user_id'] == $userdata['user_id'] || IS_AM)
  41. {
  42. $email_uri = ($bb_cfg['board_email_form']) ? 'profile.php?mode=email&amp;'. POST_USERS_URL .'='. $profiledata['user_id'] : 'mailto:'. $profiledata['user_email'];
  43. $email = '<a class="editable" href="'. $email_uri .'">'. $profiledata['user_email'] .'</a>';
  44. }
  45. else
  46. {
  47. $email = '';
  48. }
  49. // Report
  50. //
  51. // Get report user module and create report link
  52. //
  53. include(INC_DIR ."functions_report.php");
  54. $report_user = report_modules('name', 'report_user');
  55. if ($report_user && $report_user->auth_check('auth_write'))
  56. {
  57. $template->assign_block_vars('switch_report_user', array());
  58. $template->assign_vars(array(
  59. 'U_REPORT_USER' => 'report.php?mode='. $report_user->mode .'&amp;id='. $profiledata['user_id'],
  60. 'L_REPORT_USER' => $report_user->lang['WRITE_REPORT'])
  61. );
  62. }
  63. // Report [END]
  64. //
  65. // Generate page
  66. //
  67. $profile_user_id = ($profiledata['user_id'] == $userdata['user_id']);
  68. $signature = ($bb_cfg['allow_sig'] && $profiledata['user_sig']) ? $profiledata['user_sig'] : '';
  69. if(bf($profiledata['user_opt'], 'user_opt', 'allow_sig'))
  70. {
  71. if($profile_user_id)
  72. {
  73. $signature = $lang['SIGNATURE_DISABLE'];
  74. }
  75. else
  76. {
  77. $signature = '';
  78. }
  79. }
  80. else if ($signature)
  81. {
  82. $signature = bbcode2html($signature);
  83. }
  84. $template->assign_vars(array(
  85. 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
  86. 'USERNAME' => $profiledata['username'],
  87. 'PROFILE_USER_ID' => $profiledata['user_id'],
  88. 'PROFILE_USER' => $profile_user_id,
  89. 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', 'false'),
  90. 'POSTER_RANK' => ($poster_rank) ? "<span class=\"$rank_style\">". $poster_rank ."</span>" : $lang['USER'],
  91. 'RANK_IMAGE' => $rank_image,
  92. 'RANK_SELECT' => $rank_select,
  93. 'POSTS' => $profiledata['user_posts'],
  94. 'PM' => '<a href="' . PM_URL . '?mode=post&amp;'. POST_USERS_URL .'='. $profiledata['user_id'] .'">'. $lang['SEND_PRIVATE_MESSAGE'] .'</a>',
  95. 'EMAIL' => $email,
  96. 'WWW' => $profiledata['user_website'],
  97. 'ICQ' => $profiledata['user_icq'],
  98. 'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i', 'false') : $lang['NEVER'],
  99. 'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i', 'false') : $lang['NEVER'],
  100. 'ALLOW_DLS' => bf($profiledata['user_opt'], 'user_opt', 'allow_dls'),
  101. 'LOCATION' => $profiledata['user_from'],
  102. 'USER_ACTIVE' => $profiledata['user_active'],
  103. 'OCCUPATION' => $profiledata['user_occ'],
  104. 'INTERESTS' => $profiledata['user_interests'],
  105. 'SKYPE' => $profiledata['user_skype'],
  106. 'USER_POINTS' => $profiledata['user_points'],
  107. 'GENDER' => ($bb_cfg['gender'] && $profiledata['user_gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '',
  108. 'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? date('Y-m-d', strtotime($profiledata['user_birthday'])) : '',
  109. 'AGE' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? birthday_age($profiledata['user_birthday']) : '',
  110. 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
  111. 'U_SEARCH_USER' => "search.php?search_author=1&amp;uid={$profiledata['user_id']}",
  112. 'U_SEARCH_TOPICS' => "search.php?uid={$profiledata['user_id']}&amp;myt=1",
  113. 'U_SEARCH_RELEASES' => "tracker.php?rid={$profiledata['user_id']}#results",
  114. 'AVATAR_IMG' => get_avatar($profiledata['user_id'], $profiledata['avatar_ext_id'], !bf($profiledata['user_opt'], 'user_opt', 'allow_avatar')),
  115. 'AVATAR_DISALLOWED' => bf($profiledata['user_opt'], 'user_opt', 'allow_avatar'),
  116. 'S_PROFILE_ACTION' => 'profile.php',
  117. 'SIGNATURE' => $signature,
  118. 'SHOW_PASSKEY' => (IS_ADMIN || $profile_user_id),
  119. 'SHOW_ROLE' => (IS_AM || $profile_user_id || $profiledata['user_active']),
  120. 'GROUP_MEMBERSHIP' => false,
  121. 'TRAF_STATS' => !(IS_AM || $profile_user_id),
  122. 'U_MANAGE' => (IS_ADMIN) ? "profile.php?mode=editprofile&amp;u={$profiledata['user_id']}" : 'profile.php?mode=editprofile',
  123. ));
  124. if (IS_ADMIN)
  125. {
  126. $group_membership = array();
  127. $sql = "
  128. SELECT COUNT(g.group_id) AS groups_cnt, g.group_single_user, ug.user_pending
  129. FROM ". BB_USER_GROUP ." ug
  130. LEFT JOIN ". BB_GROUPS ." g USING(group_id)
  131. WHERE ug.user_id = {$profiledata['user_id']}
  132. GROUP BY ug.user_id, g.group_single_user, ug.user_pending
  133. ORDER BY NULL
  134. ";
  135. if ($rowset = DB()->fetch_rowset($sql))
  136. {
  137. $member = $pending = $single = 0;
  138. foreach ($rowset as $row)
  139. {
  140. if (!$row['group_single_user'] && !$row['user_pending'])
  141. {
  142. $member = $row['groups_cnt'];
  143. }
  144. else if (!$row['group_single_user'] && $row['user_pending'])
  145. {
  146. $pending = $row['groups_cnt'];
  147. }
  148. else if ($row['group_single_user'])
  149. {
  150. $single = $row['groups_cnt'];
  151. }
  152. }
  153. if ($member) $group_membership[] = $lang['PARTY'] ." <b>$member</b>";
  154. if ($pending) $group_membership[] = $lang['CANDIDATE'] ." <b>$pending</b>";
  155. if ($single) $group_membership[] = $lang['INDIVIDUAL'];
  156. $group_membership = join(', ', $group_membership);
  157. }
  158. $template->assign_vars(array(
  159. 'GROUP_MEMBERSHIP' => (bool) $group_membership,
  160. 'GROUP_MEMBERSHIP_TXT' => $group_membership,
  161. ));
  162. }
  163. else if (IS_MOD)
  164. {
  165. $template->assign_vars(array(
  166. 'SHOW_GROUP_MEMBERSHIP' => ($profiledata['user_level'] != USER),
  167. ));
  168. }
  169. // Ajax bt_userdata
  170. if (IS_AM || $profile_user_id)
  171. {
  172. show_bt_userdata($profiledata['user_id']);
  173. }
  174. else
  175. {
  176. $template->assign_vars(array(
  177. 'DOWN_TOTAL_BYTES' => false,
  178. 'MIN_DL_BYTES' => false,
  179. ));
  180. }
  181. if (IS_ADMIN)
  182. {
  183. $template->assign_vars(array(
  184. 'EDITABLE_TPLS' => true,
  185. 'U_PERMISSIONS' => "admin/admin_ug_auth.php?mode=user&amp;u={$profiledata['user_id']}",
  186. ));
  187. $ajax_user_opt = bb_json_encode(array(
  188. 'allow_avatar' => bf($profiledata['user_opt'], 'user_opt', 'allow_avatar'),
  189. 'allow_sig' => bf($profiledata['user_opt'], 'user_opt', 'allow_sig'),
  190. 'allow_passkey' => bf($profiledata['user_opt'], 'user_opt', 'allow_passkey'),
  191. 'allow_pm' => bf($profiledata['user_opt'], 'user_opt', 'allow_pm'),
  192. 'allow_post' => bf($profiledata['user_opt'], 'user_opt', 'allow_post'),
  193. 'allow_post_edit' => bf($profiledata['user_opt'], 'user_opt', 'allow_post_edit'),
  194. 'allow_topic' => bf($profiledata['user_opt'], 'user_opt', 'allow_topic'),
  195. ));
  196. $template->assign_vars(array(
  197. 'EDITABLE_TPLS' => true,
  198. 'AJAX_USER_OPT' => $ajax_user_opt,
  199. 'EMAIL_ADDRESS' => htmlCHR($profiledata['user_email']),
  200. ));
  201. }
  202. $user_restrictions = array();
  203. if (bf($profiledata['user_opt'], 'user_opt', 'allow_avatar')) $user_restrictions[] = $lang['HIDE_AVATARS'];
  204. if (bf($profiledata['user_opt'], 'user_opt', 'allow_sig')) $user_restrictions[] = $lang['SHOW_CAPTION'];
  205. if (bf($profiledata['user_opt'], 'user_opt', 'allow_passkey')) $user_restrictions[] = $lang['DOWNLOAD_TORRENT'];
  206. if (bf($profiledata['user_opt'], 'user_opt', 'allow_pm')) $user_restrictions[] = $lang['SEND_PM'];
  207. if (bf($profiledata['user_opt'], 'user_opt', 'allow_post')) $user_restrictions[] = $lang['SEND_MESSAGE'];
  208. if (bf($profiledata['user_opt'], 'user_opt', 'allow_post_edit')) $user_restrictions[] = $lang['EDIT_POST'];
  209. if (bf($profiledata['user_opt'], 'user_opt', 'allow_topic')) $user_restrictions[] = $lang['NEW_THREADS'];
  210. $template->assign_var('USER_RESTRICTIONS', join('</li><li>', $user_restrictions));
  211. print_page('usercp_viewprofile.tpl');