<?php
include("includes/site_info.php");
include('session_handler.inc');
include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
	
	switch ($_REQUEST["Submit"]) {
	case "showMore"; 
		showMore();
		break;
	case "addGalleryComment"; 
		addGalleryComment();
		break;
	case "deleteGalleryComment"; 
		deleteGalleryComment();
		break;
	case "addGalleryItemComment"; 
		addGalleryItemComment();
		break;
	case "deleteGalleryItemComment"; 
		deleteGalleryItemComment();
		break;
	case "addBlogComment"; 
		addBlogComment();
		break;
	case "deleteBlogComment"; 
		deleteBlogComment();
		break;
	case "addArticleComment"; 
		addArticleComment();
		break;
	case "deleteArticleComment"; 
		deleteArticleComment();
		break;
	default; 
		echo "";
		break;
	}

function showMore() {
	$comment_id = $_REQUEST["comment_id"];
	$galleryID = $_REQUEST["galleryID"];
	$userID = $_REQUEST["userID"];
//	print_r($_POST);
	
//	echo "SELECT * FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID' and com_memid = '$userID' limit 1";
	$comment_query=mysql_query("SELECT * FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID' and com_memid = '$userID' limit 1");
	$comment_TOTAL = mysql_num_rows($comment_query);
	if ($comment_TOTAL >0) {
	$comment = mysql_fetch_object($comment_query);
	echo $comment->comment;
	} else {
	echo "Failed to retrieve the content! Please try again later! <a href=\"javascript:;\" onclick=\"javascript: showmore(".$comment_id.",".$galleryID.",".$userID.");\">more</a>";
	}
	die;
}

function addGalleryComment() {
global $SITE_MAIN_WWW_ROOT, $CONST_LINK_ROOT;
$picture = new Picture();

	$comment = htmlspecialchars($_REQUEST["comment"], ENT_QUOTES);
	$galleryID = $_REQUEST["galleryID"];
	$userID = $_REQUEST["userID"];
	$userName = $_REQUEST["userName"];
	
	$sql="Insert into gallery_comment set Gallery_ID='$galleryID', com_memid='$userID', comment='$comment', com_mem_username='$userName', com_approved='1'";
	$squery=mysql_query($sql);
	$commentID=mysql_insert_id();

	$short_msg_text=strip_tags(stripslashes(substr($comment,0,100)));
	if (strlen (strip_tags($comment))>100) $short_msg_text.="...";
	
	$galleryitem_query=mysql_query("SELECT Name, mem_username, mem_id, mem_profileid FROM gallery LEFT JOIN members ON (mem_id=mem_userid) WHERE Gallery_ID = '$galleryID'") or die(mysql_error());
	$galleryitem = mysql_fetch_object($galleryitem_query);
	
	if ($galleryitem->mem_profileid != null) { $male_name= $galleryitem->mem_profileid; }
	else { $male_name= $galleryitem->mem_username; }
	
	$activityText = "say, \"$short_msg_text\" on <a href=\"$SITE_MAIN_WWW_ROOT/$male_name\">".ucwords($galleryitem->mem_username)."</a>\'s album <a href=\"$CONST_LINK_ROOT/home.php#mgallery?tab=media&gid=$galleryID&uID=$galleryitem->mem_id\" >".ucwords($galleryitem->Name)."</a>.";
	
	$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$userID', '11', '$activityText')";
	$result2=mysql_query($query2) or die(mysql_error());
	
	
	if($userID!=$galleryitem->mem_id){
	$current_query=mysql_query("SELECT mem_username, mem_userid, mem_profileid FROM members WHERE mem_userid = '$userID'") or die(mysql_error());
	$current = mysql_fetch_object($current_query);
	
	if ($current->mem_profileid != null) { $male_name2= $current->mem_profileid; }
	else { $male_name2= $current->mem_username; }
	
	$activityText2 = "got a message from <a href=\"$SITE_MAIN_WWW_ROOT/$male_name2\">".ucwords($current->mem_username)."</a>\ for album <a href=\"$CONST_LINK_ROOT/home.php#mgallery?tab=media&gid=$galleryID&uID=$galleryitem->mem_id\" >".ucwords($galleryitem->Name)."</a>.";
	
	$query22="INSERT INTO activities_user (userID, activityID, activityText) values ('$galleryitem->mem_id', '11', '$activityText2')";
	$result22=mysql_query($query22) or die(mysql_error());
	}

	if (!$squery) {
		echo "Database error!";
		die;
	} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$userID' and pic_default='Y'") 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/$userName/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($userID);
}
	?>
						<div id="commentBox<?=$commentID?>" class="comment_reply"><div class="left w65_h58"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$userID?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($userName)?>" class="img_b_p3_white"/></a></div><div class="comment_reply_text"><div class="delete"><a href="javascript:;" onclick="javascript: deleteComment(<?=$commentID?>, <?=$galleryID?>);">x</a></div><span id="contentBox<?=$commentID?>"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($comment,0,300)));
				echo $short_msg_text;
				if (strlen (strip_tags($comment))>300) echo "<span id=\"more".$commentID."\">... <a href=\"javascript:;\" onclick=\"javascript: showmore(".$commentID.");\">more</a></span><span id=\"Seemore".$commentID."\" class=\"none\">".strip_tags(stripslashes(substr($comment,300)))."</span>";
				?></span></div></div>
	<?php
	}
	die;
}

