<?php
include("includes/site_info.php");
include('session_handler.inc');
include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
$picture = new Picture();

$WUserID = $_SESSION['Sess_UserId'];
$WUserName = $_SESSION['Sess_UserName'];

if (isset($_REQUEST['uID'])) {
 $_REQUEST['VUserId'] = $_REQUEST['uID'];
}

if (isset($_REQUEST['VUserId'])) {
 $VUserID = $_REQUEST['VUserId'];
 $check_query=mysql_query("SELECT mem_userid FROM members LEFT JOIN adverts ON (mem_userid=adv_userid) where mem_userid='$VUserID' AND mem_confirm='1' AND adv_approved='1'",$link);
 $check_count=mysql_num_rows($check_query);
 $check_array = mysql_fetch_object($check_query);
 if ($check_count > 0) { $VUserID = $check_array->mem_userid; }
 else { echo "<script>location.href='" . $CONST_LINK_ROOT . "/index.php'</script>"; die; }
} else {
$VUserID = 0;
}

$member_query=mysql_query("SELECT *,(YEAR(CURDATE())-YEAR(adv_dob)) - (RIGHT(CURDATE(),5) < RIGHT(adv_dob,5)) AS age, DATE_FORMAT(adv_dob, '%M %d') as adv_dob, DATE_FORMAT(mem_lastvisit, '%d-%b-%Y, %r') as mem_lastvisit FROM adverts LEFT JOIN members ON (adv_userid=mem_userid) LEFT JOIN Geo_Countries ON (adv_countryid = CountryId) WHERE adv_userid = '$VUserID' AND adv_approved='1'") or die(mysql_error());

$TOTAL = mysql_num_rows($member_query);
?>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td><ul id="sidemenu">
				<li><a href="#ccover" onclick="javascript: callpage(this.href);" class="active">
					<div id="right_loading_c" class="right_loading"><img src="images/small_loader.gif" width="16" height="16" border="0" /></div>
					SOCIALIZER</a></li>
<!--				<li><a href="#mcover" onclick="javascript: callpage(this.href);">
					<div id="right_loading_m" class="right_loading"><img src="images/small_loader.gif" width="16" height="16" border="0" /></div>
					WauhhSociety</a></li>
