<?php
if ($_GET["folder"]=="" or substr($_GET["folder"],0,8)<>"../deppo"){$pfolder="../deppo/drive_files";}else{$pfolder=$_GET["folder"];}
if (!file_exists("../deppo/drive_files")) {
	mkdir("../deppo/drive_files", 0777, true);
}
?>
<style>
	.bc2 { list-style: none; }
	.bc2 li { float:left; margin-right:10px; }
	.wf{ width: 100%; height: 100%; background-position: center;background-size: contain;background-repeat: no-repeat;}
.item-options{
	position: absolute; right: 5px; top: 12px;
	display:none;
}
.v3-list-group-item:hover  .item-options{
	display:block;
}
</style>
<div class="inner-wrapper">
	<section role="main" class="content-body">
		<header class="page-header">
			<h2>Drive</h2>
			<div class="right-wrapper text-right">
				<ol class="breadcrumbs">
					<li>
						<a href=".">
							<i class="fa fa-home"></i>
						</a>
					</li>
					<li><span>Crm +Plus</span></li>
					<li><span>Drive</span></li>
				</ol>
				<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
			</div>
		</header>
		<div class="alert alert-warning" id="err" style="display:none;"></div>
		<div class="row">
			<div class="col">
				<section class="card">
					<header class="card-header v3-bg-info">
					<h2 class="card-title">
						<ol class="bc2" style="padding: 0px;">
							<?php $i=0;$tags = explode('/',$pfolder); foreach($tags as $tag){$i++;?>
								<?php if($i>2){?>
									<li><?php if($i==3){?><i class="fa fa-home"></i><?php }elseif($i>3){?><i class="fa fa-angle-double-right"></i><?php }?> 
									<a href="<?php if($i==3){?>?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=../deppo/drive_files<?php }elseif($i>3){?>?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=../deppo/drive_files/<?php echo $tag;?><?php }?>" style="text-transform:capitalize;">
										<?php echo $tag;?> 
									</a>
								</li>
							<?php }}?>
						</ol>
					</h2>
						<div class="card-actions" id="v-<?php echo $_GET['islem'];?>">
							<a class="mb-1 mt-1 mr-1" href="#"><?php echo ctranslate("Toplam")?> : <strong><?php echo folderSize($pfolder);?> </strong></a>
<!--
							<a href="#" class="card-action card-action-toggle" data-card-toggle=""></a>
							<a href="#" class="card-action card-action-dismiss" data-card-dismiss=""></a>
						-->
						<div class="mb-1 mt-1 mr-1 btn btn-default" onclick="toggle('.ddd')" style="position: relative;"><i class="fas fa-plus" aria-hidden="true"></i>
							<div class="dropdown-menu ddd" role="menu" style="right: 0px; left:auto;">
								<a class="dropdown-item text-1" style="padding:5px;" href="#imgupload"><i class="fas fa-cloud-upload-alt"></i> <?php echo ctranslate("Dosya Yükle")?></a>
								<a class="dropdown-item text-1 mfrm" style="padding:5px;" data-toggle="modal" data-target="#myModal" data-url="modules/public/edit_file.php?file=../../<?php echo $pfolder?>/<?php echo $dosya?>&mode=create" data-title="Düzenle"><i class="fas fa-code"></i> <?php echo ctranslate("Oluştur (Kod)")?></a>
								<a class="dropdown-item text-1 mfrm" style="padding:5px;" data-toggle="modal" data-target="#myModal" data-url="modules/public/edit_file.php?file=../../<?php echo $pfolder?>/<?php echo $dosya?>&mode=create&cke=true" data-title="Düzenle"><i class="fas fa-file-word"></i> <?php echo ctranslate("Oluştur (Dosya)")?></a>
							</div>
						</div>
					</div>
				</header>
				<div class="card-body form">
						<div class="v3-col-md-2">
								<div class="inner-menu-content">
									<a class="btn btn-block btn-primary btn-md pt-2 pb-2 text-3" id="OpenImgUpload">
										<i class="fa fa-upload mr-1"></i>
										Upload Files
									</a>
									<form id="uform" action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=ufile&folder=<?php echo $pfolder?>" method="post" enctype="multipart/form-data" style="display:none;"><?php echo ctranslate("Dosya Yükle")?> <input type="file" id="imgupload" name="q" class="custom-file-input" style=""  accept="*" onChange="this.form.submit()"></form>
									<script>
										jQuery('#OpenImgUpload').click(function(){
											jQuery('#imgupload').trigger('click');
										});
										OpenImgUpload.ondragover = OpenImgUpload.ondragenter = function(evt) {
											  evt.preventDefault();
										};
										OpenImgUpload.ondrop = function(evt) {
										  imgupload.files = evt.dataTransfer.files;
										  jQuery("#uform").submit();
										  //AjaxPResult('modules/drive/index.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=ufile&folder=<?php echo $pfolder?>','#uform','#err','2000');
										  evt.preventDefault();
										};
										jQuery( "#cfolder" ).submit(function( event ) {  
										  AjaxPResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=cfolder&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>','#cfolder','#err','2000')  
										  event.preventDefault();  
										});  
										/*
										jQuery(document).ready(function (){
											loadFunction('modules/drive/files.php?pfolder=../../<?php echo $pfolder?>&','#dfiles', '');
										});
										document.write("<div id=\"dfiles\"></div>");
										*/
									</script>
				
								<hr class="separator">
				
								<div class="sidebar-widget m-0">
									<div class="widget-header clearfix">
										<h6 class="title float-left mt-1">Klasörler</h6>
										<div class="float-right">
											<a href="#" class="btn btn-dark btn-sm btn-widget-act"  onclick="toggle('#r_add')">Klasör Ekle</a>
										</div>
									</div>
								</div>
				
								<hr class="separator">
							</div>
