<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<?php $path="../../"; include("../../map.php");?>
<style>
.media-box div:hover {
  filter: brightness(90%);
  transition: filter 0.3s ease;
}
</style>
<div class="v3-col-md-12 medias">
<!--
<select size="1" name="s4_<?php echo $i?>" class="pa top3 r5 small mdn">
	<option value="0" <?php if($rs["s4"]=="0"){?>Selected<?php }?>>[0] <?php echo ctranslate("Grup Seçimi");?></option>
	<?php if($m4<>""){$rgrups = explode(',',$m4); foreach($rgrups as $rgrup) {$g++;?>
		<option value="<?php echo $g;?>" <?php if($rs["s4"]==$g){?>Selected<?php }?>>[<?php echo $g;?>] <?php echo $rgrup;?></option>
	<?php }}?>
	<?php if($module["g1_".$_GET["ne"].""]=="1"){?>
	<?php $sql=mysqli_query($conn, "select * from t1 where ne='isayfa' and (t2='".$_SESSION['lang']."' or t2='All') and s1=".$_GET["id"]." order by s2 asc"); while($xn=mysqli_fetch_assoc($sql)){?>
		<option value="<?php echo $xn["id"];?>" <?php if($_GET["s4"]==$xn["id"]){?>Selected<?php }?>>[<?php echo $xn["id"];?>] <?php echo $xn["t1"];?></option>
	<?php }}?>
