<?php
include("includes/site_info.php");

include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
$picture = new Picture();

require 'includes/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => '132880206758943',
  'secret' => '16d42b51af2920ff3c03f9dbf7c0d5e2',
  'cookie' => true,
));
$user = $facebook->getUser();
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $me = null;
  }
}

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

if (isset($_GET['i']) && !empty($_GET['i'])) {
$_SESSION['inv_id'] = $_GET['i'];
}

if (isset($_GET['ref_id']) && !empty($_GET['ref_id'])) {
$_SESSION['ref_id'] = $_GET['ref_id'];
} 
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 = $WUserID;
}
if ($VUserID == $WUserID && $WUserID!=0) {
echo "<script>location.href='" . $CONST_LINK_ROOT . "/home.php'</script>"; die; 
}
if ($VUserID != $WUserID && $WUserID!=0) {
    $query="SELECT * FROM encounters WHERE enc_userid = '$VUserID' AND enc_viewerid='$WUserID'";
    $result=mysql_query($query,$link) or die(mysql_error());
    $TOTAL = mysql_num_rows($result);
    if ($TOTAL == 0) {
        $tempdate=date("Y-m-d H:i:s");
        $result=mysql_query("INSERT INTO encounters (enc_userid, enc_viewerid, enc_viewdate) VALUES ('$VUserID','$WUserID','$tempdate')",$link) or die(mysql_error());
    } else {
        $tempdate=date("Y-m-d H:i:s");
        $result=mysql_query("UPDATE encounters SET enc_viewdate='$tempdate' WHERE enc_userid = '$VUserID' AND enc_viewerid='$WUserID' AND siteType='main'",$link) or die(mysql_error());
    }
	
	$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;
	}

}

