<?php
if($h= opendir($pfolder)){
	$f=0; while (false !==($dosya= readdir($h))){$f++;
		if($dosya!= '.' && $dosya!= '..'){
			if(substr(($dosya),-4,4)==".png" or substr(($dosya),-4,4)==".jpg" or substr(($dosya),-4,4)==".gif" or substr(($dosya),-5,5)==".jpeg"){
				$view="<div class=\"wf\" style=\"background-image:url('".$pfolder."/".$dosya."')\"></div>";
			}elseif(substr(($dosya),-4,4)==".doc" or substr(($dosya),-5,5)==".docx"){
				$view="<div class=\"wf\" style=\"background-image:url('assets/img/icons/doc_b.png')\"></div>";
			}elseif(substr(($dosya),-4,4)==".xls" or substr(($dosya),-5,5)==".xlsx"){
				$view="<div class=\"wf\" style=\"background-image:url('assets/img/icons/xls_b.png')\"></div>";
			}elseif(substr(($dosya),-4,4)==".txt"){
				$view="<i class=\"fa fa-file\" style=\"font-size: 140px; color: #c08931; margin-top:10px;\"></i>";
			}elseif(substr(($dosya),-4,4)==".pdf"){
				$view="<div class=\"wf\" style=\"background-image:url('assets/img/icons/pdf_b.png')\"></div>";
			}elseif(substr(($dosya),-4,4)==".zip" or substr(($dosya),-4,4)==".rar"){
				$view="<div class=\"wf\" style=\"background-image:url('assets/img/icons/rar_b.png')\"></div>";
			}elseif(substr(($dosya),-4,4)==".sql" or substr(($dosya),-5,5)==".mdb"){
				$view="<i class=\"fa fa-database\" style=\"font-size: 140px; color: #c08931; margin-top:10px;\"></i>";
			}else{
				$view="<i class=\"fa fa-file\" style=\"font-size: 140px; color: #c08931; margin-top:10px;\"></i>";
			}
			if(substr(($dosya),-4,1)=="." or substr(($dosya),-5,1)=="."){
				$size=filesize("".$pfolder."/".$dosya.""); 
				$mtime=date("d-m-Y H:i:s", filemtime($dosya));
				if($size<1024){$size=$size." Bytes";}
				elseif(($size<1048576)&&($size>1023)){$size=round($size/1024, 1)." KB";}
				elseif(($size<1073741824)&&($size>1048575)){$size=round($size/1048576, 1)." MB";}
				else{$size=round($size/1073741824, 1)." GB";}
				$sfname = explode('.',$dosya);
				$fuzanti  = $sfname[count($sfname)-1];
				$fname  = $sfname[0];
				?>
				<div class="v3-col-md-3" style="padding:0px 5px !important;">
					<div  style="border: 1px solid #ccc; border-radius: 3px; margin-bottom:10px; height: 200px !important; padding:0px !important;position: relative;">
						<div style="display:none;" id="f<?php echo $f;?>"><?php echo "".$weburl."/".str_replace("../","",$pfolder)."/".$dosya."";?></div>
						<?php if($fuzanti=="php" or $fuzanti=="php" or $fuzanti=="txt" or $fuzanti=="docx" or $fuzanti=="doc"){?>
						<a class="v3-btn-warning mfrm" data-toggle="modal" data-target="#myModal" data-url="modules/public/edit_file.php?file=../../<?php echo $pfolder?>/<?php echo $dosya?>&cke=<?php if($fuzanti=="docx" or $fuzanti=="doc"){echo "true";}?>" data-title="Düzenle" title="<?php echo $mtime;?>" style="position: absolute; right: 65px; margin-top:2px; font-size: 14px; padding: 1px 5px; border-radius: 10px; cursor:pointer; width:25px; height:25px;"><i class="fa fa-edit"></i></a>
						<?php }?>
						<a class="v3-btn-warning" onclick="copyToClipboard('#f<?php echo $f;?>');" title="Linki Kopyala" style="position: absolute; right: 35px; margin-top:2px; font-size: 14px; padding: 1px 5px; border-radius: 10px; cursor:pointer; width:25px; height:25px;"><i class="fa fa-share-alt"></i></a>
						<a class="v3-btn-danger" 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 $dosya?>&durum=dfile','','','2000')" style="position: absolute; right: 5px; margin-top:2px; font-size: 14px; padding: 1px 7px; border-radius: 10px; cursor:pointer; width:25px; height:25px;"><i class="fa fa-trash"></i></a>
						<a href="<?php echo "".$weburl."/".str_replace("../","",$pfolder)."/".$dosya."";?>" data-fancybox="gallery">
							<div style="height: -webkit-fill-available; width:100%; overflow:hidden;  text-align:center;"><?php echo $view?></div>
						</a>
						<div style="width:100%; text-align:center; height:40px; position: absolute; bottom: 0px;" class="v3-bg-info">
							<form id="rf_<?php echo cevir($fname.$fuzanti)?>" method="post" style="float:left; margin-left:5px; margin-top: -5px;">
								<input type="text" name="q" class="form-control v3-text-info" placeholder="<?php echo $fname?>.<?php echo $fuzanti?>" value="<?php echo $fname?>.<?php echo $fuzanti?>" style="padding: 3px; margin-top: 12px; color:black !important;">
							</form>
						</div>
							<i class=" v3-text-info" style="position:absolute; right:10px; bottom:10px;"><?php echo $size;?></i>
						</div>
							
						<script>
							jQuery( "#rf_<?php echo cevir($fname.$fuzanti)?>" ).submit(function( event ) {
							  AjaxPResult('modules/drive/ajax.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=rfile&folder=<?php echo $pfolder?>&file=<?php echo $pfolder?>&nfile=<?php echo $dosya?>','#rf_<?php echo cevir($fname.$fuzanti)?>','#err','2000')  
							  event.preventDefault();
							});  
						</script>
				</div>
<?php }}}} ?>