function deleteGalleryComment() {
	$comment_id = $_REQUEST["comment_id"];
	$galleryID = $_REQUEST["galleryID"];
	$VUserID = $_SESSION['Sess_UserId'];
//	print_r($_POST);
//	die;
	
//	echo "SELECT * FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID' and com_memid = '$userID' limit 1";

	$comment_query=mysql_query("SELECT * FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID'");
	$comment_TOTAL = mysql_num_rows($comment_query);
	if ($comment_TOTAL >0) {
	$commentUser_query=mysql_query("SELECT com_memid FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID' and com_memid='$VUserID' limit 1");
	$commentUser_TOTAL = mysql_num_rows($commentUser_query);
	if ($commentUser_TOTAL >0) {
		$query="DELETE FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID' and com_memid='$VUserID'";
		$result=mysql_query($query) or die(mysql_error());
		if ($result) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$gallerymain_query=mysql_query("SELECT mem_id FROM gallery WHERE mem_id = '$VUserID' and Gallery_ID = '$galleryID' limit 1") or die(mysql_error());
	$gallerymain_TOTAL = mysql_num_rows($gallerymain_query);
	if ($gallerymain_TOTAL >0) {
		$query1="DELETE FROM gallery_comment WHERE comment_id = '$comment_id' and Gallery_ID = '$galleryID'";
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$return['status'] = '0';
	$return["result"] = "<font color=\"red\">You don't have the authority to delete this comment!</font> ";
	}
	}
	} else {
	$return['status'] = '1';
	$return["result"] = "<font color=\"red\">The comment was deleted!</font> ";
	}
	echo json_encode($return);
	die;
}