$Vmember_query=mysql_query("SELECT *, DATE_FORMAT(adv_dob, '%M %d') as adv_dob 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());
$Vsql_array = mysql_fetch_object($Vmember_query);
$VTOTAL = mysql_num_rows($Vmember_query);


$VsponsorRank_query = mysql_query("SET @rank = 0");
$VsponsorRank_query = mysql_query("SELECT rank
FROM (

SELECT @rank := @rank +1 AS rank, mem_userid, totalRank, mem_joindate
FROM (
SELECT *, COUNT( mem_referrer ) AS totalRank FROM (
SELECT B.mem_userid, A.mem_referrer, A.mem_joindate
FROM members AS B LEFT JOIN members AS A ON ( B.mem_userid = A.mem_referrer )order by A.mem_joindate desc
) as listing
GROUP BY mem_userid, mem_referrer
) as result

ORDER BY totalRank DESC , mem_joindate DESC, mem_userid ASC
) as data

WHERE mem_userid ='$VUserID'");
$VsponsorRank = mysql_fetch_array($VsponsorRank_query);

if (empty ($_SESSION['ref_id'])) {
$_SESSION['ref_id'] = $Vsql_array->mem_referCode;
}

$activity_query=mysql_query("SELECT * FROM (SELECT activityText, activityID, YEAR(datetime) as year, DATE_FORMAT(datetime, '%M %d, %Y at %h:%i%p') as wYear, DATE_FORMAT(datetime, '%M %d at %h:%i%p') as wtYear, DATE_FORMAT(datetime, '%Y%m%d') as date, mem_username, mem_profileid, mem_userid FROM activities_user LEFT JOIN members ON (userID=mem_userid) WHERE userID='$VUserID' and activityID NOT IN (11, 12, 13, 14) order by datetime desc) data group by activityID,date order by date desc",$link) or die(mysql_error());
$activityTotal = mysql_num_rows($activity_query);

$myhahaper_query=mysql_query("SELECT mem_userid, mem_profileid, mem_username, mem_fullname FROM my_friends LEFT JOIN members ON (friend_uid=mem_userid) WHERE uid='$VUserID' and approved='1' order by RAND()",$link) or die(mysql_error());
$myhahaper_TOTAL = mysql_num_rows($myhahaper_query);

$common_query=mysql_query("SELECT C.mem_userid, C.mem_profileid, C.mem_username, SUBSTRING(C.mem_username,1,9) as shortname, C.mem_fullname FROM members AS C, my_friends AS F1, my_friends AS F2 WHERE '$VUserID'!='$WUserID' And F1.uid='$VUserID' And F2.uid='$WUserID' And F1.friend_uid=F2.friend_uid And C.mem_userid=F1.friend_uid And F1.approved='1' And F2.approved='1' order by mem_username",$link) or die(mysql_error());
$common_TOTAL = mysql_num_rows($common_query);

$liked_query=mysql_query("SELECT mem_userid, mem_username, mem_profileid FROM like_list LEFT JOIN members ON (fav_advid=mem_userid) WHERE fav_userid='$VUserID' ORDER BY RAND()",$link) or die(mysql_error());
$liked_count = mysql_num_rows($liked_query);

if (isset($WUserID)) { 
$memberS_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 FROM adverts LEFT JOIN members ON (adv_userid=mem_userid) LEFT JOIN Geo_Countries ON (adv_countryid = CountryId) WHERE adv_userid = '$WUserID' AND adv_approved='1'") or die(mysql_error());
$sqlS_array = mysql_fetch_object($memberS_query);

$sponsorRank_query = mysql_query("SET @rank = 0, @prev_val = null");
$sponsorRank_query = mysql_query("SELECT rank
FROM (

SELECT @rank := @rank +1 AS rank, mem_userid, @prev_val := totalRank AS totalRank, mem_joindate
FROM (
SELECT *, COUNT( mem_referrer ) AS totalRank FROM (
SELECT B.mem_userid, A.mem_referrer, A.mem_joindate
FROM members AS B LEFT JOIN members AS A ON ( B.mem_userid = A.mem_referrer )order by A.mem_joindate desc
) as listing
GROUP BY mem_userid, mem_referrer
) as result

ORDER BY totalRank DESC , mem_joindate DESC, mem_userid ASC
) as data

WHERE mem_userid ='$WUserID'");
$sponsorRank = mysql_fetch_array($sponsorRank_query);

$suspended_list="0";
$mem_q=mysql_query("select * from blockmail where blk_receiverid='$WUserID'");
while($mem=mysql_fetch_array($mem_q))
{
$suspended_list.=",".$mem["blk_senderid"];
}

$msgr=mysql_query("SELECT * FROM messages LEFT JOIN adverts ON (msg_senderid=adv_userid) LEFT JOIN members ON (msg_senderid=mem_userid) WHERE (msg_receiverid='$WUserID') AND msg_receiverdel='N' AND adv_approved='1' AND msg_senderid not in ($suspended_list) AND msg_read='U' ORDER BY msg_dateadded DESC") or die(mysql_error());
$msgrTOTAL = mysql_num_rows($msgr);

}

function cutword($cutstring) {
	 $_data = explode(" ", ucwords($cutstring));
    foreach($_data as $value) {
        if (strlen($value)>9) {
				echo wordwrap($value, 7, " ", true)." ";
        } else {
		  		echo $value." ";
		  }
    }
}										 

function HahaperAge($datefrom,$dateto=-1)
{
        // Defaults and assume if 0 is passed in that
        // its an error rather than the epoch
   
        if($datefrom==0) { return "0"; }
        if($dateto==-1) { $dateto = time(); }
       
        // Make the entered date into Unix timestamp from MySQL datetime field

        $datefrom = strtotime($datefrom);
   
        // Calculate the difference in seconds betweeen
        // the two timestamps

		  $difference = $dateto - $datefrom;
		  if($difference < 0) {
		  return false;
		  }

        // Based on the interval, determine the
        // number of units between the two dates
        // From this point on, you would be hard
        // pushed telling the difference between
        // this function and DateDiff. If the $datediff
        // returned is 1, be sure to return the singular
        // of the unit, e.g. 'day' rather 'days'
   
				if((strtotime('-1 day', $dateto) < $datefrom) || (strtotime('-1 hour', $dateto) < $datefrom) || (strtotime('-1 min', $dateto) < $datefrom)) {

            // If difference is between 1 hour and 24 hours
            // hours is a good interval
                $dateH = floor($difference / 60 / 60);
					 if($dateH > 0) {
					 $dateH = ($dateH<10) ? "0".$dateH : $dateH;
//                $res = ($dateH==1) ? $dateH.' hr ' : $dateH.' hrs ';
 					 $wordH= ($dateH==1) ? 'hour' : 'hour';
                $short = "<span title=\"$wordH\" >$dateH : </span>";
                $res = "$dateH $wordH ";
					 }

            // If difference is between 60 seconds and
            // 60 minutes, minutes is a good interval
                $difference = $difference % (60 * 60); 
					 $dateM = floor($difference / 60);
					 if($dateM > 0) {
                $dateM = ($dateM<10) ? "0".$dateM : $dateM;
//                $res .= ($dateM==1) ? $dateM.' min ' : $dateM.' mins ';
 					 $wordM= ($dateM==1) ? 'minute' : 'minutes';
                $short .= "<span title=\"$wordM\" >$dateM : </span>";
                $res .= "$dateM $wordM ";
					 }

            // If difference is less than 60 seconds,
            // seconds is a good interval of choice
                $difference = $difference % (60); 
                $dateS = floor($difference);
					 if($dateS > 0) {
                $dateS = ($dateS<10) ? "0".$dateS : $dateS;
//                $res .= ($dateS==1) ? $dateS.' sec' : $dateS.' secs';
 					 $wordS= ($dateS==1) ? 'second' : 'seconds';
                $short .= "<span title=\"$wordS\" >$dateS</span>";
                $res .= "$dateS $wordS";
					 }

				} else {

            // If difference is greater than or equal to 365
            // days, return year. This will be incorrect if
            // for example, you call the function on the 28th April
            // 2008 passing in 29th April 2007. It will return
            // 1 year ago when in actual fact (yawn!) not quite
            // a year has gone by
					 $year_difference = 1;
                while (strtotime('-'.$year_difference.' year', $dateto) >= $datefrom)
                {
                    $year_difference++;
                }
               
                $dateY = $year_difference-1;
					 if ($dateY > 0) {
                $dateY = ($dateY<10) ? "0".$dateY : $dateY;
                $res = ($dateY==1) ? $dateY.' year ' : $dateY.' years ';
                $short .= $dateY.' Y ';
//						$wordY= ($dateY==1) ? 'year' : 'years';
//                  $res = "<span title=\"$wordY\" >$dateY : </span>";
					 }

            // If difference is between 30 days and 365 days
            // months is a good interval, again, the same thing
            // applies, if the 29th February happens to exist
            // between your 2 dates, the function will return
            // the 'incorrect' value for a day
					 $months_difference = 1;
                while (strtotime('-'.$months_difference.' month', $dateto) >= $datefrom)
                {
                    $months_difference++;
                }
               
                $dateM = $months_difference-1;
					 if ($dateM > 0) {
					 if ($dateM >= 12) {
					 	$dateM -= (floor($dateM/12)*12);
					 }
                $dateM = ($dateM<10) ? "0".$dateM : $dateM;
                $res .= ($dateM==1) ? $dateM.' month ' : $dateM.' months ';
                $short .= $dateM.' M ';
//						$wordM= ($dateM==1) ? 'month' : 'months';
//                  $res .= "<span title=\"$wordM\" >$dateM : </span>";
					}

            // If difference is between 1 day and 7 days
            // days is a good interval
					 $day_difference = 1;
                while (strtotime('-'.$day_difference.' day', $dateto) >= $datefrom)
                {
                    $day_difference++;
                }
               
                $dateD = $day_difference-1;
					 if ($dateD >= 30) {
					 	if ($dateD>365) {
						$dateD -= 365;
						}
					 	$dateD -= (floor($dateD/30)*30);
					 }
                $dateD = ($dateD<10) ? "0".$dateD : $dateD;
                $res .= ($dateD==1) ? $dateD.' day' : $dateD.' days';
                $short .= $dateD.' D';
//						$wordD= ($dateD==1) ? 'day' : 'days';
//                  $res .= "<span title=\"$wordD\" >$dateD</span>";
			}
               
        return array($short, " for <strong>".$res."</strong>");
	}
list($shortDV,$longDV)=HahaperAge($Vsql_array->mem_joindate);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta name="description" content="Wauhaha web is a social interaction media that gives people the power to create demand and get value while connected with the world. Wauhaha, Inc. produces interaction quality and solution in network and business marketing purposes enhances with multitasking system module for interacting, promoting and performing on own creation all in one space." />
<meta name="keyword" content="wauhaha, wow, wau malaysia, wau, malaysia, social network, wuahaha, wahaha, merketing malaysia, connects people, johor bahru, SEO, web developer, about malaysia, jadiatang, jadia tang, socializer, socializer malaysia, marketer, hahaper, creator, merchandiser, inventor, innovator" />
<link rel="alternate" media="handheld" href="<?=$CONST_LINK_ROOT?>" />
<base href="<?=$CONST_LINK_ROOT?>" />
<title>Wauhaha |
<?=ucwords($Vsql_array->adv_username)?>
</title>
<link rel="stylesheet" type="text/css" href="wauhhstyle.css">
<link rel="stylesheet" type="text/css" href="wauhhtabs.css">
<link rel="stylesheet" type="text/css" href="wauhhbox.css">
<!--[if IE 6]>
<link href="facebox/facebox_ie.css" media="screen" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if !IE 6]><!-->
<link href="facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<!--<![endif]>-->
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.history.js"></script>
<script type="text/javascript" src="js/wauhhJS.js"></script>
<script type="text/javascript" src="facebox/facebox.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').click(function (e) {
            e.preventDefault();
        });  
    })

