';
file_put_contents("../" . $page_slug . ".php", $file_content);
$message = "Page created successfully";
} else {
$error = "Failed to create page";
}
}
// Handle Update Page Settings (Title, Status)
if (isset($_POST['update_settings'])) {
$id = intval($_POST['page_id']);
$title = sanitizeInput($_POST['title']);
$status = intval($_POST['status']);
$page = getPageById($id);
if ($page) {
updatePage($id, $title, $page['content'], $page['meta_title'], $page['meta_description'], $status);
$message = "Page settings updated successfully";
}
}
// Handle Update Page Content
if (isset($_POST['update_content'])) {
$id = intval($_POST['page_id']);
$content = $_POST['content'];
$page = getPageById($id);
if ($page) {
updatePage($id, $page['title'], $content, $page['meta_title'], $page['meta_description'], $page['status']);
$message = "Page content updated successfully";
}
}
// Handle Delete Page
if (isset($_GET['delete'])) {
$id = intval($_GET['delete']);
$page = getPageById($id);
if ($page) {
$file_path = "../" . $page['page_slug'] . ".php";
if (file_exists($file_path)) {
unlink($file_path);
}
deletePage($id);
$message = "Page deleted successfully";
redirect('pages.php');
}
}
$pages = getAllPages();
?>