function addGalleryItemComment() {
global $SITE_MAIN_WWW_ROOT, $CONST_LINK_ROOT;
$picture = new Picture();

	$comment = htmlspecialchars($_REQUEST["comment"], ENT_QUOTES);
	$galleryItemID = $_REQUEST["galleryItemID"];
	$userID = $_REQUEST["userID"];
	$userName = $_REQUEST["userName"];
	
	$sql="Insert into galleryitem_comment set GalleryItem_ID='$galleryItemID', com_memid='$userID', comment='$comment', com_mem_username='$userName', com_approved='1'";
	$squery=mysql_query($sql);
	$commentID=mysql_insert_id();

	$short_msg_text=strip_tags(stripslashes(substr($comment,0,100)));
	if (strlen (strip_tags($comment))>100) $short_msg_text.="...";
	
	$galleryitem_query=mysql_query("SELECT mem_username, mem_id, mem_profileid, Gallery_ID FROM gallery LEFT JOIN members ON (mem_id=mem_userid) LEFT JOIN galleryitem USING (Gallery_ID) WHERE GalleryItem_ID = '$galleryItemID'") or die(mysql_error());
	$galleryitem = mysql_fetch_object($galleryitem_query);
	
	if ($galleryitem->mem_profileid != null) { $male_name= $galleryitem->mem_profileid; }
	else { $male_name= $galleryitem->mem_username; }
	
	$activityText = "say, \"$short_msg_text\" on <a href=\"$SITE_MAIN_WWW_ROOT/$male_name\">".ucwords($galleryitem->mem_username)."</a>\'s <a href=\"$CONST_LINK_ROOT/home.php#mgphoto?tab=media&gid=$galleryitem->Gallery_ID&pid=$galleryItemID&uID=$galleryitem->mem_id\" >photo</a>.";
	
	$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$userID', '14', '$activityText')";
	$result2=mysql_query($query2) or die(mysql_error());
	
	if($userID!=$galleryitem->mem_id){
	$current_query=mysql_query("SELECT mem_username, mem_userid, mem_profileid FROM members WHERE mem_userid = '$userID'") or die(mysql_error());
	$current = mysql_fetch_object($current_query);
	
	if ($current->mem_profileid != null) { $male_name2= $current->mem_profileid; }
	else { $male_name2= $current->mem_username; }
	
	$activityText2 = "got a message from <a href=\"$SITE_MAIN_WWW_ROOT/$male_name2\">".ucwords($current->mem_username)."</a>\ for <a href=\"$CONST_LINK_ROOT/home.php#mgphoto?tab=media&gid=$galleryitem->Gallery_ID&pid=$galleryItemID&uID=$galleryitem->mem_id\" >photo</a>.";
	
	$query22="INSERT INTO activities_user (userID, activityID, activityText) values ('$galleryitem->mem_id', '14', '$activityText2')";
	$result22=mysql_query($query22) or die(mysql_error());
	}
	
	if (!$squery) {
		echo "Database error!";
		die;
	} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$userID' and pic_default='Y'") 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/$userName/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($userID);
}
	?>
						<div id="commentBox<?=$commentID?>" class="comment_reply"><div class="left w65_h58"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$userID?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($userName)?>" class="img_b_p3_white"/></a></div><div class="comment_reply_text"><div class="delete"><a href="javascript:;" onclick="javascript: deleteComment(<?=$commentID?>, <?=$galleryItemID?>);">x</a></div><span id="contentBox<?=$commentID?>"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($comment,0,300)));
				echo $short_msg_text;
				if (strlen (strip_tags($comment))>300) echo "<span id=\"more".$commentID."\">... <a href=\"javascript:;\" onclick=\"javascript: showmore(".$commentID.");\">more</a></span><span id=\"Seemore".$commentID."\" class=\"none\">".strip_tags(stripslashes(substr($comment,300)))."</span>";
				?></span></div></div>
	<?php
	}
	die;
}

function deleteGalleryItemComment() {
	$comment_id = $_REQUEST["comment_id"];
	$galleryItemID = $_REQUEST["galleryItemID"];
	$VUserID = $_SESSION['Sess_UserId'];
//	print_r($_POST);
//	die;
	
//	echo "SELECT * FROM galleryitem_comment WHERE comment_id = '$comment_id' and GalleryItem_ID = '$galleryItemID' and com_memid = '$userID' limit 1";

	$comment_query=mysql_query("SELECT * FROM galleryitem_comment WHERE comment_id = '$comment_id' and GalleryItem_ID = '$galleryItemID'");
	$comment_TOTAL = mysql_num_rows($comment_query);
	if ($comment_TOTAL >0) {
	$commentUser_query=mysql_query("SELECT com_memid FROM galleryitem_comment WHERE comment_id = '$comment_id' and GalleryItem_ID = '$galleryItemID' and com_memid='$VUserID' limit 1");
	$commentUser_TOTAL = mysql_num_rows($commentUser_query);
	if ($commentUser_TOTAL >0) {
		$query="DELETE FROM galleryitem_comment WHERE comment_id = '$comment_id' and GalleryItem_ID = '$galleryItemID' and com_memid='$VUserID'";
		$result=mysql_query($query) or die(mysql_error());
		if ($result) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$gallerymain_query=mysql_query("SELECT mem_id FROM gallery left join galleryitem using (Gallery_ID) WHERE mem_id = '$VUserID' and GalleryItem_ID = '$galleryItemID' limit 1") or die(mysql_error());
	$gallerymain_TOTAL = mysql_num_rows($gallerymain_query);
	if ($gallerymain_TOTAL >0) {
		$query1="DELETE FROM galleryitem_comment WHERE comment_id = '$comment_id' and GalleryItem_ID = '$galleryItemID'";
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$return['status'] = '0';
	$return["result"] = "<font color=\"red\">You don't have the authority to delete this comment!</font> ";
	}
	}
	} else {
	$return['status'] = '1';
	$return["result"] = "<font color=\"red\">The comment was deleted!</font> ";
	}
	echo json_encode($return);
	die;
}

