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

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

include("includes/header.php");

$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 my_friends ON (friend_uid=userID) LEFT JOIN members ON (userID=mem_userid) WHERE uid='$WUserID' and activityID NOT IN (11, 12, 13, 14) and approved='1' order by datetime desc) data group by activityID,date,mem_userid 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='$WUserID' and approved='1' order by RAND()",$link) or die(mysql_error());
$myhahaper_TOTAL = mysql_num_rows($myhahaper_query);

?>

<!--<div id="left_panel" style="width:60px;">
	<?php include("home_panel.php");?>
</div>
--><div id="middle_panel" style="width:579px;">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb p5">
		
		<tr class="grey_12 orange_row_back solid_line_separator">
			<td><div style="background-color:#FF0000; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
				Network 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="activityFeed" style="width:569px;">
							<?php if($activityTotal > 0) {?>	<?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?>"><strong><?=ucwords($activity->mem_username)?></strong></a> <?=$activity->activityText?>
									<span class="grey_10">
									<br /><?=$date?>
									</span> </div>
								<?php } ?>
		<?php } else { ?>
		<div class="p10 clear"> You don't have friends network activity at the moment. Start expand your network today!</div>
		<?php } ?>
							</div></td>
					</tr>
				</table></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
</div>
<div id="right_panel" style="width:195px;">
<!--	<ul id="sidemenu">
		<li><a href="javascript: void(null)" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/wauhh_main.php'}, 'Wauhh Hubs', 'wauhhHubsBox'); return false;" rel="facebox" id="tabs_hubs">WAUHH HUBS </a></li>
		<li><a href="javascript:void(null)" id="tabs_search">WAUHH SEARCH</a></li>
	</ul>
-->	<div id="network_panel"><span class="heading"><a href="javascript: void(null)" title="Social Network <?="(".$myhahaper_TOTAL.")"?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/connect_all.php?RUserID=<?=$WUserID?>&oView=hahaper'}, this.title, 'connectAll'); return false;" rel="facebox">Social Network
		<?="(".$myhahaper_TOTAL.")"?>
		<img src="images/iconSocial.gif" align="absmiddle" /></a></span>
		<span class="content">
	<?php if ($myhahaper_TOTAL > 0) { ?>
		<?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!";}

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?>
		</div>
		<? 
				} ?>
	<?php } else {?>
		<div>Expand your Network today! <a href="http://socializer.wowdoyou.com/home.php#mcover"><strong class="purple_14 "> Go Socializer</strong></a>!</div>
	<?php }?>
		</span>
		</div>
</div>
<?php include("includes/footer.php"); ?>