</script>
</head>
<body>
<div id="loading"><img src="images/spacer.gif"></div>
<div id="fullBackPanel">
	<div id="fullBackPanelTop">
		<?php if (isset($WUserID)) { ?>
		<div id="topPanel">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td><a href="<?=$CONST_LINK_ROOT?>/home.php" id="HomeLogo" title="Wauhaha"><img src="images/iconWauhaha.gif" alt="Wauhaha" /></a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="<?=$CONST_LINK_ROOT?>/hahaperParks.php" id="HPark">Hahapers Park</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="javascript: void(null)" id="WauhhHubs" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/wauhh_pop.php'}, 'Wauhh Hubs', 'wauhhHubsBox'); return false;" rel="facebox" >Wauhh Hubs</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
<!--					<td><span class="SearchBox">
						<input type="text" value="Wauhh Search" class="input" />
						<input name="cmdSubmit" type="image" src="images/iconSearch1.gif" border="0" class="button">
						</span></td>
-->					<td width="100%"><span class="extraSpace"><img src="images/spacer.gif" /></span></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="javascript:;" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/mybank.php'}, 'My Bank', 'mybankBox'); return false;" rel="facebox" id="MyBankbox">My Bank</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="javascript:;" id="AddFundbox">Add Funds</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="<?=$CONST_LINK_ROOT?>/inbox.php" id="Mailbox">Inbox
						<?php if($msgrTOTAL>0) { echo " <span>(".$msgrTOTAL.")</span>";} ?>
						</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="<?=$CONST_LINK_ROOT?>/home.php" id="Homebox">Home</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="javascript:logout();" target="_self" id="Logoutbox">Log out</a></td>
				</tr>
			</table>
		</div>
		<?php } else { ?>
		<div id="topPanel">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td><a href="<?=$CONST_LINK_ROOT?>/home.php" id="HomeLogo" title="Wauhaha"><img src="images/iconWauhaha.gif" alt="Wauhaha" /></a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td width="100%"><span class="extraSpace"><img src="images/spacer.gif" /></span></td>
<!--					<td><span class="SearchBox">
						<input type="text" value="Wauhh Search" class="input" />
						<input name="cmdSubmit" type="image" src="images/iconSearch1.gif" border="0" class="button">
						</span></td>-->
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="<?=$CONST_LINK_ROOT?>/home.php" id="Homebox">Home</a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="index.php" id="Logoutbox"><span class="uppper">Login</span></a></td>
					<td><span class="break"><img src="images/spacer.gif" /></span></td>
					<td><a href="register1.php" id="tab_mysite"><span class="uppper">Join Us Now</span></a></td>
				</tr>
			</table>
		</div>
		<?php } ?>
		<div id="middleTop">
			<div id="contentWrapper">
				<div id="logoProfile">
					<!--					<?php if (isset($WUserID)) { ?>
					<a href="<?=$CONST_LINK_ROOT?>" id="logoBox"><span>logo</span></a>
					<?php } else { ?>
					<a href="<?=$CONST_LINK_ROOT?>" id="logoBox2"><span>logo</span></a>
					<?php }?>
