This commit is contained in:
Suvodip
2024-12-26 18:22:47 +05:30
parent aa252de5c9
commit d212f88f27
4 changed files with 89 additions and 26 deletions

View File

@@ -54,6 +54,8 @@
<link rel="stylesheet" type="text/css" href="/assets/pell.css">
<script src="/assets/pell.js"></script>
<?php
$fileName = $_GET['slug'] . '.html';
$contentType = $_GET['type'];
$getID = $_GET['id'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
@@ -68,6 +70,26 @@
$stmt->bindParam(':content', $_POST['content']);
$stmt->execute();
// echo "<script>window.location.href='edit-news-list';</script>";
if ($contentType === 'page') {
$contentFolder = '/';
} elseif ($contentType === 'notice') {
$contentFolder = '/notice/';
} else {
$contentFolder = ''; // Default case, you can adjust this as needed
}
$filePath = $_SERVER['DOCUMENT_ROOT'] . $contentFolder . $fileName;
// echo $filePath;
if (file_exists($filePath)) {
if (unlink($filePath)) {
// echo "File deleted successfully.";
} else {
// echo "Error: Unable to delete the file.";
}
} else {
// echo "File does not exist.";
}
} catch (PDOException $e) {
echo "Err: " . $e->getMessage();
}
@@ -138,12 +160,15 @@ try {
updateEditorContent(' . json_encode($row['content']) . ');
</script>';
};
// exit();
} catch (PDOException $e) {
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
}
} catch (PDOException $e) {
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
}
?>
<?php
// echo $fileName;
// echo $contentType;
require('../.hta_footer.php');
?>