<?php

if(!isset($WUserID)) { 	echo 'This file cannot be accessed directly!'; die;}

if ($_REQUEST['postID']) { $postID = $_REQUEST['postID']; }
else { $postID = 0; }

if ($postID > 0) {
$active_query=mysql_query("SELECT mem_username FROM market_Post LEFT JOIN members USING (mem_userid) where postID=$postID and approve=1 and expDate > now() limit 1",$link) or die(mysql_error());
$activeTotal = mysql_num_rows($active_query);

if($activeTotal>0) {
$sql = mysql_fetch_object($active_query);
 $_REQUEST['VUserId'] = $sql->mem_username;
}
}

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_username='$VUserID' or  mem_profileid='$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);
?>
<script type="text/javascript">
//jQuery(window).scroll(function() { jQuery('#wauhhPanel').css({'top': jQuery(window).scrollTop() <?php if (isset($WUserID)) { ?>+ 46<?php } ?> + 'px', 'margin': 0}); });
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<?php if (isset($WUserID)) { ?>
		<tr>
			<td><ul id="sidemenu">
<!--					<li><a href="#ccover" onclick="javascript: callpage(this.href);">
						<div id="right_loading_c" class="right_loading"><img src="images/small_loader.gif" width="16" height="16" border="0" /></div>
						MARKETER</a></li>
-->					<li><a href="<?=$CONST_LINK_ROOT?>/home.php#mcover" class="active">
					<div id="right_loading_m" class="right_loading"><img src="images/small_loader.gif" width="16" height="16" border="0" /></div>
					WAUHHHOT</a></li>

				</ul></td>
		</tr>
		<?php } ?>
	<tr>
		<td id="wauhhPanel">
		<?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 align='center' valign="middle"><a href="<?=$CONST_LINK_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 (isset($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 href="javascript: void(null)" onclick="STTAFFUNC.cw(this, {id:'2010091044975', link: <?php if ($postID > 0) {echo "'".$CONST_LINK_ROOT."/MKT".$postID."'";} else { echo "'".$CONST_LINK_ROOT."/".$sql_array->adv_username."'"; } ?>, title: document.title }); return false;"><img alt="Tell-a-Friend" src="http://images.socialtwist.com/2010091044975/button.png" border="0" align="absbottom"/></a></td>
						</tr>
					</table>
					<?php } else {?>
					<table border="0" align="center" cellpadding="0" cellspacing="0" class="solid_line_bottom2">
							<tr>
								<td id="likeme"><a href="<?=$SITE_MAIN_WWW_ROOT?>/register1.php" title="Like <?=ucwords($sql_array->adv_username)?>"><img src="images/icon-like.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
								<td><a href="<?=$SITE_MAIN_WWW_ROOT?>/register1.php" title="Send&nbsp;a&nbsp;message&nbsp;to&nbsp;
									<?=ucwords($sql_array->adv_username)?>"><img src="images/icon-mail.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
								<td><a href="<?=$SITE_MAIN_WWW_ROOT?>/register1.php" title='Up-sharing <?=ucwords($sql_array->adv_username)?> to your friends'><img src="images/icon-prop.gif" width="18" height="13" border="0" align="absbottom"/></a> </td>
								<td><a href="<?=$SITE_MAIN_WWW_ROOT?>/register1.php" title="Flirt <?=ucwords($sql_array->adv_username)?>"><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 href="javascript: void(null)" onclick="STTAFFUNC.cw(this, {id:'2010091044975', link: <?php if ($postID > 0) {echo "'".$CONST_LINK_ROOT."/MKT".$postID."'";} else { echo "'".$CONST_LINK_ROOT."/".$sql_array->adv_username."'"; } ?>, title: document.title }); return false;"><img alt="Tell-a-Friend" src="http://images.socialtwist.com/2010091044975/button.png" 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="<?=$CONST_LINK_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>
						<?php if ($sql_array->adv_comment) { ?>
						<tr>
							<td valign="baseline"><strong>About Me:</strong><br />
								<?=stripslashes($sql_array->adv_comment)?></td>
						</tr>
						<?php  }?>
					</table></td>
			</tr>
		</table>
		<?php 
		}
} 
?>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
</table>