<!--
							<div class="v3-col-md-2" style="display: flow-root; margin-bottom: 3px;border: 1px solid #ccc; border-radius: 3px; margin-right:5px; padding: 2px;">
								<div style="float:left;"><i class="fa fa-plus v3-text-info" style="font-size: 35px; margin-top: 3px;"></i></div>
								<form id="cfolder" method="post" style="position: absolute; left: 35px; margin-top:5px;"><input type="text" name="q" class="form-control v3-text-info" placeholder="<?php echo ctranslate("Yeni Klasör Adı")?>"></form>
							</div>
-->
							<ul class="v3-list-group">
							  <li class="v3-list-group-item"  id="r_add" style="display:none;">
								<form id="cfolder" method="post"><input type="text" name="q" class="form-control" placeholder="<?php echo ctranslate("Yeni Klasör Adı")?>"></form>
							  </li>
<?php $f=0;foreach(glob("".$pfolder."/*", GLOB_ONLYDIR) as $dir){$f++;?>
							  <li class="v3-list-group-item">
								<a class="text-danger" style="line-height: 32px;" id="a_<?php echo cevir(basename($dir))?>" href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=<?php echo $pfolder?>/<?php echo basename($dir)?>"><i class="far fa-folder"></i> <?php echo basename($dir)?></a>
								<form id="r_<?php echo cevir(basename($dir))?>" method="post" style="display:none;"><input type="text" name="q" class="form-control" placeholder="<?php echo basename($dir)?>" value="<?php echo basename($dir)?>"></form>
								<div class="item-options">
									<a href="#" onclick="toggle('#r_<?php echo cevir(basename($dir))?>');toggle('#a_<?php echo cevir(basename($dir))?>')">
										<i class="fa fa-edit"></i>
									</a>
									<a href="#" onclick="AjaxGResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>/<?php echo basename($dir)?>&durum=dfolder','','','2000')" class="text-danger">
										<i class="fa fa-times"></i>
									</a>
								</div>
							  </li>
								<script>
									jQuery( "#r_<?php echo cevir(basename($dir))?>" ).submit(function( event ) {
									  AjaxPResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=rfolder&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>&nfolder=<?php echo basename($dir)?>','#r_<?php echo cevir(basename($dir))?>','#err','2000')  
									  event.preventDefault();
									});  
								</script>
<?php }?>
							</ul>