-->			</ul>
			<!--ul id="sidemenu_sub">
      <li><a href="#cover" rel="sub_link" id="cover" onclick="javascript: callpage(this.href);">Cover</a></li>
      <li><a href="javascript:void(null)" rel="sub_link">Members</a></li>
      <li><a href="javascript:void(null)" rel="sub_link">Media</a></li>
      <li><a href="javascript:void(null)" rel="sub_link">Thougth</a></li>
      <li><a href="javascript:void(null)" rel="sub_link">Contribution</a></li>
       <li><a href="javascript:void(null)" rel="sub_link">Up Sharing</a></li>
   </ul--></td>
	</tr>
	<tr>
		<td><?php if($VUserID!=0) {

if ($TOTAL = 0){ print('<table width="100%" border="0" cellpadding="10" cellspacing="0" class="white_back_t_xb"><tr><td align="center">'.NO_RECORDS_SECTION_NAME.'</td></tr></table>');} else {

if ($VUserID != $WUserID && $WUserID!=0) {
	$retval=mysql_query("SELECT * FROM my_friends WHERE (uid='$WUserID' AND friend_uid='$VUserID') or (uid='$VUserID' AND friend_uid='$WUserID')",$link);
	$sql_array = mysql_fetch_object($retval);
	$result=mysql_num_rows($retval);

	if ($result == 0) {
	$request=1;
	} elseif ($sql_array->approved == 0) {
	$request=2;
	$retval=mysql_query("SELECT * FROM my_friends WHERE uid='$VUserID' AND friend_uid='$WUserID'",$link);
	$sql_array = mysql_fetch_object($retval);
	$result=mysql_num_rows($retval);
	if ($result == 0) {
	$request=2;
	} elseif ($sql_array->approved == 0) {
	$request=4;
	}else {
	$request=2;
	}
	} else {
	$request=0;
	}

}
	
$sql_array = mysql_fetch_object($member_query);
?>
			<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="white_back_t_xb">
				<?php 
$timeout = time()-900;
$query="SELECT COUNT(userid) FROM active_users where timestamp > $timeout AND userid=$sql_array->adv_userid";
$reton=mysql_query($query,$link) or die(mysql_error());
$totalon=mysql_result($reton,0,0);

if($totalon>0)
{$status="Online!";}
else{$status="Offline!";}

if ($WUserID==$sql_array->adv_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$sql_array->adv_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$sql_array->adv_userid' and pic_default='Y' and pic_private='N'") or die(mysql_error()); 
}
$pics_count = mysql_num_rows($photo_query);
$aPicture = mysql_fetch_object($photo_query);
if ($pics_count > 0) {
	$medium = $aPicture->pic_picture."_pb.".$aPicture->ext;
	$male1_picture1 = "$SITE_MAIN_WWW_ROOT/members/$sql_array->adv_username/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetPicFull($sql_array->adv_userid);
}
if ($sql_array->mem_profileid != null) { $male1_name1= $sql_array->mem_profileid; }
else { $male1_name1= $sql_array->mem_username; }
?>
				<tr>
<!--					<td width='200' align='center' valign="middle"><a href="<?=$SITE_MAIN_WWW_ROOT?>/<?=$male1_name1?>/socializer"><img src='<?=$male1_picture1?>' hspace="5" vspace="5" class="img_b_p3" title="View <?=ucwords($sql_array->adv_username)?>'s Site" border="0"/></a></td>
-->					<td width='200' align='center' valign="middle"><a href="<?=$SITE_MAIN_WWW_ROOT?>/<?=$male1_name1?>"><img src='<?=$male1_picture1?>' hspace="5" vspace="5" class="img_b_p3" title="View <?=ucwords($sql_array->adv_username)?>'s Site" border="0"/></a></td>
				</tr>
				<tr>
					<td align='center' valign="middle"><?php if ($request==1 || $request==3) { ?>
						<div id="send_request_<?=$sql_array->adv_userid?>" class="padding_b_10" align="center"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$sql_array->adv_userid?>&amp;RUserName=<?=$sql_array->adv_username?>&amp;mode=request'}, 'Request&nbsp;to&nbsp;Connect');" title="Label Me" class="button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Request to Connect</a></div>
						<div id="confirm_request_<?=$sql_array->adv_userid?>" class="none" align="center"> <span class="grey_10"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Pending Confirmation</span></div>
						<div id="accept_request_<?=$sql_array->adv_userid?>" class="none" align="center"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$sql_array->adv_userid?>&amp;AUserName=<?=$sql_array->adv_username?>&amp;mode=respond'}, 'Respond&nbsp;to&nbsp;Request');" title="Label Me" class="button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Accept Request</a></div>
						<?php } ?>
						<?php if ($request==2) { ?>
						<div class="padding_b_10" align="center"><span class="grey_10"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Pending Confirmation</span></div>
						<?php } ?>
						<?php if ($request==4) { ?>
						<div id="accept_request_<?=$sql_array->adv_userid?>" class="padding_b_10" align="center"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$sql_array->adv_userid?>&amp;AUserName=<?=$sql_array->adv_username?>&amp;mode=respond'}, 'Respond&nbsp;to&nbsp;Request');" title="Label Me" class="button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Accept Request</a></div>
						<div id="send_request_<?=$sql_array->adv_userid?>" class="none" align="center"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$sql_array->adv_userid?>&amp;RUserName=<?=$sql_array->adv_username?>&amp;mode=request'}, 'Request&nbsp;to&nbsp;Connect');" title="Label Me" class="button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Request to Connect</a></div>
						<?php } ?>
						<?php if ($VUserID != $WUserID) { ?>
						<table border="0" align="center" cellpadding="0" cellspacing="0" class="solid_line_bottom2">
							<tr>
								<?php
$fav_q=mysql_query("SELECT *,DATE_FORMAT(fav_dateadded, '%W, %D %M %Y, %r') as fav_dateadded FROM like_list WHERE (fav_userid=$WUserID AND fav_advid=$VUserID)",$link);
$fav_n=mysql_num_rows($fav_q);
if ($fav_n == 0) {
														?>
								<td id="likeme"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/like-me.php?RUserID=<?=$sql_array->adv_userid?>&amp;RUserName=<?=$sql_array->adv_username?>'}, 'Like&nbsp;Me');" title="Like Me" rel="facebox"><img src="images/icon-like.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
								<?php }?>
								<td><a href="javascript: void(null)" title="Mail Me" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/mail-compose.php?msg_senderid=<?=$sql_array->adv_userid?>'}, 'Mail&nbsp;Me');"><img src="images/icon-mail.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
								<td><a href="javascript: void(null)" title='Up-share <?=ucwords($sql_array->adv_username)?> to your friends' onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/prop-me.php?RUserID=<?=$sql_array->adv_userid?>&amp;RUserName=<?=$sql_array->adv_username?>'}, this.title);"><img src="images/icon-prop.gif" width="18" height="13" border="0" align="absbottom"/></a> </td>
								<td><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/flirt_me.php?mode=req_flirt&amp;RUserID=<?=$sql_array->adv_userid?>&amp;RUserName=<?=$sql_array->adv_username?>'}, 'Flirt&nbsp;Me');" title="Flirt Me"><img src="images/icon-flirt.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
								<td><script type="text/javascript" src="http://cdn.socialtwist.com/2010091044975/script.js"></script>
									<a class="st-taf" href="javascript: void(null)" style="border:0;padding:0;margin:0;" onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2010091044975', window.location, document.title)" onclick="STTAFFUNC.cw(this, {id:'2010091044975', link: window.location, title: document.title }); return false;"><img alt="SocialTwist Tell-a-Friend" style="border:0;padding:0;margin:0;" src="http://images.socialtwist.com/2010091044975/button.png" onmouseover="STTAFFUNC.showHoverMap(this, '2010091044975', window.location, document.title)" onclick="STTAFFUNC.cw(this, {id:'2010091044975', link: window.location, title: document.title });" border="0" align="absbottom"/></a></td>
							</tr>
						</table>
						<?php } ?></td>
				</tr>
				<tr>
					<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
							<tr>
								<td><strong> 
									Hi, I'm <a href="<?=$SITE_MAIN_WWW_ROOT?>/<?=$male1_name1?>" title="View <?=ucwords($sql_array->adv_username)?>'s Site"><span class="blue_14"><?php if(!empty($sql_array->mem_nickname)) echo ucwords($sql_array->mem_nickname); elseif(!empty($sql_array->mem_fullname)) echo ucwords($sql_array->mem_fullname); else echo ucwords($sql_array->mem_username); ?>
									</span></a> </strong> </td>
							</tr>
							<tr>
								<td valign="baseline"><strong>Last Login:</strong> <br />
									<?=$sql_array->mem_lastvisit?>
								</td>
							</tr>
							<tr>
								<td valign="baseline"><strong>Status:</strong>
									<?=$status?>
								</td>
							</tr>
							<tr>
								<td valign="baseline"><b>Gender:</b>
									<?php if($sql_array->mem_sex=="F") echo "Female"; elseif ($sql_array->mem_sex=="M") echo "Male"; else echo"Not Set";?>
								</td>
							</tr>
							<tr>
								<td valign="baseline"><b>Date of Birth :</b>
									<?php //echo $sql_array->age;?>
									<?=$sql_array->adv_dob?>
								</td>
							</tr>
							<?php
				$query=mysql_query("select drop_value from dropvalue where drop_name='marital' and drop_active='Y' and drop_id='$sql_array->adv_marital'");
				if (mysql_num_rows($query) > 0) {
				$maritalr=mysql_result($query,0);
				?>
							<tr>
								<td valign="baseline"><strong>Relationship Status:</strong> <br />
									<?=$maritalr;?>
								</td>
							</tr>
							<?php  }?>
							<?php
				if ($sql_array->adv_seeking) {
				$seeking_value=explode("|",$sql_array->adv_seeking);
				foreach ($seeking_value as $j){ 
						  $seekingr=mysql_query("select drop_value from dropvalue where drop_name='seeking' and drop_active='Y' and drop_id='$j'");
						  while($rst= mysql_fetch_array($seekingr))
						  {
						  $adv_seeking[] = $rst['drop_value'];
						  }
						  }
				$seekingr=implode (', ', $adv_seeking);
				if ($seekingr) {?>
							<tr>
								<td valign="baseline"><strong>I'm looking for:</strong><br />
									<?=$seekingr;?></td>
							</tr>
							<?php  }}?>
							<?php if ($sql_array->adv_comment) { ?>
							<tr>
								<td valign="baseline"><strong>About Me:</strong><br />
									<?=stripslashes($sql_array->adv_comment)?></td>
							</tr>
							<?php  }?>
							<tr>
								<td valign="baseline">&nbsp;</td>
							</tr>
						</table></td>
				</tr>
			</table>
			<?php 
		}
} 
?>
		</td>
	</tr>
							<tr>
								<td>&nbsp;</td>
							</tr>
</table>