function addBlogComment() {
global $SITE_MAIN_WWW_ROOT, $CONST_LINK_ROOT;
$picture = new Picture();

	$comment = htmlspecialchars($_REQUEST["comment"], ENT_QUOTES);
	$blogID = $_REQUEST["blogID"];
	$userID = $_REQUEST["userID"];
	$userName = $_REQUEST["userName"];
	
	$sql="Insert into blogs_comment set blg_id='$blogID', com_memid='$userID', comment='$comment', com_mem_username='$userName', com_approved='1'";
	$squery=mysql_query($sql);
	$commentID=mysql_insert_id();
	
	$short_msg_text=strip_tags(stripslashes(substr($comment,0,100)));
	if (strlen (strip_tags($comment))>100) $short_msg_text.="...";
	
	$BLOG_query=mysql_query("SELECT blg_title, mem_username, mem_userid, mem_profileid FROM blogs LEFT JOIN members ON (blg_userid=mem_userid) WHERE blg_id = '$blogID'") or die(mysql_error());
	$BLOG = mysql_fetch_object($BLOG_query);
	
	if ($BLOG->mem_profileid != null) { $male_name= $BLOG->mem_profileid; }
	else { $male_name= $BLOG->mem_username; }
	
	$activityText = "say, \"$short_msg_text\" on <a href=\"$SITE_MAIN_WWW_ROOT/$male_name\">".ucwords($BLOG->mem_username)."</a>\'s blog <a href=\"$CONST_LINK_ROOT/home.php#mshowblog?tab=thought&bid=$blogID&uID=$BLOG->mem_userid\" >".ucwords($BLOG->blg_title)."</a>.";
	
	$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$userID', '12', '$activityText')";
	$result2=mysql_query($query2) or die(mysql_error());
	
	if($userID!=$BLOG->mem_userid){
	$current_query=mysql_query("SELECT mem_username, mem_userid, mem_profileid FROM members WHERE mem_userid = '$userID'") or die(mysql_error());
	$current = mysql_fetch_object($current_query);
	
	if ($current->mem_profileid != null) { $male_name2= $current->mem_profileid; }
	else { $male_name2= $current->mem_username; }
	
	$activityText2 = "got a message from <a href=\"$SITE_MAIN_WWW_ROOT/$male_name2\">".ucwords($current->mem_username)."</a>\ for blog <a href=\"$CONST_LINK_ROOT/home.php#mshowblog?tab=thought&bid=$blogID&uID=$BLOG->mem_userid\" >".ucwords($BLOG->blg_title)."</a>.";
	
	$query22="INSERT INTO activities_user (userID, activityID, activityText) values ('$BLOG->mem_userid', '12', '$activityText2')";
	$result22=mysql_query($query22) or die(mysql_error());
	}
	
	if (!$squery) {
		echo "Database error!";
		die;
	} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$userID' and pic_default='Y'") 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/$userName/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($userID);
}
	?>
						<div id="commentBox<?=$commentID?>" class="comment_reply"><div class="left w65_h58"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$userID?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($userName)?>" class="img_b_p3_white"/></a></div><div class="comment_reply_text"><div class="delete"><a href="javascript:;" onclick="javascript: deleteComment(<?=$commentID?>, <?=$blogID?>);">x</a></div><span id="contentBox<?=$commentID?>"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($comment,0,300)));
				echo $short_msg_text;
				if (strlen (strip_tags($comment))>300) echo "<span id=\"more".$commentID."\">... <a href=\"javascript:;\" onclick=\"javascript: showmore(".$commentID.");\">more</a></span><span id=\"Seemore".$commentID."\" class=\"none\">".strip_tags(stripslashes(substr($comment,300)))."</span>";
				?></span></div></div>
	<?php
	}
	die;
}

