<?php

  $uid = intval($_REQUEST["uid"]);
  $this_user = forum_user($uid);
  if (!$this_user) {

    /************
     * initiate template and assign variables
     ************/         
    $QuickSkin = new QuickSkin("status_messages.html");
    $QuickSkin->assign("INFO",lang("usernotfound"));
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  } else {
    
    $this_user_post_count = forum_user_post_count($this_user->id);
    
    //Template Variables

    $DESCR_SHOWPROFILE = lang("showprofile") . ":";
    $DESCR_USERLEVEL =  lang("userlevel");
    $DESCR_USERMESS = lang("contact_member");
    $IMG_EMAIL_TITLE = lang("btn_email");
    $IMG_PM_TITLE = lang("btn_pm");
    $DESCR_JOININGDATE = lang("joingdate");
    $DESCR_POSTS = lang("posts");
    $DESCR_SHOWPOSTS = sprintf(lang("showpostsof"), $this_user->user);
    $DESCR_NOUSERMESS = lang("notification_dis");
    
    $DESCR_BIRTHDAY = lang("birthday");
    $DESCR_LOCATION = lang("location");
    $DESCR_INTERESTS = lang("interests");
    $DESCR_WEBSITE = lang("website");
    $DESCR_OCCUPATION = lang("occupation");
    $DESCR_USERRANK = lang("user_rank");
    
    $USER_NAME = $this_user->user;
    
    if ($board_config->en_avatar) {
      if ($this_user->sbb_avatar) {
        $USER_AVATAR = "$rel_path/images/avatars/" . $this_user->sbb_avatar;
      } elseif ($this_user->gravatar) {
        $USER_AVATAR = gravatar($this_user->email);
      } elseif ($this_user->avatar) {
        $USER_AVATAR = $conf_data_dir . "/" . $this_user->id . "/avatar/" . $this_user->avatar;
      } elseif ($board_config->default_avatar) {
        $USER_AVATAR = $template_path . "/images/anonymous.png";
      }
    }
    
    if ($this_user->rank_id) {
      $USER_RANK_IMG_SRC = "$rel_path/images/ranks/" . $userrank[$this_user->rank_id]->img;
      $USER_RANK = he($userrank[$this_user->rank_id]->descr);
    }
            
    $USER_ID = $uid;
    $USER_CLASS = nick_class($this_user->is_admin, $this_user->is_mod);
    $USER_JOININGDATE = date($date_format, strtotime($this_user->created));
    $USER_POSTS = $this_user_post_count;
    if ($this_user->birthday) {
      $USER_BIRTHDAY = ($this_user->age ? date($board_config->date_format,strtotime($this_user->birthday)) . " (" . $this_user->age . ")" : date($board_config->date_md_format,strtotime($this_user->birthday)));
    }
    $USER_LOCATION = $this_user->location;
    if ($this_user->website) {
      $USER_WEBSITE = "<a href='" . $this_user->website . "' onclick='javascript:window.open(this.href); return false;'>" . $this_user->website . "</a>";
    }
    $USER_INTERESTS = $this_user->interests;
    $USER_OCCUPATION = $this_user->occupation;
    
    if ($this_user->is_admin) $USER_LEVEL = lang("administrator");
    elseif ($this_user->is_mod) $USER_LEVEL = lang("moderator");
    else $USER_LEVEL = lang("defaultuser");
    
    if ($this_user->usermail && $board_config->en_user_mess) {
      $TEMPLATE_FLAGS["USERMESS"] = true;
    }
    
    $LINK_SENDMAIL = ($board_config->seo ? "$main_path/sbb-sendmail" . $uid . ".html" : "$main_script?todo=sendmail&amp;uid=$uid");
    $LINK_USERPOSTS = ($board_config->seo ? "$main_path/sbb-userposts" . $uid . ".html" : "$main_script?todo=search&amp;w=userposts&amp;uid=$uid");
    $LINK_PM = ($board_config->seo ? "$main_path/sbb-sendpm" . $uid . ".html" : "$main_script?todo=sendpm&amp;uid=$uid");
    
    /************
     * initiate template and assign variables
     ************/ 
    $showprofileVARS = array('DESCR_SHOWPROFILE' => $DESCR_SHOWPROFILE,
                            'DESCR_USERLEVEL' => $DESCR_USERLEVEL,
                            'DESCR_USERMESS' => $DESCR_USERMESS,
                            'IMG_EMAIL_TITLE' => $IMG_EMAIL_TITLE,
                            'DESCR_JOININGDATE' => $DESCR_JOININGDATE,
                            'DESCR_POSTS' => $DESCR_POSTS,
                            'DESCR_SHOWPOSTS' => $DESCR_SHOWPOSTS,
                            'DESCR_NOUSERMESS' => $DESCR_NOUSERMESS,
                            'DESCR_BIRTHDAY' => $DESCR_BIRTHDAY,
                            'DESCR_LOCATION' => $DESCR_LOCATION,
                            'DESCR_INTERESTS' => $DESCR_INTERESTS,
                            'DESCR_WEBSITE' => $DESCR_WEBSITE,
                            'DESCR_OCCUPATION' => $DESCR_OCCUPATION,
                            'IMG_PM_TITLE' => $IMG_PM_TITLE,
                            'LINK_PM' => $LINK_PM,
                            'USER_ID' => $USER_ID,
                            'USER_NAME' => $USER_NAME,
                            'USER_CLASS' => $USER_CLASS,
                            'USER_JOININGDATE' => $USER_JOININGDATE,
                            'USER_POSTS' => $USER_POSTS,
                            'USER_LEVEL' => $USER_LEVEL,
                            'USER_AVATAR' => $USER_AVATAR,
                            'USER_BIRTHDAY' => $USER_BIRTHDAY,
                            'USER_LOCATION' => $USER_LOCATION,
                            'USER_INTERESTS' => $USER_INTERESTS,
                            'USER_WEBSITE' => $USER_WEBSITE,
                            'USER_OCCUPATION' => $USER_OCCUPATION,
                            'LINK_SENDMAIL' => $LINK_SENDMAIL,
                            'LINK_USERPOSTS' => $LINK_USERPOSTS,
                            'DESCR_USERRANK' => $DESCR_USERRANK,
                            'USER_RANK_IMG_SRC' => $USER_RANK_IMG_SRC,
                            'USER_RANK' => $USER_RANK,

                            'CONF' => $GLOBAL_TEMPLATE_VARS,
                            'FLAGS' => $TEMPLATE_FLAGS
                            );

    $QuickSkin = new QuickSkin("showprofile.html");
    $QuickSkin->assign($showprofileVARS);
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  } //User found
  



?>