<?php
$path="../../../";
if(file_exists("".$path."config/map.php" )){$path2="config/"; include("".$path."config/map.php");}else{include("".$path."map.php");}
include("fonksiyon".$ver.".php");
include("SimpleImage.php");
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<?php if($_GET["medya"]=="" and $_GET["drm"]==""){?>
	<div class="v3-panel-body" style="overflow-x: auto; overflow-y: hidden;">
		<div class="v3-row">
			<?php $sqlm=mysqli_query($conn, "select * from medya where (ne='resim' or ne='video') and s1=".$_GET["s1"].""); while($rsm=mysqli_fetch_assoc($sqlm)){?>
				<div class="v3-col-xs-6 v3-col-md-3" style="height:275px; overflow:hidden;">
					<div class="v3-thumbnail" style="height:200px;">
						<?php if($rsm["ne"]=="resim"){?>
							<img src="deppo/image/<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t2"];?>" style="height:185px;">
							<div class="v3-caption" style="position:absolute; margin-top:-25px;">
								<a href="deppo/tools/script/medya.php?ne=<?php echo $_GET["ne"];?>&id=<?php echo $_GET["s1"];?>&drm=rsil&rid=<?php echo $rsm["id"];?>&medya=<?php echo $rsm["ne"];?>" onClick="return confirm('#<?php echo $sdil[215]; //Bu Kayit Silinecektir ! Onayliyor musunuz ??>'); show('islem');" target="islem" class="fa fa-trash-o" style="color:red; font-size:20px;"  title="Sil" ></a>
								<a href="deppo/tools/script/medya.php?ne=<?php echo $_GET["ne"];?>&id=<?php echo $_GET["s1"];?>&drm=monay&mid=<?php echo $rsm["id"];?>&onay=<?php if($rsm["s2"]!=1){echo "1";}else{echo "0";}?>&medya=<?php echo $rsm["ne"];?>" onclick="show('islem')" target="islem" class="fa fa-toggle-<?php if($rsm["s2"]!=1){echo "off";}else{echo "on";}?>" style="color:blue; font-size:20px;" title="Vitrin"></a>
							</div>
						<?php }else{?>
							<embed src="<?php echo $rsm["n1"];?>" style="width:100%; height:185px;">
								<div class="v3-caption" style="position:absolute; margin-top:-25px;">
									<a href="deppo/tools/script/medya.php?ne=<?php echo $_GET["ne"];?>&id=<?php echo $_GET["s1"];?>&drm=vsil&vid=<?php echo $rsm["id"];?>&medya=<?php echo $rsm["ne"];?>" onclick="show('islem')" target="islem" class="fa fa-trash-o" style="color:red; font-size:20px;"></a>
								</div>
							<?php }?>
							<div class="v3-caption" style="position:absolute; margin-top:-50px; height:35px; z-index:9999999999; font-size:12px;">&nbsp;<b><?php echo $rsi["t2"];?></b></div>
						</div>
					</div>
				<?php }?>
			</div>
		</div>
	<?php }elseif($_GET["medya"]=="resim" and $_GET["drm"]==""){?>
		<form method="POST" name="frm" enctype="multipart/form-data" action="?drm=ryukle&ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&medya=resim">
			<div class="panel panel-default">
				<div class="panel-heading">Resim Detay</div>
				<div class="panel-body">
					<label>Medya <span style="font-size:8px; color:#ccc;">(t1)</span></label>
					<input type="file" class="form-control" name="medya" accept="*"/>
					<input type="text" name="t2" class="form-control with-tip" title="Adı (t2)" placeholder="Adı" style="margin-top:5px;">
					<textarea name="n3" rows="2" class="form-control with-tip" title="Açıklama (n3)" style="margin-top:5px;"  placeholder="Açıklama"></textarea>
					<select size="1" name="s5" class="form-control" style="height:30px; margin-top:5px;">
						<option value="0">[0] Varyasyon Seçiniz</option>
						<?php $sqlc=mysqli_query($conn, "select * from varyasyon where s1=".$_GET["id"].""); while($rsc=mysqli_fetch_assoc($sqlc)){?>
							<option value="<?php echo $rsc["id"];?>">[<?php echo $rsc["id"];?>] <?php echo $rsc["t1"];?></option>
						<?php }?>
					</select>
					<button type="submit" style="float:right; margin-right:10px; margin-top:5px;" id="btn" class="btn btn-primary">Kaydet</button>
				</div>
			</div>
		</form>
	<?php }elseif($_GET["medya"]=="video" and $_GET["drm"]==""){?>
		<form method="POST" name="frm" action="?drm=vyukle&ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&medya=video">
			<div class="panel panel-default">
				<div class="panel-heading">Video Detay</div>
				<div class="panel-body">
					<label>Medya <span style="font-size:8px; color:#ccc;">(t1)</span></label>
					<input type="text" class="form-control" name="video"/>
					<input type="text" name="t2" class="form-control with-tip" title="Adı (t2)" placeholder="Adı" style="margin-top:5px;">
					<textarea name="n3" rows="2" class="form-control with-tip" title="Açıklama (n3)" style="margin-top:5px;"  placeholder="Açıklama"></textarea>
					<button type="submit" style="float:right; margin-right:10px; margin-top:5px;" id="btn" class="btn btn-primary">Kaydet</button>
				</div>
			</div>
		</form>
	<?php }elseif($_GET["medya"]=="dosya" and $_GET["drm"]==""){?>
	<?php }elseif($_GET["drm"]=="ryukle" and $_GET["medya"]=="resim"){
		if(!empty($_GET["id"])){$_GET["id"]=$_GET["id"];}else{$_GET["id"]="0";}
		$kaydedilecekyer = "../../image";
$kaynak = $_FILES['medya']['tmp_name'];	//Burası resminiz kök klasörünün yerini verir
$tipi 	= $_FILES['medya']['type']; // Dosyanın Tipi
$adi 	= $_FILES["medya"]["name"]; // Dosyanın PCdeki Adı
$uzanti = substr($adi,-4); // Dosya Uzantısı
$rand   = substr(md5(uniqid(rand())),0,10);
$yeni   = "".$isim."-".$rand.$uzanti."";
move_uploaded_file ($_FILES['medya']['tmp_name'], $kaydedilecekyer . "/".$yeni);
$conn->query("insert INTO medya (ne,s1,s2,s3,s4,t1,t3,t2,n3) VALUES ('resim','".$_GET["id"]."', '0', '0', '".$_POST["s4"]."', '".addslashes($yeni)."', '".$_GET['ne']."', '".$_POST['t2']."', '".$_POST['n3']."')");
if ($_POST["boyut1"]<>""){
	$image = new SimpleImage();
	$image->load("".$kaydedilecekyer."/".$yeni."");
	$image->resizeToWidth("".$a9."");
	$image->save("".$kaydedilecekyer."/".$yeni."");
	$image->resizeToWidth("".$a10."");
	$image->save("".$kaydedilecekyer."/k_".$yeni."");
}else{
	$image = new SimpleImage();
	$image->load("".$kaydedilecekyer."/".$yeni."");
	$image->save("".$kaydedilecekyer."/".$yeni."");
	$image->resizeToWidth("".$a10."");
	$image->save("".$kaydedilecekyer."/k_".$yeni."");
}
if($_GET["islem"]=="dilan"){
	echo location("".$weburl."?panel/ilan/dilan/".$_GET["id"]."",top,50);
}else{
	echo location("".$weburl."?panel/medya",top,50);
}
?>
<?php }elseif($_GET["drm"]=="vyukle" and $_GET["medya"]=="video"){
	include("../../../v3panel/videoal.php");
	$s1=$_GET["id"];
	if(!empty($_POST["s3"])){$s3=$_POST["s3"];}else{$s3="0";}
	if(!empty($_POST["s5"])){$s5=$_POST["s5"];}else{$s5="0";}
	if ($_POST["t1"]==""){$vadi=str_replace($degis2, $degis3, $vtitle);}else{$vadi=$_POST["t1"];}
	$_GET["ne"]=$_GET["ne"];
	$sql = $conn->query("insert into medya (ne,s1,s2,s3,s4,s5,n1,n2,n3,n4,t1,t3,t4) values ('video','".$s1."', '0', '".$s3."', '0', '".$s5."', '".$vvid."', '".$vres."', '".$_POST["n3"]."', '".$vurl."', '".$vadi."', '".$_GET["ne"]."', '".$vurl."')");
	if($_GET["islem"]=="dilan"){
		echo location("".$weburl."?panel/ilan/dilan/".$_GET["id"]."",top,50);
	}else{
		echo location("".$weburl."?panel/medya",top,50);
	}
	?>
<?php }elseif($_GET["drm"]=="monay"){
	echo "<div class=\"alert alert-success fade in\" role=\"alert\" style=\"padding:0px;\">";
	echo "<h5 style=\"margin-left:30px;\"><span class=\"fa fa-check\"></span> ".$sdil[103]." <i class=\"fa fa-refresh fa-spin\"></i> ".$sdil[69]."</h5>";
	echo "</div>";
	echo "<script language=\"JavaScript\">var delay = 2; var targetURL = \"".$_SERVER['HTTP_REFERER']."\"; setTimeout('top.location.replace(targetURL)', (delay * 500));</script>";
	$Sql = mysqli_query($conn, "update medya set s2='".$_GET["onay"]."' where id=".$_GET["mid"]."");
	?>
<?php }elseif($_GET["drm"]=="rsil" and $_GET["medya"]=="resim"){
	echo "<div class=\"alert alert-success fade in\" role=\"alert\" style=\"padding:0px;\">";
	echo "<h5 style=\"margin-left:30px;\"><span class=\"fa fa-check\"></span> ".$sdil[103]." <i class=\"fa fa-refresh fa-spin\"></i> ".$sdil[69]."</h5>";
	echo "</div>";
	echo "<script language=\"JavaScript\">var delay = 2; var targetURL = \"".$_SERVER['HTTP_REFERER']."\"; setTimeout('top.location.replace(targetURL)', (delay * 500));</script>";
	$sql=mysqli_query($conn, "select * from medya where ne='resim' and id=".$_GET["rid"].""); $rs=mysqli_fetch_assoc($sql);
	$dosya1="../deppo/image/".$rs["t1"]."";unlink($dosya1);
	$dosya2="../deppo/image/k_".$rs["t1"]."";unlink($dosya2);
	$Rs = mysqli_query($conn, "delete from medya where id=".$_GET["rid"]);
	?>
<?php }elseif($_GET["drm"]=="vsil" and $_GET["medya"]=="video"){
	echo "<div class=\"alert alert-success fade in\" role=\"alert\" style=\"padding:0px;\">";
	echo "<h5 style=\"margin-left:30px;\"><span class=\"fa fa-check\"></span> ".$sdil[103]." <i class=\"fa fa-refresh fa-spin\"></i> ".$sdil[69]."</h5>";
	echo "</div>";
	echo "<script language=\"JavaScript\">var delay = 2; var targetURL = \"".$_SERVER['HTTP_REFERER']."\"; setTimeout('top.location.replace(targetURL)', (delay * 500));</script>";
	$Rs = mysqli_query($conn, "delete from medya where id=".$_GET["vid"]);
}?>