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

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

$RUserID = $_REQUEST['RUserID'];
$RUserName = $_REQUEST['RUserName'];

if (isset($RUserID) && isset($WUserID)) {
	if ($RUserID == $WUserID) {
	echo '<table width="100%" border=0 cellpadding="5" cellspacing="0" class="white_back_t_xb">';
	echo '<tr>';
	echo '<td align="center">Don\'t be silly!<br>Sure you are like yourself!</td>';
	echo '</tr>';
	echo '</table>';
	echo "<script type='text/javascript'>setTimeout(function() { parent.jQuery.facebox.close(); }, 1000);</script>";
	} else {
	$retval2=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=$RUserID)",$link);
	$result=mysql_num_rows($retval2);
	$like = mysql_fetch_object($retval2);

	if ($result == 0) {
		$tempDate=date("Y-m-d H:i:s");
		$query="INSERT INTO like_list (fav_userid, fav_advid, fav_dateadded) values ('$WUserID', '$RUserID', '$tempDate')";
		$result=mysql_query($query,$link) or die(mysql_error());
		$RUser = mysql_fetch_object(mysql_query("SELECT mem_username, mem_profileid FROM members WHERE mem_userid=$RUserID"));
		if ($RUser->mem_profileid != null) { $male1_name1= $RUser->mem_profileid; }
		else { $male1_name1= $RUser->mem_username; }
		$activityText ="likes <a href=\"".$SITE_MAIN_WWW_ROOT."/".$male1_name1."\">". ucwords($RUser->mem_username) ."</a>.";
		$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$WUserID', '5', '$activityText')";
		$result2=mysql_query($query2,$link) or die(mysql_error());
	echo '<table width="100%" border=0 cellpadding="5" cellspacing="0" class="white_back_t_xb">';
	echo '<tr>';
	echo '<td align="center">Wow, <strong>'.$RUserName.'</strong> was in your list!</td>';
	echo '</tr>';
	echo '</table>';
	echo "<script type='text/javascript'>setTimeout(function() {  parent.jQuery.facebox.close(); document.getElementById('likeme').className = 'none'; }, 1000 );</script>";
		} else {
	echo '<table width="100%" border=0 cellpadding="5" cellspacing="0" class="white_back_t_xb">';
	echo '<tr>';
	echo '<td align="center"><strong>'.$RUserName.'</strong> was added on <br><strong>'.$like->fav_dateadded.'</strong></td>';
	echo '</tr>';
	echo '</table>';
	echo "<script type='text/javascript'>setTimeout(function() { parent.jQuery.facebox.close(); }, 1000);</script>";
		}	
	}
} 
?>