<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	11/28/2013	ELL
// 

	include ("check_session.php");
	
	$display_pruned_bkup_files_msg = $_REQUEST['display_pruned_bkup_files_msg'];
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Function Select</title>
<link rel="stylesheet" href="manager.css" type="text/css">

<style type="text/css">
#manage_users_site_options_heading	{	width:260px;	}
#help_button	{	
	position:relative;
	display:block;
	top:-15px;
	left:220px;
	height:31px;
	width:31px;
	z-index:100;
}
#prune_css_btn	{	
	width:258px;
	height:60px;
	border-top:none;
}
#prune_table_btn	{	
	width:180px;
	display:block;
	position:relative;
	left:40px;
}
#recall_plugin_btn	{	
	width:180px;
	display:block;
	position:relative;
	left:40px;
}
#prune_page_backup_table_div	{	display:none;	}
#recall_plugin_div	{	display:none;	}
</style>

<script language="javascript" type="text/javascript" src="js/browser_detect.js"></script>
<script language="javascript" type="text/javascript" src="js/mouse_position.js"></script>
<script language="javascript" type="text/javascript" src="js/popup_msg.js"></script>
<script language="javascript" type="text/javascript" src="js/admin_function_select.js"></script>

<script language="javascript" type="text/javascript">

function ActivateDeactivateConfirm()
{
	popup_msg.top_offset = 0;
	popup_msg.left_offset = 300;
	popup_msg.popup_msg_type = 3;
	popup_msg.popup_btn_cnt = 2;
	popup_msg.popup_button_2_span = "Yes";
	popup_msg.popup_button_1_span = "No";
	popup_msg.popup_timeout = -1;
	document.getElementById("popup_button_1_span").onclick = function () { HidePopupMsg(); };

<?php
	$document_root = getenv('DOCUMENT_ROOT');
	$html_index = $document_root . "/index.html";
	$construction = $document_root . "/construction.html";
	if (file_exists($html_index) && !file_exists($construction))
		$site_active = false;
	elseif (!file_exists($html_index) && file_exists($construction))
		$site_active = true;
		
	if ($site_active)
	{
		echo "	var msg = 'Do you want to take your site off line?';\n";
		echo "	var activate = 0;\n";
	}
	else
	{
		echo "	var msg = 'Do you want to take your site live?';\n";
		echo "	var activate = 1;\n";
	}
?>
	popup_msg.popup_msg_cell = msg;
	document.getElementById("popup_button_2_span").onclick = function () { ActivateDeactivate(activate); };
	popup_msg.ShowPopupMsg();
}

</script>
</head>

<body>
<div id="sub_level_1_buttons">

	<div class="button_heading_sub_level_1" id="manage_users_site_options_heading"><div class="button_heading_text_sub_level_1">Manage Users &amp; Site Options</div><div class="help_button" id="help_button" onclick="OpenHelpWindow();">&nbsp;</div></div>
    
	<div class='button_sub_level_1' onClick="window.location='users.php';"><span class='button_text_sub_level_1'>Manage Users</span></div>
    <div class='button_sub_level_1' onClick="window.location='options.php';"><span class='button_text_sub_level_1'>Change Site Options</span></div>
    <div class='button_sub_level_1' onClick="window.location='restrict_editing_access.php';"><span class='button_text_sub_level_1'>Restrict Page Editing Access</span></div>
    <div class='button_sub_level_1' onClick="ShowPrunePageEditBkupTable();"><span class='button_text_sub_level_1'>Prune Page Edit Backup Table</span></div>
	<div class='button_console' id="prune_css_btn" onClick="window.location='prune_bkup_files.php';"><span class='button_console_text'>Prune CSS, site map, and <br />JavaScript menu backup files</span></div>
	<div class='button_sub_level_1' onClick="window.location='upload_plugin.php';"><span class='button_text_sub_level_1'>Install Plugin</span></div>
	<div class='button_sub_level_1' onClick="ShowRecallPlugin();"><span class='button_text_sub_level_1'>Recall Plugin</span></div>
	<div class='button_sub_level_1' onClick="window.location='upload_update.php';"><span class='button_text_sub_level_1'>Install Update</span></div>
    <div class='button_sub_level_1' onClick="window.location='input_sql.php';"><span class='button_text_sub_level_1'>Run SQL</span></div>
	<div class='button_sub_level_1' onClick="ActivateDeactivateConfirm();"><span class='button_text_sub_level_1'><?php if ($site_active) echo "De-activate Website"; else  echo "Activate Website"; ?></span></div>
</div>

<div id="prune_page_backup_table_div">
<form name="frmPruneTable" id="frmPruneTable" method="post" action="prune_table.php">
	<p>Prune page edit backup table to 
	    <input name="prune_page_bkup_days" type="text" id="prune_page_bkup_days" value="30" size="4" />
	days<br>
      <div class='button_console' id="prune_table_btn" onClick="document.getElementById('frmPruneTable').submit();"><span class='button_console_text'>Submit</span></div>
	</p>
</form>
</div>

<div id="recall_plugin_div">
  Select the plugin you want to recall:<br />
  	<select name="recall_plugin" id="recall_plugin" style="width:400px;">
<?php
	$query = "SELECT `id`, `name`, `description` FROM `" . BWB_TABLE_PREFIX . "plugins` WHERE `deployed`=1 ORDER BY `sort_order`";
	$result = $bwb_dbh->query($query);
	while ($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		$id = $row["id"];
		$name = $row["name"];
		$description = $row["description"];
		if ($description == "")
			echo "<option value='$id'>$name</option>\n";
		else
			echo "<option value='$id'>$name - $description</option>\n";
	}
?>
 	</select>
    <div class='button_console' id="recall_plugin_btn" onClick="DeleteConfirm('recall_plugin');"><span class='button_console_text'>Recall</span></div>
    
</div>

<?php include("lib/popup_msg.html"); ?>

<script language="JavaScript"  type="text/javascript">
	HidePopupMsg();
<?php	if ($display_pruned_bkup_files_msg == 1)	{	?>
	popup_msg.top_offset = 100;
	popup_msg.left_offset = 320;
	popup_msg.popup_msg_type = 1;
	popup_msg.popup_timeout = 3000;
	popup_msg.status_msg = "CSS, site map, and JavaScript menu backup files have been pruned.";
	popup_msg.ShowPopupMsg();
<?php	}	?>
</script>

</body>
</html>