<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 4/22/2010	ELL
// Revised: 8/30/2010	ELL
// Fixed bug with handling # in HTML by using string replace. Replace ("#", ",", ".", " ") with ("POUND", "COMMA", "PERIOD", "SPACE").
// Revised: 2/8/2012	ELL
// Added table prefix handling.
// Modified: 12/2/2016	ELL
// Consolidated all class tables into site_classes table indexed by style_sheet field.
// Consolidated all CSS tables into site_css table indexed by style_sheet field.
// Revised: 5/25/2017	ELL
// Added loop to convert all NULLs to ''s.
	
	include ("check_session.php");
	
	$style_sheet = $_GET['style_sheet'];
	$class = $_GET['class'];
	$_SESSION['last_class_edited'] = $class;
	$search = array("PERIOD", "POUND", "SPACE", "COMMA", "GREATERTHAN", "GREATERTHAN", "PLUS", "TILDA");
	$replace = array(".", "#", " ", ",", ">", "&gt;", "+", "~");
	$class = str_replace($search, $replace, $class);
	
	$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "site_css` WHERE `style_sheet` = '$style_sheet' AND `class`='" . $class . "'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);

	if ($result->rowCount() < 1)
		echo "-no data-";
	else	{
		// Set all NULLs to '' because JavaScript can't deal with it.
		foreach($row as $key => $val)
		{
			if (!isset($val))
				$row[$key] = '';
		}
		print json_encode($row);
	}
?>