<?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'];

$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 FROM activities_user LEFT JOIN members ON (userID=mem_userid) WHERE userID='$WUserID' and activityID < 15 order by datetime desc) data group by activityID,date order by date desc",$link) or die(mysql_error());
$activityTotal = mysql_num_rows($activity_query);

$timeout = time()-900;
$myhahaper_query=mysql_query("SELECT DISTINCT mem_userid, mem_profileid, mem_username FROM my_friends LEFT JOIN members ON (friend_uid=mem_userid)  WHERE uid='$WUserID' and approved='1' and timestamp > $timeout limit 20",$link) or die(mysql_error());
$myhahaperTotal = mysql_num_rows($myhahaper_query);

$comment=mysql_query("SELECT  COUNT(com_memid) FROM profile_comment WHERE com_memid ='$WUserID' AND com_approved = '2' ORDER BY com_time DESC",$link) or die(mysql_error());

?>

<div id="top_panel" class="grey_row_back">
	<?php include ("panel_top.php"); ?>
</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
<!--				<tr>
					<td><form name="commentForm" id="commentForm">
											<textarea name="reply" id="reply" style="width:500px; height:25px;"></textarea>
											<span id="load"></span>
											<input name="comment" type="submit" value="Comment" class="button" />
										
									</form></td>
				</tr>-->
				<?php if($activityTotal > 0) {?>
				<tr class="white_back_t_xb">
					<td><div class="light_orang_h">
							<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>
							Activity On The Roll </div>
						<div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
						<div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
				</tr>
				<tr class="white_back_t_xb">
					<td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb">
							<tr>
								<td><div id="activityFeed">
										<?php 
		$j=0;
	 while (($activity = mysql_fetch_object($activity_query)) && ($j<12)) {
	 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="padding_5">
											<?=ucwords($activity->mem_username)?> <?=$activity->activityText?>
											<span class="grey_10">
											<?php /*?><?=$date?><?php */?>
											</span> </div>
										<?php $j++;
										} ?>
									</div></td>
							</tr>
						</table></td>
				</tr>
				<?php } ?>
				<?php if($myhahaperTotal>0){?>
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Online Friends</div>
						<div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
						<div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
				</tr>
				<tr>
					<td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb">
							<tr>
								<td><?php 
	 while ($ret_pic = mysql_fetch_object($myhahaper_query)) {
if ($WUserID==$ret_pic->mem_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->mem_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_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 = "$SITE_MAIN_WWW_ROOT/members/$ret_pic->mem_username/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($ret_pic->mem_userid);
}

if ($ret_pic->mem_profileid != null) { $male1_name1= $ret_pic->mem_profileid; }
else { $male1_name1= $ret_pic->mem_username; }
?>
									<div class="left padding_5 grey_10 w66_h66"><a href="javascript:;" onclick="javascript: callMyprofileInfo(<?=$ret_pic->mem_userid?>);"><img src="<?=$male1_picture1?>" class="img_b_p3" title="Name:&nbsp;<?=ucwords($ret_pic->mem_username)?>"/></a><br />
										<?=ucwords($ret_pic->mem_username)?>
									</div>
									<?php 
				$i++;
				} ?></td>
							</tr>
						</table></td>
				</tr>
				<?php } ?>
				<tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
			</table></td>
	</tr>
</table>
