<?php
$path="../../";
include("../../map.php");
$id=$_GET["id"];
	$sql1=mysqli_query($conn, "select * from t2 where ne='mesaj' and ((s1=".$_SESSION['user_id']." and s2=".$id.") or (s1=".$id." and s2=".$_SESSION['user_id'].")) order by id asc"); while($gelen=mysqli_fetch_assoc($sql1)){$jsi = json_decode($gelen["n6"],true);
	$notify = array ('notification'.$_SESSION['user_id'].'' => '1');
	$jsn = json_encode($notify, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
	$Rs = mysqli_query($conn, "update t2 set n12='".addslashes(stripslashes($jsn))."' where id=".$gelen["id"]."");
?>
		<div id="amessages" class="" style="margin:3px 0px;">
	<?php if($gelen["s1"]==$_SESSION["user_id"]){?>
			<div class="" style="display: grid; float: right; min-width: 15%; max-width: 60%; margin-right:10px;">
				<div class="v3-bg-success" style="text-align: right; font-size: 14px; border-radius: 20px 0px 20px 20px ; padding: 5px 15px ; font-weight: 400;">
					<a style="position: absolute; right: 10px ;" href="#" onclick="jQuery('#conn').load('messages_ajax.php?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&durum=msg_clear&id=<?php echo $gelen["id"]?>');" class="fa fa-trash"></a>
					<?php echo $gelen["n1"]?>
					<?php if($gelen["n6"]<>""){?>
						<div class="v3-row">
					<?php foreach($jsi as $key=>$value){ ?>
						<div class="v3-col-md-1 v3-col-xs-3" style="padding: 5px;">
							<a data-fancybox="gallery" href="<?php echo $media_path_slash?>deppo/dosya/<?php echo $value;?>" class="v3-thumbnail">
								<img src="<?php echo $weburl?>/deppo/dosya/<?php echo $value;?>">
							</a>
						</div>
					<?php }echo "</div>";}?>
					<div style="float:left; font-size:10px;"><?php echo timeago($gelen["ts1"])?></div>
				</div>
			</div>
			<div style="clear:both;"></div>
	<?php }else{?>
			<div class="" style="display: grid; float: left; min-width: 15%; max-width: 60%;">
				<div class="v3-bg-warning" style="text-align: left; font-size: 14px; border-radius: 0 20px 20px 20px ; padding: 5px 15px ; font-weight: 400;">
					<a style="position: absolute; left: 0px ;" href="#" onclick="jQuery('#conn').load('messages_ajax.php?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&durum=msg_clear&id=<?php echo $gelen["id"]?>');" class="fa fa-trash"></a>
					<?php echo $gelen["n1"]?>
					<?php if($gelen["n6"]<>""){?>
						<div class="v3-row">
					<?php foreach($jsi as $key=>$value){ ?>
						<div class="v3-col-md-2 v3-col-xs-3" style="padding: 5px;">
							<a data-fancybox="gallery" href="<?php echo $media_path_slash?>deppo/dosya/<?php echo $value;?>" class="v3-thumbnail">
								<img src="<?php echo $weburl?>/deppo/dosya/<?php echo $value;?>">
							</a>
						</div>
					<?php }echo "</div>";}?>
					<div style="float:right; font-size:10px;"><?php echo timeago($gelen["ts1"])?></div>
				</div>
			</div>
	<?php } ?>
		</div>
		<div style="clear:both;"></div>
<?php $cuser="";} ?>
<script type="text/JavaScript" language="JavaScript">
	jQuery(document).ready(function() {
		var messageBody = document.querySelector('#mlist');
		messageBody.scrollTop = messageBody.scrollHeight - messageBody.clientHeight;
	});
</script>
<?php
if($_GET["durum"]=="all_clear"){
	$msil = mysqli_query($conn, "delete from t2 where ne='mesaj'");
	header("location:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&nedir=".$_GET["nedir"]."");
}elseif($_GET["durum"]=="user_clear"){
	$msil = mysqli_query($conn, "delete from t2 where ne='mesaj' and (s1=".$_GET["id"]." or s1=".$_GET["id"].")");
	//header("location:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&nedir=".$_GET["nedir"]."");
}elseif($_GET["durum"]=="msg_clear"){
	$msil = mysqli_query($conn, "delete from t2 where id=".$_GET["id"]."");
	//header("location:?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&nedir=".$_GET["nedir"]."");
}
?>