function deleteBlogComment() {
	$comment_id = $_REQUEST["comment_id"];
	$blogID = $_REQUEST["blogID"];
	$VUserID = $_SESSION['Sess_UserId'];
//	print_r($_POST);
//	die;
	
//	echo "SELECT * FROM blogs_comment WHERE comment_id = '$comment_id' and blg_id = '$blogID' and com_memid = '$userID' limit 1";

	$comment_query=mysql_query("SELECT * FROM blogs_comment WHERE comment_id = '$comment_id' and blg_id = '$blogID'");
	$comment_TOTAL = mysql_num_rows($comment_query);
	if ($comment_TOTAL >0) {
	$commentUser_query=mysql_query("SELECT com_memid FROM blogs_comment WHERE comment_id = '$comment_id' and blg_id = '$blogID' and com_memid='$VUserID' limit 1");
	$commentUser_TOTAL = mysql_num_rows($commentUser_query);
	if ($commentUser_TOTAL >0) {
		$query="DELETE FROM blogs_comment WHERE comment_id = '$comment_id' and blg_id = '$blogID' and com_memid='$VUserID'";
		$result=mysql_query($query) or die(mysql_error());
		if ($result) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$blog_query=mysql_query("SELECT blg_userid FROM blogs WHERE blg_userid = '$VUserID' and blg_id = '$blogID' limit 1") or die(mysql_error());
	$blog_TOTAL = mysql_num_rows($blog_query);
	if ($blog_TOTAL >0) {
		$query1="DELETE FROM blogs_comment WHERE comment_id = '$comment_id' and blg_id = '$blogID'";
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$return['status'] = '0';
	$return["result"] = "<font color=\"red\">You don't have the authority to delete this comment!</font> ";
	}
	}
	} else {
	$return['status'] = '1';
	$return["result"] = "<font color=\"red\">The comment was deleted!</font> ";
	}
	echo json_encode($return);
	die;
}

