<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 12/4/2014	ELL
// Revised: 1/6/2015	ELL
// Fixed bug with page not previewing due to single quotes.
// Revised: 7/13/2024	ELL
// Fixed bug where content was not getting updated in cache. (Bad INSERT SQL.)


	include ("check_session.php");

	$ID = $_POST['ID'];
	
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "page_data_bkup WHERE `ID`='$ID'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$page_content = addslashes(stripslashes($row["page_content"]));
	
	echo json_encode($row);
	
	$query = "TRUNCATE " . BWB_TABLE_PREFIX . "page_cache";
	$cnt = $bwb_dbh->exec($query);
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_cache (id, tmp_page_data) VALUES (1, '" . addslashes(stripslashes($page_content)) . "')";
	$cnt = $bwb_dbh->exec($query);
?>