<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 6/3/2009
// Revised: 1/12/2/12	ELL
// Added saving to page_data_draft table to accomodate new upgrade for save to draft mode.
// Revised: 1/16/2012	ELL
// Added seed HTML to make it easier to start editing the page.
// Revised: 2/7/2012	ELL
// Added table prefix handling.
// Revised: 6/24/2013	ELL
// Added ability to specify meaningful names.
// Revised: 10/28/2016	ELL
// Added automatic assignment at border area creation switched based on assign_border flag.
	
	include ("check_session.php");
		
	$area_type = $_REQUEST['area_type'];
	$suffix = $_REQUEST['suffix'];
	$assign_border = $_REQUEST['assign_border'];
	if (is_numeric($suffix))
		$special_page_name = $area_type . $suffix;
	else
		$special_page_name = $area_type . "_" . $suffix;
	
	$body_html = "\n<p>" . CREATE_PAGE_DEFAULT_CONTENT . "</p>\n<!-- Page Content Divider -->\n";
	$today = date("Y-m-d H:i:s");
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_data_special SET page_name='" . $special_page_name . "', page_content='" . $body_html . "', revised='" . $today . "'";
	$cnt = $bwb_dbh->exec($query);
	// Copy page data to draft table.
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_data_draft SET page_name='" . $special_page_name . "', page_content='" . $body_html . "', revised='" . $today . "', `source`=1";
	$cnt2 = $bwb_dbh->exec($query);
	
	if ($assign_border == 1)	{
		$page_name = $suffix;
		$query = "UPDATE " . BWB_TABLE_PREFIX . "page_data SET " . $area_type . "_name = '" . $special_page_name . "' WHERE page_name ='" . $page_name . "'";
		$cnt = $bwb_dbh->exec($query);
	}
	
	echo $cnt . "@@@@@" . $special_page_name  . "@@@@@" . $area_type;
?>