From 30398b36530aaaefc75516ccc61a43efae8ca407 Mon Sep 17 00:00:00 2001 From: Larry Browning Date: Sat, 27 Jun 2026 18:46:50 +0800 Subject: [PATCH 1/2] Fix multiple issues in vhosts panel and Httpd class Security: - Replace $_SERVER['HTTP_HOST'] with Docker internal hostname to prevent SSRF - Add cURL connect/read timeouts (3s/5s) to prevent hung PHP-FPM workers Robustness: - Add fopen() error handling in getVhostBackend() with logged warning - Clean up IPv6 address parsing using array_pop/implode/array_slice - Replace hardcoded PHP container IP with dynamic gethostname()/SERVER_ADDR - Fix XHR timeout race: use native xhr.ontimeout instead of manual setTimeout - Make vhost AJAX endpoint return consistent JSON with status/message fields Cleanup: - Fix unscoped JS variable (i) in for-loop - Change read-only status check from POST to GET - Fix operator precedence in XHR status check (readyState vs status) - Remove dead/commented-out code in checkDns() - Add backup files and local shell scripts to .gitignore Co-Authored-By: Claude --- .devilbox/www/htdocs/_ajax_callback.php | 9 ++- .devilbox/www/htdocs/vhosts.php | 57 +++++++++---------- .devilbox/www/include/lib/container/Httpd.php | 15 +++-- .gitignore | 4 ++ 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.devilbox/www/htdocs/_ajax_callback.php b/.devilbox/www/htdocs/_ajax_callback.php index c98b98aca..3d0469a09 100644 --- a/.devilbox/www/htdocs/_ajax_callback.php +++ b/.devilbox/www/htdocs/_ajax_callback.php @@ -27,7 +27,14 @@ // ?vhost= // else if (isset($_GET['vhost'])) { - echo loadClass('Httpd')->checkVirtualHost($_GET['vhost']); + $vhostResult = loadClass('Httpd')->checkVirtualHost($_GET['vhost']); + if (strlen($vhostResult) === 0) { + echo json_encode(array('status' => 'ok', 'message' => '')); + } else if (strpos($vhostResult, 'error') === 0) { + echo json_encode(array('status' => 'error', 'message' => substr($vhostResult, 10))); + } else { + echo json_encode(array('status' => 'warning', 'message' => substr($vhostResult, 12))); + } } diff --git a/.devilbox/www/htdocs/vhosts.php b/.devilbox/www/htdocs/vhosts.php index 4b37386e7..262a01496 100644 --- a/.devilbox/www/htdocs/vhosts.php +++ b/.devilbox/www/htdocs/vhosts.php @@ -53,7 +53,7 @@