<?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");
	
	$custom_site_css_table = $_REQUEST['custom_site_css_table'];
	
	$query = "SELECT page_content, revised FROM " . BWB_TABLE_PREFIX . "page_data_draft WHERE page_name='$custom_site_css_table' AND `source`=3";
	$result = $bwb_dbh->query($query);
	if ($result->rowCount() > 0)
	{
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$custom_css = $row["page_content"];
	}
	else
	{
		$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . $custom_site_css_table . "`";
		$result = $bwb_dbh->query($query);
		$row = $result->fetch(PDO::FETCH_ASSOC);
		if ($row["custom_css"])
			$custom_css = $row["custom_css"];
		else
			$custom_css = "";
	}
	
	// Before we go any farther, back this puppy up!
	$revised = $row['revised'];
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_data_bkup SET page_name='$custom_site_css_table', page_content=:custom_css, revised='$revised', source=3";
	$stmt = $bwb_dbh->prepare($query);
	$stmt->execute(array(':custom_css' => $custom_css));
		
	echo stripslashes($custom_css);
?>