<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 10/19/2014	ELL

	include ("check_session.php");
	
	$head_name = $_REQUEST['head_name'];
	
	$query = "SELECT page_content, revised FROM " . BWB_TABLE_PREFIX . "page_data_draft WHERE page_name='$head_name' AND `source`=2";
	$result = $bwb_dbh->query($query);
	if ($result->rowCount() > 0)
	{
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$head_content = $row["page_content"];
	}
	else
	{
		$query = "SELECT head_content, revised FROM " . BWB_TABLE_PREFIX . "head WHERE head_name = '$head_name'";
		$result = $bwb_dbh->query($query);
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$head_content = $row["head_content"];
	}
	
	// Before we go any farther, back this puppy up!
	$revised = $row['revised'];
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_data_bkup SET page_name='$head_name', page_content=:head_content, revised='$revised', source=2";
	$stmt = $bwb_dbh->prepare($query);
	$stmt->execute(array(':head_content' => $head_content));
		
	echo stripslashes($head_content);
?>