<?php
session_start();

include("includes/site_config.php");
//include('session_handler.inc.php');
include('includes/functions.php');

//echo $_REQUEST["user_id"];
if(!isset($_REQUEST["user_id"]))       
{    
// Save current request and redirect to the login page.
//save_request();
	echo "<script>location.href='" . $CONST_LINK_ROOT . "/login.php?redir=1'</script>";
//header("Location: $CONST_LINK_ROOT/login.php?redir=1");
//exit;
}
//$Sess_UserId = 14845;
$Sess_UserId=$_REQUEST["user_id"];
$Sess_UserType=$_SESSION['Sess_UserType'];
$Sess_Userlevel=$_SESSION['Sess_Userlevel']; $Sess_UserName=$_SESSION['Sess_UserName'];

include_once __INCLUDE_CLASS_PATH."/class.Adverts.php";
$adv = new Adverts();

# retrieve the template

$area = 'member';
include_once __INCLUDE_CLASS_PATH."/class.DB.php";
$db = new DB();
$ONLINE = $db->get_var("SELECT COUNT(mem_timeout)
					        FROM members
					            INNER JOIN adverts ON (adv_userid=mem_userid)
					        WHERE
					          adv_approved=1
					          AND adv_paused='N'
					          AND unix_timestamp(mem_timeout) > unix_timestamp(NOW())-".ONLINE_TIMEOUT_PERIOD*60);

# Email Notification
$MSGTOTAL = $db->get_var("SELECT COUNT(msg_receiverid) FROM messages WHERE (msg_receiverid='$Sess_UserId') AND msg_receiverdel='N' AND msg_read='U'");

# get member handle for welcome message
$handle = $db->get_var("SELECT mem_username FROM members WHERE mem_userid=$Sess_UserId");

# check users member status to display expire date
if ($Sess_Userlevel!="silver") {
        $exp_date = $db->get_var("SELECT unix_timestamp(mem_expiredate) FROM members WHERE mem_userid = '$Sess_UserId'");
        $retStatus= "".GENERAL_WELCOME_STATUS_GOLD." ".date($CONST_FORMAT_DATE_SHORT,$exp_date);
} else {
        $retStatus= "".GENERAL_WELCOME_STATUS_SILVER." <a href='$CONST_LINK_ROOT/get_premium.php?PHPSESSID=".session_id()."'>".HOME_UPGRADE."</a>";
}
?>
<?=$skin->ShowHeader($area)?>
<table width="<?php print("$CONST_TABLE_WIDTH"); ?>" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
  <tr> 
    <td align="right"> 
      <?php 	  	  //require_once("$CONST_INCLUDE_ROOT/user_status.inc.php");	  require_once("user_status.inc.php");	  	  	  ?>
    </td>
  </tr>
  <tr> 
    <td class="pageheader"> 
      <?= GENERAL_WELCOME?>
      <?php print("$handle"); ?></td>
  </tr>
  <tr> 
    <td> <table width="100%"  border="0" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>">
        <tr align="left"  > 
          <td align="right" valign="top" nowrap> <table width="100%"  border="0" cellpadding="5" cellspacing="0">
              <tr> 
                <td colspan="4" align="left" class="tdhead"><?php print("$retStatus"); ?></td>
              </tr>
              <tr class="tdtoprow"> 
                <td colspan="2" align="left" ><?php echo $MSGTOTAL ?> 
                  <?= HOME_UNREAD?>
                  . 
                  <?php if($MSGTOTAL > 0)  print("<a href='$CONST_LINK_ROOT/myemail.php?$sess_id'><img border='0' src='$CONST_IMAGE_ROOT/icons/mail.gif' width='16' height='12'><a>"); ?>
                </td>
                <td colspan="2" align="left"><a href="whoson.php?<?php echo $sess_id ?>"> 
                  <?=$ONLINE ?>
                  </a>&nbsp; 
                  <?= HOME_NOW ?>
                </td>
              </tr>
              <tr> 
                <td width="1%" align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_03.gif"></td>
                <td width="48%" align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/prghotlist.php?<?php echo $sess_id ?>"> 
                  <?= HOME_FRIENDS?>
                  </a></td>
                <td width="1%" align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_05.gif"></td>
                <td width="48%" align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/myinfo.php?<?php echo $sess_id ?>"> 
                  <?= HOME_SETTINGS?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_09.gif"></td>
                <td align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/myemail.php?<?php echo $sess_id ?>"> 
                  <?= HOME_EMAIL?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_10.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/prgamendad.php?<?php echo $sess_id ?>"> 
                  <?= HOME_PROFILE?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_13.gif"></td>
                <td align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/search.php?<?php echo $sess_id ?>"> 
                  <?= HOME_SEARCH?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_14.gif"></td>
                <td align="left" class="tdodd"><a href="<?="$CONST_LINK_ROOT/prgpicadmin.php?PHPSESSID=".session_id()."&mode=show"?>"> 
                  <?= HOME_VIDEO?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_17.gif"></td>
                <td align="left" class="tdodd"> <a href="javascript:MDM_openWindow('<?php echo $CONST_LINK_ROOT?>/messenger/?<?php echo $sess_id ?>&new_win_launched=TRUE','IM','width=146,height=298')"> 
                  <?= HOME_MESS?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/blog.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_BLOG_LINK_ROOT?>/myblogs.php?<?php echo $sess_id ?>"> 
                  <?= MYBLOGS_SECTION_NAME?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icon_new.gif"></td>
                <td align="left" class="tdodd"> <a href="javascript:MDM_openWindow('<?php echo $CONST_LINK_ROOT?>/prgencounters.php?<?php echo $sess_id ?>','Encounters','scrollbars=yes, width=560,height=550')"> 
                  <?= HOME_ENCOUNT?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_21.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/get_premium.php?<?php echo $sess_id ?>"> 
                  <?= HOME_UPGRADE?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_22.gif"></td>
                <td align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/eventscalendar.php?<?php echo $sess_id ?>"> 
                  <?= HOME_CALENDAR?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/my_interests.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/my_interests.php?<?php echo $sess_id ?>"> 
                  <?= HOME_MY_INTERESTS?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/whos_online.gif"></td>
                <td align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/whoson.php?<?php echo $sess_id ?>"> 
                  <?= HOME_WHOSEON?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/interested_me.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/interested_in_me.php?<?php echo $sess_id ?>"> 
                  <?= HOME_INTERESTED_IN_ME?>
                  </a></td>
              </tr>
              <tr> 
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/my_match.gif"></td>
                <td align="left" class="tdodd"> <a href="<?php echo $CONST_LINK_ROOT?>/my_matches.php?<?php echo $sess_id ?>"> 
                  <?= HOME_MYMATCH?>
                  </a></td>
                <td align="left" class="tdodd"><img src="<?php echo $CONST_IMAGE_ROOT?>/icons/icons_25.gif"></td>
                <td align="left" class="tdodd"><a href="<?php echo $CONST_LINK_ROOT?>/logoff.php?<?php echo $sess_id ?>"> 
                  <?= HOME_LOGOUT?>
                  </a></td>
              </tr>
              <tr> 
                <td colspan="4" align="left" class="tdfoot">&nbsp;</td>
              </tr>
              <? //if ($option_manager->GetValue('snetwork')){?>
              <tr > 
                <td colspan="2" align="left" class="tdhead"><?php echo SOCIAL_NETWORK_SECTION_NAME ?></td>
                <td colspan="2" align="right" class="tdhead"><a class='forumlinks' href="<?php echo $CONST_LINK_ROOT?>/invitefriend.php?<?php echo $sess_id ?>"> 
                  <?= HOME_INVITE_FRIENDS?>
                  </a></td>
              </tr>
              <tr> 
                <td colspan="4" class="td2"><? include_once "$CONST_NETWORK_INCLUDE_ROOT/requests.inc.php"?>
                 <?=display_network_friends($Sess_UserId)?>
                </td>
              </tr>
              
              <?//}?>
              <tr> 
                <td colspan="4" align="center" class="tdfoot"> 
                  <?php if ($Sess_UserType == "A") print("<img src='$CONST_IMAGE_ROOT/icons/icons_26.gif'> <a href='$CONST_LINK_ROOT/admin/index.php?$sess_id'>".HOME_ADMIN."</a><br>"); ?>
                  <?= $CONST_LINK_LANG_SWITCHER;?>
                </td>
              </tr>
            </table></td>
        </tr>
       
        
      </table></td>
  </tr>
</table>
<?=$skin->ShowFooter($area)?>
