From 10a087f891bc2e678ff365adb020a1b45dcb0cbe Mon Sep 17 00:00:00 2001 From: usmannasir Date: Mon, 21 Jul 2025 00:32:21 +0500 Subject: [PATCH] bug fix: https://github.com/usmannasir/cyberpanel/issues/1449 --- websiteFunctions/website.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index c4fa10c9d..8f5c979e2 100644 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -2819,8 +2819,23 @@ Require valid-user """ try: - with open(suspensionPagePath, 'w') as f: - f.write(defaultSuspensionHTML) + # Create directory if it doesn't exist + dirPath = os.path.dirname(suspensionPagePath) + if not os.path.exists(dirPath): + command = f"mkdir -p {dirPath}" + ProcessUtilities.executioner(command) + + # Write the HTML content to a temporary file first + tempFile = "/tmp/suspension_temp.html" + # Use cat with heredoc to create the file + command = f'''cat > {tempFile} << 'EOF' +{defaultSuspensionHTML} +EOF''' + ProcessUtilities.executioner(command, shell=True) + + # Move the temporary file to the final location + command = f"mv {tempFile} {suspensionPagePath}" + ProcessUtilities.executioner(command) except: pass