</select>
-->
<a class="msa cp" onclick="AjaxGResult('<?php echo $weburl."/".$crmpath."/"?>modules/ajax/ajax_medya.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&nedir=<?php echo $_GET["nedir"]?>&durum=mdel','#m<?php echo $_GET["nedir"]?>','','',''); jQuery('.m<?php echo $_GET["nedir"]?>').hide();" style="position: absolute; right: 0px; top: -48px;" title="Tümünü temizle"><i class="fa fa-eraser " aria-hidden="true"></i></a>
<script>jQuery(function(){jQuery(".mfrm").on("click",function(){var t=jQuery(this).data("target"),m=jQuery(t),title=jQuery(this).data("title"),width=jQuery(this).data("width"),frm=jQuery(this).data("url"),ref=jQuery(this).data("ref");m.fadeIn().addClass("in");m.find(".v3-modal-title").text(title);<?php if($mobile==""){?>if(width!==undefined){m.css("width",width);}<?php }?>if(ref!==undefined){m.find(".mcbtn").attr("onclick","location.href='"+ref+"'");}m.find("iframe").attr("src",frm);m.find(".close").on("click",function(){m.find("iframe").attr("src","about:blank");});});});</script>

	<?php
	if(!empty($_GET["id"])){
		$sql=mysqli_query($conn, "select * from medya where ne='".$_GET['nedir']."' and t3='".$_GET['ne']."' and s1='".$_GET['id']."' $luye order by s3 asc,id desc");
	}else{
		$sql=mysqli_query($conn, "select * from medya where ne='".$_GET['nedir']."' $luye order by s3 asc,id desc");
	}
	if(mysqli_num_rows($sql)==0){
		if($_GET['nedir']=="resim"){
			echo "".ihb($_GET['nedir'])." ".ctranslate("Bulunamadı, hemen yüklemek için")." <a class=\"cp mfrm v3-btn-xs v3-btn-success\" data-toggle=\"modal\" data-ajax=\"mresim\" data-width=\"50%\" data-target=\"#myModal\" data-title=\"".$sdil[75]."\" data-url=\"".$weburl."/".$crmpath."/modules/upload/upload_image.php?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."\">".ctranslate("tıklayınız")."</a>";
		}elseif($_GET['nedir']=="video"){
			echo "".ihb($_GET['nedir'])." ".ctranslate("Bulunamadı, hemen yüklemek için")." <a class=\"cp mfrm v3-btn-xs v3-btn-danger\" data-toggle=\"modal\" data-ajax=\"mvideo\" data-width=\"50%\" data-target=\"#myModal\" data-title=\"".$sdil[76]."\" data-url=\"".$weburl."/".$crmpath."/modules/video/video_add.php?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."\">".ctranslate("tıklayınız")."</a>";
		}elseif($_GET['nedir']=="dosya"){
			echo "".ihb($_GET['nedir'])." ".ctranslate("Bulunamadı, hemen yüklemek için")." <a class=\"cp mfrm v3-btn-xs v3-btn-warning\" data-toggle=\"modal\" data-ajax=\"mdosya\" data-width=\"50%\" data-target=\"#myModal\" data-title=\"".$sdil[77]."\" data-url=\"".$weburl."/".$crmpath."/modules/upload/upload_file.php?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."\">".ctranslate("tıklayınız")."</a>";
		}
	}
	while($rsm=mysqli_fetch_assoc($sql)){
		$uzanti_ = explode('.',$rsm["t1"]);
		$uzanti=$uzanti_[count($uzanti_)-1];
		if ($_GET["nedir"] == "resim") {
			// Resim türü kontrolü
			if (in_array($uzanti, ['gif', 'png', 'jpg', 'jpeg'])) {
				$medya = $weburl . "/deppo/image/k_" . $rsm["t1"];
			} else {
				$medya = $weburl . "/deppo/image/" . $rsm["t1"];
			}
			$link = $weburl . "/deppo/image/" . $rsm["t1"];

		} elseif ($_GET["nedir"] == "video") {
			// Video türü kontrolü
			if (substr($rsm["t4"], 0, 4) == "http") {
				$medya = $weburl . "/deppo/video/" . $rsm["n2"];
				$link = $rsm["t4"];
			} else {
				$medya = $weburl . "/deppo/video/" . $rsm["t5"];
				$link = $weburl . "/deppo/video/" . $rsm["t1"];
			}

		} elseif ($_GET["nedir"] == "dosya") {
			// Dosya türü kontrolü
			if ($rsm["t5"] == "") {
				$medya = "../../assets/img/icons/" . $rsm["t4"] . "_b.png";
			} else {
				$medya = $weburl . "/deppo/dosya/" . $rsm["t5"];
			}
			$link = $weburl . "/deppo/dosya/" . $rsm["t1"];
		}
		?>
		<!---/Ana-div/-->
		<div data-id="<?php echo $rsm["id"];?>" class="v3-col-md-3 v3-col-sm-6 v3-col-xs-12 mdiv m<?php echo $rsm["ne"];?> img-fluid appear-animation animated fadeIn appear-animation-visible" data-appear-animation="fadeIn" data-appear-animation-delay="0" data-appear-animation-duration="1s" id="<?php echo $rsm["id"]; ?>" style="">
			<div style="position:absolute; right:-2px; padding:0px; width:15px; height:15px; top:-7px;">
				<a class="t<?php echo $rsm["ne"]?>" data-href="<?php echo $weburl."/".$crmpath."/"?>modules/ajax/ajax_medya.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&durum=mvitrin&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>&monay=<?php if($rsm["s2"]=="1"){echo 0;}else{ echo 1;}?>"><i class="fa fa<?php if($rsm["s2"]==1){?>-check<?php }?>-square-o" aria-hidden="true" style="font-size:20px; cursor:pointer;color:#fe8200"></i></a>
			</div>
			<?php if ($rsm["s20"] > 0) { ?>
				<div style="position: absolute; right: 5px; bottom: 40px; background: rgba(255, 243, 205, 0.7); color: #856404; padding: 2px 6px; font-size: 10px; font-weight: bold; border-radius: 3px; z-index: 10; pointer-events: none; border: 1px solid rgba(133, 100, 4, 0.2); font-family: sans-serif;">
					<?php echo nice_number($rsm["s20"]); ?>
				</div>
			<?php } ?>
			<!---/Resim/-->
				<?php
				$downloadable = ["docx", "doc", "xls", "xlsx", "zip", "rar"];
				$is_downloadable = in_array($uzanti, $downloadable);
				?>

				<a href="<?php echo $link; ?>" <?php echo $is_downloadable ? 'download' : 'data-fancybox="gallery"'; ?>>
					<div style="overflow: hidden; border: 1px solid #ccc; width: 100%; height: 175px; background-image: url('<?php echo $medya; ?>'); background-size: cover; background-position: center; background-repeat: no-repeat; border-radius: 5px 0 0 0; "></div>
				</a>
				<div class="v3-bg-warning" style="position:absolute; top:1px; left:1px; padding: 0px 5px; border-radius: 5px 0px 0px;">
					<?php if ($m1<>""){$d=0; $diller = explode(',',$m1); foreach($diller as $dil) {$d++;?> <?php if ($rsm["t6"]=="lang".$d.""){echo $dil;}}}else{echo $sdil[150];}?>
				</div>
				<?php $rgrups = explode(',',$m4); $sqlsp=mysqli_query($conn, "select id,t1 from t1 where ne='isayfa' and s1=".$_GET["id"]." and id=".$rsm["s4"].""); $sp=mysqli_fetch_assoc($sqlsp);?>
				<?php if(mysqli_num_rows($sqlsp)>0){?>
					<div class="v3-bg-warning" style="left: 1px;position: absolute; font-size: 11px; margin-top: -22px; padding: 0px 10px; border-radius: 0px 10px 0px 0px;"><?php echo kisalt($sp["t1"],3);?></div>
				<?php }else{?>
					<div class="v3-bg-warning" style="left: 1px;position: absolute; font-size: 11px; margin-top: -22px; padding: 0px 10px; border-radius: 0px 5px 0px 0px;" title="<?php echo $rsm["t2"];?> <?php if($rgrups[($rsm["s4"]-1)]<>""){echo "> ".$rgrups[($rsm["s4"]-1)]." #".($rsm["s4"]-1)."";}?>"><?php echo kisalt($rsm["t2"],60);?> <?php if($rgrups[($rsm["s4"]-1)]<>""){echo "> ".$rgrups[($rsm["s4"]-1)]."";}?></div>
				<?php }?>
				<!---/Resim/-->
				<!--/Form/-->
				<div style="overflow:hidden; border:1px #ccc; width:100%; margin-top:5px;">
					<div style="display:none;" id="i<?php echo $rsm["id"]; ?>"><?php echo $link; ?></div>
					<form style="width:100%; padding:0px; margin:0px; height: 34px;" action="<?php echo $weburl."/".$crmpath."/"?>modules/ajax/ajax_medya.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&durum=sira&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>" method="post">
						<input type="text" value="<?php echo $rsm["s3"];?>" onfocus="if(this.value == '<?php echo $rsm["s3"];?>') { this.value = ''}" onblur="if(this.value == '') { this.value='<?php echo $rsm["s3"];?>';}" name="s3" style="max-width: 55px;margin-left: 5px;font-size:8pt; border: 1px #e0d8d8 solid !important; text-align: center;" size="5" class="mbtn20 btn btn-default" title="Sıra">
						<a style="cursor:pointer;" class="mbtn20 btn btn-danger btn-delete-div" data-href="<?php echo $weburl."/".$crmpath."/"?>modules/ajax/ajax_medya.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&durum=mdel&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>" title="Kayıt Sil"><i class="fas fa-trash" aria-hidden="true"></i></a>
						<a style="cursor:pointer;"  class="btn btn-warning mbtn20 mfrm" data-toggle="modal" data-width="50%" data-target="#myModal" data-title="<?php echo ctranslate("Düzenle")?>" data-url="../public/media_edit.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>" title="Düzenle"><i class="fa fa-pencil" aria-hidden="true"></i></a>
						<?php if($_GET["nedir"]=="resim"){?>
						<a style="cursor:pointer;"  class="btn btn-default mbtn20 mfrm" data-toggle="modal" data-width="90%" data-target="#myModal" data-url="<?php echo $weburl."/".$crmpath."/"?>modules/upload/upload_crop.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>" title="Düzenle"><i class="fa fa-crop" aria-hidden="true"></i></a>
						<?php }?>
						<a style="cursor:pointer;" class="btn btn-info mbtn20" onclick="copyToClipboard('#i<?php echo $rsm["id"]; ?>');" title="Editör için Kopyala"><i class="fa fa-clipboard"></i></a>
						<a style="cursor:pointer;" class="mbtn20 t<?php echo $rsm["ne"]?> btn btn-<?php if($rsm["s13"]==1){?>success<?php }else{?>danger<?php }?>" data-href="<?php echo $weburl."/".$crmpath."/"?>modules/ajax/ajax_medya.php?nedir=<?php echo $_GET["nedir"]; ?>&ne=<?php echo $_GET["ne"]; ?>&islem=<?php echo $_GET["islem"]; ?>&durum=monoff&id=<?php echo $_GET["id"]; ?>&mid=<?php echo $rsm["id"]; ?>&monoff=<?php if($rsm["s13"]=="1"){echo 0;}else{ echo 1;}?>" title="On/Off"><i class="fa fa-power-off"></i></a>
						<div style="position: absolute; font-size: 11px; color: #ccc; right: 10px; bottom: 10px;">#<?php echo i2a($rsm["id"],7);?><?php if($rsm["s4"]>0){echo " > ".$rsm["s4"]."";}?></div>
					<img class="mload" style="margin-top:1px; margin-left:4px; display: none;" src="assets/img/loading.gif">
					</form>
				</div>
				<!--/Form/--> 
			</div>
			<!---/Ana-div/-->
		<?php } ?>
		<div>