<!--
								<div class="v3-col-md-2" style="display: flow-root; margin-bottom: 3px;border: 1px solid #ccc; border-radius: 3px; height: 142px !important;">
									<a onclick="AjaxGResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>/<?php echo basename($dir)?>&durum=dfolder','','','2000')" style="position: absolute; right: 10px; font-size: 14; color: red; margin-top: 7px;"><i class="fa fa-trash"></i>
										<a href="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&folder=<?php echo $pfolder?>/<?php echo basename($dir)?>">
											<div style="float:left;"><i class="fa fa-folder" style="font-size: 35px; color: #c08931;margin-top: 3px;"></i></div>
										</a>
										<div style="float:left; margin-left:5px; margin-top:10px; text-transform:capitalize;"><form id="r_<?php echo cevir(basename($dir))?>" method="post" style="float:left; margin-left:5px;margin-top: -5px;"><input type="text" name="q" class="form-control" placeholder="<?php echo basename($dir)?>" value="<?php echo basename($dir)?>"></form></div>
									</div>
									<script>
										jQuery( "#r_<?php echo cevir(basename($dir))?>" ).submit(function( event ) {
										  AjaxPResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=rfolder&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>&nfolder=<?php echo basename($dir)?>','#r_<?php echo cevir(basename($dir))?>','#err','2000')  
										  event.preventDefault();
										});  
									</script>
-->
						</div>
						<div class="v3-col-md-10">
							<div class="v3-col-md-12">
								<?php //include("ajax_upload.php");?>
								<?php include("files.php");?>
							</div>
					</div>
				</div>
			</section>
		</div>
	</div>
	<!-- end: page -->
	</section>
	</div>
<script>
	jQuery('#OpenImgUpload').click(function(){
		jQuery('#imgupload').trigger('click');
	});
	OpenImgUpload.ondragover = OpenImgUpload.ondragenter = function(evt) {
		  evt.preventDefault();
	};
	OpenImgUpload.ondrop = function(evt) {
	  imgupload.files = evt.dataTransfer.files;
	  jQuery("#uform").submit();
	  //AjaxPResult('modules/drive/index.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=ufile&folder=<?php echo $pfolder?>','#uform','#err','2000');
	  evt.preventDefault();
	};
	jQuery( "#cfolder" ).submit(function( event ) {  
	  AjaxPResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=cfolder&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>','#cfolder','#err','2000')  
	  event.preventDefault();  
	});  
	/*
	jQuery(document).ready(function (){
		loadFunction('modules/drive/files.php?pfolder=../../<?php echo $pfolder?>&','#dfiles', '');
	});
	document.write("<div id=\"dfiles\"></div>");
	*/
</script>
<?php
if($_GET["durum"]=="cfolder"){
	if (!file_exists("".$_GET["folder"]."/".$_POST["q"]."")) {
		mkdir("".$_GET["folder"]."/".$_POST["q"]."", 0777, true);
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="ufile"){
	$kaynak = $_FILES['q']['tmp_name'];
	$isim   = $_FILES['q']['name'];
	$rand   = substr(md5(uniqid(rand())),0,5);
	$yeni   = $_FILES['q']['name'];
	move_uploaded_file ($_FILES['q']['tmp_name'], $_GET["folder"] . "/".$yeni);
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="dfile"){
	unlink($_GET["file"]);
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="dfolder"){
	rrmdir($_GET["file"]);
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="rfolder"){
	rename("".$_GET["folder"]."/".$_GET["nfolder"]."","".$_GET["folder"]."/".$_POST["q"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}elseif($_GET["durum"]=="rfile"){
	rename("".$_GET["folder"]."/".$_GET["nfile"]."","".$_GET["folder"]."/".$_POST["q"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&folder=".$_GET["folder"]."&durum=ok",self,0,0);
}
?>
<aside id="sidebar-right" class="sidebar-right">
	<div class="nano">
		<div class="nano-content">
			<a href="#" class="mobile-close d-md-none">
				Collapse <i class="fa fa-chevron-right"></i>
			</a>
			<div class="sidebar-right-wrapper">
				...
			</div>
		</div>
	</div>
</aside>
</section>
<script src="assets/js/examples/examples.mediagallery.js"></script>