-->
					<div id="profileBox">
						<?php 
	if ($WUserID==$Vsql_array->adv_userid) {
		$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$Vsql_array->adv_userid' and pic_default='Y'") or die(mysql_error());
	} else {
		$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$Vsql_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 = "members/$Vsql_array->adv_username/picture/$medium";
             }else{
$male1_picture1=$picture->GetPicFull($Vsql_array->adv_userid);
}
?>
						<div class="left p5">
							<div class="clippedImage_w176_h176" style="background-image: 
url(&quot;<?=$CONST_LINK_ROOT?>/<?=$male1_picture1?>&quot;);">&nbsp;</div>
						</div>
						<div id="profileTop">
							<?php if ($request==1 || $request==3) { ?>
										<div id="send_request" class="style_right_xtop"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>&amp;mode=request'}, 'Request&nbsp;to&nbsp;Connect');" title="Label Me" class="a_button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Request to Connect</a></div>
										<div id="confirm_request" class="style_right_xtop none p5"> <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" class="style_right_xtop none"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$Vsql_array->adv_userid?>&amp;AUserName=<?=$Vsql_array->adv_username?>&amp;mode=respond'}, 'Respond&nbsp;to&nbsp;Request');" title="Label Me" class="a_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="style_right_xtop p5"><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" class="style_right_xtop"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$Vsql_array->adv_userid?>&amp;AUserName=<?=$Vsql_array->adv_username?>&amp;mode=respond'}, 'Respond&nbsp;to&nbsp;Request');" title="Label Me" class="a_button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Accept Request</a></div>
								<div id="send_request" class="style_right_xtop none"><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>&amp;mode=request'}, 'Request&nbsp;to&nbsp;Connect');" title="Label Me" class="a_button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Request to Connect</a></div>
								<?php } ?>
								<?php if ($request==5) { ?>
								<div id="send_request" class="style_right_xtop"><a href="register1.php" title="Label Me" class="a_button"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Request to Connect</a></div>
								<?php } ?><div id="infoBoxTitle">About Me! </div>
							
								<p> <span class="grey_14">Hi, I'm
								<?php if(!empty($Vsql_array->mem_nickname)) {echo ucwords($Vsql_array->mem_nickname);} elseif(!empty($Vsql_array->mem_fullname)) {echo ucwords($Vsql_array->mem_fullname);} else {echo ucwords($Vsql_array->mem_username);} echo "."; ?>
								</span></p>
							<p>
								<?php 
						if (!empty($Vsql_array->adv_location)) { echo "I lives in <strong>".$Vsql_array->adv_location."</strong>"; if(!empty($Vsql_array->Country)){ echo ", <strong>".$Vsql_array->Country."</strong>"; } echo ". "; }
						if (!empty($Vsql_array->adv_dob)) { echo "I was born on <strong>".$Vsql_array->adv_dob."</strong>. "; }
						?>
								I am a hahaper since
								<?=date("Y",strtotime($Vsql_array->mem_joindate)).$longDV?>
								.
								My last login was on
								<?="<strong>".date('d M, Y \a\t h:ia', strtotime($Vsql_array->mem_lastvisit))."</strong>."?>
							</p>
							<p>
								<?=$Vsql_array->adv_comment?>
							</p>
						</div>
						<div id="profileBottom">
							<table border="0" align="right" cellpadding="0" cellspacing="0" class="p5">
								<tr>
								<?php if (isset($WUserID) && ($WUserID!=$VUserID)) {  ?>
								<?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=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>'}, 'Like&nbsp;Me');" title="Like <?=ucwords($Vsql_array->adv_username)?>" 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="Send&nbsp;a&nbsp;message&nbsp;to&nbsp;<?=ucwords($Vsql_array->adv_username)?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/mail-compose.php?msg_senderid=<?=$Vsql_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-sharing <?=ucwords($Vsql_array->adv_username)?> to your friends' onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/prop-me.php?RUserID=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>'}, this.title, 'popProp');"><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=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>'}, 'Flirt&nbsp;Me');" title="Flirt <?=ucwords($Vsql_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 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>
									<?php } else {?>
									<td id="likeme"><a href="register1.php" title="Like <?=ucwords($Vsql_array->adv_username)?>"><img src="images/icon-like.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
									<td><a href="register1.php" title="Send&nbsp;a&nbsp;message&nbsp;to&nbsp;<?=ucwords($Vsql_array->adv_username)?>"><img src="images/icon-mail.gif" width="18" height="15" border="0" align="absbottom"/></a></td>
									<td><a href="register1.php" title='Up-sharing <?=ucwords($Vsql_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="register1.php" title="Flirt <?=ucwords($Vsql_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 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>
									<?php } ?>
								</tr>
							</table>
						</div>
					</div>
					<div id="infoBox">
						<div id="infoBoxTitle">Cools Feed </div>
						<marquee direction="up" scrollamount="2" scrolldelay=80 onmouseout="this.start();" onmouseover="this.stop();" height="80%">
						<div id="infoBoxContent">
							<div class="sidebox">
								<div class="marquee">MY RANKING (Sponsor:
									<?="#".$VsponsorRank["rank"]?>
									)</div>
							</div>
							<!-- start common relations -->
							<?php if ($common_TOTAL > 0) { ?>
							<div id="commonRelation" class="sidebox">
								<div class="marquee"><a href="javascript: void(null)" title="MUTUAL RELATIONS (<?=$common_TOTAL?>)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/mutual_all.php?RUserID=<?=$VUserID?>'}, this.title, 'mutualAll'); return false;" rel="facebox">MUTUAL RELATIONS (
									<?=$common_TOTAL?>
									)</a> </div>
							</div>
							<?php } ?>
							<!-- end common relations -->
							<?php if ($liked_count > 0) { ?>
							<div class="sidebox">
								<div class="marquee">
									<?php if (isset($WUserID)) { ?>
										<a href="javascript: void(null)" title="LIKES (<?=$liked_count?>)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/likes_all.php?RUserID=<?=$VUserID?>'}, this.title, 'likesAll'); return false;" rel="facebox">
										<?php } else {?>
										<a href="register1.php" title="Login / Register">
										<?php } ?>
									LIKES  (
									<?=$liked_count?>
									)</a></div>
							</div>
							<?php } ?>
						</div>
						</marquee>
					</div>
				</div>
				<div id="middleContent">
					<!--<div id="left_panel" style="width:60px;">
						<ul id="tabmenu">
							<li><a href="javascript: void(null)" onclick="return false;" rel="facebox" id="tab_Marketer">Marketer</a></li>
							<li ><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/myprofile_socializer.php?VUserId=<?=$Vsql_array->mem_username?>'}, 'Socializer', 'socialPopBox'); return false;" rel="facebox" id="tab_Socializer">Socializer</a></li>
						</ul>
					</div>-->
					<div id="middle_panel" style="width:579px; max-height:420px;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb p5">
							<?php if($activityTotal > 0) {?>
							<tr class="grey_12 purple_back solid_line_separator">
								<td><?=ucwords($Vsql_array->adv_username)?>'s Activity On The Roll </td>
							</tr>
							<tr class="p0">
								<td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
										<tr>
											<td><div class="activityFeedProfile" style="width:569px;">
													<?php while ($activity = mysql_fetch_object($activity_query)) {
	if ($WUserID==$activity->mem_userid) {
		$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$activity->mem_userid' and pic_default='Y'") or die(mysql_error()); 
	} else {
		$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$activity->mem_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."_ps.".$aPicture->ext;
		$male1_picture = "members/$activity->mem_username/picture/$medium";
	}else{
		$male1_picture=$picture->GetProfilePicture($activity->mem_userid);
	}

	 if ($activity->mem_profileid != null) { $profile_name= $activity->mem_profileid; }
	 else { $profile_name= $activity->mem_username; }

	 if ($activity->year==date('Y')) {
	 	$date = $activity->wtYear;
	 } else {
	 	$date = $activity->wYear;
	 }
?>
													<div class="p5 clear"> <span class="left img_b_p3 w50_h50 mr_10"><a href="<?=$CONST_LINK_ROOT?>/<?=$profile_name?>"><img src="<?=$CONST_LINK_ROOT?>/<?=$male1_picture?>" border="0" title="Name:&nbsp;<?=ucwords($activity->mem_username)?>"/></a></span><a href="<?=$CONST_LINK_ROOT?>/<?=$profile_name?>">
														<?=ucwords($activity->mem_username)?>
														</a>
														<?=$activity->activityText?>
														<span class="grey_10"> <br />
														<?=$date?>
														</span> </div>
													<?php } ?>
												</div></td>
										</tr>
									</table></td>
							</tr>
							<tr>
								<td>&nbsp;</td>
							</tr>
							<?php } ?>
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>
					</div>
					<div id="right_panel" style="width:195px;">
						<div id="network_panel"><span class="heading">
						<?php if ($myhahaper_TOTAL > 0) { ?>
							<?php if (isset($WUserID)) { ?>
								<a href="javascript: void(null)" title="Social Network <?="(".$myhahaper_TOTAL.")"?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/connect_all.php?RUserID=<?=$VUserID?>'}, this.title, 'connectAll'); return false;" rel="facebox" >
								<?php } else {?>
								<a href="register1.php" title="Login / Register">
								<?php } ?>
							Social Network
							<?="(".$myhahaper_TOTAL.")"?>
							<img src="images/iconSocial.gif" align="absmiddle" /></a></span><span class="content">
							<?php 
$h = 0;
while ($hahaper_pic = mysql_fetch_object($myhahaper_query)) {
$timeout = time()-900; //in 15 mins
$reton=mysql_query("SELECT userid FROM active_users where timestamp > $timeout AND userid='$hahaper_pic->mem_userid'",$link) or die(mysql_error());
$totalon=mysql_num_rows($reton);

if($totalon>0)
{$status="<span style=\"color:green\">Online!</span>";}
else{$status="Offline!";}

	$Hretval=mysql_query("SELECT * FROM my_friends WHERE (uid='$WUserID' AND friend_uid='$hahaper_pic->mem_userid') or (uid='$hahaper_pic->mem_userid' AND friend_uid='$WUserID')",$link);
	$Hsql_array = mysql_fetch_object($Hretval);
	$Hresult=mysql_num_rows($Hretval);

	if ($hahaper_pic->mem_userid == $WUserID) {
	$Hrequest=0;
	} elseif ($Hresult == 0) {
	$Hrequest=1;
	} elseif ($Hsql_array->approved == 0) {
	$Hrequest=2;
	$Hretval=mysql_query("SELECT * FROM my_friends WHERE uid='$hahaper_pic->mem_userid' AND friend_uid='$WUserID'",$link);
	$Hsql_array = mysql_fetch_object($Hretval);
	$Hresult=mysql_num_rows($Hretval);
	if ($Hresult == 0) {
	$Hrequest=2;
	} elseif ($Hsql_array->approved == 0) {
	$Hrequest=4;
	}else {
	$Hrequest=2;
	}
	} else {
	$Hrequest=0;
	}

if ($WUserID==$hahaper_pic->mem_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$hahaper_pic->mem_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$hahaper_pic->mem_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."_ps.".$aPicture->ext;
	$male1_picture1 = "members/$hahaper_pic->mem_username/picture/$medium";
             }else{
$male1_picture1=$picture->GetProfilePicture($hahaper_pic->mem_userid);
}

if ($hahaper_pic->mem_profileid != null) { $male1_name1= $hahaper_pic->mem_profileid; }
else { $male1_name1= $hahaper_pic->mem_username; }

$fullname = $hahaper_pic->mem_username;
?>
							<div><span class="left img_b_p3 w50_h50 mr_10"><a href="<?=$CONST_LINK_ROOT?>/<?=$male1_name1?>"><img src="<?=$CONST_LINK_ROOT?>/<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($fullname)?>"/></a></span><a href="<?=$CONST_LINK_ROOT?>/<?=$male1_name1?>">
								<?=ucwords($fullname);?>
								</a><br />
								<?=$status?><br/>
      <?php if ($Hrequest==1 || $Hrequest==3) { ?>
      <span id="send_request_<?=$hahaper_pic->mem_userid?>" class=""> <a href="javascript:void(null);" title="Request to Connect" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$hahaper_pic->mem_userid?>&amp;RUserName=<?=$hahaper_pic->mem_username?>&amp;mode=request&amp;backmode=social'}, this.title, 'popLabel'); return false;" class="a_button2 left" rel="facebox"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Connect<sup>+</sup> </a></span> <span id="confirm_request_<?=$hahaper_pic->mem_userid?>" class="none"> <span class="left p5"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Pending </span></span> <span id="accept_request_<?=$hahaper_pic->mem_userid?>" class="none"> <a href="javascript:void(null);" title="Respond to Request" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$hahaper_pic->mem_userid?>&amp;AUserName=<?=$hahaper_pic->mem_username?>&amp;mode=respond&amp;backmode=social'}, this.title, 'popLabel'); return false;" class="a_button2 left" rel="facebox"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Accept Request</a></span>
      <?php } ?>
      <?php if ($Hrequest==2) { ?>
      <span class="left p5"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Pending </span>
      <?php } ?>
      <?php if ($Hrequest==4) { ?>
      <span id="accept_request_<?=$hahaper_pic->mem_userid?>" class=""> <a href="javascript:void(null);" title="Respond to Request" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?AUserID=<?=$hahaper_pic->mem_userid?>&amp;AUserName=<?=$hahaper_pic->mem_username?>&amp;mode=respond&amp;backmode=social'}, this.title, 'popLabel'); return false;" class="a_button2 left" rel="facebox"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Respond<sup>+</sup> </a></span> <span id="send_request_<?=$hahaper_pic->mem_userid?>" class="none"> <a href="javascript:void(null);" title="Request to Connect" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/label-me.php?RUserID=<?=$hahaper_pic->mem_userid?>&amp;RUserName=<?=$hahaper_pic->mem_username?>&amp;mode=request&amp;backmode=social'}, this.title, 'popLabel'); return false;" class="a_button2 left" rel="facebox"><img src="images/icon-label.gif" width="18" height="15" border="0" align="absbottom"/> Connect<sup>+</sup> </a></span>
      <?php } ?>
							</div>
							<? 
				} ?>
						<?php } else {?>
						Social Network <img src="images/iconSocial.gif" align="absmiddle" /></span><span class="content"><div><?php if (isset($WUserID) && ($WUserID!=$VUserID)) {?><a href="javascript: void(null)" title='Up-sharing <?=ucwords($Vsql_array->adv_username)?> to your friends' onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/prop-me.php?RUserID=<?=$Vsql_array->adv_userid?>&amp;RUserName=<?=$Vsql_array->adv_username?>'}, this.title, 'popProp');"> <?php } else { ?><a href="register1.php" title='Up-sharing <?=ucwords($Vsql_array->adv_username)?> to your friends'><?php } ?>Help <?php if('M'==$Vsql_array->mem_sex) {echo "him";} if('F'==$Vsql_array->mem_sex) {echo "her";}?> to expand <?php if('M'==$Vsql_array->mem_sex) {echo "his";} if('F'==$Vsql_array->mem_sex) {echo "her";}?> network!</a> </div>
						<?php } ?>
							</span></div>
					</div>
				</div>
			</div>
			<div id="ads_panel">&nbsp; </div>
		</div>
		<div class="menu_bottom_t"><a href="wauhhBiz.php" target="_self" title="WAUHHBIZ">WAUHHBIZ</a> <a href="http://marketer.wowdoyou.com/wauhhHot.php" target="_self" title="WAUHHHOT">WAUHHHOT</a><a href="http://socializer.wowdoyou.com/wauhhSoc.php" target="_self" title="WAUHHSOCIETY">WAUHHSOCIETY</a><a href="index.php" target="_self" title="Home">HOME</a><a href="about.php" target="_self" title="About">ABOUT</a><a href="contactus.html" target="_self" title="Contact">CONTACT</a><a href="career.php" target="_self" title="Careers">CAREERS</a><a href="terms.html" target="_self" title="Terms">TERMS</a><a href="privacy.html" target="_self" title="Privacy">PRIVACY</a><a href="invmsg.php" title="Investor Message" target="_self">INVESTOR</a> <a href="http://www.facebook.com/pages/Wauhaha/125760707473366" target="_blank" title="Facebook Page">FB PAGE</a></div>
		<div class="p5 copyright">Copyright &copy; 2011 Wauhaha.com. All Rights Reserved. Reproduction strictly prohibited.<br>
			All brand names and products are registered trademarks and patent pending of their respective companies</div>
	</div>
</div>
<div id="fb-root"></div>
<script type="text/javascript">
      window.fbAsyncInit = function() {
        FB.init({
          appId   : '<?php echo $facebook->getAppId(); ?>',
          status  : true, // check login status
          cookie  : true, // enable cookies to allow the server to access the session
          xfbml   : true // parse XFBML
        });
      };

        // whenever the user logs in, we refresh the page
        function logout (){
		  var checkSess = <?php echo json_encode($me); ?>;
		  if (checkSess!= null) {
		  FB.logout(function(response) {
				location.href = '<?=$CONST_LINK_ROOT?>/logoff.php';
        });
		  } else {
				location.href = '<?=$CONST_LINK_ROOT?>/logoff.php';
			}
		  }

      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
		  
      }());
</script>
</body>
</html>
