<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 6/3/2009
// 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 head content creation switched based on assign_head flag.
	
	include ("check_session.php");
	
	$suffix = $_REQUEST['suffix'];
	$assign_head = $_REQUEST['assign_head'];
	if (is_numeric($suffix))
		$head_name = "head" . $suffix;
	else
		$head_name = "head_" . $suffix;
	
	$today = date("Y-m-d H:i:s");
	$query = "INSERT INTO " . BWB_TABLE_PREFIX . "head SET head_name = '" . $head_name . "', head_content='<!-- Page Content Divider -->', revised='$today'";
	$cnt = $bwb_dbh->exec($query);
	
	if ($assign_head == 1)	{
		$page_name = $suffix;
		$query = "UPDATE " . BWB_TABLE_PREFIX . "page_data SET head_name = '" . $head_name . "' WHERE page_name ='" . $page_name . "'";
		$cnt = $bwb_dbh->exec($query);
	}
	
	echo $cnt . "@@@@@" . $head_name;
?>