function addArticleComment() {
global $SITE_MAIN_WWW_ROOT, $CONST_LINK_ROOT;
$picture = new Picture();

	$comment = htmlspecialchars($_REQUEST["comment"], ENT_QUOTES);
	$artID = $_REQUEST["artID"];
	$userID = $_REQUEST["userID"];
	$userName = $_REQUEST["userName"];
	
	$sql="Insert into articles_comment set art_id='$artID', com_memid='$userID', comment='$comment', com_mem_username='$userName', com_approved='1'";
	$squery=mysql_query($sql);
	$commentID=mysql_insert_id();
	
	$short_msg_text=strip_tags(stripslashes(substr($comment,0,100)));
	if (strlen (strip_tags($comment))>100) $short_msg_text.="...";
	
	$articles_query=mysql_query("SELECT art_title, mem_username, mem_userid, mem_profileid FROM articles LEFT JOIN members ON (art_userid=mem_userid) WHERE art_id = '$artID'") or die(mysql_error());
	$articles = mysql_fetch_object($articles_query);
	
	if ($articles->mem_profileid != null) { $male_name= $articles->mem_profileid; }
	else { $male_name= $articles->mem_username; }
	
	$activityText = "say, \"$short_msg_text\" on <a href=\"$SITE_MAIN_WWW_ROOT/$male_name\">".ucwords($articles->mem_username)."</a>\'s note <a href=\"$CONST_LINK_ROOT/home.php#mshownote?tab=thought&aid=$artID&uID=$articles->mem_userid\" >".ucwords($articles->art_title)."</a>.";
	
	$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$userID', '13', '$activityText')";
	$result2=mysql_query($query2) or die(mysql_error());
	
	if($userID!=$articles->mem_userid){
	$current_query=mysql_query("SELECT mem_username, mem_userid, mem_profileid FROM members WHERE mem_userid = '$userID'") or die(mysql_error());
	$current = mysql_fetch_object($current_query);
	
	if ($current->mem_profileid != null) { $male_name2= $current->mem_profileid; }
	else { $male_name2= $current->mem_username; }
	
	$activityText2 = "got a message from <a href=\"$SITE_MAIN_WWW_ROOT/$male_name2\">".ucwords($current->mem_username)."</a>\ for note <a href=\"$CONST_LINK_ROOT/home.php#mshownote?tab=thought&aid=$artID&uID=$articles->mem_userid\" >".ucwords($articles->art_title)."</a>.";
	
	$query22="INSERT INTO activities_user (userID, activityID, activityText) values ('$articles->mem_userid', '13', '$activityText2')";
	$result22=mysql_query($query22) or die(mysql_error());
	}
	
	if (!$squery) {
		echo "Database error!";
		die;
	} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$userID' and pic_default='Y'") 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/$userName/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($userID);
}
	?>
						<div id="commentBox<?=$commentID?>" class="comment_reply"><div class="left w65_h58"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$userID?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($userName)?>" class="img_b_p3_white"/></a></div><div class="comment_reply_text"><div class="delete"><a href="javascript:;" onclick="javascript: deleteComment(<?=$commentID?>, <?=$artID?>);">x</a></div><span id="contentBox<?=$commentID?>"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($comment,0,300)));
				echo $short_msg_text;
				if (strlen (strip_tags($comment))>300) echo "<span id=\"more".$commentID."\">... <a href=\"javascript:;\" onclick=\"javascript: showmore(".$commentID.");\">more</a></span><span id=\"Seemore".$commentID."\" class=\"none\">".strip_tags(stripslashes(substr($comment,300)))."</span>";
				?></span></div></div>
	<?php
	}
	die;
}

function deleteArticleComment() {
	$comment_id = $_REQUEST["comment_id"];
	$artID = $_REQUEST["artID"];
	$VUserID = $_SESSION['Sess_UserId'];
//	print_r($_POST);
//	die;
	
//	echo "SELECT * FROM articles_comment WHERE comment_id = '$comment_id' and art_id = '$artID' and com_memid = '$userID' limit 1";

	$comment_query=mysql_query("SELECT * FROM articles_comment WHERE comment_id = '$comment_id' and art_id = '$artID'");
	$comment_TOTAL = mysql_num_rows($comment_query);
	if ($comment_TOTAL >0) {
	$commentUser_query=mysql_query("SELECT com_memid FROM articles_comment WHERE comment_id = '$comment_id' and art_id = '$artID' and com_memid='$VUserID' limit 1");
	$commentUser_TOTAL = mysql_num_rows($commentUser_query);
	if ($commentUser_TOTAL >0) {
		$query="DELETE FROM articles_comment WHERE comment_id = '$comment_id' and art_id = '$artID' and com_memid='$VUserID'";
		$result=mysql_query($query) or die(mysql_error());
		if ($result) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$blog_query=mysql_query("SELECT art_userid FROM articles WHERE art_userid = '$VUserID' and art_id = '$artID' limit 1") or die(mysql_error());
	$blog_TOTAL = mysql_num_rows($blog_query);
	if ($blog_TOTAL >0) {
		$query1="DELETE FROM articles_comment WHERE comment_id = '$comment_id' and art_id = '$artID'";
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1) {
			$return['status'] = '1';
			$return["result"] = "<font color=\"green\">Delete success!</font> ";
		} else {
			$return['status'] = '0';
			$return["result"] = "<font color=\"red\">Failed to delete the content! Please try again later!</font> ";
		}
	} else {
	$return['status'] = '0';
	$return["result"] = "<font color=\"red\">You don't have the authority to delete this comment!</font> ";
	}
	}
	} else {
	$return['status'] = '1';
	$return["result"] = "<font color=\"red\">The comment was deleted!</font> ";
	}
	echo json_encode($return);
	die;
}
?>