<?php
/////////////////////////////////////////////
// Remove Menu Code /////
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/13/2009	ELL
// Revised: 2/9/2012	ELL
// Added table prefix handling.
//
// 
//
	include ("check_session.php");
	
	$today = addslashes(date("m/d/Y  H:m:s"));
	
	// Remove code from selected border area.
	$query = "SELECT page_content FROM " . BWB_TABLE_PREFIX . "page_data_special WHERE page_name = '$border_area'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$page_content = $row["page_content"];
	
	$pos = strrpos($page_content, "new menu (MENU");
	if ($pos !== false)
	{
		$pos2 = $pos + strlen("new menu (MENU_ITEMS");
		$pos3 = strpos($page_content, ",", $pos);
		$lnth = $pos3 - $pos2;
		$suf = substr($page_content, $pos2, $lnth);
		$searchStr = "<!--js menu script--><script>";
		$page_content = str_replace($searchStr, "", $page_content);
		$searchStr = "if (is_mobile === true) new menu (MENU" . $suf . "_ITEMS, MENU" . $suf . "_POS);";
		$page_content = str_replace($searchStr, "", $page_content);
		$searchStr = "else new menu (MENU_MOBILE" . $suf . "_ITEMS, MENU_MOBILE" . $suf . "_POS);";
		$page_content = str_replace($searchStr, "", $page_content);
		$searchStr = "</script><!--js menu script-->";
		$page_content = str_replace($searchStr, "", $page_content);
	
		$page_content=addslashes($page_content);
		$query = "UPDATE " . BWB_TABLE_PREFIX . "page_data_special SET page_content='$page_content', revised='$today' WHERE page_name='$border_area'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "page_data_draft WHERE page_name='$border_area'";
		$cnt = $bwb_dbh->exec($query);
	}
?>
