PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/profile_view_user.php

https://github.com/igorw-forks/icy_phoenix
PHP | 82 lines | 60 code | 12 blank | 10 comment | 4 complexity | 08e3ae86ac90191f9cf2b8007599396e MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. define('IN_ICYPHOENIX', true);
  11. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
  12. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  13. include(IP_ROOT_PATH . 'common.' . PHP_EXT);
  14. // Start session management
  15. $userdata = session_pagestart($user_ip);
  16. init_userprefs($userdata);
  17. // End session management
  18. $link_name = $lang['Profile_viewed'];
  19. $nav_server_url = create_server_url();
  20. $breadcrumbs_address = $lang['Nav_Separator'] . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_PROFILE_MAIN) . '"' . (!empty($link_name) ? '' : ' class="nav-current"') . '>' . $lang['Profile'] . '</a>' . (!empty($link_name) ? ($lang['Nav_Separator'] . '<a class="nav-current" href="#">' . $link_name . '</a>') : '');
  21. include_once(IP_ROOT_PATH . 'includes/users_zebra_block.' . PHP_EXT);
  22. $user_id = request_var(POST_USERS_URL, 0);
  23. $start = request_var('start', 0);
  24. $start = ($start < 0) ? 0 : $start;
  25. $sql = "SELECT username FROM " . USERS_TABLE . "
  26. WHERE user_id = '" . $user_id . "'";
  27. $result = $db->sql_query($sql);
  28. $profile = $db->sql_fetchrow($result);
  29. if (!is_array($profile))
  30. {
  31. message_die(GENERAL_ERROR, "Unknown User-ID!!!", '', __LINE__, __FILE__, $sql);
  32. }
  33. $sql = "SELECT p.*, u.user_avatar_type, u.user_allowavatar, u.user_avatar
  34. FROM " . PROFILE_VIEW_TABLE . " p, " . USERS_TABLE . " u
  35. WHERE p.viewer_id = u.user_id
  36. AND p.user_id = " . $user_id;
  37. $result = $db->sql_query($sql);
  38. $total = $db->sql_numrows($result);
  39. $db->sql_freeresult($result);
  40. $pagination = generate_pagination('profile_view_user.' . PHP_EXT . '?' . POST_USERS_URL . '=' . $user_id, $total, $config['posts_per_page'], $start);
  41. $sql = "SELECT p.*, u.username, u.user_active, u.user_color, u.user_level, u.user_avatar_type, u.user_allowavatar, u.user_avatar
  42. FROM " . PROFILE_VIEW_TABLE . " p, " . USERS_TABLE . " u
  43. WHERE p.viewer_id = u.user_id
  44. AND p.user_id = " . $user_id . "
  45. ORDER BY p.view_stamp DESC
  46. LIMIT " . $start . ", " . $config['posts_per_page'];
  47. $result = $db->sql_query($sql);
  48. while ($row = $db->sql_fetchrow($result))
  49. {
  50. $viewer = $row['viewer_id'];
  51. $viewer_avatar = user_get_avatar($row['viewer_id'], $row['user_level'], $row['user_avatar'], $row['user_avatar_type'], $row['user_allowavatar']);
  52. $template->assign_block_vars('row', array(
  53. 'AVATAR' => $viewer_avatar,
  54. 'VIEW_BY' => colorize_username($viewer, $row['username'], $row['user_color'], $row['user_active']),
  55. 'NUMBER' => $row['counter'],
  56. 'STAMP' => create_date_ip($userdata['user_dateformat'], $row['view_stamp'], $userdata['user_timezone'])
  57. )
  58. );
  59. }
  60. $template->assign_vars(array(
  61. 'PAGINATION' => $pagination,
  62. 'PROFILE' => '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $user_id) . '" class="nav-current">' . $profile['username'] . '</a>',
  63. 'L_VIEW_TITLE' => $meta_content['page_title'],
  64. 'L_VIEWER' => $lang['Username'],
  65. 'L_NUMBER' => $lang['Views'],
  66. 'L_STAMP' => $lang['Last_updated']
  67. )
  68. );
  69. full_page_generation('profile_view_user_body.tpl', $lang['Profile'] . ' - ' . $lang['Views'], '', '');
  70. ?>