home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / includes / usercp_viewprofile.php < prev   
PHP Script  |  2004-07-11  |  14KB  |  286 lines

  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.1 2003/02/25 23:28:30 acydburn Exp $
  10.  *
  11.  *
  12.  ***************************************************************************/
  13. /***************************************************************************
  14. * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  15. *
  16. * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  17. * and debugging completed by the Elite Nukers and site members.
  18. *
  19. * You run this package at your sole risk. Nuke Cops and affiliates cannot
  20. * be held liable if anything goes wrong. You are advised to test this
  21. * package on a development system. Backup everything before implementing
  22. * in a production environment. If something goes wrong, you can always
  23. * backout and restore your backups.
  24. *
  25. * Installing and running this also means you agree to the terms of the AUP
  26. * found at Nuke Cops.
  27. *
  28. * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  29. * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  30. * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  31. * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  32. * invalid_session error message.
  33. ***************************************************************************/
  34. /***************************************************************************
  35.  *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  36.  *   by Tom Nitzschner (tom@toms-home.com)
  37.  *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  38.  *
  39.  *   As always, make a backup before messing with anything. All code
  40.  *   release by me is considered sample code only. It may be fully
  41.  *   functual, but you use it at your own risk, if you break it,
  42.  *   you get to fix it too. No waranty is given or implied.
  43.  *
  44.  *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  45.  *   then on my site. All original header code and copyright messages will be maintained
  46.  *   to give credit where credit is due. If you modify this, the only requirement is
  47.  *   that you also maintain all original copyright messages. All my work is released
  48.  *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  49.  *
  50.  ***************************************************************************/
  51. /***************************************************************************
  52.  *
  53.  *   This program is free software; you can redistribute it and/or modify
  54.  *   it under the terms of the GNU General Public License as published by
  55.  *   the Free Software Foundation; either version 2 of the License, or
  56.  *   (at your option) any later version.
  57.  *
  58.  *
  59.  ***************************************************************************/
  60.  
  61. if ( !defined('IN_PHPBB') )
  62. {
  63.         die("Hacking attempt");
  64.         exit;
  65. }
  66.  
  67. if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
  68. {
  69.         message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  70. }
  71. $profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
  72.  
  73. $sql = "SELECT *
  74.         FROM " . RANKS_TABLE . "
  75.         ORDER BY rank_special, rank_min";
  76. if ( !($result = $db->sql_query($sql)) )
  77. {
  78.         message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
  79. }
  80.  
  81. while ( $row = $db->sql_fetchrow($result) )
  82. {
  83.         $ranksrow[] = $row;
  84. }
  85. $db->sql_freeresult($result);
  86.  
  87. //
  88. // Output page header and profile_view template
  89. //
  90. $template->set_filenames(array(
  91.         'body' => 'profile_view_body.tpl')
  92. );
  93. if (is_active("Forums")) {
  94.     make_jumpbox('viewforum.'.$phpEx);
  95. }
  96. //
  97. // Calculate the number of days this user has been a member ($memberdays)
  98. // Then calculate their posts per day
  99. //
  100. $regdate = $profiledata['user_regdate'];
  101. $nukedate = strtotime($regdate);
  102. $memberdays = max(1, round( ( time() - $nukedate ) / 86400 ));
  103. $posts_per_day = $profiledata['user_posts'] / $memberdays;
  104.  
  105. // Get the users percentage of total posts
  106. if ( $profiledata['user_posts'] != 0  )
  107. {
  108.         $total_posts = get_db_stat('postcount');
  109.         $percentage = ( $total_posts ) ? min(100, ($profiledata['user_posts'] / $total_posts) * 100) : 0;
  110. }
  111. else
  112. {
  113.         $percentage = 0;
  114. }
  115.  
  116. $avatar_img = '';
  117. if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] )
  118. {
  119.         switch( $profiledata['user_avatar_type'] )
  120.         {
  121.                 case USER_AVATAR_UPLOAD:
  122.                         $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
  123.                         break;
  124.                 case USER_AVATAR_REMOTE:
  125.                         $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
  126.                         break;
  127.                 case USER_AVATAR_GALLERY:
  128.                         $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : '';
  129.                         break;
  130.         }
  131. }
  132.  
  133. $poster_rank = '';
  134. $rank_image = '';
  135. if ( $profiledata['user_rank'] )
  136. {
  137.         for($i = 0; $i < count($ranksrow); $i++)
  138.         {
  139.                 if ( $profiledata['user_rank'] == $ranksrow[$i]['rank_id'] && $ranksrow[$i]['rank_special'] )
  140.                 {
  141.                         $poster_rank = $ranksrow[$i]['rank_title'];
  142.                         $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
  143.                 }
  144.         }
  145. }
  146. else
  147. {
  148.         for($i = 0; $i < count($ranksrow); $i++)
  149.         {
  150.                 if ( $profiledata['user_posts'] >= $ranksrow[$i]['rank_min'] && !$ranksrow[$i]['rank_special'] )
  151.                 {
  152.                         $poster_rank = $ranksrow[$i]['rank_title'];
  153.                         $rank_image = ( $ranksrow[$i]['rank_image'] ) ? '<img src="' . $ranksrow[$i]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
  154.                 }
  155.         }
  156. }
  157.  
  158. $temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);
  159. if (is_active("Private_Messages")) {
  160.     $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
  161.     $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
  162. }
  163.  
  164. if ( !empty($profiledata['user_viewemail']) || $userdata['user_level'] == ADMIN )
  165. {
  166.         $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $profiledata['user_id']) : 'mailto:' . $profiledata['user_email'];
  167.  
  168.         $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
  169.         $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
  170. }
  171. else
  172. {
  173.         $email_img = ' ';
  174.         $email = ' ';
  175. }
  176. if (( $profiledata['user-website'] == "http:///") || ( $profiledata['user_website'] == "http://")){
  177.     $profiledata['user_website'] =  "";
  178. }
  179. if (($profiledata['user_website'] != "" ) && (substr($profiledata['user_website'],0, 7) != "http://")) {
  180.     $profiledata['user_website'] = "http://".$profiledata['user_website'];
  181. }
  182.  
  183. $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>' : ' ';
  184. $www = ( $profiledata['user_website'] ) ? '<a href="' . $profiledata['user_website'] . '" target="_userwww">' . $profiledata['user_website'] . '</a>' : ' ';
  185.  
  186. if ( !empty($profiledata['user_icq']) )
  187. {
  188.         $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>';
  189.         $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>';
  190.         $icq =  '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '">' . $lang['ICQ'] . '</a>';
  191. }
  192. else
  193. {
  194.         $icq_status_img = ' ';
  195.         $icq_img = ' ';
  196.         $icq = ' ';
  197. }
  198.  
  199. $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>' : ' ';
  200. $aim = ( $profiledata['user_aim'] ) ? '<a href="aim:goim?screenname=' . $profiledata['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : ' ';
  201.  
  202. $msn_img = ( $profiledata['user_msnm'] ) ? $profiledata['user_msnm'] : ' ';
  203. $msn = $msn_img;
  204.  
  205. $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>' : '';
  206. $yim = ( $profiledata['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $profiledata['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
  207.  
  208. $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username']) . "&showresults=posts");
  209. $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
  210. $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
  211. #
  212. //
  213. // Generate page
  214. //
  215. $page_title = $lang['Viewing_profile'];
  216. include("includes/page_header.php");
  217. $profiledata['user_from'] = str_replace(".gif", "", $profiledata['user_from']);
  218.  
  219. //modifikace datumu registrace dle narodnich podmφnek - start
  220. $usercp_viewprolfile_file = 1;
  221. include('includes/phpbb_date_fix.php');
  222. //modifikace datumu registrace - konec
  223.  
  224. $template->assign_vars(array(
  225.         'USERNAME' => $profiledata['username'],
  226.         'JOINED' => $new_date_by_locale,
  227.         'POSTER_RANK' => $poster_rank,
  228.         'RANK_IMAGE' => $rank_image,
  229.         'POSTS_PER_DAY' => $posts_per_day,
  230.         'POSTS' => $profiledata['user_posts'],
  231.         'PERCENTAGE' => $percentage . '%',
  232.         'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
  233.         'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
  234.         'SEARCH_IMG' => $search_img,
  235.         'SEARCH' => $search,
  236.         'PM_IMG' => $pm_img,
  237.         'PM' => $pm,
  238.         'EMAIL_IMG' => $email_img,
  239.         'EMAIL' => $email,
  240.         'WWW_IMG' => $www_img,
  241.         'WWW' => $www,
  242.         'ICQ_STATUS_IMG' => $icq_status_img,
  243.         'ICQ_IMG' => $icq_img,
  244.         'ICQ' => $icq,
  245.         'AIM_IMG' => $aim_img,
  246.         'AIM' => $aim,
  247.         'MSN_IMG' => $msn_img,
  248.         'MSN' => $msn,
  249.         'YIM_IMG' => $yim_img,
  250.         'YIM' => $yim,
  251.  
  252.         'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : ' ',
  253.         'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : ' ',
  254.         'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ',
  255.         'AVATAR_IMG' => $avatar_img,
  256.  
  257.         'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
  258.         'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
  259.         'L_AVATAR' => $lang['Avatar'],
  260.         'L_POSTER_RANK' => $lang['Poster_rank'],
  261.         'L_JOINED' => $lang['Joined'],
  262.         'L_TOTAL_POSTS' => $lang['Total_posts'],
  263.         'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
  264.         'L_CONTACT' => $lang['Contact'],
  265.         'L_EMAIL_ADDRESS' => $lang['Email_address'],
  266.         'L_EMAIL' => $lang['Email'],
  267.         'L_PM' => $lang['Private_Message'],
  268.         'L_ICQ_NUMBER' => $lang['ICQ'],
  269.         'L_YAHOO' => $lang['YIM'],
  270.         'L_AIM' => $lang['AIM'],
  271.         'L_MESSENGER' => $lang['MSNM'],
  272.         'L_WEBSITE' => $lang['Website'],
  273.         'L_LOCATION' => $lang['Location'],
  274.         'L_OCCUPATION' => $lang['Occupation'],
  275.         'L_INTERESTS' => $lang['Interests'],
  276.  
  277.         'U_SEARCH_USER' => append_sid("search.$phpEx?search_author=" . urlencode($profiledata['username'])),
  278.  
  279.         'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
  280. );
  281.  
  282. $template->pparse('body');
  283.  
  284. include("includes/page_tail.php");
  285.  
  286. ?>