<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 12/17/2010	ELL
// Revised: 2/10/2012	ELL
// Added table prefix handling.
// Revised: 5/14/2013	ELL
// Added URL escaping and unescaping of URL itself.
// Revised: 10/25/2016	ELL
// Added handling of mega menus.
// Modified: 12/2/2016	ELL
// Consolidated all menu items tables into menu_items.
// 
//
//

	include ("check_session.php");
	include("lib/unescape_url.php");

	$menu = $_POST['menu'];

	// Build item arrays from POST variables.
	$ID = $_POST["ID"];
	$item_text = $_POST['item_text'];
	$item_text = trim(UnescapeURL($item_text));
	$level = $_POST["level"];
	$URL = $_POST["URL"];
	$URL = trim(UnescapeURL($URL));
	$target = $_POST["target"];
	$mega_menu = $_POST["mega_menu"];
	$sort_order = $_POST["sort_order"];
		
	//Insert new data into table.
	$item_text = str_replace("'", "&#39;", $item_text);
	$item_text = str_replace("\"", "&quot;", $item_text);
	$level = addslashes($level);
	$URL = addslashes($URL);
	$target = addslashes($target);
		
	$query = "UPDATE " . BWB_TABLE_PREFIX . "menu_items SET item_text='" . $item_text . "', level='" . $level . "', URL='" . $URL . "', target='" . $target . "', mega_menu='" . $mega_menu . "', sort_order=" . $sort_order . " WHERE menu='" . $menu . "' AND ID=" . $ID;
	$cnt = $bwb_dbh->exec($query);
	
	// Re-write sitemap.xml for web crawlers.
	include("generate_site_map.php");
	
	echo "Update complete";
?>