<?php
if($_GET["durum"] == "mvitrin"){
	$Rs = mysqli_query($conn, "update medya set s2='".$_GET["monay"]."' where id=".$_GET["mid"]."");

}elseif($_GET["durum"] == "monoff"){
	$Rs = mysqli_query($conn, "update medya set s13='".$_GET["monoff"]."' where id=".$_GET["mid"]."");

}elseif($_GET["durum"] == "mdel"){
	if($_GET["mid"]<>""){$qry="and id=".$_GET["mid"]."";}else{$qry="and s1=".$_GET["id"]."";}
	$sql=mysqli_query($conn, "select * from medya where ne='".$_GET['nedir']."' $qry"); while($rs=mysqli_fetch_assoc($sql)){
		if($_SESSION["V3Server"]==""){
			if($_GET["nedir"]=="resim"){
				unlink("../../../deppo/image/".$rs["t1"]."");
				unlink("../../../deppo/image/k_".$rs["t1"]."");
			}elseif($_GET["nedir"]=="video"){
				unlink("../../../deppo/video/".$rsv["t7"].".jpg");
			}elseif($_GET["nedir"]=="dosya"){
				unlink("../../../deppo/dosya/".$rs["t1"]."");
				unlink("../../../deppo/dosya/".$rs["t5"]."");
			}
			$Rs = mysqli_query($conn, "delete from medya where id=".$rs["id"]);
		}
	}
	
}elseif($_GET["durum"] == "msira"){
	$Rs = mysqli_query($conn, "update medya set s3='".$_GET["s3"]."' where id=".$_GET["mid"]."");
}
include("../public/log.php");
?>